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
This commit is contained in:
Martchus 2024-01-26 23:53:01 +01:00
parent 5667aad412
commit afe9cb2135
2 changed files with 28 additions and 2 deletions

View File

@ -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")

View File

@ -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)