From afe9cb21352d6324a4eb375925d91b0d156b77a2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 26 Jan 2024 23:53:01 +0100 Subject: [PATCH] Add actions/shortcuts to desktop file * Remove the old approach to specify actions as it is lacking the `Actions` key and doesn't allow customizing the executable name * Add actions for most important use cases --- cli/CMakeLists.txt | 5 +++++ tray/CMakeLists.txt | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 606efb0..4c21efd 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -49,6 +49,11 @@ include(ShellCompletion) include(Doxygen) include(ConfigHeader) +# export target name to use syncthingctl for shortcuts in syncthingtray's desktop file +set(${META_PROJECT_VARNAME_UPPER}_TARGET_NAME + "${META_TARGET_NAME}" + PARENT_SCOPE) + # avoid running this test in parallel with other tests spawning a Syncthing test instance if (META_MAIN_TEST_NAME) set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance") diff --git a/tray/CMakeLists.txt b/tray/CMakeLists.txt index 1832bc1..8445110 100644 --- a/tray/CMakeLists.txt +++ b/tray/CMakeLists.txt @@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR) # metadata set(META_PROJECT_TYPE application) set(META_APP_NAME "Syncthing Tray") -set(META_APP_ACTIONS OPEN_WEBUI) -set(META_APP_ACTION_OPEN_WEBUI "open-webui" "Open web UI" "--webui") # use testfiles directory from syncthingconnector set(META_SRCDIR_REFS "${CMAKE_CURRENT_SOURCE_DIR}\n${CMAKE_CURRENT_SOURCE_DIR}/../syncthingconnector") @@ -148,6 +146,29 @@ if (UNIFY_TRAY_MENUS) message(STATUS "left- and right-click context menus will be unified") endif () +# add shortcuts/actions to desktop file +set(ACTIONS + "Actions=ShowTrayMenu;ShowSyncthing;RescanAll;PauseAllDevs;ResumeAllDevs;Restart\n\n\ +[Desktop Action ShowTrayMenu]\n\ +Name=Show tray menu\n\ +Exec=${META_TARGET_NAME} qt-widgets-gui --trigger\n\ +[Desktop Action ShowSyncthing]\n\ +Name=Show Syncthing (currently selected instance)\n\ +Exec=${META_TARGET_NAME} qt-widgets-gui --webui\n\ +[Desktop Action RescanAll]\n\ +Name=Rescan all folders (of local Syncthing instance)\n\ +Exec=${SYNCTHINGCTL_TARGET_NAME} rescan-all\n\ +[Desktop Action PauseAllDevs]\n\ +Name=Pause all devices (of local Syncthing instance)\n\ +Exec=${SYNCTHINGCTL_TARGET_NAME} pause --all-devs\n\ +[Desktop Action ResumeAllDevs]\n\ +Name=Resume all devices (of local Syncthing instance)\n\ +Exec=${SYNCTHINGCTL_TARGET_NAME} resume --all-devs\n\ +[Desktop Action Restart]\n\ +Name=Restart Syncthing (local instance)\n\ +Exec=${SYNCTHINGCTL_TARGET_NAME} restart") +set(DESKTOP_FILE_ADDITIONAL_ENTRIES "${DESKTOP_FILE_ADDITIONAL_ENTRIES}${ACTIONS}\n") + # include modules to apply configuration include(QtGuiConfig) include(QtConfig)