129 lines
3.4 KiB
Diff
129 lines
3.4 KiB
Diff
diff --git a/PkSession/CMakeLists.txt b/PkSession/CMakeLists.txt
|
|
--- a/PkSession/CMakeLists.txt
|
|
+++ b/PkSession/CMakeLists.txt
|
|
@@ -44,6 +44,7 @@
|
|
KF5::KIOFileWidgets
|
|
KF5::KDELibs4Support
|
|
KF5::IconThemes
|
|
+ KF5::DBusAddons
|
|
${PackageKitQt5_LIBRARIES}
|
|
apper_private
|
|
)
|
|
diff --git a/PkSession/PkSession.h b/PkSession/PkSession.h
|
|
--- a/PkSession/PkSession.h
|
|
+++ b/PkSession/PkSession.h
|
|
@@ -21,15 +21,15 @@
|
|
#ifndef PKSESSION_H
|
|
#define PKSESSION_H
|
|
|
|
-#include <KUniqueApplication>
|
|
+#include <QObject>
|
|
#include <QTimer>
|
|
|
|
class PkInterface;
|
|
-class PkSession : public KUniqueApplication
|
|
+class PkSession : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
- PkSession();
|
|
+ explicit PkSession(QObject* parent = 0);
|
|
virtual ~PkSession();
|
|
int newInstance();
|
|
|
|
diff --git a/PkSession/PkSession.cpp b/PkSession/PkSession.cpp
|
|
--- a/PkSession/PkSession.cpp
|
|
+++ b/PkSession/PkSession.cpp
|
|
@@ -22,6 +22,7 @@
|
|
|
|
#include "PkInterface.h"
|
|
|
|
+#include <QApplication>
|
|
#include <QStringBuilder>
|
|
|
|
#include <KLocalizedString>
|
|
@@ -35,8 +36,8 @@
|
|
|
|
using namespace PackageKit;
|
|
|
|
-PkSession::PkSession() :
|
|
- KUniqueApplication()
|
|
+PkSession::PkSession(QObject* parent)
|
|
+ : QObject(parent)
|
|
{
|
|
m_pkInterface = new PkInterface(this);
|
|
connect(m_pkInterface, SIGNAL(close()),
|
|
@@ -46,7 +47,7 @@
|
|
Daemon::global()->setHints(QLatin1String("locale=") % locale);
|
|
|
|
// this enables not quitting when closing a transaction ui
|
|
- setQuitOnLastWindowClosed(false);
|
|
+ qApp->setQuitOnLastWindowClosed(false);
|
|
|
|
// create the close timer and connect it's signal
|
|
m_closeT = new QTimer(this);
|
|
@@ -83,7 +84,7 @@
|
|
// again just to be sure.
|
|
if (!isRunning()) {
|
|
kDebug() << "Closed by Timer";
|
|
- quit();
|
|
+ qApp->quit();
|
|
}
|
|
}
|
|
|
|
diff --git a/PkSession/main.cpp b/PkSession/main.cpp
|
|
--- a/PkSession/main.cpp
|
|
+++ b/PkSession/main.cpp
|
|
@@ -21,14 +21,21 @@
|
|
#include "PkSession.h"
|
|
#include <config.h>
|
|
|
|
-#include <KDebug>
|
|
+#include <QApplication>
|
|
+#include <QDebug>
|
|
+#include <QIcon>
|
|
+#include <QSessionManager>
|
|
+
|
|
+#include <KAboutData>
|
|
#include <KConfig>
|
|
+#include <KDBusService>
|
|
#include <KLocalizedString>
|
|
-#include <KAboutData>
|
|
-#include <KCmdLineArgs>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
+ QApplication app(argc, argv);
|
|
+ app.setWindowIcon(QIcon::fromTheme("system-software-install"));
|
|
+
|
|
KLocalizedString::setApplicationDomain("apper");
|
|
|
|
KAboutData aboutData("PkSession",
|
|
@@ -41,18 +48,16 @@
|
|
aboutData.addAuthor(i18n("Trever Fischer"), QString(), "wm161@wm161.net", "http://wm161.net");
|
|
|
|
aboutData.addCredit(i18n("Adrien Bustany"), i18n("libpackagekit-qt and other stuff"),"@");
|
|
- aboutData.setProgramIconName("system-software-install");
|
|
KAboutData::setApplicationData(aboutData);
|
|
|
|
- //! KCmdLineArgs::init(argc, argv);
|
|
- Q_UNUSED(argc);
|
|
- Q_UNUSED(argv);
|
|
-
|
|
- if (!PkSession::start()) {
|
|
- //kDebug() << "PkSession is already running!";
|
|
- return 0;
|
|
- }
|
|
+ // Let's ensure we only have one PkSession at any one time on the same session
|
|
+ KDBusService service(KDBusService::Unique);
|
|
+ auto disableSessionManagement = [](QSessionManager &sm) {
|
|
+ sm.setRestartHint(QSessionManager::RestartNever);
|
|
+ };
|
|
+ QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement);
|
|
+ QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement);
|
|
|
|
- PkSession app;
|
|
+ PkSession session;
|
|
return app.exec();
|
|
}
|
|
|