diff --git a/indicator/indicatorhelper.h b/indicator/indicatorhelper.h index c40d09841..7474ce6c6 100644 --- a/indicator/indicatorhelper.h +++ b/indicator/indicatorhelper.h @@ -27,7 +27,11 @@ class IndicatorHelper { public: +#ifdef Q_OS_WIN + IndicatorHelper(const QUrl& indicatorUrl); +#else IndicatorHelper(); +#endif ~IndicatorHelper(); void preInit(); @@ -43,6 +47,11 @@ public: void systrayIconHook(KStatusNotifierItem &systray); #endif +private: +#ifdef Q_OS_MAC + QSplashScreen *m_splashScreen; +#endif + #ifdef Q_OS_WIN /** * Terminate processes of KDE Connect like kdeconnectd.exe and dbus-daemon.exe @@ -51,12 +60,9 @@ public: */ bool terminateProcess(const QString &processName, const QUrl &indicatorUrl) const; + QUrl m_indicatorUrl; #endif -private: -#ifdef Q_OS_MAC - QSplashScreen *m_splashScreen; -#endif }; #endif diff --git a/indicator/indicatorhelper_win.cpp b/indicator/indicatorhelper_win.cpp index fadaf4580..d52ece00b 100644 --- a/indicator/indicatorhelper_win.cpp +++ b/indicator/indicatorhelper_win.cpp @@ -17,8 +17,13 @@ #include "indicatorhelper.h" #include "indicator_debug.h" -IndicatorHelper::IndicatorHelper() {} -IndicatorHelper::~IndicatorHelper() {} +IndicatorHelper::IndicatorHelper(const QUrl& indicatorUrl) + : m_indicatorUrl(indicatorUrl) {} + +IndicatorHelper::~IndicatorHelper() { + this->terminateProcess(processes::dbus_daemon, m_indicatorUrl); + this->terminateProcess(processes::kdeconnect_daemon, m_indicatorUrl); +} void IndicatorHelper::preInit() {} diff --git a/indicator/main.cpp b/indicator/main.cpp index 2d47e3bae..943c91958 100644 --- a/indicator/main.cpp +++ b/indicator/main.cpp @@ -41,7 +41,11 @@ int main(int argc, char** argv) i18n("(C) 2016 Aleix Pol Gonzalez")); KAboutData::setApplicationData(about); +#ifdef Q_OS_WIN + IndicatorHelper helper(QUrl::fromLocalFile(qApp->applicationDirPath())); +#else IndicatorHelper helper; +#endif helper.preInit(); @@ -109,12 +113,7 @@ int main(int argc, char** argv) }); #elif defined Q_OS_WIN - menu->addAction(i18n("Quit"), [&helper](){ - const QUrl indicatorUrl = QUrl::fromLocalFile(qApp->applicationDirPath()); - helper.terminateProcess(processes::dbus_daemon, indicatorUrl); - helper.terminateProcess(processes::kdeconnect_daemon, indicatorUrl); - qApp->quit(); - }); + menu->addAction(i18n("Quit"), [](){qApp->quit();}); #endif };