From 71ec233f888f012820cd97be63e5d9c836109fa3 Mon Sep 17 00:00:00 2001 From: Weixuan XIAO Date: Tue, 19 Nov 2019 22:42:30 +0100 Subject: [PATCH] Move splash screen to header --- indicator/indicatorhelper.h | 6 ++++++ indicator/indicatorhelper_mac.cpp | 26 ++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/indicator/indicatorhelper.h b/indicator/indicatorhelper.h index 45b3a9380..c80fe8c9a 100644 --- a/indicator/indicatorhelper.h +++ b/indicator/indicatorhelper.h @@ -19,6 +19,7 @@ */ #include +#include #ifdef QSYSTRAY #include @@ -44,4 +45,9 @@ public: #else void systrayIconHook(KStatusNotifierItem &systray); #endif + +private: +#ifdef Q_OS_MAC + QSplashScreen *m_splashScreen; +#endif }; diff --git a/indicator/indicatorhelper_mac.cpp b/indicator/indicatorhelper_mac.cpp index 9a78d445f..4542b2506 100644 --- a/indicator/indicatorhelper_mac.cpp +++ b/indicator/indicatorhelper_mac.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -33,26 +32,23 @@ #include "indicatorhelper.h" -static QSplashScreen *splashScreen = nullptr; IndicatorHelper::IndicatorHelper() { QIcon kdeconnectIcon = QIcon::fromTheme(QStringLiteral("kdeconnect")); QPixmap splashPixmap(kdeconnectIcon.pixmap(256, 256)); - if (::splashScreen == nullptr) { - ::splashScreen = new QSplashScreen(splashPixmap); - } + m_splashScreen = new QSplashScreen(splashPixmap); - ::splashScreen->showMessage(i18n("Launching") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); - ::splashScreen->show(); + m_splashScreen->showMessage(i18n("Launching") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); + m_splashScreen->show(); } IndicatorHelper::~IndicatorHelper() { - if (::splashScreen) { - delete ::splashScreen; - ::splashScreen = nullptr; + if (m_splashScreen != nullptr) { + delete m_splashScreen; + m_splashScreen = nullptr; } } @@ -60,9 +56,7 @@ void IndicatorHelper::preInit() {} void IndicatorHelper::postInit() { - if (::splashScreen) { - ::splashScreen->finish(nullptr); - } + m_splashScreen->finish(nullptr); } void IndicatorHelper::iconPathHook() @@ -81,7 +75,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd) DBusHelper::macosUnsetLaunchctlEnv(); // Start kdeconnectd - ::splashScreen->showMessage(i18n("Launching daemon") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); + m_splashScreen->showMessage(i18n("Launching daemon") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); if (QFile::exists(QCoreApplication::applicationDirPath() + QStringLiteral("/kdeconnectd"))) { kdeconnectd.startDetached(QCoreApplication::applicationDirPath() + QStringLiteral("/kdeconnectd")); } else if (QFile::exists(QString::fromLatin1(qgetenv("craftRoot")) + QStringLiteral("/../lib/libexec/kdeconnectd"))) { @@ -96,7 +90,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd) // Wait for dbus daemon env QProcess getLaunchdDBusEnv; - ::splashScreen->showMessage(i18n("Waiting D-Bus") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); + m_splashScreen->showMessage(i18n("Waiting D-Bus") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); int retry = 0; do { getLaunchdDBusEnv.setProgram(QStringLiteral("launchctl")); @@ -127,7 +121,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd) } } while(true); - ::splashScreen->showMessage(i18n("Loading modules") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); + m_splashScreen->showMessage(i18n("Loading modules") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::white); return 0; }