summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Riddell <jr@jriddell.org>2016-09-23 16:13:21 (GMT)
committerJonathan Riddell <jr@jriddell.org>2016-09-23 16:13:21 (GMT)
commit155c99030370dfcc2aaf44c834db353854c587ff (patch)
tree4afc2a62354abf51bb7d62c2cb43af39b2ba4e5f
parent5a280dd2f44dc3d5693a59390df309658dc12da7 (diff)
yay, an installing plugin installer
-rw-r--r--CMakeLists.txt14
-rw-r--r--app/CMakeLists.txt5
-rw-r--r--app/kipiexportaction.cpp2
-rw-r--r--app/kipiinterface.cpp56
-rw-r--r--app/kipiinterface.h7
5 files changed, 82 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 82b219a..ab19f6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,6 +103,20 @@ if(X11_FOUND)
set(HAVE_X11 1)
endif()
+find_package(PackageKitQt5 0.9.5)
+set_package_properties(PackageKitQt5
+ PROPERTIES DESCRIPTION "Software Manager integration"
+ TYPE OPTIONAL
+ PURPOSE "Needed to automatically install the samba package."
+)
+
+find_package(AppstreamQt 0.9.8)
+set_package_properties(AppstreamQt
+ PROPERTIES DESCRIPTION "Appstream"
+ TYPE OPTIONAL
+ PURPOSE "Needed to find KIPI plugins."
+)
+
configure_file(config-gwenview.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-gwenview.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index ed77d7c..ac6b01d 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -82,6 +82,11 @@ target_link_libraries(gwenview LINK_INTERFACE_LIBRARIES KF5::KIOCore Qt5::Core)
if (KF5Kipi_FOUND)
target_link_libraries(gwenview KF5::Kipi)
+
+ # TODO Add if (packagekit) and if (appstream)
+ target_link_libraries(gwenview PK::packagekitqt5)
+ target_link_libraries(gwenview AppstreamQt)
+
endif()
if (APPLE)
diff --git a/app/kipiexportaction.cpp b/app/kipiexportaction.cpp
index cd74b6a..e148da2 100644
--- a/app/kipiexportaction.cpp
+++ b/app/kipiexportaction.cpp
@@ -60,7 +60,7 @@ struct KIPIExportActionPrivate
}
if (menu->isEmpty()) {
QAction* action = new QAction(menu);
- action->setText(i18n("No Plugin Found"));
+ action->setText(i18n("XXNo Plugin Found"));
action->setEnabled(false);
menu->addAction(action);
}
diff --git a/app/kipiinterface.cpp b/app/kipiinterface.cpp
index 04dccb3..2e5e1ff 100644
--- a/app/kipiinterface.cpp
+++ b/app/kipiinterface.cpp
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <QList>
#include <QMenu>
#include <QRegExp>
+#include <QProgressDialog>
// KDE
#include <QAction>
@@ -43,6 +44,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <kipi/pluginloader.h>
//#include <kipi/version.h>
+//Appstream, TODO add an If installed here
+#include <AppstreamQt/database.h>
+#include <AppstreamQt/component.h>
+
// local
#include "mainwindow.h"
#include "kipiimagecollectionselector.h"
@@ -202,6 +207,8 @@ struct KIPIInterfacePrivate
MenuInfoMap mMenuInfoMap;
QAction * mLoadingAction;
QAction * mNoPluginAction;
+ QAction * mInstallPluginAction;
+ QProgressDialog * installDialog;
void setupPluginsMenu()
{
@@ -228,7 +235,8 @@ KIPIInterface::KIPIInterface(MainWindow* mainWindow)
d->mMainWindow = mainWindow;
d->mPluginLoader = 0;
d->mLoadingAction = d->createDummyPluginAction(i18n("Loading..."));
- d->mNoPluginAction = d->createDummyPluginAction(i18n("No Plugin Found"));
+ d->mNoPluginAction = d->createDummyPluginAction(i18n("YYYNo Plugin Found"));
+ d->mInstallPluginAction = d->createDummyPluginAction(i18n("Install Plugins"));
d->setupPluginsMenu();
QObject::connect(d->mMainWindow->contextManager(), SIGNAL(selectionChanged()),
@@ -331,11 +339,57 @@ void KIPIInterface::loadOnePlugin()
d->mPluginMenu->removeAction(d->mLoadingAction);
if (d->mPluginMenu->isEmpty()) {
d->mPluginMenu->addAction(d->mNoPluginAction);
+ d->mPluginMenu->addAction(d->mInstallPluginAction);
+ d->mInstallPluginAction->setEnabled(true);
+ QObject::connect(d->mInstallPluginAction, SIGNAL(triggered(bool)),
+ this, SLOT(slotInstallPlugins(bool)));
}
loadingFinished();
}
+void KIPIInterface::slotInstallPlugins(bool checked) {
+ Q_UNUSED(checked);
+ qDebug() << "slotInstallPlugins()" << endl;
+ d->installDialog = new QProgressDialog(i18n("Installing Plugins..."), i18n("Cancel"), 0, 0);
+ d->installDialog->setWindowModality(Qt::WindowModal);
+
+ Appstream::Database* appstreamDatabase = new Appstream::Database();
+ appstreamDatabase->open();
+ Appstream::Component kipiPlugins = appstreamDatabase->componentById("photolayoutseditor.desktop");
+ qDebug() << "The Package: " << kipiPlugins.packageNames()[0] << endl;
+ QString package = kipiPlugins.packageNames()[0];
+
+ PackageKit::Transaction *transaction = PackageKit::Daemon::resolve(package,
+ PackageKit::Transaction::FilterArch);
+ connect(transaction,
+ SIGNAL(package(PackageKit::Transaction::Info,QString,QString)),
+ SLOT(packageInstall(PackageKit::Transaction::Info,QString,QString)));
+
+ d->installDialog->show();
+}
+
+void KIPIInterface::packageInstall(PackageKit::Transaction::Info, QString packageID, QString summary) {
+ qDebug() << "packageInstall()" << packageID << endl;
+ qDebug() << "packageInstall()" << summary << endl;
+ PackageKit::Transaction *installTransaction = PackageKit::Daemon::installPackage(packageID);
+ connect(installTransaction,
+ SIGNAL(finished(PackageKit::Transaction::Exit, uint)),
+ SLOT(packageFinished(PackageKit::Transaction::Exit, uint)));
+}
+
+void KIPIInterface::packageFinished(PackageKit::Transaction::Exit status, uint runtime) {
+ qDebug() << "packageFinished() status: " << status << endl;
+ qDebug() << "packageFinished() no of seconds: " << runtime << endl;
+ if (status == PackageKit::Transaction::Exit::ExitSuccess) {
+ d->installDialog->setLabelText("installed!");
+ d->mPluginLoader = 0;
+ loadPlugins();
+ } else {
+ d->installDialog->setLabelText("failed to install :(");
+ }
+}
+
QList<QAction*> KIPIInterface::pluginActions(KIPI::Category category) const
{
const_cast<KIPIInterface*>(this)->loadPlugins();
diff --git a/app/kipiinterface.h b/app/kipiinterface.h
index 1c06cd4..dbefaae 100644
--- a/app/kipiinterface.h
+++ b/app/kipiinterface.h
@@ -28,6 +28,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <kipi/plugin.h>
#include <libkipi_version.h>
+//TODO if packagekit
+#include <PackageKit/Daemon>
+#include <PackageKit/Transaction>
+
class QAction;
#ifndef KIPI_VERSION_MAJOR
@@ -88,6 +92,9 @@ public Q_SLOTS:
private Q_SLOTS:
void slotSelectionChanged();
void slotDirectoryChanged();
+ void slotInstallPlugins(bool checked);
+ void packageInstall(PackageKit::Transaction::Info, QString, QString);
+ void packageFinished(PackageKit::Transaction::Exit, uint);
void init();
void loadOnePlugin();