Fix system tray icon on macOS
This commit is contained in:
parent
4f4b6c309f
commit
6672e3eef5
1 changed files with 10 additions and 2 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#ifdef QSYSTRAY
|
#ifdef QSYSTRAY
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
@ -65,6 +66,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
QProcess kdeconnectdProcess;
|
QProcess kdeconnectdProcess;
|
||||||
kdeconnectdProcess.start(basePath + QStringLiteral("Contents/MacOS/kdeconnectd")); // Start kdeconnectd
|
kdeconnectdProcess.start(basePath + QStringLiteral("Contents/MacOS/kdeconnectd")); // Start kdeconnectd
|
||||||
|
QThread::sleep(5); // Wait for kdeconnectd and its dbus-daemon
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USE_PRIVATE_DBUS
|
#ifndef USE_PRIVATE_DBUS
|
||||||
|
@ -116,11 +118,17 @@ int main(int argc, char** argv)
|
||||||
QObject::connect(&model, &DevicesModel::rowsInserted, &model, refreshMenu);
|
QObject::connect(&model, &DevicesModel::rowsInserted, &model, refreshMenu);
|
||||||
QObject::connect(&model, &DevicesModel::rowsRemoved, &model, refreshMenu);
|
QObject::connect(&model, &DevicesModel::rowsRemoved, &model, refreshMenu);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QStringList themeSearchPaths = QIcon::themeSearchPaths();
|
||||||
|
themeSearchPaths << basePath + QStringLiteral("Contents/Resources/icons/");
|
||||||
|
QIcon::setThemeSearchPaths(themeSearchPaths);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef QSYSTRAY
|
#ifdef QSYSTRAY
|
||||||
QSystemTrayIcon systray;
|
QSystemTrayIcon systray;
|
||||||
systray.setIcon(QIcon::fromTheme("kdeconnectindicatordark"));
|
systray.setIcon(QIcon::fromTheme(QStringLiteral("kdeconnectindicatordark")));
|
||||||
systray.setVisible(true);
|
systray.setVisible(true);
|
||||||
systray.setToolTip("KDE Connect");
|
systray.setToolTip(QStringLiteral("KDE Connect"));
|
||||||
QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
|
QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
|
||||||
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
|
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue