summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Riddell <jr@jriddell.org>2016-09-29 12:05:03 (GMT)
committerJonathan Riddell <jr@jriddell.org>2016-09-29 12:05:03 (GMT)
commit4d75abc91339e1bf4ac7c731f8a6a654a36109c1 (patch)
tree340263c93d0fd34fd939002b2cebc0ee76eba18a
parent892ce0bd1bb930b689fb40d9cc9a32f3cdad94ae (diff)
implementation using appstream URLs and plasma discover
-rw-r--r--CMakeLists.txt18
-rw-r--r--app/CMakeLists.txt5
-rw-r--r--app/kipiinterface.cpp82
-rw-r--r--app/kipiinterface.h14
4 files changed, 23 insertions, 96 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index be759f8..4f4adad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,22 +103,8 @@ 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 KIPI Plugins."
-)
-
-find_package(AppstreamQt 0.9.8)
-set_package_properties(AppstreamQt
- PROPERTIES DESCRIPTION "Appstream"
- TYPE OPTIONAL
- PURPOSE "Needed to find KIPI Plugins."
-)
-
-if (KF5Kipi_FOUND AND PackageKitQt5_FOUND AND AppstreamQt_FOUND)
- set(KIPI_INSTALLER true)
+option(KIPI_INSTALLER "Build with Kipi Installer menu option (requires Plasma Discover built with Appstream" ON)
+if (KIPI_INSTALLER)
add_definitions(-DKIPI_INSTALLER)
endif()
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 281b80e..ed77d7c 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -84,11 +84,6 @@ if (KF5Kipi_FOUND)
target_link_libraries(gwenview KF5::Kipi)
endif()
-if (KIPI_INSTALLER)
- target_link_libraries(gwenview PK::packagekitqt5)
- target_link_libraries(gwenview AppstreamQt)
-endif()
-
if (APPLE)
# own plist template
set_target_properties (gwenview PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in)
diff --git a/app/kipiinterface.cpp b/app/kipiinterface.cpp
index 209e203..0cf8024 100644
--- a/app/kipiinterface.cpp
+++ b/app/kipiinterface.cpp
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <QMenu>
#include <QRegExp>
#include <QProgressDialog>
+#include <QDesktopServices>
+#include <QFileSystemWatcher>
+#include <QTimer>
// KDE
#include <QAction>
@@ -45,12 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <kipi/pluginloader.h>
//#include <kipi/version.h>
-//Appstream
-#ifdef KIPI_INSTALLER
-#include <AppstreamQt/database.h>
-#include <AppstreamQt/component.h>
-#endif
-
// local
#include "mainwindow.h"
#include "kipiimagecollectionselector.h"
@@ -212,6 +209,7 @@ struct KIPIInterfacePrivate
QAction * mNoPluginAction;
QAction * mInstallPluginAction;
QProgressDialog * installDialog;
+ QFileSystemWatcher * mPluginWatcher;
void setupPluginsMenu()
{
@@ -237,6 +235,7 @@ KIPIInterface::KIPIInterface(MainWindow* mainWindow)
d->q = this;
d->mMainWindow = mainWindow;
d->mPluginLoader = 0;
+ d->mPluginWatcher = 0;
d->mLoadingAction = d->createDummyPluginAction(i18n("Loading..."));
d->mNoPluginAction = d->createDummyPluginAction(i18n("No Plugin Found"));
d->mInstallPluginAction = d->createDummyPluginAction(i18n("Install Plugins"));
@@ -339,6 +338,10 @@ void KIPIInterface::loadOnePlugin()
}
}
+ if (d->mPluginWatcher) {
+ delete d->mPluginWatcher;
+ d->mPluginWatcher = 0;
+ }
d->mPluginMenu->removeAction(d->mLoadingAction);
if (d->mPluginMenu->isEmpty()) {
d->mPluginMenu->addAction(d->mNoPluginAction);
@@ -347,6 +350,9 @@ void KIPIInterface::loadOnePlugin()
d->mInstallPluginAction->setEnabled(true);
QObject::connect(d->mInstallPluginAction, SIGNAL(triggered(bool)),
this, SLOT(slotInstallPlugins(bool)));
+ d->mPluginWatcher = new QFileSystemWatcher(d->mMainWindow);
+ d->mPluginWatcher->addPaths(QCoreApplication::libraryPaths());
+ connect(d->mPluginWatcher, SIGNAL(directoryChanged(QString)), SLOT(packageFinished()));
#endif
}
@@ -356,67 +362,17 @@ void KIPIInterface::loadOnePlugin()
#ifdef KIPI_INSTALLER
void KIPIInterface::slotInstallPlugins(bool checked) {
Q_UNUSED(checked);
- m_installTransaction = 0;
- d->installDialog = new QProgressDialog(i18n("Installing Plugins..."), i18n("Cancel"), 0, 100, d->mMainWindow);
- d->installDialog->setWindowModality(Qt::WindowModal);
- connect(d->installDialog, SIGNAL(canceled()), SLOT(cancelInstall()));
-
- Appstream::Database appstreamDatabase;
- appstreamDatabase.open();
- Appstream::Component kipiPlugins = appstreamDatabase.componentById("photolayoutseditor.desktop");
- QString package;
- if (kipiPlugins.packageNames().length() > 0) {
- package = kipiPlugins.packageNames()[0];
- } else {
- KMessageBox::sorry(d->mMainWindow, i18n("Could not install plugins."));
- return;
- }
-
- 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();
+ QDesktopServices::openUrl(QUrl("appstream://photolayoutseditor.desktop"));
}
-void KIPIInterface::packageInstall(PackageKit::Transaction::Info, QString packageID, QString summary) {
- m_installTransaction = PackageKit::Daemon::installPackage(packageID);
- connect(m_installTransaction,
- SIGNAL(finished(PackageKit::Transaction::Exit, uint)),
- SLOT(packageFinished(PackageKit::Transaction::Exit, uint)));
- connect(m_installTransaction,
- SIGNAL(percentageChanged()),
- SLOT(percentageChanged()));
-}
-
-void KIPIInterface::packageFinished(PackageKit::Transaction::Exit status, uint runtime) {
- if (status == PackageKit::Transaction::Exit::ExitSuccess) {
- d->installDialog->setLabelText(i18n("Image plugins have been installed."));
- d->installDialog->setValue(100);
- KMessageBox::information(d->mMainWindow, i18n("Image plugins have been installed."));
- d->mPluginLoader = 0;
- loadPlugins();
- d->mPluginMenu->removeAction(d->mInstallPluginAction);
- d->mPluginMenu->removeAction(d->mNoPluginAction);
- } else {
- d->installDialog->setValue(100);
- KMessageBox::information(d->mMainWindow, i18n("Could not install plugins."));
- }
-}
-
-void KIPIInterface::percentageChanged() {
- d->installDialog->setValue(m_installTransaction->percentage());
+void KIPIInterface::packageFinished() {
+ qDebug() << "packageFinished()" << endl;
+ d->mPluginLoader = 0;
+ d->mPluginMenu->removeAction(d->mInstallPluginAction);
+ d->mPluginMenu->removeAction(d->mNoPluginAction);
+ QTimer::singleShot(5000, this, SLOT(loadPlugins()));
}
-void KIPIInterface::cancelInstall() {
- if (m_installTransaction) {
- if (m_installTransaction->allowCancel()) {
- m_installTransaction->cancel();
- }
- }
-}
#endif
QList<QAction*> KIPIInterface::pluginActions(KIPI::Category category) const
diff --git a/app/kipiinterface.h b/app/kipiinterface.h
index 59f1a2a..e3cf390 100644
--- a/app/kipiinterface.h
+++ b/app/kipiinterface.h
@@ -28,12 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <kipi/plugin.h>
#include <libkipi_version.h>
-#ifdef KIPI_INSTALLER
-#include <PackageKit/Daemon>
-#include <PackageKit/Transaction>
-#endif
-
class QAction;
+class QFileSystemWatcher;
#ifndef KIPI_VERSION_MAJOR
#error KIPI_VERSION_MAJOR should be provided.
@@ -95,19 +91,13 @@ private Q_SLOTS:
void slotDirectoryChanged();
#ifdef KIPI_INSTALLER
void slotInstallPlugins(bool checked);
- void packageInstall(PackageKit::Transaction::Info, QString, QString);
- void packageFinished(PackageKit::Transaction::Exit, uint);
- void percentageChanged();
- void cancelInstall();
+ void packageFinished();
#endif
void init();
void loadOnePlugin();
private:
KIPIInterfacePrivate* const d;
-#ifdef KIPI_INSTALLER
- PackageKit::Transaction* m_installTransaction;
-#endif
};
class ImageCollection : public KIPI::ImageCollectionShared