Commit 155c9903 authored by Jonathan Esk-Riddell's avatar Jonathan Esk-Riddell 🏄
Browse files

yay, an installing plugin installer

parent 5a280dd2
......@@ -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})
......
......@@ -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)
......
......@@ -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);
}
......
......@@ -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();
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment