summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Riddell <jr@jriddell.org>2016-09-26 16:18:55 (GMT)
committerJonathan Riddell <jr@jriddell.org>2016-09-26 16:18:55 (GMT)
commit8431c32e087f8ca9b3dfe8e25f02ea55ee93ce00 (patch)
tree8fa569ee1bbaff78590e2e7c776b5b8efe35219a
parentfc475a805c80b1d5841b562b6c53023217cc4b31 (diff)
handle cancel button
-rw-r--r--app/kipiinterface.cpp14
-rw-r--r--app/kipiinterface.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/app/kipiinterface.cpp b/app/kipiinterface.cpp
index 8f9c3fd..f7c2040 100644
--- a/app/kipiinterface.cpp
+++ b/app/kipiinterface.cpp
@@ -355,13 +355,16 @@ 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->installDialog->setWindowModality(Qt::WindowModal);
+ d->installDialog->setAutoClose(false);
+ connect(d->installDialog, SIGNAL(canceled()), SLOT(cancelInstall()));
Appstream::Database appstreamDatabase;
appstreamDatabase.open();
Appstream::Component kipiPlugins = appstreamDatabase.componentById("photolayoutseditor.desktop");
- QString package = kipiPlugins.packageNames()[0];
+ QString package = kipiPlugins.packageNames()[0]; //TODO check
PackageKit::Transaction *transaction = PackageKit::Daemon::resolve(package,
PackageKit::Transaction::FilterArch);
@@ -385,7 +388,6 @@ void KIPIInterface::packageInstall(PackageKit::Transaction::Info, QString packag
void KIPIInterface::packageFinished(PackageKit::Transaction::Exit status, uint runtime) {
if (status == PackageKit::Transaction::Exit::ExitSuccess) {
d->installDialog->setLabelText("Image plugins have been installed.");
- d->installDialog->setAutoClose(false);
d->installDialog->setValue(100);
d->installDialog->setCancelButtonText("&Close");
d->mPluginLoader = 0;
@@ -401,6 +403,14 @@ void KIPIInterface::packageFinished(PackageKit::Transaction::Exit status, uint r
void KIPIInterface::percentageChanged() {
d->installDialog->setValue(m_installTransaction->percentage());
}
+
+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 2b8242c..59f1a2a 100644
--- a/app/kipiinterface.h
+++ b/app/kipiinterface.h
@@ -98,13 +98,16 @@ private Q_SLOTS:
void packageInstall(PackageKit::Transaction::Info, QString, QString);
void packageFinished(PackageKit::Transaction::Exit, uint);
void percentageChanged();
+ void cancelInstall();
#endif
void init();
void loadOnePlugin();
private:
KIPIInterfacePrivate* const d;
+#ifdef KIPI_INSTALLER
PackageKit::Transaction* m_installTransaction;
+#endif
};
class ImageCollection : public KIPI::ImageCollectionShared