Commit 86b82677 authored by Weixuan Xiao's avatar Weixuan Xiao

Allow kdeconnectd auto launch from kdeconnect-indicator on macOS

parent 13230ff5
Pipeline #4172 passed with stage
in 12 minutes and 12 seconds
...@@ -17,6 +17,9 @@ ecm_add_app_icon(indicator_SRCS ICONS ...@@ -17,6 +17,9 @@ ecm_add_app_icon(indicator_SRCS ICONS
add_executable(kdeconnect-indicator ${indicator_SRCS}) add_executable(kdeconnect-indicator ${indicator_SRCS})
target_include_directories(kdeconnect-indicator PUBLIC ${CMAKE_BINARY_DIR}) 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) 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(TARGETS kdeconnect-indicator ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS org.kde.kdeconnect.nonplasma.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) install(PROGRAMS org.kde.kdeconnect.nonplasma.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include "kdeconnect-version.h" #include "kdeconnect-version.h"
#include "deviceindicator.h" #include "deviceindicator.h"
#ifdef Q_OS_MAC
#include <CoreFoundation/CFBundle.h>
#endif
#include <dbushelper.h> #include <dbushelper.h>
int main(int argc, char** argv) int main(int argc, char** argv)
...@@ -54,6 +58,15 @@ int main(int argc, char** argv) ...@@ -54,6 +58,15 @@ int main(int argc, char** argv)
QProcess::startDetached("kdeconnectd.exe"); QProcess::startDetached("kdeconnectd.exe");
#endif #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 #ifndef Q_OS_MAC
KDBusService dbusService(KDBusService::Unique); KDBusService dbusService(KDBusService::Unique);
#endif #endif
...@@ -90,6 +103,13 @@ int main(int argc, char** argv) ...@@ -90,6 +103,13 @@ int main(int argc, char** argv)
pairMenu->addAction(i18n("Reject"), dev, &DeviceDbusInterface::rejectPairing); 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); QObject::connect(&iface, &DaemonDbusInterface::pairingRequestsChangedProxy, &model, refreshMenu);
......
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