diff --git a/CMakeLists.txt b/CMakeLists.txt index 42c3cdc13..bf78c7f98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set(KF5_LOCALE_PREFIX "") find_package(ECM 1.8.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS Quick Qml) +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED NO_MODULE COMPONENTS Quick Qml DBus) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma PlasmaQuick WindowSystem Declarative Activities I18n CoreAddons XmlGui DBusAddons IconThemes Wayland) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4cb263b5d..c1c783f07 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -15,14 +15,19 @@ set(lattedock-app_SRCS main.cpp ) +set(latte_dbusXML dbus/org.kde.LatteDock.xml) +qt5_add_dbus_adaptor(lattedock-app_SRCS ${latte_dbusXML} dockcorona.h Latte::DockCorona lattedockadaptor) + add_executable(latte-dock ${lattedock-app_SRCS}) include(FakeTarget.cmake) target_link_libraries(latte-dock + Qt5::DBus Qt5::Quick Qt5::Qml KF5::I18n + KF5::DBusAddons KF5::Declarative KF5::CoreAddons KF5::XmlGui @@ -43,5 +48,7 @@ if(HAVE_X11) endif() configure_file(latte-dock.desktop.cmake latte-dock.desktop) + install(TARGETS latte-dock ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/latte-dock.desktop DESTINATION ${KDE_INSTALL_APPDIR}) +install(FILES dbus/org.kde.LatteDock.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} ) diff --git a/app/dbus/org.kde.LatteDock.xml b/app/dbus/org.kde.LatteDock.xml new file mode 100644 index 000000000..30fe479b3 --- /dev/null +++ b/app/dbus/org.kde.LatteDock.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 682075ce3..3b7c452cc 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -24,10 +24,13 @@ #include "abstractwindowinterface.h" #include "alternativeshelper.h" #include "screenpool.h" +//dbus adaptor +#include "lattedockadaptor.h" #include #include #include +#include #include #include #include @@ -77,6 +80,11 @@ DockCorona::DockCorona(QObject *parent) m_docksScreenSyncTimer.setSingleShot(true); m_docksScreenSyncTimer.setInterval(2500); connect(&m_docksScreenSyncTimer, &QTimer::timeout, this, &DockCorona::syncDockViews); + + //! Dbus adaptor initialization + new LatteDockAdaptor(this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject(QStringLiteral("/Latte"), this); } DockCorona::~DockCorona() @@ -1088,6 +1096,25 @@ bool DockCorona::containmentContainsTasks(Plasma::Containment *cont) return false; } +//! Activate launcher menu through dbus interface +void DockCorona::activateLauncherMenu() +{ + for (auto it = m_dockViews.constBegin(), end = m_dockViews.constEnd(); it != end; ++it) { + const auto applets = it.key()->applets(); + + for (auto applet : applets) { + const auto provides = KPluginMetaData::readStringList(applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); + + if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) { + // if (!applet->globalShortcut().isEmpty()) { + emit applet->activated(); + return; + // } + } + } + } +} + inline void DockCorona::qmlRegisterTypes() const { qmlRegisterType(); diff --git a/app/dockcorona.h b/app/dockcorona.h index 6b47d6d65..3f1c459e2 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -45,6 +45,7 @@ namespace Latte { class DockCorona : public Plasma::Corona { Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.LatteDock") public: DockCorona(QObject *parent = nullptr); @@ -82,6 +83,7 @@ public: ScreenPool *screenPool() const; public slots: + void activateLauncherMenu(); void loadDefaultLayout() override; void dockContainmentDestroyed(QObject *cont); diff --git a/app/latte-dock.desktop.cmake b/app/latte-dock.desktop.cmake index 23a41fc24..93cf6ec38 100644 --- a/app/latte-dock.desktop.cmake +++ b/app/latte-dock.desktop.cmake @@ -20,9 +20,11 @@ Categories=Utility;X-SuSE-DesktopUtility; Exec=latte-dock %u Icon=latte-dock InitialPreference=1 -StartupNotify=true Terminal=false Type=Application X-KDE-PluginInfo-Author=@AUTHOR@ X-KDE-PluginInfo-Email=@EMAIL@ X-KDE-PluginInfo-Website=@WEBSITE@ +X-KDE-StartupNotify=false +X-DBUS-StartupType=Unique +X-DBUS-ServiceName=org.kde.lattedock diff --git a/app/main.cpp b/app/main.cpp index 213abfb18..05b62144f 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -36,6 +36,7 @@ #include #include +#include //! COLORS @@ -50,7 +51,8 @@ inline void configureAboutData(); int main(int argc, char **argv) -{ // Devive pixel ratio has some problems in latte (plasmashell) currently. +{ + // Devive pixel ratio has some problems in latte (plasmashell) currently. // - dialog continually expands (347951) // - Text element text is screwed (QTBUG-42606) // - Panel struts (350614) @@ -70,11 +72,11 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addVersionOption(); parser.addOptions({ - {{"r", "replace"}, i18nc("command line", "Replace the current dock instance.")} - , {{"d", "debug"}, i18nc("command line", "Show the debugging messages on stdout.")} - , {"mask", i18nc("command line" , "Show messages of debugging for the mask (Only useful to devs).")} - , {"graphics", i18nc("command line", "Draw boxes around of the applets.")} - , {"with-window", i18nc("command line", "Open a window with much debug information.")} + {{"r", "replace"}, i18nc("command line", "Replace the current dock instance.")} + , {{"d", "debug"}, i18nc("command line", "Show the debugging messages on stdout.")} + , {"mask", i18nc("command line" , "Show messages of debugging for the mask (Only useful to devs).")} + , {"graphics", i18nc("command line", "Draw boxes around of the applets.")} + , {"with-window", i18nc("command line", "Open a window with much debug information.")} }); parser.process(app); @@ -82,8 +84,10 @@ int main(int argc, char **argv) QLockFile lockFile {QDir::tempPath() + "/latte-dock.lock"}; int timeout {100}; + if (parser.isSet(QStringLiteral("replace"))) { - qint64 pid{-1}; + qint64 pid{ -1}; + if (lockFile.getLockInfo(&pid, nullptr, nullptr)) { kill(static_cast<__pid_t>(pid), SIGINT); timeout = 3000; @@ -96,19 +100,19 @@ int main(int argc, char **argv) } if (parser.isSet(QStringLiteral("debug")) || parser.isSet(QStringLiteral("mask"))) { - //! set pattern for debug messages - //! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}] + //! set pattern for debug messages + //! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}] qSetMessagePattern(QStringLiteral( CIGREEN "[%{type} " CGREEN "%{time h:mm:ss.zz}" CIGREEN "]" CNORMAL - #ifndef QT_NO_DEBUG +#ifndef QT_NO_DEBUG CIRED " [" CCYAN "%{function}" CIRED ":" CCYAN "%{line}" CIRED "]" - #endif +#endif CICYAN " - " CNORMAL "%{message}" CIRED "%{if-fatal}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" "%{if-critical}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" CNORMAL)); } else { - const auto noMessageOutput = [](QtMsgType, const QMessageLogContext&, const QString&){}; + const auto noMessageOutput = [](QtMsgType, const QMessageLogContext &, const QString &) {}; qInstallMessageHandler(noMessageOutput); } @@ -121,6 +125,8 @@ int main(int argc, char **argv) std::signal(SIGINT, signal_handler); Latte::DockCorona corona; + KDBusService service(KDBusService::Unique); + return app.exec(); } diff --git a/po/desktop-templates/latte-dock.desktop.template b/po/desktop-templates/latte-dock.desktop.template index 722ad30e4..6e57133a3 100644 --- a/po/desktop-templates/latte-dock.desktop.template +++ b/po/desktop-templates/latte-dock.desktop.template @@ -8,9 +8,11 @@ Categories=Utility;X-SuSE-DesktopUtility; Exec=latte-dock %u Icon=latte-dock InitialPreference=1 -StartupNotify=true Terminal=false Type=Application X-KDE-PluginInfo-Author=@AUTHOR@ X-KDE-PluginInfo-Email=@EMAIL@ X-KDE-PluginInfo-Website=@WEBSITE@ +X-KDE-StartupNotify=false +X-DBUS-StartupType=Unique +X-DBUS-ServiceName=org.kde.lattedock