Commit cc3e7450 authored by Alexander Volkov's avatar Alexander Volkov

Improve single-instance application behavior

Summary:
1) Avoid showing the window of the second instance by creating
   KDBusService object before creating the window object.
2) Activate the window on the second start.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: mart, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D12760
parent c11246ec
......@@ -30,6 +30,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Service
Solid
WidgetsAddons
WindowSystem
XmlGui
Declarative
Package
......@@ -126,6 +127,7 @@ target_link_libraries( kinfocenter
KF5::Service
KF5::Solid
KF5::WidgetsAddons
KF5::WindowSystem
KF5::XmlGui
)
......
......@@ -29,6 +29,7 @@
#include <KLocalizedString>
#include <config-workspace.h>
#include <KDBusService>
#include <KWindowSystem>
//Qt
#include <QCommandLineParser>
......@@ -61,10 +62,14 @@ KicApp::KicApp(int &argc, char **argv)
parser.process(*this);
aboutData.processCommandLine(&parser);
auto *service = new KDBusService(KDBusService::Unique, this);
display = new KInfoCenter();
display->show();
(void)new KDBusService(KDBusService::Unique, this);
connect(service, &KDBusService::activateRequested, this, [this]() {
KWindowSystem::forceActiveWindow(display->winId());
});
}
int main(int argc, char *argv[])
......
Markdown is supported
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