From 86b82677a199165360cecf1cb3c24335f62c335c Mon Sep 17 00:00:00 2001 From: Weixuan Xiao Date: Sun, 9 Jun 2019 21:36:42 +0000 Subject: [PATCH] Allow kdeconnectd auto launch from kdeconnect-indicator on macOS --- indicator/CMakeLists.txt | 3 +++ indicator/main.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/indicator/CMakeLists.txt b/indicator/CMakeLists.txt index 1c4a4de5d..db3960c19 100644 --- a/indicator/CMakeLists.txt +++ b/indicator/CMakeLists.txt @@ -17,6 +17,9 @@ ecm_add_app_icon(indicator_SRCS ICONS add_executable(kdeconnect-indicator ${indicator_SRCS}) target_include_directories(kdeconnect-indicator PUBLIC ${CMAKE_BINARY_DIR}) target_link_libraries(kdeconnect-indicator Qt5::Widgets KF5::CoreAddons KF5::I18n KF5::Notifications KF5::DBusAddons KF5::KCMUtils kdeconnectinterfaces kdeconnectcore) +if (APPLE) + target_link_libraries(kdeconnect-indicator "-framework CoreFoundation") +endif() install(TARGETS kdeconnect-indicator ${INSTALL_TARGETS_DEFAULT_ARGS}) install(PROGRAMS org.kde.kdeconnect.nonplasma.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/indicator/main.cpp b/indicator/main.cpp index 0cd95db1f..27cb8a249 100644 --- a/indicator/main.cpp +++ b/indicator/main.cpp @@ -37,6 +37,10 @@ #include "kdeconnect-version.h" #include "deviceindicator.h" +#ifdef Q_OS_MAC +#include +#endif + #include int main(int argc, char** argv) @@ -54,6 +58,15 @@ int main(int argc, char** argv) QProcess::startDetached("kdeconnectd.exe"); #endif +#ifdef Q_OS_MAC + // Get bundle path + CFURLRef url = (CFURLRef)CFAutorelease((CFURLRef)CFBundleCopyBundleURL(CFBundleGetMainBundle())); + QString basePath = QUrl::fromCFURL(url).path(); + + QProcess kdeconnectdProcess; + kdeconnectdProcess.start(basePath + QStringLiteral("Contents/MacOS/kdeconnectd")); // Start kdeconnectd +#endif + #ifndef Q_OS_MAC KDBusService dbusService(KDBusService::Unique); #endif @@ -90,6 +103,13 @@ int main(int argc, char** argv) pairMenu->addAction(i18n("Reject"), dev, &DeviceDbusInterface::rejectPairing); } } + +#ifdef Q_OS_MAC + // Add quit menu + menu->addAction(i18n("Quit"), [](){ + QCoreApplication::quit(); // Close this application + }); +#endif }; QObject::connect(&iface, &DaemonDbusInterface::pairingRequestsChangedProxy, &model, refreshMenu);