Compare commits
No commits in common. 'ubuntu/plucky' and 'ubuntu/bionic' have entirely different histories.
ubuntu/plu
...
ubuntu/bio
@ -0,0 +1,10 @@
|
||||
Upstream Authors:
|
||||
LXQt team: http://lxqt.org
|
||||
Razor team: http://razor-qt.org
|
||||
|
||||
Copyright:
|
||||
Copyright (c) 2010-2012 Razor team
|
||||
Copyright (c) 2012-2017 LXQt team
|
||||
|
||||
License: LGPL-2.1+
|
||||
The full text of the licenses can be found in the 'COPYING' file.
|
@ -0,0 +1,272 @@
|
||||
|
||||
lxqt-globalkeys-0.12.0 / 2017-10-21
|
||||
===================================
|
||||
|
||||
* Set patch version
|
||||
* Don't export github templates
|
||||
* fix deadlock - don't accept keyPress when processing dbus call (#56)
|
||||
* Added Lithuanian language
|
||||
* lxqt-config-globalkeys: set Qt::AA_UseHighDpiPixmaps to true
|
||||
* Added QCommandLineParser and basic cli interface to lxqt-config-globalkeys
|
||||
* Adeed LXQT_GLOBALKEYS_PATCH_VERSION
|
||||
* Fixes a FTBFS in superbuild mode (#51)
|
||||
* Added autostart and xdg to CMakeLists.txt
|
||||
* changed xdg/CmakeLists.txt
|
||||
* fixed xdg/CMakeLists.txt renamed config to xdg - merge preparation
|
||||
* Use const iterators
|
||||
* globalkeys: Open "empty" browser on activation
|
||||
* Updated *_da.desktop files and removed *_da_DK.desktop files
|
||||
* Update AUTHORS
|
||||
* Open https://duckduckgo.com instead of google.com as default
|
||||
* Update desktop entries and Replace fr_FR by fr
|
||||
* lxqt-rc.xml: Change default config install path
|
||||
* Settings Openbox updated.
|
||||
* Screenshot (Shift+Print), file manager (ctl+Alt+e) and web browser (Ctl+atl+i) key shortcuts added.
|
||||
* Default key shortcuts added to lxqt-globalkeysd.
|
||||
* Update Greek translation (el) Remove country variant from language code
|
||||
* CMake: Adds Runtime and Devel install COMPONENTs
|
||||
* Coding style changes
|
||||
* Adds double quotes to everything that may break
|
||||
* Updates the build system to use the Targets infrastructure
|
||||
* Drops hardcoded /etc/xdg paths
|
||||
* Updated german translation, replaced Qt4 by Qt in all xsession/translations
|
||||
* Updates translations infrastructure
|
||||
* Update the required minimum cmake version
|
||||
* remove dead template lines switch OnlyShowIn from Razor -> LXQt stringchanges LxQt -> LXQt
|
||||
* Add session.conf and windowmanagers.conf.
|
||||
* Support lxqt-session and add necessary xdg autostart desktop entry files.
|
||||
* Rename dirs and replace razor with lxqt. Install lxqt.conf to /etc/xdg/lxqt and provide theme config.
|
||||
* Properly set default wallpaper for pcmanfm-qt. Comment out openbox config handling in startlxde-qt since it's not needed.
|
||||
* Fix file paths, replacing razor with lxqt. * Remove Alt+F2 and Ctrl+Esc from openbox config file to avoid conflicts with lxqt-panel & lxqt-globalkeys.
|
||||
* Add default configuration files for lxde-qt session.
|
||||
|
||||
0.11.1 / 2017-01-01
|
||||
===================
|
||||
|
||||
* Release 0.11.1: Update changelog
|
||||
* Added *da.desktop
|
||||
* Use the lxqt-build-tools/lxqt_create_portable_headers
|
||||
* Use the new lxqt-build-tools package
|
||||
* Create lxqt-config-globalkeyshortcuts_fr.desktop
|
||||
* Remove cpack (#41)
|
||||
|
||||
0.11.0 / 2016-09-24
|
||||
===================
|
||||
|
||||
* Release 0.11.0: Add changelog
|
||||
* Add README.md
|
||||
* Add Catalan translation
|
||||
* daemon: Use QDBusServiceWatcher
|
||||
* Fix typo in German translation for desktop file (#38)
|
||||
* build: Use external translations
|
||||
* ts-files removal (#35)
|
||||
* Improve foreach iterator use
|
||||
* daemon/core: Optimize Core startup string stuff
|
||||
* Client: Fix memory leak (static data)
|
||||
* Fix untranslated string in French translation
|
||||
* fix reseting the state of the edit dialog
|
||||
* Default configs from /etc/xdg/lxqt must be loaded.
|
||||
* static_cast<error_t>, fixes FTBFS for the Hurd
|
||||
* lxqt-globalkeys is LGPL only, there are no GPL files in it
|
||||
* Update italian translation, remove country-specific variant
|
||||
* Italian translation update
|
||||
* Update Russian translation Remove ru_RU files
|
||||
* Update French translation
|
||||
* client: Fix typo in pkg-config dependencies
|
||||
* upd: lxqt-config-globalkeyshortcuts_hu.ts
|
||||
* Fix warning
|
||||
|
||||
0.10.0 / 2015-10-31
|
||||
===================
|
||||
|
||||
* Fix license file
|
||||
* Update translations
|
||||
* Fix regression for config add dialog
|
||||
* Remove shortcut grabbing from the main window
|
||||
* Add KDevelop project type to .gitignore
|
||||
* OnlyShowIn=LXQt;
|
||||
* Rename LxQt to LXQt everywhere
|
||||
* Update Greek translation Remove country variant from language code
|
||||
* Updated german translation, make it common for all german speaking regions.
|
||||
* Updated template.
|
||||
* Handles CMake policy CMP0063
|
||||
* Export the ShortutSelector class
|
||||
* Use LXQtCompilerSettings CMake module
|
||||
* Install lxqt-globalkeysd to where it belongs
|
||||
* Renames development and runtime CMake COMPONENT's
|
||||
* Use target_compile_definitions()
|
||||
* Coding style changes
|
||||
* Double Quote CMake variables that may contain blanks
|
||||
* Removes unneeded CMake stuff
|
||||
* Use CMAKE_AUTOUIC
|
||||
* Removes not needed include_directories()
|
||||
* Removes hardcoded install dirs
|
||||
* Drops LIB_SUFFIX. Use GNUInstallDirs.
|
||||
* Fix three memory leaks in daemon error handling
|
||||
* Fix FTBFS after new CMake Targets
|
||||
* main: use standard liblxqt unix signal handling to quit
|
||||
* Adds intree/superbuild support
|
||||
* Generate -config-version.cmake files
|
||||
* Drops xxx_use.cmake files. Adopt Targets
|
||||
* Makes the config.cmake usable in an super build
|
||||
* Update to use the new liblxqt Targets infrastructure
|
||||
* daemon: fix two memory leaks
|
||||
* Removes commented CMake code
|
||||
* Removes unused FindInstallConfigPath.cmake
|
||||
* Hungarian translation added
|
||||
* Add additional map to track disabled actions
|
||||
* daemon: not grabbing disabled shortcuts
|
||||
* Update lxqt-config-globalkeyshortcuts_it_IT.desktop
|
||||
* client: emitting registrationFinished signal
|
||||
* Add check for NULL pointer. See lxde/lxqt#521
|
||||
* Use ~ instead of / as working dir. Fixes lxde/lxqt#521
|
||||
* Make DBus calls to addClientAction async
|
||||
|
||||
0.9.0 / 2015-01-07
|
||||
==================
|
||||
|
||||
* Portuguese update
|
||||
* - Unify naming for a unique lxqt. No more suffixes
|
||||
* Use the new LxQt::SingleApplication
|
||||
* CMakeLists maitenance
|
||||
* Uses the new translations cmake modules
|
||||
* Update Russian translation
|
||||
* Drop Qt4 support in code
|
||||
* Clean up CMakeLists.txt and drop Qt 4 support
|
||||
|
||||
0.8.0 / 2014-10-10
|
||||
==================
|
||||
|
||||
* Adapt to the translation infrastructure
|
||||
* - Fix Greek translation to conform with desktopfile validation
|
||||
* Link to correct version of lxqt-globalkeys for lxqt-globalkeys-ui.
|
||||
* Updates translations files install destination
|
||||
* Adds include_directories() to the _use.cmake file
|
||||
* Adds portable headers
|
||||
* Fix broken qt4 build and make lib and include paths of qt4 and qt5 versions different.
|
||||
* Do simplification and cleanup for the qt5 port. * Use cmake 2.8.9 by default and require 2.8.11 for qt5.
|
||||
* Initial Qt5 support
|
||||
* Use new LXQt header files.
|
||||
* Improve FreeBSD support
|
||||
|
||||
0.7.0 / 2014-05-07
|
||||
==================
|
||||
|
||||
* Update COPYING
|
||||
|
||||
0.6.99 / 2014-04-30
|
||||
===================
|
||||
|
||||
* remove old translation templates remove translated icon names
|
||||
* Add #include <libgen.h> for using basename(). Add typedef for error_t if it's not defined.
|
||||
* Update AUTHORS
|
||||
* Add CPack rules for creating tarball
|
||||
* Bring desktop file in line with the others
|
||||
* Don't append library suffix to library install path, but use it by default
|
||||
* Respect standard LIB_INSTALL_DIR
|
||||
* Removed CMAKE_SOURCE_DIR usage from CMakeLists.txt files
|
||||
* Fix renaming bugs, replacing lxqt-qt with lxde-qt
|
||||
* Finish the crazy razor=>lxqt renaming tasks.
|
||||
* Project name added to cmake file
|
||||
* Fix incorrect header inclusion.
|
||||
* Fix broken cmake config and use files.
|
||||
* Rename to lxqt-globalkeys. * Add cmake config and use files for liblxqt-globalkeys and liblxqt-globalkeys-ui.
|
||||
* Add client and ui libs (original razor-global-key-shortcuts-client and razor-global-key-shortcut-selector).
|
||||
* Fix incorrect dbus address by replacing razorqt with lxqt.
|
||||
* Fix broken build and rename binary to lxqt-globalshortcutsd.
|
||||
* Add COPYING and AUTHORS
|
||||
* Desktop file for global key shortcut configurator added to install
|
||||
* X-RAZOR changed to Razor in desktop files
|
||||
* Small CMake improvements
|
||||
* Qt 4.8.2+ compatibility improved
|
||||
* C includes fixed
|
||||
* Qt 4.6 compatibility
|
||||
* No dependencies on STL
|
||||
* Fix build
|
||||
* Fix #601
|
||||
* Typo really fixed (https://github.com/Razor-qt/razor-qt/commit/a8e71608fad71dfe8ad6be6ff1057067a19d93dc#commitcomment-3111401)
|
||||
* Fix 'Unknown CMake command "razor_translate_ts"' error.
|
||||
* Global key shortcuts config behaviour fixed
|
||||
* TODO file removed (github issues to be used)
|
||||
* Todo list updated
|
||||
* Shortcut selectors fix for reset by timeout
|
||||
* Shortcut selectors unified
|
||||
* Shortcut can be changed just in the table
|
||||
* Typo fixed
|
||||
* New shortcut can be automatically applied to the selector text
|
||||
* Should not set empty shortcuts - there is "enabled" feature for this
|
||||
* Never allow to grab printable keys
|
||||
* Todo list updated
|
||||
* Shortcuts can be cleared from manager
|
||||
* Stricter checks for client actions
|
||||
* Inactive client actions can be removed from manager
|
||||
* Todo list updated
|
||||
* Todo list updated
|
||||
* Temp files removed
|
||||
* Global shortcuts client library added and all support for it refactored and fixed.
|
||||
* Todo list updated
|
||||
* Run as app by default
|
||||
* Using PROJECT_NAME variable instead of PROJECT in CMake files
|
||||
* Configurator ready for translation
|
||||
* Header guards updated
|
||||
* HPP files renamed to H and AStyle applied
|
||||
* Missing license header added
|
||||
* Unused files removed
|
||||
* AStyle applied
|
||||
* Initial import of global shortcut configurator
|
||||
* Initial import of global shortcut daemon
|
||||
* Todo updated
|
||||
* Edit action dialog added
|
||||
* Model indexes fixed
|
||||
* Smart column autoresize
|
||||
* Better dbus proxy usage
|
||||
* Better optimisation handling
|
||||
* Always printing a message in case of action failure
|
||||
* Grabbing already grabbed shortcut releases keyboard
|
||||
* Better command line info
|
||||
* Todo file added
|
||||
* Disabled actions grayed out
|
||||
* Duplicate shortcuts highlighted Algorithm speed increased
|
||||
* Unorderness of QSet fixed
|
||||
* Shortcut editor added (but not used yet) Multiple actions behaviour selector added Some minor code style changes
|
||||
* Minor style changes
|
||||
* Manager has complete default read-only model
|
||||
* More headers included
|
||||
* Delayed actions model initialisation (allows correct signals handling)
|
||||
* Correct daemon service name
|
||||
* Correct command action info generation
|
||||
* Prevent actions from multiplying when saving to the settings file
|
||||
* Fixed meta types
|
||||
* getAllActionsById renamed to getAllActions
|
||||
* The simplest proxy model added to the manager
|
||||
* More info returned by daemon
|
||||
* Standard Qt header used
|
||||
* Demo client app
|
||||
* Qt4 compatibility issues fixed
|
||||
* CMakefiles standardised
|
||||
* Better actions IDs code Enable action methods exposed to DBus Config file fixed
|
||||
* Daemon presence can be detected by native library - and it can reconnect
|
||||
* Library refactored heavily
|
||||
* Checking X11 error after each call CancelShortcutGrab method added Freshly grabbed shortcut checked More verbose X11 error output
|
||||
* Removed non existing signal connection
|
||||
* daemon_native* renamed to native* grabShortcut method duplicated in native* interface now install/uninstall added to project
|
||||
* Native client library
|
||||
* Meta types improved Better request functions
|
||||
* Initial copy of Qt-based global action system
|
||||
* globalkeyshortucts: fix segfault and other bugs in daemon
|
||||
* Translations updated
|
||||
* Translations updated
|
||||
* Fix components missing translations
|
||||
* Translations
|
||||
* Install translations into correct places
|
||||
* Update translations
|
||||
* Enable translations for some components that were missing them
|
||||
* Removed line num from TS files.
|
||||
* Deleted old translation methods.
|
||||
* New translation infrastructure
|
||||
* complete setting parsing part for dbus call
|
||||
* re-define classes to make server side ready for DBUS shortcuts
|
||||
* global keys: server settings renaming
|
||||
* globalkeys config: UI fixes; translations; proper layouting
|
||||
* globalkeys: missing license; display groups as a whole line in the config dialog
|
||||
* global keyobard shortcuts: initial import from Aaron's repo. Astyle-d. License added where required. Renamed to be more descriptive.
|
@ -0,0 +1,106 @@
|
||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
|
||||
project(lxqt-globalkeys)
|
||||
|
||||
# additional cmake files
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
set(LXQTBT_MINIMUM_VERSION "0.4.0")
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5DBus REQUIRED)
|
||||
find_package(Qt5LinguistTools REQUIRED)
|
||||
find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
|
||||
find_package(lxqt REQUIRED)
|
||||
|
||||
|
||||
# Patch Version
|
||||
set(LXQT_GLOBALKEYS_PATCH_VERSION 0)
|
||||
|
||||
set(LXQT_GLOBALKEYS_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_GLOBALKEYS_PATCH_VERSION})
|
||||
add_definitions("-DLXQT_GLOBALKEYS_VERSION=\"${LXQT_GLOBALKEYS_VERSION}\"")
|
||||
|
||||
include(LXQtTranslate)
|
||||
include(LXQtCreatePkgConfigFile)
|
||||
include(LXQtCreatePortableHeaders)
|
||||
include(LXQtCompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
include(GNUInstallDirs) # Standard directories for installation
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(LXQT_GLOBALKEYS_LIBRARY_NAME lxqt-globalkeys)
|
||||
set(LXQT_GLOBALKEYS_UI_LIBRARY_NAME lxqt-globalkeys-ui)
|
||||
set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake")
|
||||
|
||||
#************************************************
|
||||
# Build config.cmake files
|
||||
#************************************************
|
||||
set(LXQT_GLOBALKEYS_CMAKE_NAME ${LXQT_GLOBALKEYS_LIBRARY_NAME})
|
||||
set(LXQT_GLOBALKEYS_UI_CMAKE_NAME ${LXQT_GLOBALKEYS_UI_LIBRARY_NAME})
|
||||
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys-config.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake"
|
||||
INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys_ui-config.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake"
|
||||
INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
|
||||
)
|
||||
#************************************************
|
||||
# End of build config.cmake
|
||||
#************************************************
|
||||
|
||||
#************************************************
|
||||
# Generate config-version.cmake files
|
||||
#************************************************
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config-version.cmake"
|
||||
VERSION ${LXQT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config-version.cmake"
|
||||
VERSION ${LXQT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
#************************************************
|
||||
# End of generate config-version.cmake files
|
||||
#************************************************
|
||||
|
||||
set(LXQT_GLOBALKEYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
add_subdirectory(daemon)
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(ui)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake"
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config-version.cmake"
|
||||
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake"
|
||||
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config-version.cmake"
|
||||
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}"
|
||||
)
|
||||
|
||||
# merged from lxqt-common
|
||||
add_subdirectory(autostart)
|
||||
add_subdirectory(xdg)
|
||||
|
@ -0,0 +1,458 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
@ -0,0 +1,37 @@
|
||||
# lxqt-globalkeys
|
||||
|
||||
## Overview
|
||||
|
||||
This repository is providing tools to set global keyboard shortcuts in LXQt sessions, that is shortcuts which apply to the LXQt session as a whole and are not limited to distinct applications.
|
||||
|
||||
The core components are two binaries `lxqt-globalkeysd` and `lxqt-config-globalkeyshortcuts`.
|
||||
`lxqt-globalkeysd` is running in a daemon-like manner as so-called [LXQt Module](https://github.com/lxde/lxqt-session#lxqt-modules) and doing the actual work. GUI `lxqt-config-globalkeyshortcuts` is used to customize the shortcut settings.
|
||||
|
||||
## Installation
|
||||
|
||||
### Compiling source code
|
||||
|
||||
The only runtime dependencies is [liblxqt](https://github.com/lxde/liblxqt).
|
||||
Additional build dependencies are CMake and optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information.
|
||||
|
||||
Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` has to be set to `/usr` on most operating systems, depending on the way library paths are dealt with on 64bit systems variables like `CMAKE_INSTALL_LIBDIR` may have to be set as well.
|
||||
|
||||
To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual.
|
||||
|
||||
### Binary packages
|
||||
|
||||
Official binary packages are provided by all major Linux distributions like Arch Linux, Debian (as of Debian stretch only), Fedora and openSUSE. Just use your package manager to search for string `lxqt-globalkeys`.
|
||||
|
||||
## Configuration, Usage
|
||||
|
||||
### Caveat lxqt-globalkeys vs. window managers
|
||||
|
||||
Window managers can assign shortcuts as well and their scope may overlap with the one of lxqt-globalkeys in LXQt sessions.
|
||||
This was e. g. affecting elderly configuration files `rc.xml` of Openbox which were assigning `Ctrl+Alt+D` to toggling the display of the desktop which lxqt-globalkeys tries to do as well. This resulted in a warning message "Global shortcut C+A+d+ cannot be registered", see https://github.com/lxde/lxqt/issues/1032.
|
||||
As depicted in this issue [lxqt-notificationd](https://github.com/lxde/lxqt-notificationd) will show a warning when conflicts like this come up and users can thus decide whether they want to have the shortcut in question handled by the respective window manager or lxqt-globalkeys.
|
||||
|
||||
### lxqt-globalkeys
|
||||
|
||||
Daemon-like `lxqt-globalkeysd` can be adjusted from section "Basic Settings" in configuration dialogue [LXQt Session Settings](https://github.com/lxde/lxqt-session#overview) of [lxqt-session](https://github.com/lxde/lxqt-session).
|
||||
|
||||
Configuration dialogue "Global Actions Manager" (binary `lxqt-config-globalkeyshortcuts`) which is used to customize shortcuts can be opened from the panel's main menu - Preferences - LXQt Settings - Shortcut Keys and is provided by the [Configuration Center](https://github.com/lxde/lxqt-config#configuration-center) of [lxqt-config](https://github.com/lxde/lxqt-config) as well.
|
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
|
||||
file(GLOB DESKTOP_FILES_IN *.desktop.in)
|
||||
|
||||
# Translations **********************************
|
||||
lxqt_translate_desktop(DESKTOP_FILES
|
||||
SOURCES
|
||||
${DESKTOP_FILES_IN}
|
||||
)
|
||||
add_custom_target(lxqt_globlalkeys_autostart_desktop_files ALL DEPENDS ${DESKTOP_FILES})
|
||||
#************************************************
|
||||
|
||||
install(FILES
|
||||
${DESKTOP_FILES}
|
||||
DESTINATION "${LXQT_ETC_XDG_DIR}/autostart"
|
||||
COMPONENT Runtime
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Global Keyboard Shortcuts
|
||||
TryExec=lxqt-globalkeysd
|
||||
Exec=lxqt-globalkeysd
|
||||
OnlyShowIn=LXQt;
|
||||
X-LXQt-Module=true
|
||||
|
||||
#TRANSLATIONS_DIR=translations
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[cs]=Celkové klávesové zkratky
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[cs_CZ]=Celkové klávesové zkratky
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[da]=Globale tastaturgenveje
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[de]=Globale Kurzbefehle
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[el]=Καθολικές συντομεύσεις πληκτρολογίου
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[es]=Atajos Globales del Teclado
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[es_VE]=Atajos de teclados de LXQt
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[eu]=Teklatuko lasterbide orokorrak
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[fi]=Yleiset pikanäppäimet
|
@ -0,0 +1 @@
|
||||
Name[fr]=Raccourcis clavier globaux
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[it_IT]=Scorciatoie globali della tastiera
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[lt]=Visuotiniai spartieji klavišai
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pl_PL]=Globalne Skróty Klawiszowe
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pt]=Teclas de atalho globais
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pt_BR]=Atalhos Globais Do Teclado
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ro_RO]=Taste rapide globale
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ru]=Глобальные горячих клавиш
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ru_RU]=Глобальные сочетания клавиш
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[th_TH]=ปุ่มลัดหลักต่างๆ
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[uk]=Глобальні клавіатурні скорочення
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[zh_CN]=全局键盘快捷键
|
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[zh_TW]=全域鍵盤快捷鍵
|
@ -0,0 +1,252 @@
|
||||
set(PROJECT_NAME ${LXQT_GLOBALKEYS_LIBRARY_NAME})
|
||||
project(${PROJECT_NAME})
|
||||
|
||||
set(QT_DBUS_PREFIX "org.qtproject")
|
||||
|
||||
set(${PROJECT_NAME}_HEADER_NAMESPACE "LXQtGlobalKeys")
|
||||
|
||||
set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon")
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
client.cpp
|
||||
action.cpp
|
||||
)
|
||||
|
||||
#
|
||||
# WARNING: Changing stuff here implies changing this:
|
||||
# install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT Devel RENAME "lxqtglobalkeys.h")
|
||||
#
|
||||
set(${PROJECT_NAME}_MAIN_HEADER
|
||||
lxqt-globalkeys.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PUBLIC_CPP_HEADERS
|
||||
client.h
|
||||
action.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PUBLIC_CLASSES
|
||||
Client
|
||||
Action
|
||||
LXQtGlobalKeys
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PRIVATE_CPP_HEADERS
|
||||
client_p.h
|
||||
action_p.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_FORMS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_RESOURCES
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATIONS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_ADAPTORS
|
||||
"${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml"
|
||||
)
|
||||
|
||||
set_source_files_properties("${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml" PROPERTIES
|
||||
INCLUDE action_p.h
|
||||
PARENT_CLASSNAME GlobalKeyShortcut::ActionImpl
|
||||
BASENAME org.lxqt.global_key_shortcuts.client
|
||||
CLASSNAME OrgLxqtActionClientAdaptor
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_INTERFACES
|
||||
"${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml"
|
||||
)
|
||||
|
||||
set_source_files_properties("${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml" PROPERTIES
|
||||
BASENAME org.lxqt.global_key_shortcuts.native
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PUBLIC_HEADERS
|
||||
${${PROJECT_NAME}_PUBLIC_CPP_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PRIVATE_HEADERS
|
||||
${${PROJECT_NAME}_PRIVATE_CPP_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_CPP_HEADERS
|
||||
${${PROJECT_NAME}_PUBLIC_CPP_HEADERS}
|
||||
${${PROJECT_NAME}_PRIVATE_CPP_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
${${PROJECT_NAME}_PUBLIC_HEADERS}
|
||||
${${PROJECT_NAME}_PRIVATE_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATABLE
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_FORMS}
|
||||
)
|
||||
|
||||
foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
|
||||
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
|
||||
configure_file(
|
||||
${DBUS_ADAPTOR}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
|
||||
get_source_file_property(DBUS_ADAPTOR_PARENT_CLASSNAME ${DBUS_ADAPTOR} PARENT_CLASSNAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_BASENAME ${DBUS_ADAPTOR} BASENAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
|
||||
if(DBUS_ADAPTOR_BASENAME)
|
||||
if(DBUS_ADAPTOR_CLASSNAME)
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
|
||||
endif()
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
|
||||
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
|
||||
configure_file(
|
||||
${DBUS_INTERFACE}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
|
||||
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
|
||||
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
|
||||
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
|
||||
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
|
||||
INCLUDE ${DBUS_INTERFACE_INCLUDE}
|
||||
CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
|
||||
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
|
||||
)
|
||||
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
|
||||
endforeach()
|
||||
|
||||
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
|
||||
|
||||
set(${PROJECT_NAME}_GENERATED_FILES
|
||||
${${PROJECT_NAME}_FORM_FILES}
|
||||
${${PROJECT_NAME}_RESOURCE_FILES}
|
||||
${${PROJECT_NAME}_QM_FILES}
|
||||
${${PROJECT_NAME}_DBUS_INTERFACE_FILES}
|
||||
${${PROJECT_NAME}_DBUS_ADAPTOR_FILES}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_ALL_FILES
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_GENERATED_FILES}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_PKG_CONFIG_REQUIRES "Qt5Widgets, Qt5DBus")
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
Qt5::Widgets
|
||||
Qt5::DBus
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
VERSION ${LXQT_VERSION}
|
||||
SOVERSION ${LXQT_MAJOR_VERSION}
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_GLOBALKEYS_LIBRARY_NAME}>"
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include>"
|
||||
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}>"
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE "SHARED_EXPORT=Q_DECL_EXPORT"
|
||||
)
|
||||
|
||||
export(TARGETS ${PROJECT_NAME} FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}-targets.cmake")
|
||||
|
||||
|
||||
lxqt_create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS
|
||||
PATH_PREFIX ".."
|
||||
NAME_PREFIX "${${PROJECT_NAME}_NAMESPACE}"
|
||||
HEADER_NAMES ${${PROJECT_NAME}_PUBLIC_CLASSES}
|
||||
)
|
||||
|
||||
# Copy public headers for intree building
|
||||
foreach(h ${${PROJECT_NAME}_PUBLIC_HEADERS})
|
||||
get_filename_component(bh ${h} NAME)
|
||||
configure_file(${h} "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${bh}" COPYONLY)
|
||||
endforeach()
|
||||
|
||||
foreach(h ${${PROJECT_NAME}_PORTABLE_HEADERS})
|
||||
get_filename_component(bh ${h} NAME)
|
||||
configure_file(${h} "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}/${bh}" COPYONLY)
|
||||
endforeach()
|
||||
|
||||
configure_file(
|
||||
"${${PROJECT_NAME}_MAIN_HEADER}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${${PROJECT_NAME}_MAIN_HEADER}"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${${PROJECT_NAME}_MAIN_HEADER}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/lxqtglobalkeys.h"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
install(TARGETS
|
||||
${PROJECT_NAME}
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
COMPONENT Runtime
|
||||
)
|
||||
|
||||
install(EXPORT
|
||||
${PROJECT_NAME}-targets
|
||||
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${${PROJECT_NAME}_MAIN_HEADER}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${${PROJECT_NAME}_MAIN_HEADER}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
|
||||
COMPONENT Devel
|
||||
RENAME "lxqtglobalkeys.h"
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${${PROJECT_NAME}_PORTABLE_HEADERS}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${${PROJECT_NAME}_PUBLIC_HEADERS}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
lxqt_create_pkgconfig_file(
|
||||
PACKAGE_NAME ${PROJECT_NAME}
|
||||
DESCRIPTIVE_NAME ${PROJECT_NAME}
|
||||
DESCRIPTION "LXQt global key shortcuts client library"
|
||||
INCLUDEDIRS ${PROJECT_NAME}
|
||||
LIBS ${PROJECT_NAME}
|
||||
REQUIRES ${${PROJECT_NAME}_PKG_CONFIG_REQUIRES}
|
||||
VERSION ${LXQT_VERSION}
|
||||
INSTALL
|
||||
)
|
@ -0,0 +1,151 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "action.h"
|
||||
#include "action_p.h"
|
||||
#include "client_p.h"
|
||||
|
||||
#include "org.lxqt.global_key_shortcuts.client.h"
|
||||
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
|
||||
ActionImpl::ActionImpl(ClientImpl *client, Action *interface, const QString &path, const QString &description, QObject *parent)
|
||||
: QObject(parent)
|
||||
, mClient(client)
|
||||
, mInterface(interface)
|
||||
, mPath(path)
|
||||
, mDescription(description)
|
||||
, mRegistrationPending(false)
|
||||
{
|
||||
new OrgLxqtActionClientAdaptor(this);
|
||||
|
||||
connect(this, SIGNAL(emitRegistrationFinished()), mInterface, SIGNAL(registrationFinished()));
|
||||
connect(this, SIGNAL(emitActivated()), mInterface, SIGNAL(activated()));
|
||||
connect(this, SIGNAL(emitShortcutChanged(QString, QString)), mInterface, SIGNAL(shortcutChanged(QString, QString)));
|
||||
}
|
||||
|
||||
ActionImpl::~ActionImpl()
|
||||
{
|
||||
mClient->removeAction(this);
|
||||
}
|
||||
|
||||
QString ActionImpl::changeShortcut(const QString &shortcut)
|
||||
{
|
||||
if (mRegistrationPending)
|
||||
return mShortcut;
|
||||
|
||||
mShortcut = mClient->changeClientActionShortcut(mPath, shortcut);
|
||||
return mShortcut;
|
||||
}
|
||||
|
||||
bool ActionImpl::changeDescription(const QString &description)
|
||||
{
|
||||
if (mRegistrationPending)
|
||||
return false;
|
||||
|
||||
bool result = mClient->modifyClientAction(mPath, description);
|
||||
if (result)
|
||||
{
|
||||
mDescription = description;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ActionImpl::setShortcut(const QString &shortcut)
|
||||
{
|
||||
mShortcut = shortcut;
|
||||
}
|
||||
|
||||
QString ActionImpl::path() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
QString ActionImpl::shortcut() const
|
||||
{
|
||||
return mShortcut;
|
||||
}
|
||||
|
||||
QString ActionImpl::description() const
|
||||
{
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
void ActionImpl::setValid(bool valid)
|
||||
{
|
||||
mValid = valid;
|
||||
}
|
||||
|
||||
bool ActionImpl::isValid() const
|
||||
{
|
||||
return mValid;
|
||||
}
|
||||
|
||||
void ActionImpl::setRegistrationPending(bool registrationPending)
|
||||
{
|
||||
mRegistrationPending = registrationPending;
|
||||
if (!mRegistrationPending)
|
||||
emit emitRegistrationFinished();
|
||||
|
||||
}
|
||||
|
||||
bool ActionImpl::isRegistrationPending() const
|
||||
{
|
||||
return mRegistrationPending;
|
||||
}
|
||||
|
||||
void ActionImpl::activated()
|
||||
{
|
||||
emit emitActivated();
|
||||
}
|
||||
|
||||
void ActionImpl::shortcutChanged(const QString &oldShortcut, const QString &newShortcut)
|
||||
{
|
||||
emit emitShortcutChanged(oldShortcut, newShortcut);
|
||||
}
|
||||
|
||||
|
||||
Action::Action(QObject *parent)
|
||||
: QObject(parent)
|
||||
, impl(0)
|
||||
{
|
||||
}
|
||||
|
||||
Action::~Action()
|
||||
{
|
||||
}
|
||||
|
||||
QString Action::changeShortcut(const QString &shortcut) { return impl->changeShortcut(shortcut); }
|
||||
bool Action::changeDescription(const QString &description) { return impl->changeDescription(description); }
|
||||
QString Action::path() const { return impl->path(); }
|
||||
QString Action::shortcut() const { return impl->shortcut(); }
|
||||
QString Action::description() const { return impl->description(); }
|
||||
bool Action::isValid() const { return impl->isValid(); }
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
|
||||
#define GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
|
||||
class ActionImpl;
|
||||
class ClientImpl;
|
||||
|
||||
#ifndef SHARED_EXPORT
|
||||
#define SHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
class SHARED_EXPORT Action : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class ActionImpl;
|
||||
friend class ClientImpl;
|
||||
|
||||
public:
|
||||
~Action();
|
||||
|
||||
QString changeShortcut(const QString &shortcut);
|
||||
bool changeDescription(const QString &description);
|
||||
|
||||
QString path() const;
|
||||
QString shortcut() const;
|
||||
QString description() const;
|
||||
|
||||
bool isValid() const;
|
||||
bool isRegistrationPending() const;
|
||||
|
||||
signals:
|
||||
void registrationFinished();
|
||||
void activated();
|
||||
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
private:
|
||||
Action(QObject *parent = 0);
|
||||
|
||||
ActionImpl *impl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
|
@ -0,0 +1,88 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
|
||||
#define GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QSharedPointer>
|
||||
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
|
||||
class Action;
|
||||
class ClientImpl;
|
||||
|
||||
class ActionImpl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionImpl(ClientImpl *client, Action *interface, const QString &path, const QString &description, QObject *parent = 0);
|
||||
~ActionImpl();
|
||||
|
||||
QString changeShortcut(const QString &shortcut);
|
||||
bool changeDescription(const QString &description);
|
||||
|
||||
void setShortcut(const QString &shortcut);
|
||||
|
||||
QString path() const;
|
||||
QString shortcut() const;
|
||||
QString description() const;
|
||||
|
||||
void setValid(bool valid);
|
||||
bool isValid() const;
|
||||
|
||||
void setRegistrationPending(bool registrationPending);
|
||||
bool isRegistrationPending() const;
|
||||
|
||||
public slots:
|
||||
void activated();
|
||||
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
signals:
|
||||
void emitRegistrationFinished();
|
||||
void emitActivated();
|
||||
void emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
private:
|
||||
ClientImpl *mClient;
|
||||
Action *mInterface;
|
||||
QString mAlias;
|
||||
QString mPath;
|
||||
QString mShortcut;
|
||||
QString mDescription;
|
||||
bool mValid;
|
||||
bool mRegistrationPending;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
|
@ -0,0 +1,333 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "client.h"
|
||||
#include "client_p.h"
|
||||
#include "action_p.h"
|
||||
#include "org.lxqt.global_key_shortcuts.native.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
|
||||
ClientImpl::ClientImpl(Client *interface, QObject *parent)
|
||||
: QObject(parent)
|
||||
, mInterface(interface)
|
||||
, mServiceWatcher(new QDBusServiceWatcher("org.lxqt.global_key_shortcuts", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
|
||||
, mDaemonPresent(false)
|
||||
{
|
||||
connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(daemonDisappeared(QString)));
|
||||
connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(daemonAppeared(QString)));
|
||||
mProxy = new org::lxqt::global_key_shortcuts::native("org.lxqt.global_key_shortcuts", "/native", QDBusConnection::sessionBus(), this);
|
||||
mDaemonPresent = mProxy->isValid();
|
||||
|
||||
connect(this, SIGNAL(emitShortcutGrabbed(QString)), mInterface, SIGNAL(shortcutGrabbed(QString)));
|
||||
connect(this, SIGNAL(emitGrabShortcutFailed()), mInterface, SIGNAL(grabShortcutFailed()));
|
||||
connect(this, SIGNAL(emitGrabShortcutCancelled()), mInterface, SIGNAL(grabShortcutCancelled()));
|
||||
connect(this, SIGNAL(emitGrabShortcutTimedout()), mInterface, SIGNAL(grabShortcutTimedout()));
|
||||
connect(this, SIGNAL(emitDaemonDisappeared()), mInterface, SIGNAL(daemonDisappeared()));
|
||||
connect(this, SIGNAL(emitDaemonAppeared()), mInterface, SIGNAL(daemonAppeared()));
|
||||
connect(this, SIGNAL(emitDaemonPresenceChanged(bool)), mInterface, SIGNAL(daemonPresenceChanged(bool)));
|
||||
}
|
||||
|
||||
ClientImpl::~ClientImpl()
|
||||
{
|
||||
QMap<QString, Action*>::iterator M = mActions.end();
|
||||
for (QMap<QString, Action*>::iterator I = mActions.begin(); I != M; ++I)
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterObject(QString("/global_key_shortcuts") + I.key());
|
||||
|
||||
delete I.value();
|
||||
}
|
||||
mActions.clear();
|
||||
}
|
||||
|
||||
void ClientImpl::daemonDisappeared(const QString &)
|
||||
{
|
||||
mDaemonPresent = false;
|
||||
emit emitDaemonDisappeared();
|
||||
emit emitDaemonPresenceChanged(mDaemonPresent);
|
||||
}
|
||||
|
||||
void ClientImpl::daemonAppeared(const QString &)
|
||||
{
|
||||
QMap<QString, Action*>::iterator last = mActions.end();
|
||||
for (QMap<QString, Action*>::iterator I = mActions.begin(); I != last; ++I)
|
||||
{
|
||||
ActionImpl *globalActionImpl = I.value()->impl;
|
||||
|
||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(mProxy->addClientAction(globalActionImpl->shortcut(), QDBusObjectPath(globalActionImpl->path()), globalActionImpl->description()));
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(registrationFinished(QDBusPendingCallWatcher *)));
|
||||
mPendingRegistrationsActions[watcher] = globalActionImpl;
|
||||
mPendingRegistrationsWatchers[globalActionImpl] = watcher;
|
||||
globalActionImpl->setRegistrationPending(true);
|
||||
}
|
||||
mDaemonPresent = true;
|
||||
emit emitDaemonAppeared();
|
||||
emit emitDaemonPresenceChanged(mDaemonPresent);
|
||||
}
|
||||
|
||||
bool ClientImpl::isDaemonPresent() const
|
||||
{
|
||||
return mDaemonPresent;
|
||||
}
|
||||
|
||||
void ClientImpl::registrationFinished(QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
QMap<QDBusPendingCallWatcher*, ActionImpl*>::Iterator I = mPendingRegistrationsActions.find(watcher);
|
||||
if (I != mPendingRegistrationsActions.end())
|
||||
{
|
||||
ActionImpl *globalActionImpl = I.value();
|
||||
|
||||
QDBusPendingReply<QString, qulonglong> reply = *watcher;
|
||||
globalActionImpl->setValid(!reply.isError() && reply.argumentAt<1>());
|
||||
|
||||
if (globalActionImpl->isValid())
|
||||
{
|
||||
globalActionImpl->setShortcut(reply.argumentAt<0>());
|
||||
}
|
||||
|
||||
mPendingRegistrationsWatchers.remove(globalActionImpl);
|
||||
mPendingRegistrationsActions.erase(I);
|
||||
watcher->deleteLater();
|
||||
|
||||
globalActionImpl->setRegistrationPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
Action *ClientImpl::addClientAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent)
|
||||
{
|
||||
if (!QRegExp("(/[A-Za-z0-9_]+){2,}").exactMatch(path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mActions.contains(path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Action *globalAction = new Action(parent);
|
||||
|
||||
ActionImpl *globalActionImpl = new ActionImpl(this, globalAction, path, description, globalAction);
|
||||
globalAction->impl = globalActionImpl;
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerObject(QString("/global_key_shortcuts") + path, globalActionImpl))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mDaemonPresent)
|
||||
{
|
||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(mProxy->addClientAction(shortcut, QDBusObjectPath(path), description));
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(registrationFinished(QDBusPendingCallWatcher *)));
|
||||
mPendingRegistrationsActions[watcher] = globalActionImpl;
|
||||
mPendingRegistrationsWatchers[globalActionImpl] = watcher;
|
||||
globalActionImpl->setRegistrationPending(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
globalActionImpl->setValid(false);
|
||||
}
|
||||
|
||||
mActions[path] = globalAction;
|
||||
|
||||
|
||||
return globalAction;
|
||||
}
|
||||
|
||||
void removeAction(Action *action);
|
||||
|
||||
QString ClientImpl::changeClientActionShortcut(const QString &path, const QString &shortcut)
|
||||
{
|
||||
if (!mActions.contains(path))
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QDBusPendingReply<QString> reply = mProxy->changeClientActionShortcut(QDBusObjectPath(path), shortcut);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool ClientImpl::modifyClientAction(const QString &path, const QString &description)
|
||||
{
|
||||
if (!mActions.contains(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusPendingReply<bool> reply = mProxy->modifyClientAction(QDBusObjectPath(path), description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool ClientImpl::removeClientAction(const QString &path)
|
||||
{
|
||||
if (!mActions.contains(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusPendingReply<bool> reply = mProxy->removeClientAction(QDBusObjectPath(path));
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(QString("/global_key_shortcuts") + path);
|
||||
|
||||
mActions[path]->disconnect();
|
||||
mActions.remove(path);
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
void ClientImpl::removeAction(ActionImpl *actionImpl)
|
||||
{
|
||||
if (actionImpl->isRegistrationPending())
|
||||
{
|
||||
QMap<ActionImpl*, QDBusPendingCallWatcher*>::Iterator I = mPendingRegistrationsWatchers.find(actionImpl);
|
||||
if (I != mPendingRegistrationsWatchers.end())
|
||||
{
|
||||
QDBusPendingCallWatcher *watcher = I.value();
|
||||
|
||||
watcher->disconnect();
|
||||
|
||||
mPendingRegistrationsActions.remove(watcher);
|
||||
mPendingRegistrationsWatchers.erase(I);
|
||||
watcher->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
QString path = actionImpl->path();
|
||||
if (!mActions.contains(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusPendingReply<bool> reply = mProxy->deactivateClientAction(QDBusObjectPath(path));
|
||||
reply.waitForFinished();
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(QString("/global_key_shortcuts") + path);
|
||||
|
||||
mActions[path]->disconnect();
|
||||
mActions.remove(path);
|
||||
}
|
||||
|
||||
void ClientImpl::grabShortcut(uint timeout)
|
||||
{
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(mProxy->grabShortcut(timeout), this);
|
||||
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(grabShortcutFinished(QDBusPendingCallWatcher *)));
|
||||
}
|
||||
|
||||
void ClientImpl::cancelShortcutGrab()
|
||||
{
|
||||
mProxy->cancelShortcutGrab();
|
||||
}
|
||||
|
||||
void ClientImpl::grabShortcutFinished(QDBusPendingCallWatcher *call)
|
||||
{
|
||||
QDBusPendingReply<QString, bool, bool, bool> reply = *call;
|
||||
if (reply.isError())
|
||||
{
|
||||
emit emitGrabShortcutFailed();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<1>())
|
||||
{
|
||||
emit emitGrabShortcutFailed();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<2>())
|
||||
{
|
||||
emit emitGrabShortcutCancelled();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<3>())
|
||||
{
|
||||
emit emitGrabShortcutTimedout();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit emitShortcutGrabbed(reply.argumentAt<0>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
call->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
static QScopedPointer<Client> globalActionNativeClient;
|
||||
|
||||
Client *Client::instance()
|
||||
{
|
||||
if (!globalActionNativeClient)
|
||||
{
|
||||
globalActionNativeClient.reset(new Client());
|
||||
}
|
||||
|
||||
return globalActionNativeClient.data();
|
||||
}
|
||||
|
||||
Client::Client()
|
||||
: QObject(0)
|
||||
, impl(new ClientImpl(this, this))
|
||||
{
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
globalActionNativeClient.take();
|
||||
}
|
||||
|
||||
Action *Client::addAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent) { return impl->addClientAction(shortcut, path, description, parent); }
|
||||
bool Client::removeAction(const QString &path) { return impl->removeClientAction(path); }
|
||||
void Client::grabShortcut(uint timeout) { impl->grabShortcut(timeout); }
|
||||
void Client::cancelShortcutGrab() { impl->cancelShortcutGrab(); }
|
||||
bool Client::isDaemonPresent() const { return impl->isDaemonPresent(); }
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__INCLUDED
|
||||
#define GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__INCLUDED
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
|
||||
class Action;
|
||||
class ClientImpl;
|
||||
|
||||
#ifndef SHARED_EXPORT
|
||||
#define SHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
class SHARED_EXPORT Client : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Client *instance();
|
||||
~Client();
|
||||
|
||||
Action *addAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent = 0);
|
||||
bool removeAction(const QString &path);
|
||||
|
||||
bool isDaemonPresent() const;
|
||||
|
||||
public slots:
|
||||
void grabShortcut(uint timeout);
|
||||
void cancelShortcutGrab();
|
||||
|
||||
signals:
|
||||
void shortcutGrabbed(const QString &);
|
||||
void grabShortcutFailed();
|
||||
void grabShortcutCancelled();
|
||||
void grabShortcutTimedout();
|
||||
|
||||
void daemonDisappeared();
|
||||
void daemonAppeared();
|
||||
void daemonPresenceChanged(bool);
|
||||
|
||||
private:
|
||||
Client();
|
||||
|
||||
ClientImpl *impl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__INCLUDED
|
@ -0,0 +1,47 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "client_adaptor.hpp"
|
||||
|
||||
#include "org.lxqt.global_action.client.h"
|
||||
|
||||
|
||||
ClientAdaptor::ClientAdaptor(const QString &path, QObject *parent)
|
||||
: QObject(parent)
|
||||
, mPath(path)
|
||||
{
|
||||
}
|
||||
|
||||
void ClientAdaptor::activated()
|
||||
{
|
||||
emit on_activated(mPath);
|
||||
}
|
||||
|
||||
void ClientAdaptor::shortcutChanged(const QString &oldShortcut, const QString &newShortcut)
|
||||
{
|
||||
emit on_shortcutChanged(mPath, oldShortcut, newShortcut);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_NATIVE_CLIENT__CLIENT_ADAPTOR__INCLUDED
|
||||
#define GLOBAL_ACTION_NATIVE_CLIENT__CLIENT_ADAPTOR__INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class ClientAdaptor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClientAdaptor(const QString &path, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void on_activated(const QString &path);
|
||||
void on_shortcutChanged(const QString &path, const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
public slots:
|
||||
void activated();
|
||||
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
private:
|
||||
QString mPath;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_NATIVE_CLIENT__CLIENT_ADAPTOR__INCLUDED
|
@ -0,0 +1,109 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__IMPL__INCLUDED
|
||||
#define GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__IMPL__INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QDBusPendingCallWatcher>
|
||||
|
||||
#include "action.h"
|
||||
|
||||
|
||||
class OrgLxqtGlobal_key_shortcutsNativeInterface;
|
||||
namespace org
|
||||
{
|
||||
namespace lxqt
|
||||
{
|
||||
namespace global_key_shortcuts
|
||||
{
|
||||
typedef ::OrgLxqtGlobal_key_shortcutsNativeInterface native;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class QDBusServiceWatcher;
|
||||
|
||||
namespace GlobalKeyShortcut
|
||||
{
|
||||
class Client;
|
||||
|
||||
class ClientAdaptor;
|
||||
|
||||
class ClientImpl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ClientImpl(Client *interface, QObject *parent = 0);
|
||||
~ClientImpl();
|
||||
|
||||
Action *addClientAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent);
|
||||
|
||||
QString changeClientActionShortcut(const QString &path, const QString &shortcut);
|
||||
bool modifyClientAction(const QString &path, const QString &description);
|
||||
bool removeClientAction(const QString &path);
|
||||
|
||||
void removeAction(ActionImpl *action);
|
||||
|
||||
void grabShortcut(uint timeout);
|
||||
void cancelShortcutGrab();
|
||||
|
||||
bool isDaemonPresent() const;
|
||||
|
||||
public slots:
|
||||
void grabShortcutFinished(QDBusPendingCallWatcher *call);
|
||||
void daemonDisappeared(const QString &);
|
||||
void daemonAppeared(const QString &);
|
||||
void registrationFinished(QDBusPendingCallWatcher *call);
|
||||
|
||||
signals:
|
||||
void emitShortcutGrabbed(const QString &);
|
||||
void emitGrabShortcutFailed();
|
||||
void emitGrabShortcutCancelled();
|
||||
void emitGrabShortcutTimedout();
|
||||
|
||||
void emitDaemonDisappeared();
|
||||
void emitDaemonAppeared();
|
||||
void emitDaemonPresenceChanged(bool);
|
||||
|
||||
private:
|
||||
Client *mInterface;
|
||||
org::lxqt::global_key_shortcuts::native *mProxy;
|
||||
QMap<QString, Action*> mActions;
|
||||
QDBusServiceWatcher *mServiceWatcher;
|
||||
bool mDaemonPresent;
|
||||
|
||||
QMap<QDBusPendingCallWatcher*, ActionImpl*> mPendingRegistrationsActions;
|
||||
QMap<ActionImpl*, QDBusPendingCallWatcher*> mPendingRegistrationsWatchers;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__CLIENT__IMPL__INCLUDED
|
@ -0,0 +1,34 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__INCLUDED
|
||||
#define GLOBAL_KEY_SHORTCUT_CLIENT__INCLUDED
|
||||
|
||||
#include <LXQtGlobalKeys/Action>
|
||||
#include <LXQtGlobalKeys/Client>
|
||||
|
||||
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__INCLUDED
|
@ -0,0 +1,26 @@
|
||||
# - Find the lxqt-globalkeys include and library dirs and define a some macros
|
||||
#
|
||||
# The module defines the following variables
|
||||
# LXQT_GLOBALKEYS_FOUND - Set to TRUE if all of the above has been found
|
||||
#
|
||||
# Typical usage:
|
||||
# find_package(lxqt-globalkeys)
|
||||
# add_executable(use-lxqt-globalkeys main.cpp)
|
||||
# target_link_libraries(use-lxqt-globalkeys lxqt-globalkeys)
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
set(LXQT_GLOBALKEYS_MAJOR_VERSION @LXQT_MAJOR_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_MINOR_VERSION @LXQT_MINOR_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_PATCH_VERSION @LXQT_PATCH_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_VERSION @LXQT_VERSION@)
|
||||
|
||||
find_dependency(Qt5Widgets)
|
||||
find_dependency(Qt5DBus)
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
|
||||
cmake_policy(SET CMP0024 OLD)
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/lxqt-globalkeys-targets.cmake")
|
@ -0,0 +1,27 @@
|
||||
# - Find the lxqt-globalkeys-ui include and library dirs and define a some macros
|
||||
#
|
||||
# The module defines the following variables
|
||||
# LXQT_GLOBALKEYS_UI_FOUND - Set to TRUE if all of the above has been found
|
||||
#
|
||||
# Typical usage:
|
||||
# find_package(lxqt-globalkeys-ui)
|
||||
# add_executable(use-lxqt-globalkeys-ui main.cpp)
|
||||
# target_link_libraries(use-lxqt-globalkeys-ui lxqt-globalkeys-ui)
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
set(LXQT_GLOBALKEYS_UI_MAJOR_VERSION @LXQT_MAJOR_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_UI_MINOR_VERSION @LXQT_MINOR_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_UI_PATCH_VERSION @LXQT_PATCH_VERSION@)
|
||||
set(LXQT_GLOBALKEYS_UI_VERSION @LXQT_VERSION@)
|
||||
|
||||
find_dependency(Qt5Widgets)
|
||||
find_dependency(Qt5DBus)
|
||||
find_dependency(lxqt-globalkeys)
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
|
||||
cmake_policy(SET CMP0024 OLD)
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/lxqt-globalkeys-ui-targets.cmake")
|
@ -0,0 +1,158 @@
|
||||
set(PROJECT_NAME lxqt-config-globalkeyshortcuts)
|
||||
project(${PROJECT_NAME})
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
find_package(KF5WindowSystem REQUIRED QUIET)
|
||||
|
||||
set(QT_DBUS_PREFIX "org.qtproject")
|
||||
|
||||
set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon")
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
main.cpp
|
||||
main_window.cpp
|
||||
actions.cpp
|
||||
default_model.cpp
|
||||
shortcut_selector.cpp
|
||||
${${PROJECT_NAME}_PATH_TO_DAEMON}/meta_types.cpp
|
||||
edit_action_dialog.cpp
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_FORMS
|
||||
main_window.ui
|
||||
edit_action_dialog.ui
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_RESOURCES
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATIONS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_CPP_HEADERS
|
||||
${${PROJECT_NAME}_PATH_TO_DAEMON}/meta_types.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_ADAPTORS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_INTERFACES
|
||||
${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.daemon.xml
|
||||
)
|
||||
set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.daemon.xml PROPERTIES
|
||||
BASENAME org.lxqt.global_key_shortcuts.daemon
|
||||
INCLUDE ${${PROJECT_NAME}_PATH_TO_DAEMON}/meta_types.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
${${PROJECT_NAME}_CPP_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATABLE
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_FORMS}
|
||||
)
|
||||
|
||||
foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
|
||||
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
|
||||
configure_file(
|
||||
${DBUS_ADAPTOR}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
|
||||
get_source_file_property(DBUS_ADAPTOR_PARENT_CLASSNAME ${DBUS_ADAPTOR} PARENT_CLASSNAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_BASENAME ${DBUS_ADAPTOR} BASENAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
|
||||
if(DBUS_ADAPTOR_BASENAME)
|
||||
if(DBUS_ADAPTOR_CLASSNAME)
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
|
||||
endif()
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
|
||||
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
|
||||
configure_file(
|
||||
${DBUS_INTERFACE}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
|
||||
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
|
||||
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
|
||||
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
|
||||
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
|
||||
INCLUDE ${DBUS_INTERFACE_INCLUDE}
|
||||
CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
|
||||
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
|
||||
)
|
||||
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
|
||||
endforeach()
|
||||
|
||||
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
|
||||
|
||||
# Translations **********************************
|
||||
lxqt_translate_ts(${PROJECT_NAME}_QM_FILES
|
||||
UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
|
||||
SOURCES
|
||||
${${PROJECT_NAME}_TRANSLATABLE}
|
||||
INSTALL_DIR
|
||||
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
|
||||
PULL_TRANSLATIONS
|
||||
${PULL_TRANSLATIONS}
|
||||
CLEAN_TRANSLATIONS
|
||||
${CLEAN_TRANSLATIONS}
|
||||
TRANSLATIONS_REPO
|
||||
${TRANSLATIONS_REPO}
|
||||
TRANSLATIONS_REFSPEC
|
||||
${TRANSLATIONS_REFSPEC}
|
||||
REPO_SUBDIR
|
||||
"lxqt-globalkeys/${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
lxqt_app_translation_loader(${PROJECT_NAME}_QM_LOADER ${PROJECT_NAME})
|
||||
lxqt_translate_desktop(${PROJECT_NAME}_DESKTOP_FILES
|
||||
SOURCES
|
||||
${PROJECT_NAME}.desktop.in
|
||||
)
|
||||
#************************************************
|
||||
|
||||
set(${PROJECT_NAME}_GENERATED_FILES
|
||||
${${PROJECT_NAME}_FORM_FILES}
|
||||
${${PROJECT_NAME}_RESOURCE_FILES}
|
||||
${${PROJECT_NAME}_QM_FILES}
|
||||
${${PROJECT_NAME}_DBUS_INTERFACE_FILES}
|
||||
${${PROJECT_NAME}_DBUS_ADAPTOR_FILES}
|
||||
${${PROJECT_NAME}_DESKTOP_FILES}
|
||||
${${PROJECT_NAME}_QM_LOADER}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_ALL_FILES
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_GENERATED_FILES}
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES})
|
||||
target_link_libraries(${PROJECT_NAME} KF5::WindowSystem lxqt)
|
||||
|
||||
install(TARGETS
|
||||
${PROJECT_NAME}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
COMPONENT Runtime
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${${PROJECT_NAME}_DESKTOP_FILES}
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
|
||||
COMPONENT Runtime
|
||||
)
|
@ -0,0 +1,680 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "actions.h"
|
||||
|
||||
#include "org.lxqt.global_key_shortcuts.daemon.h"
|
||||
|
||||
Actions::Actions(QObject *parent)
|
||||
: QObject(parent)
|
||||
, mServiceWatcher(new QDBusServiceWatcher("org.lxqt.global_key_shortcuts", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
|
||||
, mMultipleActionsBehaviour(MULTIPLE_ACTIONS_BEHAVIOUR_FIRST)
|
||||
{
|
||||
connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(on_daemonDisappeared(QString)));
|
||||
connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(on_daemonAppeared(QString)));
|
||||
mDaemonProxy = new org::lxqt::global_key_shortcuts::daemon("org.lxqt.global_key_shortcuts", "/daemon", QDBusConnection::sessionBus(), this);
|
||||
|
||||
connect(mDaemonProxy, SIGNAL(actionAdded(qulonglong)), this, SLOT(on_actionAdded(qulonglong)));
|
||||
connect(mDaemonProxy, SIGNAL(actionEnabled(qulonglong, bool)), this, SLOT(on_actionEnabled(qulonglong, bool)));
|
||||
connect(mDaemonProxy, SIGNAL(clientActionSenderChanged(qulonglong, QString)), this, SLOT(on_clientActionSenderChanged(qulonglong, QString)));
|
||||
connect(mDaemonProxy, SIGNAL(actionModified(qulonglong)), this, SLOT(on_actionModified(qulonglong)));
|
||||
connect(mDaemonProxy, SIGNAL(actionRemoved(qulonglong)), this, SLOT(on_actionRemoved(qulonglong)));
|
||||
connect(mDaemonProxy, SIGNAL(actionShortcutChanged(qulonglong)), this, SLOT(on_actionShortcutChanged(qulonglong)));
|
||||
connect(mDaemonProxy, SIGNAL(actionsSwapped(qulonglong, qulonglong)), this, SLOT(on_actionsSwapped(qulonglong, qulonglong)));
|
||||
connect(mDaemonProxy, SIGNAL(multipleActionsBehaviourChanged(uint)), this, SLOT(on_multipleActionsBehaviourChanged(uint)));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(delayedInit()));
|
||||
}
|
||||
|
||||
Actions::~Actions()
|
||||
{
|
||||
}
|
||||
|
||||
void Actions::delayedInit()
|
||||
{
|
||||
if (mDaemonProxy->isValid())
|
||||
{
|
||||
on_daemonAppeared(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void Actions::on_daemonDisappeared(const QString &)
|
||||
{
|
||||
clear();
|
||||
emit daemonDisappeared();
|
||||
}
|
||||
|
||||
void Actions::on_daemonAppeared(const QString &)
|
||||
{
|
||||
init();
|
||||
emit daemonAppeared();
|
||||
}
|
||||
|
||||
void Actions::init()
|
||||
{
|
||||
clear();
|
||||
|
||||
mGeneralActionInfo = getAllActions();
|
||||
GeneralActionInfos::const_iterator M = mGeneralActionInfo.constEnd();
|
||||
for (GeneralActionInfos::const_iterator I = mGeneralActionInfo.constBegin(); I != M; ++I)
|
||||
{
|
||||
if (I.value().type == "client")
|
||||
{
|
||||
QString shortcut;
|
||||
QString description;
|
||||
bool enabled = false;
|
||||
QDBusObjectPath path;
|
||||
if (getClientActionInfoById(I.key(), shortcut, description, enabled, path))
|
||||
{
|
||||
ClientActionInfo info;
|
||||
info.shortcut = shortcut;
|
||||
info.description = description;
|
||||
info.enabled = enabled;
|
||||
info.path = path;
|
||||
mClientActionInfo[I.key()] = info;
|
||||
|
||||
updateClientActionSender(I.key());
|
||||
}
|
||||
}
|
||||
else if (I.value().type == "method")
|
||||
{
|
||||
QString shortcut;
|
||||
QString description;
|
||||
bool enabled = false;
|
||||
QString service;
|
||||
QDBusObjectPath path;
|
||||
QString interface;
|
||||
QString method;
|
||||
if (getMethodActionInfoById(I.key(), shortcut, description, enabled, service, path, interface, method))
|
||||
{
|
||||
MethodActionInfo info;
|
||||
info.shortcut = shortcut;
|
||||
info.description = description;
|
||||
info.enabled = enabled;
|
||||
info.service = service;
|
||||
info.path = path;
|
||||
info.interface = interface;
|
||||
info.method = method;
|
||||
mMethodActionInfo[I.key()] = info;
|
||||
}
|
||||
}
|
||||
else if (I.value().type == "command")
|
||||
{
|
||||
QString shortcut;
|
||||
QString description;
|
||||
bool enabled = false;
|
||||
QString command;
|
||||
QStringList arguments;
|
||||
if (getCommandActionInfoById(I.key(), shortcut, description, enabled, command, arguments))
|
||||
{
|
||||
CommandActionInfo info;
|
||||
info.shortcut = shortcut;
|
||||
info.description = description;
|
||||
info.enabled = enabled;
|
||||
info.command = command;
|
||||
info.arguments = arguments;
|
||||
mCommandActionInfo[I.key()] = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mMultipleActionsBehaviour = static_cast<MultipleActionsBehaviour>(getMultipleActionsBehaviour());
|
||||
}
|
||||
|
||||
void Actions::clear()
|
||||
{
|
||||
mGeneralActionInfo.clear();
|
||||
mClientActionInfo.clear();
|
||||
mMethodActionInfo.clear();
|
||||
mCommandActionInfo.clear();
|
||||
mMultipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_FIRST;
|
||||
}
|
||||
|
||||
QList<qulonglong> Actions::allActionIds() const
|
||||
{
|
||||
return mGeneralActionInfo.keys();
|
||||
}
|
||||
|
||||
QPair<bool, GeneralActionInfo> Actions::actionById(qulonglong id) const
|
||||
{
|
||||
GeneralActionInfos::const_iterator I = mGeneralActionInfo.constFind(id);
|
||||
if (I == mGeneralActionInfo.constEnd())
|
||||
{
|
||||
return qMakePair(false, GeneralActionInfo());
|
||||
}
|
||||
return qMakePair(true, I.value());
|
||||
}
|
||||
|
||||
QList<qulonglong> Actions::allClientActionIds() const
|
||||
{
|
||||
return mClientActionInfo.keys();
|
||||
}
|
||||
|
||||
QPair<bool, ClientActionInfo> Actions::clientActionInfoById(qulonglong id) const
|
||||
{
|
||||
ClientActionInfos::const_iterator I = mClientActionInfo.constFind(id);
|
||||
if (I == mClientActionInfo.constEnd())
|
||||
{
|
||||
return qMakePair(false, ClientActionInfo());
|
||||
}
|
||||
return qMakePair(true, I.value());
|
||||
}
|
||||
|
||||
QList<qulonglong> Actions::allMethodActionIds() const
|
||||
{
|
||||
return mMethodActionInfo.keys();
|
||||
}
|
||||
|
||||
QPair<bool, MethodActionInfo> Actions::methodActionInfoById(qulonglong id) const
|
||||
{
|
||||
MethodActionInfos::const_iterator I = mMethodActionInfo.constFind(id);
|
||||
if (I == mMethodActionInfo.constEnd())
|
||||
{
|
||||
return qMakePair(false, MethodActionInfo());
|
||||
}
|
||||
return qMakePair(true, I.value());
|
||||
}
|
||||
|
||||
QList<qulonglong> Actions::allCommandActionIds() const
|
||||
{
|
||||
return mCommandActionInfo.keys();
|
||||
}
|
||||
|
||||
QPair<bool, CommandActionInfo> Actions::commandActionInfoById(qulonglong id) const
|
||||
{
|
||||
CommandActionInfos::const_iterator I = mCommandActionInfo.constFind(id);
|
||||
if (I == mCommandActionInfo.constEnd())
|
||||
{
|
||||
return qMakePair(false, CommandActionInfo());
|
||||
}
|
||||
return qMakePair(true, I.value());
|
||||
}
|
||||
|
||||
MultipleActionsBehaviour Actions::multipleActionsBehaviour() const
|
||||
{
|
||||
return mMultipleActionsBehaviour;
|
||||
}
|
||||
|
||||
void Actions::do_actionAdded(qulonglong id)
|
||||
{
|
||||
QString shortcut;
|
||||
QString description;
|
||||
bool enabled = false;
|
||||
QString type;
|
||||
QString info;
|
||||
if (getActionById(id, shortcut, description, enabled, type, info))
|
||||
{
|
||||
GeneralActionInfo generalActionInfo;
|
||||
generalActionInfo.shortcut = shortcut;
|
||||
generalActionInfo.description = description;
|
||||
generalActionInfo.enabled = enabled;
|
||||
generalActionInfo.type = type;
|
||||
generalActionInfo.info = info;
|
||||
mGeneralActionInfo[id] = generalActionInfo;
|
||||
}
|
||||
|
||||
if (type == "client")
|
||||
{
|
||||
QDBusObjectPath path;
|
||||
if (getClientActionInfoById(id, shortcut, description, enabled, path))
|
||||
{
|
||||
ClientActionInfo clientActionInfo;
|
||||
clientActionInfo.shortcut = shortcut;
|
||||
clientActionInfo.description = description;
|
||||
clientActionInfo.enabled = enabled;
|
||||
clientActionInfo.path = path;
|
||||
mClientActionInfo[id] = clientActionInfo;
|
||||
}
|
||||
}
|
||||
else if (type == "method")
|
||||
{
|
||||
QString service;
|
||||
QDBusObjectPath path;
|
||||
QString interface;
|
||||
QString method;
|
||||
if (getMethodActionInfoById(id, shortcut, description, enabled, service, path, interface, method))
|
||||
{
|
||||
MethodActionInfo methodActionInfo;
|
||||
methodActionInfo.shortcut = shortcut;
|
||||
methodActionInfo.description = description;
|
||||
methodActionInfo.enabled = enabled;
|
||||
methodActionInfo.service = service;
|
||||
methodActionInfo.path = path;
|
||||
methodActionInfo.interface = interface;
|
||||
methodActionInfo.method = method;
|
||||
mMethodActionInfo[id] = methodActionInfo;
|
||||
}
|
||||
}
|
||||
else if (type == "command")
|
||||
{
|
||||
QString command;
|
||||
QStringList arguments;
|
||||
if (getCommandActionInfoById(id, shortcut, description, enabled, command, arguments))
|
||||
{
|
||||
CommandActionInfo commandActionInfo;
|
||||
commandActionInfo.shortcut = shortcut;
|
||||
commandActionInfo.description = description;
|
||||
commandActionInfo.enabled = enabled;
|
||||
commandActionInfo.command = command;
|
||||
commandActionInfo.arguments = arguments;
|
||||
mCommandActionInfo[id] = commandActionInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Actions::on_actionAdded(qulonglong id)
|
||||
{
|
||||
do_actionAdded(id);
|
||||
emit actionAdded(id);
|
||||
}
|
||||
|
||||
void Actions::on_actionEnabled(qulonglong id, bool enabled)
|
||||
{
|
||||
GeneralActionInfos::iterator GI = mGeneralActionInfo.find(id);
|
||||
if (GI != mGeneralActionInfo.end())
|
||||
{
|
||||
GI.value().enabled = enabled;
|
||||
|
||||
if (GI.value().type == "client")
|
||||
{
|
||||
ClientActionInfos::iterator DI = mClientActionInfo.find(id);
|
||||
if (DI != mClientActionInfo.end())
|
||||
{
|
||||
DI.value().enabled = enabled;
|
||||
}
|
||||
}
|
||||
else if (GI.value().type == "method")
|
||||
{
|
||||
MethodActionInfos::iterator MI = mMethodActionInfo.find(id);
|
||||
if (MI != mMethodActionInfo.end())
|
||||
{
|
||||
MI.value().enabled = enabled;
|
||||
}
|
||||
}
|
||||
else if (GI.value().type == "command")
|
||||
{
|
||||
CommandActionInfos::iterator CI = mCommandActionInfo.find(id);
|
||||
if (CI != mCommandActionInfo.end())
|
||||
{
|
||||
CI.value().enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
emit actionEnabled(id, enabled);
|
||||
}
|
||||
|
||||
void Actions::on_clientActionSenderChanged(qulonglong id, const QString &sender)
|
||||
{
|
||||
mClientActionSenders[id] = sender;
|
||||
emit actionModified(id);
|
||||
}
|
||||
|
||||
void Actions::on_actionModified(qulonglong id)
|
||||
{
|
||||
do_actionAdded(id);
|
||||
emit actionModified(id);
|
||||
}
|
||||
|
||||
void Actions::on_actionShortcutChanged(qulonglong id)
|
||||
{
|
||||
do_actionAdded(id);
|
||||
emit actionModified(id);
|
||||
}
|
||||
|
||||
void Actions::on_actionsSwapped(qulonglong id1, qulonglong id2)
|
||||
{
|
||||
GeneralActionInfos::iterator GI1 = mGeneralActionInfo.find(id1);
|
||||
GeneralActionInfos::iterator GI2 = mGeneralActionInfo.find(id2);
|
||||
if ((GI1 != mGeneralActionInfo.end()) && (GI2 != mGeneralActionInfo.end()))
|
||||
{
|
||||
bool swapped = false;
|
||||
|
||||
if (GI1.value().type == GI2.value().type)
|
||||
{
|
||||
if (GI1.value().type == "client")
|
||||
{
|
||||
ClientActionInfos::iterator DI1 = mClientActionInfo.find(id1);
|
||||
ClientActionInfos::iterator DI2 = mClientActionInfo.find(id2);
|
||||
if ((DI1 != mClientActionInfo.end()) && (DI2 != mClientActionInfo.end()))
|
||||
{
|
||||
ClientActionInfo clientActionInfo = DI1.value();
|
||||
DI1.value() = DI2.value();
|
||||
DI2.value() = clientActionInfo;
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
else if (GI1.value().type == "method")
|
||||
{
|
||||
MethodActionInfos::iterator MI1 = mMethodActionInfo.find(id1);
|
||||
MethodActionInfos::iterator MI2 = mMethodActionInfo.find(id2);
|
||||
if ((MI1 != mMethodActionInfo.end()) && (MI2 != mMethodActionInfo.end()))
|
||||
{
|
||||
MethodActionInfo methodActionInfo = MI1.value();
|
||||
MI1.value() = MI2.value();
|
||||
MI2.value() = methodActionInfo;
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
else if (GI1.value().type == "command")
|
||||
{
|
||||
CommandActionInfos::iterator CI1 = mCommandActionInfo.find(id1);
|
||||
CommandActionInfos::iterator CI2 = mCommandActionInfo.find(id2);
|
||||
if ((CI1 != mCommandActionInfo.end()) && (CI2 != mCommandActionInfo.end()))
|
||||
{
|
||||
CommandActionInfo commandActionInfo = CI1.value();
|
||||
CI1.value() = CI2.value();
|
||||
CI2.value() = commandActionInfo;
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (swapped)
|
||||
{
|
||||
GeneralActionInfo generalActionInfo = GI1.value();
|
||||
GI1.value() = GI2.value();
|
||||
GI2.value() = generalActionInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
do_actionRemoved(id1);
|
||||
do_actionRemoved(id2);
|
||||
do_actionAdded(id1);
|
||||
do_actionAdded(id2);
|
||||
}
|
||||
}
|
||||
emit actionsSwapped(id1, id2);
|
||||
}
|
||||
|
||||
void Actions::do_actionRemoved(qulonglong id)
|
||||
{
|
||||
mGeneralActionInfo.remove(id);
|
||||
mClientActionInfo.remove(id);
|
||||
mMethodActionInfo.remove(id);
|
||||
mCommandActionInfo.remove(id);
|
||||
}
|
||||
|
||||
void Actions::on_actionRemoved(qulonglong id)
|
||||
{
|
||||
do_actionRemoved(id);
|
||||
emit actionRemoved(id);
|
||||
}
|
||||
|
||||
void Actions::on_multipleActionsBehaviourChanged(uint behaviour)
|
||||
{
|
||||
mMultipleActionsBehaviour = static_cast<MultipleActionsBehaviour>(behaviour);
|
||||
emit multipleActionsBehaviourChanged(mMultipleActionsBehaviour);
|
||||
}
|
||||
|
||||
bool Actions::getClientActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QDBusObjectPath &path)
|
||||
{
|
||||
return mDaemonProxy->getClientActionInfoById(id, shortcut, description, enabled, path);
|
||||
}
|
||||
|
||||
bool Actions::getMethodActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &service, QDBusObjectPath &path, QString &interface, QString &method)
|
||||
{
|
||||
return mDaemonProxy->getMethodActionInfoById(id, shortcut, description, enabled, service, path, interface, method);
|
||||
}
|
||||
|
||||
bool Actions::getCommandActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &command, QStringList &arguments)
|
||||
{
|
||||
return mDaemonProxy->getCommandActionInfoById(id, shortcut, description, enabled, command, arguments);
|
||||
}
|
||||
|
||||
QList<qulonglong> Actions::getAllActionIds()
|
||||
{
|
||||
QDBusPendingReply<QList<qulonglong> > reply = mDaemonProxy->getAllActionIds();
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return QList<qulonglong>();
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::getActionById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &type, QString &info)
|
||||
{
|
||||
return mDaemonProxy->getActionById(id, shortcut, description, enabled, type, info);
|
||||
}
|
||||
|
||||
QMap<qulonglong, GeneralActionInfo> Actions::getAllActions()
|
||||
{
|
||||
QDBusPendingReply<QMap<qulonglong, GeneralActionInfo> > reply = mDaemonProxy->getAllActions();
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return QMap<qulonglong, GeneralActionInfo>();
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
uint Actions::getMultipleActionsBehaviour()
|
||||
{
|
||||
QDBusPendingReply<uint> reply = mDaemonProxy->getMultipleActionsBehaviour();
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
QPair<QString, qulonglong> Actions::addMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description)
|
||||
{
|
||||
QDBusPendingReply<QString, qulonglong> reply = mDaemonProxy->addMethodAction(shortcut, service, path, interface, method, description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return qMakePair<QString, qulonglong>(QString(), 0ull);
|
||||
}
|
||||
|
||||
return qMakePair<QString, qulonglong>(reply.argumentAt<0>(), reply.argumentAt<1>());
|
||||
}
|
||||
|
||||
QPair<QString, qulonglong> Actions::addCommandAction(const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description)
|
||||
{
|
||||
QDBusPendingReply<QString, qulonglong> reply = mDaemonProxy->addCommandAction(shortcut, command, arguments, description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return qMakePair<QString, qulonglong>(QString(), 0ull);
|
||||
}
|
||||
|
||||
return qMakePair<QString, qulonglong>(reply.argumentAt<0>(), reply.argumentAt<1>());
|
||||
}
|
||||
|
||||
bool Actions::modifyActionDescription(const qulonglong &id, const QString &description)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->modifyActionDescription(id, description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::modifyMethodAction(const qulonglong &id, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->modifyMethodAction(id, service, path, interface, method, description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::modifyCommandAction(const qulonglong &id, const QString &command, const QStringList &arguments, const QString &description)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->modifyCommandAction(id, command, arguments, description);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::enableAction(qulonglong id, bool enabled)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->enableAction(id, enabled);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::isActionEnabled(qulonglong id)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->isActionEnabled(id);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
QString Actions::getClientActionSender(qulonglong id)
|
||||
{
|
||||
return mClientActionSenders[id];
|
||||
}
|
||||
|
||||
QString Actions::updateClientActionSender(qulonglong id)
|
||||
{
|
||||
QDBusPendingReply<QString> reply = mDaemonProxy->getClientActionSender(id);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString sender = reply.argumentAt<0>();
|
||||
mClientActionSenders[id] = sender;
|
||||
return sender;
|
||||
}
|
||||
|
||||
QString Actions::changeShortcut(const qulonglong &id, const QString &shortcut)
|
||||
{
|
||||
QDBusPendingReply<QString> reply = mDaemonProxy->changeShortcut(id, shortcut);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::swapActions(const qulonglong &id1, const qulonglong &id2)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->swapActions(id1, id2);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
bool Actions::removeAction(const qulonglong &id)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->removeAction(id);
|
||||
reply.waitForFinished();
|
||||
if (reply.isError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reply.argumentAt<0>();
|
||||
}
|
||||
|
||||
void Actions::setMultipleActionsBehaviour(const MultipleActionsBehaviour &behaviour)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = mDaemonProxy->setMultipleActionsBehaviour(behaviour);
|
||||
reply.waitForFinished();
|
||||
}
|
||||
|
||||
void Actions::grabShortcut(uint timeout)
|
||||
{
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(mDaemonProxy->grabShortcut(timeout), this);
|
||||
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(grabShortcutFinished(QDBusPendingCallWatcher *)));
|
||||
}
|
||||
|
||||
void Actions::cancelShortcutGrab()
|
||||
{
|
||||
mDaemonProxy->cancelShortcutGrab();
|
||||
}
|
||||
|
||||
void Actions::grabShortcutFinished(QDBusPendingCallWatcher *call)
|
||||
{
|
||||
QDBusPendingReply<QString, bool, bool, bool> reply = *call;
|
||||
if (reply.isError())
|
||||
{
|
||||
emit grabShortcutFailed();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<1>())
|
||||
{
|
||||
emit grabShortcutFailed();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<2>())
|
||||
{
|
||||
emit grabShortcutCancelled();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reply.argumentAt<3>())
|
||||
{
|
||||
emit grabShortcutTimedout();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit shortcutGrabbed(reply.argumentAt<0>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
call->deleteLater();
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_CONFIG__ACTIONS__INCLUDED
|
||||
#define GLOBAL_ACTION_CONFIG__ACTIONS__INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
#include "../daemon/meta_types.h"
|
||||
|
||||
|
||||
class OrgLxqtGlobal_key_shortcutsDaemonInterface;
|
||||
namespace org
|
||||
{
|
||||
namespace lxqt
|
||||
{
|
||||
namespace global_key_shortcuts
|
||||
{
|
||||
typedef ::OrgLxqtGlobal_key_shortcutsDaemonInterface daemon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class QDBusServiceWatcher;
|
||||
class QDBusPendingCallWatcher;
|
||||
|
||||
class Actions : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Actions(QObject *parent = 0);
|
||||
~Actions();
|
||||
|
||||
|
||||
QList<qulonglong> allActionIds() const;
|
||||
QPair<bool, GeneralActionInfo> actionById(qulonglong id) const;
|
||||
|
||||
QList<qulonglong> allClientActionIds() const;
|
||||
QPair<bool, ClientActionInfo> clientActionInfoById(qulonglong id) const;
|
||||
|
||||
QList<qulonglong> allMethodActionIds() const;
|
||||
QPair<bool, MethodActionInfo> methodActionInfoById(qulonglong id) const;
|
||||
|
||||
QList<qulonglong> allCommandActionIds() const;
|
||||
QPair<bool, CommandActionInfo> commandActionInfoById(qulonglong id) const;
|
||||
|
||||
|
||||
QPair<QString, qulonglong> addMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
QPair<QString, qulonglong> addCommandAction(const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
bool modifyActionDescription(const qulonglong &id, const QString &description);
|
||||
bool modifyMethodAction(const qulonglong &id, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
bool modifyCommandAction(const qulonglong &id, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
bool enableAction(qulonglong id, bool enabled);
|
||||
bool isActionEnabled(qulonglong id);
|
||||
|
||||
QString getClientActionSender(qulonglong id);
|
||||
QString updateClientActionSender(qulonglong id);
|
||||
|
||||
QString changeShortcut(const qulonglong &id, const QString &shortcut);
|
||||
|
||||
bool swapActions(const qulonglong &id1, const qulonglong &id2);
|
||||
|
||||
bool removeAction(const qulonglong &id);
|
||||
|
||||
|
||||
MultipleActionsBehaviour multipleActionsBehaviour() const;
|
||||
|
||||
void setMultipleActionsBehaviour(const MultipleActionsBehaviour &behaviour);
|
||||
|
||||
|
||||
void grabShortcut(uint timeout);
|
||||
void cancelShortcutGrab();
|
||||
|
||||
signals:
|
||||
void daemonDisappeared();
|
||||
void daemonAppeared();
|
||||
|
||||
void actionAdded(qulonglong id);
|
||||
void actionEnabled(qulonglong id, bool enabled);
|
||||
void actionModified(qulonglong id);
|
||||
void actionsSwapped(qulonglong id1, qulonglong id2);
|
||||
void actionRemoved(qulonglong id);
|
||||
|
||||
void multipleActionsBehaviourChanged(MultipleActionsBehaviour behaviour);
|
||||
|
||||
void shortcutGrabbed(const QString &);
|
||||
void grabShortcutFailed();
|
||||
void grabShortcutCancelled();
|
||||
void grabShortcutTimedout();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void clear();
|
||||
|
||||
QList<qulonglong> getAllActionIds();
|
||||
|
||||
bool getActionById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &type, QString &info);
|
||||
QMap<qulonglong, GeneralActionInfo> getAllActions();
|
||||
|
||||
bool getClientActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QDBusObjectPath &path);
|
||||
bool getMethodActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &service, QDBusObjectPath &path, QString &interface, QString &method);
|
||||
bool getCommandActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &command, QStringList &arguments);
|
||||
|
||||
uint getMultipleActionsBehaviour();
|
||||
|
||||
private slots:
|
||||
void delayedInit();
|
||||
|
||||
void on_daemonDisappeared(const QString &);
|
||||
void on_daemonAppeared(const QString &);
|
||||
|
||||
void on_actionAdded(qulonglong id);
|
||||
void on_actionEnabled(qulonglong id, bool enabled);
|
||||
void on_clientActionSenderChanged(qulonglong id, const QString &sender);
|
||||
void on_actionModified(qulonglong id);
|
||||
void on_actionShortcutChanged(qulonglong id);
|
||||
void on_actionsSwapped(qulonglong id1, qulonglong id2);
|
||||
void on_actionRemoved(qulonglong id);
|
||||
void on_multipleActionsBehaviourChanged(uint behaviour);
|
||||
|
||||
void grabShortcutFinished(QDBusPendingCallWatcher *call);
|
||||
|
||||
private:
|
||||
void do_actionAdded(qulonglong id);
|
||||
void do_actionRemoved(qulonglong id);
|
||||
|
||||
private:
|
||||
org::lxqt::global_key_shortcuts::daemon *mDaemonProxy;
|
||||
QDBusServiceWatcher *mServiceWatcher;
|
||||
|
||||
typedef QMap<qulonglong, GeneralActionInfo> GeneralActionInfos;
|
||||
GeneralActionInfos mGeneralActionInfo;
|
||||
|
||||
typedef QMap<qulonglong, ClientActionInfo> ClientActionInfos;
|
||||
ClientActionInfos mClientActionInfo;
|
||||
|
||||
typedef QMap<qulonglong, QString> ClientActionSenders;
|
||||
ClientActionSenders mClientActionSenders;
|
||||
|
||||
typedef QMap<qulonglong, MethodActionInfo> MethodActionInfos;
|
||||
MethodActionInfos mMethodActionInfo;
|
||||
|
||||
typedef QMap<qulonglong, CommandActionInfo> CommandActionInfos;
|
||||
CommandActionInfos mCommandActionInfo;
|
||||
|
||||
MultipleActionsBehaviour mMultipleActionsBehaviour;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_CONFIG__ACTIONS__INCLUDED
|
@ -0,0 +1,334 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
|
||||
#include "default_model.h"
|
||||
#include "actions.h"
|
||||
|
||||
|
||||
DefaultModel::DefaultModel(Actions *actions, const QColor &grayedOutColour, const QFont &highlightedFont, const QFont &italicFont, const QFont &highlightedItalicFont, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, mActions(actions)
|
||||
, mGrayedOutColour(grayedOutColour)
|
||||
, mHighlightedFont(highlightedFont)
|
||||
, mItalicFont(italicFont)
|
||||
, mHighlightedItalicFont(highlightedItalicFont)
|
||||
{
|
||||
connect(actions, SIGNAL(daemonDisappeared()), SLOT(daemonDisappeared()));
|
||||
connect(actions, SIGNAL(daemonAppeared()), SLOT(daemonAppeared()));
|
||||
connect(actions, SIGNAL(actionAdded(qulonglong)), SLOT(actionAdded(qulonglong)));
|
||||
connect(actions, SIGNAL(actionModified(qulonglong)), SLOT(actionModified(qulonglong)));
|
||||
connect(actions, SIGNAL(actionEnabled(qulonglong, bool)), SLOT(actionEnabled(qulonglong, bool)));
|
||||
connect(actions, SIGNAL(actionsSwapped(qulonglong, qulonglong)), SLOT(actionsSwapped(qulonglong, qulonglong)));
|
||||
connect(actions, SIGNAL(actionRemoved(qulonglong)), SLOT(actionRemoved(qulonglong)));
|
||||
|
||||
mVerboseType["command"] = tr("Command");
|
||||
mVerboseType["method"] = tr("DBus call");
|
||||
mVerboseType["client"] = tr("Client");
|
||||
}
|
||||
|
||||
DefaultModel::~DefaultModel()
|
||||
{
|
||||
}
|
||||
|
||||
int DefaultModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return mContent.size();
|
||||
}
|
||||
|
||||
int DefaultModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
QVariant DefaultModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
if ((index.row() >= 0) && (index.row() < rowCount()) && (index.column() >= 0) && (index.column() < columnCount()))
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return mContent.keys()[index.row()];
|
||||
|
||||
case 1:
|
||||
return mContent[mContent.keys()[index.row()]].shortcut;
|
||||
|
||||
case 2:
|
||||
return mContent[mContent.keys()[index.row()]].description;
|
||||
|
||||
case 3:
|
||||
return mVerboseType[mContent[mContent.keys()[index.row()]].type];
|
||||
|
||||
case 4:
|
||||
return mContent[mContent.keys()[index.row()]].info;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::EditRole:
|
||||
break;
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
if ((index.row() >= 0) && (index.row() < rowCount()))
|
||||
{
|
||||
qulonglong id = mContent.keys()[index.row()];
|
||||
bool multiple = (index.column() == 1) && (mShortcuts[mContent[id].shortcut].size() > 1);
|
||||
bool inactive = (mContent[id].type == "client") && (mActions->getClientActionSender(id).isEmpty());
|
||||
if (multiple || inactive)
|
||||
return multiple ? (inactive ? mHighlightedItalicFont : mHighlightedFont) : mItalicFont;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::ForegroundRole:
|
||||
if (!mContent[mContent.keys()[index.row()]].enabled)
|
||||
{
|
||||
return mGrayedOutColour;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::CheckStateRole:
|
||||
if ((index.row() >= 0) && (index.row() < rowCount()) && (index.column() == 0))
|
||||
{
|
||||
return mContent[mContent.keys()[index.row()]].enabled ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DefaultModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
switch (orientation)
|
||||
{
|
||||
case Qt::Horizontal:
|
||||
switch (section)
|
||||
{
|
||||
case 0:
|
||||
return tr("Id");
|
||||
|
||||
case 1:
|
||||
return tr("Shortcut");
|
||||
|
||||
case 2:
|
||||
return tr("Description");
|
||||
|
||||
case 3:
|
||||
return tr("Type");
|
||||
|
||||
case 4:
|
||||
return tr("Info");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags DefaultModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags result = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
if (index.column() == 0)
|
||||
{
|
||||
result |= Qt::ItemIsUserCheckable;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DefaultModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
qulonglong DefaultModel::id(const QModelIndex &index) const
|
||||
{
|
||||
if ((index.row() >= 0) && (index.row() < rowCount()))
|
||||
{
|
||||
return mContent.keys()[index.row()];
|
||||
}
|
||||
return 0ull;
|
||||
}
|
||||
|
||||
void DefaultModel::daemonDisappeared()
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
mContent.clear();
|
||||
mShortcuts.clear();
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void DefaultModel::daemonAppeared()
|
||||
{
|
||||
QList<qulonglong> allIds = mActions->allActionIds();
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, allIds.size() - 1);
|
||||
|
||||
foreach(qulonglong id, allIds)
|
||||
{
|
||||
mContent[id] = mActions->actionById(id).second;
|
||||
mShortcuts[mContent[id].shortcut].insert(id);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void DefaultModel::actionAdded(qulonglong id)
|
||||
{
|
||||
if (!mContent.contains(id))
|
||||
{
|
||||
QPair<bool, GeneralActionInfo> result = mActions->actionById(id);
|
||||
if (result.first)
|
||||
{
|
||||
QList<qulonglong> keys = mContent.keys();
|
||||
int row = qBinaryFind(keys, mContent.lowerBound(id).key()) - keys.constBegin();
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
|
||||
mContent[id] = result.second;
|
||||
mShortcuts[mContent[id].shortcut].insert(id);
|
||||
|
||||
endInsertRows();
|
||||
|
||||
keys = mContent.keys();
|
||||
foreach(qulonglong siblingId, mShortcuts[mContent[id].shortcut])
|
||||
{
|
||||
if (id != siblingId)
|
||||
{
|
||||
int siblingRow = qBinaryFind(keys, siblingId) - keys.constBegin();
|
||||
emit dataChanged(index(siblingRow, 1), index(siblingRow, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultModel::actionEnabled(qulonglong id, bool enabled)
|
||||
{
|
||||
if (mContent.contains(id))
|
||||
{
|
||||
QList<qulonglong> keys = mContent.keys();
|
||||
int row = qBinaryFind(keys, id) - keys.constBegin();
|
||||
|
||||
mContent[id].enabled = enabled;
|
||||
|
||||
emit dataChanged(index(row, 0), index(row, 3));
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultModel::actionModified(qulonglong id)
|
||||
{
|
||||
if (mContent.contains(id))
|
||||
{
|
||||
QPair<bool, GeneralActionInfo> result = mActions->actionById(id);
|
||||
if (result.first)
|
||||
{
|
||||
QList<qulonglong> keys = mContent.keys();
|
||||
int row = qBinaryFind(keys, id) - keys.constBegin();
|
||||
|
||||
if (mContent[id].shortcut != result.second.shortcut)
|
||||
{
|
||||
mShortcuts[result.second.shortcut].insert(id);
|
||||
mShortcuts[mContent[id].shortcut].remove(id);
|
||||
foreach(qulonglong siblingId, mShortcuts[mContent[id].shortcut])
|
||||
{
|
||||
int siblingRow = qBinaryFind(keys, siblingId) - keys.constBegin();
|
||||
emit dataChanged(index(siblingRow, 1), index(siblingRow, 1));
|
||||
}
|
||||
foreach(qulonglong siblingId, mShortcuts[result.second.shortcut])
|
||||
{
|
||||
int siblingRow = qBinaryFind(keys, siblingId) - keys.constBegin();
|
||||
emit dataChanged(index(siblingRow, 1), index(siblingRow, 1));
|
||||
}
|
||||
}
|
||||
|
||||
mContent[id] = result.second;
|
||||
|
||||
emit dataChanged(index(row, 0), index(row, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultModel::actionsSwapped(qulonglong id1, qulonglong id2)
|
||||
{
|
||||
if (mContent.contains(id1) && mContent.contains(id2))
|
||||
{
|
||||
QList<qulonglong> keys = mContent.keys();
|
||||
int row1 = qBinaryFind(keys, id1) - keys.constBegin();
|
||||
int row2 = qBinaryFind(keys, id2) - keys.constBegin();
|
||||
|
||||
// swap
|
||||
GeneralActionInfo tmp = mContent[id1];
|
||||
mContent[id1] = mContent[id2];
|
||||
mContent[id2] = tmp;
|
||||
|
||||
emit dataChanged(index(row1, 0), index(row1, 3));
|
||||
emit dataChanged(index(row2, 0), index(row2, 3));
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultModel::actionRemoved(qulonglong id)
|
||||
{
|
||||
if (mContent.contains(id))
|
||||
{
|
||||
QList<qulonglong> keys = mContent.keys();
|
||||
int row = qBinaryFind(keys, id) - keys.constBegin();
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
|
||||
mShortcuts[mContent[id].shortcut].remove(id);
|
||||
QString shortcut = mContent[id].shortcut;
|
||||
|
||||
mContent.remove(id);
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
foreach(qulonglong siblingId, mShortcuts[shortcut])
|
||||
{
|
||||
int siblingRow = qBinaryFind(keys, siblingId) - keys.constBegin();
|
||||
emit dataChanged(index(siblingRow, 1), index(siblingRow, 1));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_CONFIG__DEFAULT_MODEL__INCLUDED
|
||||
#define GLOBAL_ACTION_CONFIG__DEFAULT_MODEL__INCLUDED
|
||||
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QMap>
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
#include "../daemon/meta_types.h"
|
||||
|
||||
|
||||
class Actions;
|
||||
|
||||
|
||||
template<class Key>
|
||||
class QOrderedSet : public QMap<Key, Key>
|
||||
{
|
||||
public:
|
||||
typename QMap<Key, Key>::iterator insert(const Key &akey)
|
||||
{
|
||||
return QMap<Key, Key>::insert(akey, akey);
|
||||
}
|
||||
};
|
||||
|
||||
class DefaultModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DefaultModel(Actions *actions, const QColor &grayedOutColour, const QFont &highlightedFont, const QFont &italicFont, const QFont &highlightedItalicFont, QObject *parent = 0);
|
||||
~DefaultModel();
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
|
||||
qulonglong id(const QModelIndex &index) const;
|
||||
|
||||
public slots:
|
||||
void daemonDisappeared();
|
||||
void daemonAppeared();
|
||||
|
||||
void actionAdded(qulonglong id);
|
||||
void actionEnabled(qulonglong id, bool enabled);
|
||||
void actionModified(qulonglong id);
|
||||
void actionsSwapped(qulonglong id1, qulonglong id2);
|
||||
void actionRemoved(qulonglong id);
|
||||
|
||||
private:
|
||||
Actions *mActions;
|
||||
QMap<qulonglong, GeneralActionInfo> mContent;
|
||||
QMap<QString, QOrderedSet<qulonglong> > mShortcuts;
|
||||
|
||||
QColor mGrayedOutColour;
|
||||
QFont mHighlightedFont;
|
||||
QFont mItalicFont;
|
||||
QFont mHighlightedItalicFont;
|
||||
|
||||
QMap<QString, QString> mVerboseType;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_CONFIG__DEFAULT_MODEL__INCLUDED
|
@ -0,0 +1,258 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "edit_action_dialog.h"
|
||||
#include "actions.h"
|
||||
|
||||
EditActionDialog::EditActionDialog(Actions *actions, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, mActions(actions)
|
||||
{
|
||||
setupUi(this);
|
||||
shortcut_SS->setActions(mActions);
|
||||
|
||||
connect(this, SIGNAL(accepted()), SLOT(when_accepted()));
|
||||
}
|
||||
|
||||
void EditActionDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static QString joinCommandLine(const QString &command, QStringList arguments)
|
||||
{
|
||||
arguments.prepend(command);
|
||||
int m = arguments.length();
|
||||
for (int i = 0; i < m; ++i)
|
||||
{
|
||||
QString &item = arguments[i];
|
||||
if (item.contains(QRegExp("[ \r\n\t\"']")))
|
||||
{
|
||||
item.prepend("'").append("'");
|
||||
}
|
||||
else if (item.isEmpty())
|
||||
{
|
||||
item = QString("''");
|
||||
}
|
||||
}
|
||||
return arguments.join(" ");
|
||||
}
|
||||
|
||||
static QStringList splitCommandLine(QString commandLine)
|
||||
{
|
||||
commandLine.prepend(" ").append(" ");
|
||||
QStringList result;
|
||||
QRegExp spacePattern("\\s+");
|
||||
QRegExp itemPattern("([^ \r\n\t\"']+)|((\"([^\"]|\\\")*\")|('([^']|\\')*'))(?=\\s)");
|
||||
|
||||
for (int pos = 0; ;)
|
||||
{
|
||||
if (commandLine.indexOf(spacePattern, pos) != pos)
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
pos += spacePattern.matchedLength();
|
||||
|
||||
if (pos == commandLine.length())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (commandLine.indexOf(itemPattern, pos) != pos)
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
pos += itemPattern.matchedLength();
|
||||
|
||||
QString item = itemPattern.cap(2);
|
||||
if (item.length())
|
||||
{
|
||||
result << item.mid(1, item.length() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
result << itemPattern.cap(1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void EditActionDialog::when_accepted()
|
||||
{
|
||||
if (mId)
|
||||
{
|
||||
if (command_RB->isChecked())
|
||||
{
|
||||
QStringList commandLine = splitCommandLine(command_PTE->toPlainText());
|
||||
if (!commandLine.length())
|
||||
{
|
||||
return;
|
||||
}
|
||||
mActions->modifyCommandAction(mId, commandLine[0], commandLine.mid(1), description_LE->text());
|
||||
}
|
||||
else if (dbus_method_RB->isChecked())
|
||||
{
|
||||
mActions->modifyMethodAction(mId, service_LE->text(), QDBusObjectPath(path_LE->text()), interface_LE->text(), method_LE->text(), description_LE->text());
|
||||
}
|
||||
mActions->changeShortcut(mId, mShortcut);
|
||||
mActions->enableAction(mId, enabled_CB->isChecked());
|
||||
}
|
||||
else
|
||||
{
|
||||
QPair<QString, qulonglong> result = qMakePair(QString(), 0ull);
|
||||
if (command_RB->isChecked())
|
||||
{
|
||||
QStringList commandLine = splitCommandLine(command_PTE->toPlainText());
|
||||
if (!commandLine.length())
|
||||
{
|
||||
return;
|
||||
}
|
||||
result = mActions->addCommandAction(mShortcut, commandLine[0], commandLine.mid(1), description_LE->text());
|
||||
}
|
||||
else if (dbus_method_RB->isChecked())
|
||||
{
|
||||
result = mActions->addMethodAction(mShortcut, service_LE->text(), QDBusObjectPath(path_LE->text()), interface_LE->text(), method_LE->text(), description_LE->text());
|
||||
}
|
||||
if (result.second && !enabled_CB->isChecked())
|
||||
{
|
||||
mActions->enableAction(result.second, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EditActionDialog::load(qulonglong id)
|
||||
{
|
||||
mId = id;
|
||||
|
||||
if (mId)
|
||||
{
|
||||
QPair<bool, GeneralActionInfo> info = mActions->actionById(id);
|
||||
if (!info.first)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool canEdit = ((info.second.type == "command") || (info.second.type == "method"));
|
||||
|
||||
mShortcut = info.second.shortcut;
|
||||
shortcut_SS->setText(mShortcut);
|
||||
description_LE->setText(info.second.description);
|
||||
enabled_CB->setChecked(info.second.enabled);
|
||||
command_RB->setChecked(info.second.type == "command");
|
||||
dbus_method_RB->setChecked(info.second.type == "method");
|
||||
action_SW->setCurrentWidget((info.second.type == "method") ? dbus_method_P : command_P);
|
||||
if (info.second.type == "command")
|
||||
{
|
||||
QPair<bool, CommandActionInfo> commandInfo = mActions->commandActionInfoById(id);
|
||||
if (!commandInfo.first)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
command_PTE->setPlainText(joinCommandLine(commandInfo.second.command, commandInfo.second.arguments));
|
||||
}
|
||||
else if (info.second.type == "method")
|
||||
{
|
||||
QPair<bool, MethodActionInfo> methodInfo = mActions->methodActionInfoById(id);
|
||||
if (!methodInfo.first)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
service_LE->setText(methodInfo.second.service);
|
||||
path_LE->setText(methodInfo.second.path.path());
|
||||
interface_LE->setText(methodInfo.second.interface);
|
||||
method_LE->setText(methodInfo.second.method);
|
||||
}
|
||||
else
|
||||
{
|
||||
command_PTE->clear();
|
||||
}
|
||||
|
||||
description_LE->setEnabled(canEdit);
|
||||
command_RB->setEnabled(false);
|
||||
dbus_method_RB->setEnabled(false);
|
||||
action_SW->setEnabled(canEdit);
|
||||
}
|
||||
else
|
||||
{
|
||||
shortcut_SS->setText(QString());
|
||||
description_LE->clear();
|
||||
enabled_CB->setChecked(true);
|
||||
action_SW->setCurrentWidget(command_P);
|
||||
command_PTE->clear();
|
||||
service_LE->clear();
|
||||
path_LE->clear();
|
||||
interface_LE->clear();
|
||||
method_LE->clear();
|
||||
|
||||
// To disable all radio boxes, once one has been selected, we need to turn exclusivity off temporarily
|
||||
command_RB->setAutoExclusive(false);
|
||||
dbus_method_RB->setAutoExclusive(false);
|
||||
command_RB->setChecked(false);
|
||||
dbus_method_RB->setChecked(false);
|
||||
command_RB->setAutoExclusive(true);
|
||||
dbus_method_RB->setAutoExclusive(true);
|
||||
|
||||
description_LE->setEnabled(true);
|
||||
command_RB->setEnabled(true);
|
||||
dbus_method_RB->setEnabled(true);
|
||||
action_SW->setEnabled(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditActionDialog::on_shortcut_SS_shortcutGrabbed(const QString &shortcut)
|
||||
{
|
||||
mShortcut = shortcut;
|
||||
shortcut_SS->setText(shortcut);
|
||||
}
|
||||
|
||||
void EditActionDialog::on_command_RB_clicked(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
action_SW->setCurrentWidget(command_P);
|
||||
action_SW->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void EditActionDialog::on_dbus_method_RB_clicked(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
action_SW->setCurrentWidget(dbus_method_P);
|
||||
action_SW->setEnabled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_CONFIG__EDIT_ACTION_DIALOG__INCLUDED
|
||||
#define GLOBAL_ACTION_CONFIG__EDIT_ACTION_DIALOG__INCLUDED
|
||||
|
||||
|
||||
#include "ui_edit_action_dialog.h"
|
||||
|
||||
|
||||
class Actions;
|
||||
|
||||
class EditActionDialog : public QDialog, private Ui::EditActionDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditActionDialog(Actions *actions, QWidget *parent = 0);
|
||||
|
||||
bool load(qulonglong id);
|
||||
|
||||
protected slots:
|
||||
void when_accepted();
|
||||
|
||||
void on_shortcut_SS_shortcutGrabbed(const QString &);
|
||||
void on_command_RB_clicked(bool);
|
||||
void on_dbus_method_RB_clicked(bool);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
Actions *mActions;
|
||||
qulonglong mId;
|
||||
QString mShortcut;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_CONFIG__EDIT_ACTION_DIALOG__INCLUDED
|
@ -0,0 +1,328 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditActionDialog</class>
|
||||
<widget class="QDialog" name="EditActionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>286</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Edit Action</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="shortcut_L">
|
||||
<property name="text">
|
||||
<string>&Shortcut:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>shortcut_SS</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ShortcutSelector" name="shortcut_SS">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="description_L">
|
||||
<property name="text">
|
||||
<string>&Description:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>description_LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="description_LE"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="enabled_CB">
|
||||
<property name="text">
|
||||
<string>&Enabled</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="command_RB">
|
||||
<property name="text">
|
||||
<string>&Command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="dbus_method_RB">
|
||||
<property name="text">
|
||||
<string>&DBus message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="type_L">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="action_SW">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="command_P">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="command_L">
|
||||
<property name="text">
|
||||
<string>Co&mmand:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>command_PTE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPlainTextEdit" name="command_PTE"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="dbus_method_P">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="service_L">
|
||||
<property name="text">
|
||||
<string>S&ervice:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>service_LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="service_LE"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="path_L">
|
||||
<property name="text">
|
||||
<string>&Path:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>path_LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="path_LE"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="interface_L">
|
||||
<property name="text">
|
||||
<string>&Interface:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>interface_LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="interface_LE"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="method_L">
|
||||
<property name="text">
|
||||
<string>&Method:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>method_LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="method_LE"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ShortcutSelector</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>shortcut_selector.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>shortcut_SS</tabstop>
|
||||
<tabstop>description_LE</tabstop>
|
||||
<tabstop>enabled_CB</tabstop>
|
||||
<tabstop>command_RB</tabstop>
|
||||
<tabstop>dbus_method_RB</tabstop>
|
||||
<tabstop>command_PTE</tabstop>
|
||||
<tabstop>service_LE</tabstop>
|
||||
<tabstop>path_LE</tabstop>
|
||||
<tabstop>interface_LE</tabstop>
|
||||
<tabstop>method_LE</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>EditActionDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>EditActionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Shortcut Keys
|
||||
GenericName=Keyboard Shortcut Settings
|
||||
Comment=Configure shortcut keys in LXQt
|
||||
Exec=lxqt-config-globalkeyshortcuts
|
||||
Icon=preferences-desktop-keyboard
|
||||
Categories=Settings;DesktopSettings;Qt;LXQt;
|
||||
OnlyShowIn=LXQt;
|
||||
|
||||
#TRANSLATIONS_DIR=translations
|
@ -0,0 +1,53 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include <LXQt/SingleApplication>
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include "main_window.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
LXQt::SingleApplication a(argc, argv);
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(QStringLiteral("LXQt Config Globalkeys "));
|
||||
const QString VERINFO = QStringLiteral(LXQT_GLOBALKEYS_VERSION
|
||||
"\nliblxqt " LXQT_VERSION
|
||||
"\nQt " QT_VERSION_STR);
|
||||
a.setApplicationVersion(VERINFO);
|
||||
parser.addVersionOption();
|
||||
parser.addHelpOption();
|
||||
parser.process(a);
|
||||
|
||||
MainWindow w;
|
||||
a.setActivationWindow(&w);
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "main_window.h"
|
||||
#include "actions.h"
|
||||
#include "default_model.h"
|
||||
#include "edit_action_dialog.h"
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, mEditActionDialog(0)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
QColor grayedOutColour(actions_TV->palette().color(actions_TV->foregroundRole()));
|
||||
QColor backgroundColour(actions_TV->palette().color(actions_TV->backgroundRole()));
|
||||
grayedOutColour.toHsl();
|
||||
backgroundColour.toHsl();
|
||||
grayedOutColour.setHslF(grayedOutColour.hslHueF(), grayedOutColour.hslSaturationF(), (grayedOutColour.lightnessF() + backgroundColour.lightnessF() * 3) / 4.0);
|
||||
grayedOutColour.toRgb();
|
||||
|
||||
QFont highlightedFont(actions_TV->font());
|
||||
QFont italicFont(actions_TV->font());
|
||||
QFont highlightedItalicFont(actions_TV->font());
|
||||
highlightedFont.setBold(!highlightedFont.bold());
|
||||
italicFont.setItalic(!italicFont.italic());
|
||||
highlightedItalicFont.setItalic(!highlightedItalicFont.italic());
|
||||
highlightedItalicFont.setBold(!highlightedItalicFont.bold());
|
||||
|
||||
mActions = new Actions(this);
|
||||
mDefaultModel = new DefaultModel(mActions, grayedOutColour, highlightedFont, italicFont, highlightedItalicFont, this);
|
||||
mSortFilterProxyModel = new QSortFilterProxyModel(this);
|
||||
|
||||
mSortFilterProxyModel->setSourceModel(mDefaultModel);
|
||||
actions_TV->setModel(mSortFilterProxyModel);
|
||||
|
||||
mSelectionModel = new QItemSelectionModel(actions_TV->model());
|
||||
actions_TV->setSelectionModel(mSelectionModel);
|
||||
|
||||
connect(mSelectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(selectionChanged(QItemSelection, QItemSelection)));
|
||||
|
||||
connect(mActions, SIGNAL(daemonDisappeared()), SLOT(daemonDisappeared()));
|
||||
connect(mActions, SIGNAL(daemonAppeared()), SLOT(daemonAppeared()));
|
||||
connect(mActions, SIGNAL(multipleActionsBehaviourChanged(MultipleActionsBehaviour)), SLOT(multipleActionsBehaviourChanged(MultipleActionsBehaviour)));
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::daemonDisappeared()
|
||||
{
|
||||
add_PB->setEnabled(false);
|
||||
actions_TV->setEnabled(false);
|
||||
multipleActionsBehaviour_CB->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::daemonAppeared()
|
||||
{
|
||||
add_PB->setEnabled(true);
|
||||
actions_TV->setEnabled(true);
|
||||
multipleActionsBehaviour_CB->setEnabled(true);
|
||||
|
||||
multipleActionsBehaviour_CB->setCurrentIndex(mActions->multipleActionsBehaviour());
|
||||
|
||||
actions_TV->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
|
||||
int m = actions_TV->model()->columnCount() - 1;
|
||||
for (int i = 0; i < m; ++i)
|
||||
{
|
||||
actions_TV->resizeColumnToContents(i);
|
||||
actions_TV->setColumnWidth(i, actions_TV->columnWidth(i) + 20);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::multipleActionsBehaviourChanged(MultipleActionsBehaviour behaviour)
|
||||
{
|
||||
multipleActionsBehaviour_CB->setCurrentIndex(behaviour);
|
||||
}
|
||||
|
||||
void MainWindow::on_multipleActionsBehaviour_CB_currentIndexChanged(int index)
|
||||
{
|
||||
mActions->setMultipleActionsBehaviour(static_cast<MultipleActionsBehaviour>(index));
|
||||
}
|
||||
|
||||
void MainWindow::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
QModelIndexList rows = mSelectionModel->selectedRows();
|
||||
|
||||
modify_PB->setEnabled(rows.length() == 1);
|
||||
remove_PB->setEnabled(rows.length() != 0);
|
||||
|
||||
bool enableSwap = (rows.length() == 2);
|
||||
if (enableSwap)
|
||||
{
|
||||
QPair<bool, GeneralActionInfo> info0 = mActions->actionById(mDefaultModel->id(mSortFilterProxyModel->mapToSource(rows[0])));
|
||||
QPair<bool, GeneralActionInfo> info1 = mActions->actionById(mDefaultModel->id(mSortFilterProxyModel->mapToSource(rows[1])));
|
||||
enableSwap = (info0.first && info1.first && (info0.second.shortcut == info1.second.shortcut));
|
||||
}
|
||||
swap_PB->setEnabled(enableSwap);
|
||||
}
|
||||
|
||||
void MainWindow::on_add_PB_clicked()
|
||||
{
|
||||
editAction(QModelIndex());
|
||||
}
|
||||
|
||||
void MainWindow::on_modify_PB_clicked()
|
||||
{
|
||||
editAction(mSelectionModel->currentIndex());
|
||||
}
|
||||
|
||||
void MainWindow::on_swap_PB_clicked()
|
||||
{
|
||||
QModelIndexList rows = mSelectionModel->selectedRows();
|
||||
mActions->swapActions(mDefaultModel->id(mSortFilterProxyModel->mapToSource(rows[0])), mDefaultModel->id(mSortFilterProxyModel->mapToSource(rows[1])));
|
||||
}
|
||||
|
||||
void MainWindow::on_remove_PB_clicked()
|
||||
{
|
||||
foreach(const QModelIndex &rowIndex, mSelectionModel->selectedRows())
|
||||
mActions->removeAction(mDefaultModel->id(mSortFilterProxyModel->mapToSource(rowIndex)));
|
||||
}
|
||||
|
||||
void MainWindow::on_actions_TV_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
qulonglong id = mDefaultModel->id(mSortFilterProxyModel->mapToSource(index));
|
||||
mActions->enableAction(id, !mActions->isActionEnabled(id));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
editAction(index);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::editAction(const QModelIndex &index)
|
||||
{
|
||||
qulonglong id = 0;
|
||||
|
||||
if (index.isValid())
|
||||
id = mDefaultModel->id(mSortFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (!mEditActionDialog)
|
||||
mEditActionDialog = new EditActionDialog(mActions, this);
|
||||
|
||||
if (mEditActionDialog->load(id))
|
||||
mEditActionDialog->exec();
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_CONFIG__MAIN_WINDOW__INCLUDED
|
||||
#define GLOBAL_ACTION_CONFIG__MAIN_WINDOW__INCLUDED
|
||||
|
||||
|
||||
#include "ui_main_window.h"
|
||||
#include "../daemon/meta_types.h"
|
||||
|
||||
|
||||
class Actions;
|
||||
class DefaultModel;
|
||||
class QItemSelectionModel;
|
||||
class QSortFilterProxyModel;
|
||||
class EditActionDialog;
|
||||
|
||||
class MainWindow : public QDialog, private Ui::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void daemonDisappeared();
|
||||
void daemonAppeared();
|
||||
|
||||
void multipleActionsBehaviourChanged(MultipleActionsBehaviour behaviour);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
protected slots:
|
||||
void selectionChanged(const QItemSelection &, const QItemSelection &);
|
||||
|
||||
void on_add_PB_clicked();
|
||||
void on_modify_PB_clicked();
|
||||
void on_swap_PB_clicked();
|
||||
void on_remove_PB_clicked();
|
||||
|
||||
void on_multipleActionsBehaviour_CB_currentIndexChanged(int);
|
||||
|
||||
void on_actions_TV_doubleClicked(const QModelIndex &);
|
||||
|
||||
private:
|
||||
Actions *mActions;
|
||||
DefaultModel *mDefaultModel;
|
||||
QSortFilterProxyModel *mSortFilterProxyModel;
|
||||
QItemSelectionModel *mSelectionModel;
|
||||
EditActionDialog *mEditActionDialog;
|
||||
|
||||
void editAction(const QModelIndex &);
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_CONFIG__MAIN_WINDOW__INCLUDED
|
@ -0,0 +1,212 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QDialog" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>314</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Global Actions Manager</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTableView" name="actions_TV">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="add_PB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove_PB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="modify_PB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modify ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="swap_PB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Swap</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="multipleActionsBehaviour_L">
|
||||
<property name="text">
|
||||
<string>Multiple actions behaviour:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="multipleActionsBehaviour_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>First</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Last</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>All</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="close_PB">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<tabstops>
|
||||
<tabstop>actions_TV</tabstop>
|
||||
<tabstop>add_PB</tabstop>
|
||||
<tabstop>remove_PB</tabstop>
|
||||
<tabstop>modify_PB</tabstop>
|
||||
<tabstop>swap_PB</tabstop>
|
||||
<tabstop>close_PB</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>close_PB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>476</x>
|
||||
<y>281</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>488</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,164 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "shortcut_selector.h"
|
||||
#include "actions.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
ShortcutSelector::ShortcutSelector(Actions *actions, QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
, mActions(0)
|
||||
, mShortcutTimer(new QTimer(this))
|
||||
, mAutoApplyShortcut(false)
|
||||
{
|
||||
init();
|
||||
setActions(actions);
|
||||
}
|
||||
|
||||
ShortcutSelector::ShortcutSelector(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
, mActions(0)
|
||||
, mShortcutTimer(new QTimer(this))
|
||||
, mAutoApplyShortcut(false)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void ShortcutSelector::init()
|
||||
{
|
||||
setCheckable(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
mShortcutTimer->setInterval(1000);
|
||||
mShortcutTimer->setSingleShot(false);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(grabShortcut()));
|
||||
|
||||
connect(mShortcutTimer, SIGNAL(timeout()), this, SLOT(shortcutTimer_timeout()));
|
||||
}
|
||||
|
||||
void ShortcutSelector::setActions(Actions *actions)
|
||||
{
|
||||
if (mActions)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mActions = actions;
|
||||
connect(mActions, SIGNAL(grabShortcutCancelled()), this, SLOT(grabShortcut_fail()));
|
||||
connect(mActions, SIGNAL(grabShortcutTimedout()), this, SLOT(grabShortcut_fail()));
|
||||
connect(mActions, SIGNAL(grabShortcutFailed()), this, SLOT(grabShortcut_fail()));
|
||||
connect(mActions, SIGNAL(shortcutGrabbed(QString)), this, SLOT(newShortcutGrabbed(QString)));
|
||||
}
|
||||
|
||||
void ShortcutSelector::grabShortcut(int timeout)
|
||||
{
|
||||
if (!mActions)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isChecked())
|
||||
{
|
||||
mActions->cancelShortcutGrab();
|
||||
return;
|
||||
}
|
||||
|
||||
mTimeoutCounter = timeout;
|
||||
mOldShortcut = text();
|
||||
setText(QString::number(mTimeoutCounter));
|
||||
mShortcutTimer->start();
|
||||
mActions->grabShortcut(mTimeoutCounter * mShortcutTimer->interval());
|
||||
}
|
||||
|
||||
void ShortcutSelector::shortcutTimer_timeout()
|
||||
{
|
||||
if (mTimeoutCounter > 0)
|
||||
{
|
||||
--mTimeoutCounter;
|
||||
setText(QString::number(mTimeoutCounter));
|
||||
}
|
||||
else
|
||||
setText(QString());
|
||||
}
|
||||
|
||||
void ShortcutSelector::grabShortcut_fail()
|
||||
{
|
||||
if (isChecked())
|
||||
{
|
||||
setChecked(false);
|
||||
mShortcutTimer->stop();
|
||||
setText(mOldShortcut);
|
||||
emit shortcutGrabbed(mOldShortcut);
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutSelector::newShortcutGrabbed(const QString &newShortcut)
|
||||
{
|
||||
setChecked(false);
|
||||
mShortcutTimer->stop();
|
||||
if (mAutoApplyShortcut)
|
||||
setText(newShortcut);
|
||||
else
|
||||
setText(QString());
|
||||
emit shortcutGrabbed(newShortcut);
|
||||
}
|
||||
|
||||
void ShortcutSelector::clear()
|
||||
{
|
||||
setText(QString());
|
||||
}
|
||||
|
||||
QAction * ShortcutSelector::addMenuAction(const QString &title)
|
||||
{
|
||||
QMenu *subMenu = menu();
|
||||
if (!subMenu)
|
||||
{
|
||||
setPopupMode(QToolButton::MenuButtonPopup);
|
||||
subMenu = new QMenu(this);
|
||||
setMenu(subMenu);
|
||||
}
|
||||
QAction *action = new QAction(title, subMenu);
|
||||
subMenu->addAction(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
bool ShortcutSelector::isGrabbing() const
|
||||
{
|
||||
return isChecked();
|
||||
}
|
||||
|
||||
void ShortcutSelector::cancelNow()
|
||||
{
|
||||
if (isChecked())
|
||||
{
|
||||
grabShortcut_fail();
|
||||
mActions->cancelShortcutGrab();
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_CONFIG__SHORTCUT_SELECTOR__INCLUDED
|
||||
#define GLOBAL_ACTION_CONFIG__SHORTCUT_SELECTOR__INCLUDED
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class Actions;
|
||||
class QTimer;
|
||||
|
||||
class ShortcutSelector : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ShortcutSelector(Actions *actions, QWidget *parent = 0);
|
||||
explicit ShortcutSelector(QWidget *parent = 0);
|
||||
void setActions(Actions *actions);
|
||||
|
||||
QAction *addMenuAction(const QString &title);
|
||||
|
||||
bool shortcutAutoApplied(void) const { return mAutoApplyShortcut; }
|
||||
|
||||
bool isGrabbing() const;
|
||||
|
||||
signals:
|
||||
void shortcutGrabbed(const QString &);
|
||||
|
||||
public slots:
|
||||
void grabShortcut(int timeout = 10);
|
||||
|
||||
void clear();
|
||||
|
||||
void autoApplyShortcut(bool value = true) { mAutoApplyShortcut = value; }
|
||||
|
||||
void cancelNow();
|
||||
|
||||
private slots:
|
||||
void shortcutTimer_timeout();
|
||||
void grabShortcut_fail();
|
||||
void newShortcutGrabbed(const QString &);
|
||||
|
||||
private:
|
||||
Actions *mActions;
|
||||
QString mOldShortcut;
|
||||
int mTimeoutCounter;
|
||||
QTimer *mShortcutTimer;
|
||||
bool mAutoApplyShortcut;
|
||||
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_CONFIG__SHORTCUT_SELECTOR__INCLUDED
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[ca]=Tecles de les dreceres
|
||||
GenericName[ca]=Ajusts de les dreceres de teclat
|
||||
Comment[ca]=Configureu les tecles de les dreceres a LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[cs]=Nastavení klávesových zkratek
|
||||
Comment[cs]=Nastavit celkové klávesové zkratky pro prostředí LXQt
|
||||
GenericName[cs]=Nastavení celkových klávesových zkratek
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[cs_CZ]=Nastavení klávesových zkratek
|
||||
Comment[cs_CZ]=Nastavit celkové klávesové zkratky pro prostředí LXQt
|
||||
GenericName[cs_CZ]=Nastavení celkových klávesových zkratek
|
@ -0,0 +1,3 @@
|
||||
Name[da]=Genvejstaster
|
||||
GenericName[da]=Indstillinger for tastaturgenveje
|
||||
Comment[da]=Konfigurér genvejstaster i LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[de]=Kurzbefehl-Konfiguration
|
||||
GenericName[de]=Globale Kurzbefehlkonfiguration
|
||||
Comment[de]=Globale Kurzbefehle für die LXQt-Arbeitsfläche definieren
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[el]=Πλήκτρα συντομεύσεων
|
||||
GenericName[el]=Ρυθμίσεις συντομεύσεων πληκτρολογίου
|
||||
Comment[el]=Διαμόρφωση των πλήκτρων συντομεύσεων του LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[es]=Configuración de Atajos de LXQt
|
||||
Comment[es]=Configure atajos globales del Escritorio de LXQt
|
||||
GenericName[es]=Configuración de Atajos Globales de LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[es_VE]=Configuracion de atajos de LXQt
|
||||
Comment[es_VE]=Configura atajos de teclado para el escritorio LXQt
|
||||
GenericName[es_VE]=Configuracion de Atajos globales de LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[eu]=LXQt lasterbideen konfigurazioa
|
||||
Comment[eu]=Konfiguratu LXQt mahaigainaren lasterbide globalak
|
||||
GenericName[eu]=LXQt lasterbide globalen konfigurazioa
|
@ -0,0 +1,3 @@
|
||||
Name[fr]=Touches de raccourcis
|
||||
GenericName[fr]=Configuration des touches de raccourcis
|
||||
Comment[fr]=Configuration des touches de raccourcis de LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[hu]=LXQt gyorsbillentyűk
|
||||
Comment[hu]=LXQt általános forróbillentyűinek beállítása
|
||||
GenericName[hu]=LXQt gyorsbillentyűk beállítása
|
@ -0,0 +1,3 @@
|
||||
# Translations
|
||||
Name[it]=Scorciatoie globali
|
||||
Comment[it]=Configura le scorciatoie globali di LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[lt]=Spartieji klavišai
|
||||
GenericName[lt]=Sparčiųjų klavišų nustatymai
|
||||
Comment[lt]=Konfigūruoti LXQt sparčiuosius klavišus
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[pl_PL]=Konfiguracja skrótów pulpitu LXQt
|
||||
Comment[pl_PL]=Określ globalny skrót pulpitu LXQt
|
||||
GenericName[pl_PL]=Konfiguracja globalnych skrótów pulpitu LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[pt]=Teclas de atalho
|
||||
GenericName[pt]=Definições das teclas de atalho
|
||||
Comment[pt]=Configurar as teclas de atalho do LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[pt_BR]=Configuração Do Atalho
|
||||
Comment[pt_BR]=Configurar atalhos globais do desktop LXQt
|
||||
GenericName[pt_BR]=Configurações Dos Atalhos Globais
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[ro_RO]=Configurație acceleratori LXQt
|
||||
Comment[ro_RO]=Configurează acceleratorii globali pentru LXQt
|
||||
GenericName[ro_RO]=Configurație acceleratori globali LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[ru]=Сочетания клавиш
|
||||
Comment[ru]=Настроить сочетания клавиш в LXQt
|
||||
GenericName[ru]=Настроить сочетания клавиш
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[th_TH]=การตั้งค่าปุ่มลัด LXQt
|
||||
Comment[th_TH]=ตั้งค่าปุ่มลัดหลักของ LXQt เดกส์ท็อป
|
||||
GenericName[th_TH]=การตั้งค่าปุ่มลัดหลัก LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[uk]=Налаштування скорочень LXQt
|
||||
Comment[uk]=Налаштувати глобальні скорочення стільниці LXQt
|
||||
GenericName[uk]=Налаштування глобальних скорочень LXQt
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[zh_CN]=LXQt 快捷键配置
|
||||
Comment[zh_CN]=配置 LXQt 桌面全局快捷键
|
||||
GenericName[zh_CN]=LXQt 全局快捷键配置
|
@ -0,0 +1,4 @@
|
||||
# Translations
|
||||
Name[zh_TW]=LXQt快捷鍵設定
|
||||
Comment[zh_TW]=設定LXQt桌面的全域快捷鍵
|
||||
GenericName[zh_TW]=LXQt全域快捷鍵設定
|
@ -0,0 +1,151 @@
|
||||
set(PROJECT_NAME lxqt-globalkeysd)
|
||||
project(${PROJECT_NAME})
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
find_package(X11)
|
||||
include_directories("${X11_INCLUDE_DIR}")
|
||||
|
||||
set(QT_DBUS_PREFIX "org.qtproject")
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
main.cpp
|
||||
core.cpp
|
||||
daemon_adaptor.cpp
|
||||
native_adaptor.cpp
|
||||
client_proxy.cpp
|
||||
log_target.cpp
|
||||
pipe_utils.cpp
|
||||
string_utils.cpp
|
||||
base_action.cpp
|
||||
method_action.cpp
|
||||
client_action.cpp
|
||||
command_action.cpp
|
||||
meta_types.cpp
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_CPP_HEADERS
|
||||
log_target.h
|
||||
pipe_utils.h
|
||||
string_utils.h
|
||||
base_action.h
|
||||
method_action.h
|
||||
client_action.h
|
||||
command_action.h
|
||||
meta_types.h
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_FORMS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_RESOURCES
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATIONS
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_ADAPTORS
|
||||
org.lxqt.global_key_shortcuts.daemon.xml
|
||||
org.lxqt.global_key_shortcuts.native.xml
|
||||
)
|
||||
|
||||
set_source_files_properties(org.lxqt.global_key_shortcuts.daemon.xml PROPERTIES
|
||||
INCLUDE daemon_adaptor.h
|
||||
PARENT_CLASSNAME DaemonAdaptor
|
||||
BASENAME org.lxqt.global_key_shortcuts.daemon
|
||||
CLASSNAME OrgLxqtGlobalActionDaemonAdaptor
|
||||
)
|
||||
|
||||
set_source_files_properties(org.lxqt.global_key_shortcuts.native.xml PROPERTIES
|
||||
INCLUDE native_adaptor.h
|
||||
PARENT_CLASSNAME NativeAdaptor
|
||||
BASENAME org.lxqt.global_key_shortcuts.native
|
||||
CLASSNAME OrgLxqtGlobalActionNativeAdaptor
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_DBUS_INTERFACES
|
||||
org.lxqt.global_key_shortcuts.client.xml
|
||||
)
|
||||
|
||||
set_source_files_properties(org.lxqt.global_key_shortcuts.client.xml PROPERTIES
|
||||
BASENAME org.lxqt.global_key_shortcuts.client
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
${${PROJECT_NAME}_CPP_HEADERS}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_TRANSLATABLE
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_FORMS}
|
||||
)
|
||||
|
||||
foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
|
||||
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
|
||||
configure_file(
|
||||
${DBUS_ADAPTOR}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
|
||||
get_source_file_property(DBUS_ADAPTOR_PARENT_CLASSNAME ${DBUS_ADAPTOR} PARENT_CLASSNAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_BASENAME ${DBUS_ADAPTOR} BASENAME)
|
||||
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
|
||||
if(DBUS_ADAPTOR_BASENAME)
|
||||
if(DBUS_ADAPTOR_CLASSNAME)
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
|
||||
endif()
|
||||
else()
|
||||
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
|
||||
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
|
||||
configure_file(
|
||||
${DBUS_INTERFACE}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
|
||||
@ONLY
|
||||
)
|
||||
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
|
||||
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
|
||||
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
|
||||
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
|
||||
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
|
||||
INCLUDE ${DBUS_INTERFACE_INCLUDE}
|
||||
CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
|
||||
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
|
||||
)
|
||||
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
|
||||
endforeach()
|
||||
|
||||
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
|
||||
|
||||
set(${PROJECT_NAME}_GENERATED_FILES
|
||||
${${PROJECT_NAME}_FORM_FILES}
|
||||
${${PROJECT_NAME}_RESOURCE_FILES}
|
||||
${${PROJECT_NAME}_QM_FILES}
|
||||
${${PROJECT_NAME}_DBUS_INTERFACE_FILES}
|
||||
${${PROJECT_NAME}_DBUS_ADAPTOR_FILES}
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_ALL_FILES
|
||||
${${PROJECT_NAME}_SOURCES}
|
||||
${${PROJECT_NAME}_HEADERS}
|
||||
${${PROJECT_NAME}_GENERATED_FILES}
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES})
|
||||
target_link_libraries(${PROJECT_NAME} ${X11_LIBRARIES} lxqt Qt5::Widgets Qt5::DBus)
|
||||
lxqt_enable_target_exceptions(${PROJECT_NAME} PRIVATE)
|
||||
|
||||
install(TARGETS
|
||||
${PROJECT_NAME}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
COMPONENT Runtime
|
||||
)
|
@ -0,0 +1,41 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "base_action.h"
|
||||
#include "log_target.h"
|
||||
|
||||
|
||||
BaseAction::BaseAction(LogTarget *logTarget, const QString &description)
|
||||
: mLogTarget(logTarget)
|
||||
, mDescription(description)
|
||||
, mEnabled(true)
|
||||
{
|
||||
}
|
||||
|
||||
BaseAction::~BaseAction()
|
||||
{
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__BASE_ACTION__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__BASE_ACTION__INCLUDED
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
class LogTarget;
|
||||
|
||||
class BaseAction
|
||||
{
|
||||
public:
|
||||
BaseAction(LogTarget *logTarget, const QString &description);
|
||||
virtual ~BaseAction();
|
||||
|
||||
virtual const char *type() const = 0;
|
||||
|
||||
virtual bool call() = 0;
|
||||
|
||||
const QString &description() const { return mDescription; }
|
||||
void setDescription(const QString &description) { mDescription = description; }
|
||||
|
||||
void setEnabled(bool value = true) { mEnabled = value; }
|
||||
void setDisabled(bool value = true) { mEnabled = !value; }
|
||||
bool isEnabled() const { return mEnabled; }
|
||||
|
||||
protected:
|
||||
LogTarget *mLogTarget;
|
||||
|
||||
private:
|
||||
QString mDescription;
|
||||
|
||||
bool mEnabled;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__BASE_ACTION__INCLUDED
|
@ -0,0 +1,94 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "client_action.h"
|
||||
#include "client_proxy.h"
|
||||
#include "log_target.h"
|
||||
|
||||
|
||||
ClientAction::ClientAction(LogTarget *logTarget, const QDBusObjectPath &path, const QString &description)
|
||||
: BaseAction(logTarget, description)
|
||||
, mProxy(0)
|
||||
, mPath(path)
|
||||
{
|
||||
}
|
||||
|
||||
ClientAction::ClientAction(LogTarget *logTarget, const QDBusConnection &connection, const QString &service, const QDBusObjectPath &path, const QString &description)
|
||||
: BaseAction(logTarget, description)
|
||||
, mProxy(0)
|
||||
, mPath(path)
|
||||
{
|
||||
appeared(connection, service);
|
||||
}
|
||||
|
||||
ClientAction::~ClientAction()
|
||||
{
|
||||
delete mProxy;
|
||||
}
|
||||
|
||||
bool ClientAction::call()
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mProxy)
|
||||
{
|
||||
mLogTarget->log(LOG_WARNING, "No native client: \"%s\"", qPrintable(mService));
|
||||
return false;
|
||||
}
|
||||
|
||||
mProxy->emitActivated();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClientAction::appeared(const QDBusConnection &connection, const QString &service)
|
||||
{
|
||||
if (mProxy) // should never happen
|
||||
{
|
||||
return;
|
||||
}
|
||||
mService = service;
|
||||
mProxy = new ClientProxy(mService, QDBusObjectPath("/global_key_shortcuts" + mPath.path()), connection);
|
||||
}
|
||||
|
||||
void ClientAction::disappeared()
|
||||
{
|
||||
mService.clear();
|
||||
delete mProxy;
|
||||
mProxy = 0;
|
||||
}
|
||||
|
||||
void ClientAction::shortcutChanged(const QString &oldShortcut, const QString &newShortcut)
|
||||
{
|
||||
if (mProxy)
|
||||
{
|
||||
mProxy->emitShortcutChanged(oldShortcut, newShortcut);
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__DBUS_ACTION__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__DBUS_ACTION__INCLUDED
|
||||
|
||||
|
||||
#include "base_action.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusConnection>
|
||||
|
||||
|
||||
class ClientProxy;
|
||||
|
||||
class ClientAction : public BaseAction
|
||||
{
|
||||
public:
|
||||
ClientAction(LogTarget *logTarget, const QDBusObjectPath &path, const QString &description);
|
||||
ClientAction(LogTarget *logTarget, const QDBusConnection &connection, const QString &service, const QDBusObjectPath &path, const QString &description);
|
||||
~ClientAction();
|
||||
|
||||
static const char *id() { return "client"; }
|
||||
|
||||
virtual const char *type() const { return id(); }
|
||||
|
||||
virtual bool call();
|
||||
|
||||
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
const QString &service() const { return mService; }
|
||||
const QDBusObjectPath &path() const { return mPath; }
|
||||
|
||||
void appeared(const QDBusConnection &connection, const QString &service);
|
||||
void disappeared();
|
||||
|
||||
bool isPresent() const { return mProxy; }
|
||||
|
||||
private:
|
||||
ClientProxy *mProxy;
|
||||
|
||||
QString mService;
|
||||
QDBusObjectPath mPath;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__DBUS_ACTION__INCLUDED
|
@ -0,0 +1,50 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "client_proxy.h"
|
||||
|
||||
|
||||
#include "org.lxqt.global_key_shortcuts.client.h"
|
||||
|
||||
|
||||
ClientProxy::ClientProxy(const QString &service, const QDBusObjectPath &path, const QDBusConnection &connection, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
org::lxqt::global_key_shortcuts::client *iface = new org::lxqt::global_key_shortcuts::client(service, path.path(), connection, this);
|
||||
connect(this, SIGNAL(activated()), iface, SLOT(activated()));
|
||||
connect(this, SIGNAL(shortcutChanged(QString, QString)), iface, SLOT(shortcutChanged(QString, QString)));
|
||||
}
|
||||
|
||||
void ClientProxy::emitActivated()
|
||||
{
|
||||
emit activated();
|
||||
}
|
||||
|
||||
void ClientProxy::emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut)
|
||||
{
|
||||
emit shortcutChanged(oldShortcut, newShortcut);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__CLIENT_PROXY__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__CLIENT_PROXY__INCLUDED
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusConnection>
|
||||
|
||||
|
||||
class ClientAction;
|
||||
|
||||
class ClientProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class ClientAction;
|
||||
|
||||
public:
|
||||
ClientProxy(const QString &service, const QDBusObjectPath &path, const QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void activated();
|
||||
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
|
||||
protected:
|
||||
void emitActivated();
|
||||
void emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut);
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__CLIENT_PROXY__INCLUDED
|
@ -0,0 +1,60 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "command_action.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log_target.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
|
||||
CommandAction::CommandAction(LogTarget *logTarget, const QString &command, const QStringList &args, const QString &description)
|
||||
: BaseAction(logTarget, description)
|
||||
, mCommand(command)
|
||||
, mArgs(args)
|
||||
{
|
||||
}
|
||||
|
||||
bool CommandAction::call()
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = QProcess::startDetached(mCommand, mArgs);
|
||||
if (!result)
|
||||
{
|
||||
mLogTarget->log(LOG_WARNING, "Failed to launch command \"%s\"%s", qPrintable(mCommand), qPrintable(joinToString(mArgs, " \"", "\" \"", "\"")));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__COMMAND_ACTION__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__COMMAND_ACTION__INCLUDED
|
||||
|
||||
|
||||
#include "base_action.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class CommandAction : public BaseAction
|
||||
{
|
||||
public:
|
||||
CommandAction(LogTarget *logTarget, const QString &command, const QStringList &args, const QString &description);
|
||||
|
||||
static const char *id() { return "command"; }
|
||||
|
||||
virtual const char *type() const { return id(); }
|
||||
|
||||
virtual bool call();
|
||||
|
||||
QString command() const { return mCommand; }
|
||||
|
||||
QStringList args() const { return mArgs; }
|
||||
|
||||
private:
|
||||
QString mCommand;
|
||||
QStringList mArgs;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__COMMAND_ACTION__INCLUDED
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,255 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__CORE__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__CORE__INCLUDED
|
||||
|
||||
|
||||
#include <QThread>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QQueue>
|
||||
#include <QMutex>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
#include "meta_types.h"
|
||||
#include "log_target.h"
|
||||
|
||||
extern "C" {
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xproto.h>
|
||||
#undef Bool
|
||||
}
|
||||
|
||||
|
||||
class QTimer;
|
||||
class DaemonAdaptor;
|
||||
class NativeAdaptor;
|
||||
class DBusProxy;
|
||||
class BaseAction;
|
||||
class QDBusServiceWatcher;
|
||||
|
||||
template<class Key>
|
||||
class QOrderedSet : public QMap<Key, Key>
|
||||
{
|
||||
public:
|
||||
typename QMap<Key, Key>::iterator insert(const Key &akey)
|
||||
{
|
||||
return QMap<Key, Key>::insert(akey, akey);
|
||||
}
|
||||
};
|
||||
|
||||
class Core : public QThread, public LogTarget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Core(bool useSyslog, bool minLogLevelSet, int minLogLevel, const QStringList &configFiles, bool multipleActionsBehaviourSet, MultipleActionsBehaviour multipleActionsBehaviour, QObject *parent = 0);
|
||||
~Core();
|
||||
|
||||
bool ready() const { return mReady; }
|
||||
|
||||
virtual void log(int level, const char *format, ...) const;
|
||||
|
||||
signals:
|
||||
void onShortcutGrabbed();
|
||||
|
||||
private:
|
||||
Core(const Core &);
|
||||
Core &operator = (const Core &);
|
||||
|
||||
private:
|
||||
typedef QPair<KeyCode, unsigned int> X11Shortcut;
|
||||
typedef QMap<X11Shortcut, QString> ShortcutByX11;
|
||||
typedef QMap<QString, X11Shortcut> X11ByShortcut;
|
||||
typedef QOrderedSet<qulonglong> Ids;
|
||||
typedef QMap<QString, Ids> IdsByShortcut;
|
||||
typedef QDBusObjectPath ClientPath;
|
||||
typedef QMap<ClientPath, qulonglong> IdByClientPath;
|
||||
typedef QPair<QString, BaseAction *> ShortcutAndAction;
|
||||
typedef QMap<qulonglong, ShortcutAndAction> ShortcutAndActionById;
|
||||
typedef QMap<ClientPath, QString> SenderByClientPath;
|
||||
typedef QSet<ClientPath> ClientPaths;
|
||||
typedef QMap<QString, ClientPaths> ClientPathsBySender;
|
||||
|
||||
private slots:
|
||||
void serviceDisappeared(const QString &sender);
|
||||
|
||||
void addClientAction(QPair<QString, qulonglong> &result, const QString &shortcut, const QDBusObjectPath &path, const QString &description, const QString &sender);
|
||||
void addMethodAction(QPair<QString, qulonglong> &result, const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
void addCommandAction(QPair<QString, qulonglong> &result, const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
void modifyClientAction(qulonglong &result, const QDBusObjectPath &path, const QString &description, const QString &sender);
|
||||
void modifyActionDescription(bool &result, const qulonglong &id, const QString &description);
|
||||
void modifyMethodAction(bool &result, const qulonglong &id, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
void modifyCommandAction(bool &result, const qulonglong &id, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
void enableClientAction(bool &result, const QDBusObjectPath &path, bool enabled, const QString &sender);
|
||||
void isClientActionEnabled(bool &enabled, const QDBusObjectPath &path, const QString &sender);
|
||||
void enableAction(bool &result, qulonglong id, bool enabled);
|
||||
void isActionEnabled(bool &enabled, qulonglong id);
|
||||
|
||||
void getClientActionSender(QString &sender, qulonglong id);
|
||||
|
||||
|
||||
void changeClientActionShortcut(QPair<QString, qulonglong> &result, const QDBusObjectPath &path, const QString &shortcut, const QString &sender);
|
||||
void changeShortcut(QString &result, const qulonglong &id, const QString &shortcut);
|
||||
|
||||
void swapActions(bool &result, const qulonglong &id1, const qulonglong &id2);
|
||||
|
||||
void removeClientAction(bool &result, const QDBusObjectPath &path, const QString &sender);
|
||||
void removeAction(bool &result, const qulonglong &id);
|
||||
|
||||
void deactivateClientAction(bool &result, const QDBusObjectPath &path, const QString &sender);
|
||||
|
||||
void setMultipleActionsBehaviour(const MultipleActionsBehaviour &behaviour);
|
||||
void getMultipleActionsBehaviour(MultipleActionsBehaviour &result) const;
|
||||
|
||||
void getAllActionIds(QList<qulonglong> &result) const;
|
||||
void getActionById(QPair<bool, GeneralActionInfo> &result, const qulonglong &id) const;
|
||||
void getAllActions(QMap<qulonglong, GeneralActionInfo> &result) const;
|
||||
|
||||
void getClientActionInfoById(QPair<bool, ClientActionInfo> &result, const qulonglong &id) const;
|
||||
void getMethodActionInfoById(QPair<bool, MethodActionInfo> &result, const qulonglong &id) const;
|
||||
void getCommandActionInfoById(QPair<bool, CommandActionInfo> &result, const qulonglong &id) const;
|
||||
|
||||
void grabShortcut(const uint &timeout, QString &shortcut, bool &failed, bool &cancelled, bool &timedout, const QDBusMessage &message);
|
||||
void cancelShortcutGrab();
|
||||
|
||||
void shortcutGrabbed();
|
||||
void shortcutGrabTimedout();
|
||||
|
||||
private:
|
||||
bool enableActionNonGuarded(qulonglong id, bool enabled);
|
||||
QPair<QString, qulonglong> addOrRegisterClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description, const QString &sender);
|
||||
qulonglong registerClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description);
|
||||
qulonglong registerMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
qulonglong registerCommandAction(const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
GeneralActionInfo actionInfo(const ShortcutAndAction &shortcutAndAction) const;
|
||||
|
||||
friend void unixSignalHandler(int signalNumber);
|
||||
void unixSignalHandler(int signalNumber);
|
||||
|
||||
friend int x11ErrorHandler(Display *display, XErrorEvent *errorEvent);
|
||||
int x11ErrorHandler(Display *display, XErrorEvent *errorEvent);
|
||||
|
||||
X11Shortcut ShortcutToX11(const QString &shortcut);
|
||||
QString X11ToShortcut(const X11Shortcut &X11shortcut);
|
||||
|
||||
void wakeX11Thread();
|
||||
|
||||
void run();
|
||||
|
||||
KeyCode remoteStringToKeycode(const QString &str);
|
||||
QString remoteKeycodeToString(KeyCode keyCode);
|
||||
bool remoteXGrabKey(const X11Shortcut &X11shortcut);
|
||||
bool remoteXUngrabKey(const X11Shortcut &X11shortcut);
|
||||
|
||||
QString grabOrReuseKey(const X11Shortcut &X11shortcut, const QString &shortcut);
|
||||
|
||||
QString checkShortcut(const QString &shortcut, X11Shortcut &X11shortcut);
|
||||
|
||||
bool isEscape(KeySym keySym, unsigned int modifiers);
|
||||
bool isModifier(KeySym keySym);
|
||||
bool isAllowed(KeySym keySym, unsigned int modifiers);
|
||||
|
||||
void saveConfig();
|
||||
|
||||
void lockX11Error();
|
||||
bool checkX11Error(int level = LOG_NOTICE, uint timeout = 10);
|
||||
|
||||
bool waitForX11Error(int level, uint timeout);
|
||||
|
||||
private:
|
||||
bool mReady;
|
||||
bool mUseSyslog;
|
||||
|
||||
int mMinLogLevel;
|
||||
|
||||
int mX11ErrorPipe[2];
|
||||
int mX11RequestPipe[2];
|
||||
int mX11ResponsePipe[2];
|
||||
Display *mDisplay;
|
||||
Window mInterClientCommunicationWindow;
|
||||
bool mX11EventLoopActive;
|
||||
|
||||
mutable QMutex mX11ErrorMutex;
|
||||
|
||||
QDBusServiceWatcher *mServiceWatcher;
|
||||
DaemonAdaptor *mDaemonAdaptor;
|
||||
NativeAdaptor *mNativeAdaptor;
|
||||
|
||||
mutable QMutex mDataMutex;
|
||||
|
||||
qulonglong mLastId;
|
||||
|
||||
bool mGrabbingShortcut;
|
||||
|
||||
X11ByShortcut mX11ByShortcut;
|
||||
ShortcutByX11 mShortcutByX11;
|
||||
IdsByShortcut mIdsByShortcut;
|
||||
IdsByShortcut mDisabledIdsByShortcut;
|
||||
ShortcutAndActionById mShortcutAndActionById;
|
||||
IdByClientPath mIdByClientPath;
|
||||
SenderByClientPath mSenderByClientPath; // add: path->sender
|
||||
ClientPathsBySender mClientPathsBySender; // disappear: sender->[path]
|
||||
|
||||
|
||||
unsigned int NumLockMask;
|
||||
unsigned int ScrollLockMask;
|
||||
unsigned int CapsLockMask;
|
||||
unsigned int AltMask;
|
||||
unsigned int MetaMask;
|
||||
unsigned int Level3Mask;
|
||||
unsigned int Level5Mask;
|
||||
|
||||
MultipleActionsBehaviour mMultipleActionsBehaviour;
|
||||
|
||||
bool mAllowGrabLocks;
|
||||
bool mAllowGrabBaseSpecial;
|
||||
bool mAllowGrabMiscSpecial;
|
||||
bool mAllowGrabBaseKeypad;
|
||||
bool mAllowGrabMiscKeypad;
|
||||
bool mAllowGrabPrintable;
|
||||
|
||||
QString mConfigFile;
|
||||
bool mSaveAllowed;
|
||||
|
||||
QTimer *mShortcutGrabTimeout;
|
||||
QDBusMessage mShortcutGrabRequest;
|
||||
bool mShortcutGrabRequested;
|
||||
|
||||
bool mSuppressX11ErrorMessages;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__CORE__INCLUDED
|
@ -0,0 +1,299 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "daemon_adaptor.h"
|
||||
|
||||
#include "org.lxqt.global_key_shortcuts.daemon.h"
|
||||
|
||||
|
||||
DaemonAdaptor::DaemonAdaptor(QObject *parent)
|
||||
: QObject(parent)
|
||||
, QDBusContext()
|
||||
{
|
||||
new OrgLxqtGlobalActionDaemonAdaptor(this);
|
||||
}
|
||||
|
||||
QString DaemonAdaptor::addMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description, qulonglong &id)
|
||||
{
|
||||
QPair<QString, qulonglong> result;
|
||||
emit onAddMethodAction(result, shortcut, service, path, interface, method, description);
|
||||
QString usedShortcut = result.first;
|
||||
id = result.second;
|
||||
if (id)
|
||||
{
|
||||
emit actionAdded(id);
|
||||
}
|
||||
return usedShortcut;
|
||||
}
|
||||
|
||||
QString DaemonAdaptor::addCommandAction(const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description, qulonglong &id)
|
||||
{
|
||||
QPair<QString, qulonglong> result;
|
||||
emit onAddCommandAction(result, shortcut, command, arguments, description);
|
||||
QString usedShortcut = result.first;
|
||||
id = result.second;
|
||||
if (id)
|
||||
{
|
||||
emit actionAdded(id);
|
||||
}
|
||||
return usedShortcut;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::modifyActionDescription(qulonglong id, const QString &description)
|
||||
{
|
||||
bool result;
|
||||
emit onModifyActionDescription(result, id, description);
|
||||
if (result)
|
||||
{
|
||||
emit actionModified(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::modifyMethodAction(qulonglong id, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description)
|
||||
{
|
||||
bool result;
|
||||
emit onModifyMethodAction(result, id, service, path, interface, method, description);
|
||||
if (result)
|
||||
{
|
||||
emit actionModified(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::modifyCommandAction(qulonglong id, const QString &command, const QStringList &arguments, const QString &description)
|
||||
{
|
||||
bool result;
|
||||
emit onModifyCommandAction(result, id, command, arguments, description);
|
||||
if (result)
|
||||
{
|
||||
emit actionModified(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::enableAction(qulonglong id, bool enabled)
|
||||
{
|
||||
bool result;
|
||||
emit onEnableAction(result, id, enabled);
|
||||
if (result)
|
||||
{
|
||||
emit actionEnabled(id, enabled);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::isActionEnabled(qulonglong id)
|
||||
{
|
||||
bool enabled;
|
||||
emit onIsActionEnabled(enabled, id);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
QString DaemonAdaptor::getClientActionSender(qulonglong id)
|
||||
{
|
||||
QString sender;
|
||||
emit onGetClientActionSender(sender, id);
|
||||
return sender;
|
||||
}
|
||||
|
||||
QString DaemonAdaptor::changeShortcut(qulonglong id, const QString &shortcut)
|
||||
{
|
||||
QString result;
|
||||
emit onChangeShortcut(result, id, shortcut);
|
||||
if (!result.isEmpty())
|
||||
{
|
||||
emit actionShortcutChanged(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::swapActions(qulonglong id1, qulonglong id2)
|
||||
{
|
||||
bool result;
|
||||
emit onSwapActions(result, id1, id2);
|
||||
if (result)
|
||||
{
|
||||
emit actionsSwapped(id1, id2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::removeAction(qulonglong id)
|
||||
{
|
||||
bool result;
|
||||
emit onRemoveAction(result, id);
|
||||
if (result)
|
||||
{
|
||||
emit actionRemoved(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::setMultipleActionsBehaviour(uint behaviour)
|
||||
{
|
||||
if (behaviour >= MULTIPLE_ACTIONS_BEHAVIOUR__COUNT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
emit onSetMultipleActionsBehaviour(static_cast<MultipleActionsBehaviour>(behaviour));
|
||||
emit multipleActionsBehaviourChanged(behaviour);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint DaemonAdaptor::getMultipleActionsBehaviour()
|
||||
{
|
||||
MultipleActionsBehaviour result;
|
||||
emit onGetMultipleActionsBehaviour(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<qulonglong> DaemonAdaptor::getAllActionIds()
|
||||
{
|
||||
QList<qulonglong> result;
|
||||
emit onGetAllActionIds(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::getActionById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &type, QString &info)
|
||||
{
|
||||
QPair<bool, GeneralActionInfo> result;
|
||||
emit onGetActionById(result, id);
|
||||
bool success = result.first;
|
||||
if (success)
|
||||
{
|
||||
shortcut = result.second.shortcut;
|
||||
description = result.second.description;
|
||||
enabled = result.second.enabled;
|
||||
type = result.second.type;
|
||||
info = result.second.info;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
QMap<qulonglong, GeneralActionInfo> DaemonAdaptor::getAllActions()
|
||||
{
|
||||
QMap<qulonglong, GeneralActionInfo> result;
|
||||
emit onGetAllActions(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::getClientActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QDBusObjectPath &path)
|
||||
{
|
||||
QPair<bool, ClientActionInfo> result;
|
||||
emit onGetClientActionInfoById(result, id);
|
||||
bool success = result.first;
|
||||
if (success)
|
||||
{
|
||||
shortcut = result.second.shortcut;
|
||||
description = result.second.description;
|
||||
enabled = result.second.enabled;
|
||||
path = result.second.path;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::getMethodActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &service, QDBusObjectPath &path, QString &interface, QString &method)
|
||||
{
|
||||
QPair<bool, MethodActionInfo> result;
|
||||
emit onGetMethodActionInfoById(result, id);
|
||||
bool success = result.first;
|
||||
if (success)
|
||||
{
|
||||
shortcut = result.second.shortcut;
|
||||
description = result.second.description;
|
||||
enabled = result.second.enabled;
|
||||
service = result.second.service;
|
||||
path = result.second.path;
|
||||
interface = result.second.interface;
|
||||
method = result.second.method;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool DaemonAdaptor::getCommandActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &command, QStringList &arguments)
|
||||
{
|
||||
QPair<bool, CommandActionInfo> result;
|
||||
emit onGetCommandActionInfoById(result, id);
|
||||
bool success = result.first;
|
||||
if (success)
|
||||
{
|
||||
shortcut = result.second.shortcut;
|
||||
description = result.second.description;
|
||||
enabled = result.second.enabled;
|
||||
command = result.second.command;
|
||||
arguments = result.second.arguments;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
QString DaemonAdaptor::grabShortcut(uint timeout, bool &failed, bool &cancelled, bool &timedout)
|
||||
{
|
||||
QString shortcut;
|
||||
emit onGrabShortcut(timeout, shortcut, failed, cancelled, timedout, message());
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
void DaemonAdaptor::cancelShortcutGrab()
|
||||
{
|
||||
emit onCancelShortcutGrab();
|
||||
}
|
||||
|
||||
void DaemonAdaptor::quit()
|
||||
{
|
||||
emit onQuit();
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_actionAdded(qulonglong id)
|
||||
{
|
||||
emit actionAdded(id);
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_actionModified(qulonglong id)
|
||||
{
|
||||
emit actionModified(id);
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_actionRemoved(qulonglong id)
|
||||
{
|
||||
emit actionRemoved(id);
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_actionShortcutChanged(qulonglong id)
|
||||
{
|
||||
emit actionShortcutChanged(id);
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_actionEnabled(qulonglong id, bool enabled)
|
||||
{
|
||||
emit actionEnabled(id, enabled);
|
||||
}
|
||||
|
||||
void DaemonAdaptor::emit_clientActionSenderChanged(qulonglong id, const QString &sender)
|
||||
{
|
||||
emit clientActionSenderChanged(id, sender);
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__DAEMON_ADAPTOR__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__DAEMON_ADAPTOR__INCLUDED
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusContext>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QPair>
|
||||
|
||||
#include "meta_types.h"
|
||||
|
||||
|
||||
class DaemonAdaptor : public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DaemonAdaptor(QObject *parent = 0);
|
||||
|
||||
public slots:
|
||||
QString addMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description, qulonglong &id);
|
||||
QString addCommandAction(const QString &shortcut, const QString &command, const QStringList &arguments, const QString &description, qulonglong &id);
|
||||
|
||||
bool modifyActionDescription(qulonglong id, const QString &description);
|
||||
bool modifyMethodAction(qulonglong id, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
bool modifyCommandAction(qulonglong id, const QString &command, const QStringList &arguments, const QString &description);
|
||||
|
||||
bool enableAction(qulonglong id, bool enabled);
|
||||
bool isActionEnabled(qulonglong id);
|
||||
|
||||
QString getClientActionSender(qulonglong id);
|
||||
|
||||
QString changeShortcut(qulonglong id, const QString &shortcut);
|
||||
|
||||
bool swapActions(qulonglong id1, qulonglong id2);
|
||||
|
||||
bool removeAction(qulonglong id);
|
||||
|
||||
bool setMultipleActionsBehaviour(uint behaviour);
|
||||
uint getMultipleActionsBehaviour();
|
||||
|
||||
QList<qulonglong> getAllActionIds();
|
||||
QMap<qulonglong, GeneralActionInfo> getAllActions();
|
||||
bool getActionById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &type, QString &info);
|
||||
bool getClientActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QDBusObjectPath &path);
|
||||
bool getMethodActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &service, QDBusObjectPath &path, QString &interface, QString &method);
|
||||
bool getCommandActionInfoById(qulonglong id, QString &shortcut, QString &description, bool &enabled, QString &command, QStringList &arguments);
|
||||
|
||||
QString grabShortcut(uint timeout, bool &failed, bool &cancelled, bool &timedout);
|
||||
void cancelShortcutGrab();
|
||||
|
||||
void quit();
|
||||
|
||||
void emit_actionAdded(qulonglong id);
|
||||
void emit_actionModified(qulonglong id);
|
||||
void emit_actionRemoved(qulonglong id);
|
||||
void emit_actionShortcutChanged(qulonglong id);
|
||||
void emit_actionEnabled(qulonglong id, bool enabled);
|
||||
void emit_clientActionSenderChanged(qulonglong id, const QString &sender);
|
||||
|
||||
signals:
|
||||
void actionAdded(qulonglong id);
|
||||
void actionModified(qulonglong id);
|
||||
void actionRemoved(qulonglong id);
|
||||
void actionShortcutChanged(qulonglong id);
|
||||
void actionEnabled(qulonglong id, bool enabled);
|
||||
void clientActionSenderChanged(qulonglong id, const QString &sender);
|
||||
void actionsSwapped(qulonglong id1, qulonglong id2);
|
||||
void multipleActionsBehaviourChanged(uint behaviour);
|
||||
|
||||
signals:
|
||||
void onAddMethodAction(QPair<QString, qulonglong> &, const QString &, const QString &, const QDBusObjectPath &, const QString &, const QString &, const QString &);
|
||||
void onAddCommandAction(QPair<QString, qulonglong> &, const QString &, const QString &, const QStringList &, const QString &);
|
||||
|
||||
void onModifyActionDescription(bool &, qulonglong, const QString &);
|
||||
void onModifyMethodAction(bool &, qulonglong, const QString &, const QDBusObjectPath &, const QString &, const QString &, const QString &);
|
||||
void onModifyCommandAction(bool &, qulonglong, const QString &, const QStringList &, const QString &);
|
||||
|
||||
void onEnableAction(bool &, qulonglong, bool);
|
||||
void onIsActionEnabled(bool &, qulonglong);
|
||||
|
||||
void onGetClientActionSender(QString &, qulonglong);
|
||||
|
||||
void onChangeShortcut(QString &, qulonglong, const QString &);
|
||||
|
||||
void onSwapActions(bool &, qulonglong, qulonglong);
|
||||
|
||||
void onRemoveAction(bool &, qulonglong);
|
||||
|
||||
void onSetMultipleActionsBehaviour(const MultipleActionsBehaviour &);
|
||||
void onGetMultipleActionsBehaviour(MultipleActionsBehaviour &);
|
||||
|
||||
void onGetAllActionIds(QList<qulonglong> &);
|
||||
void onGetActionById(QPair<bool, GeneralActionInfo> &, qulonglong);
|
||||
void onGetAllActions(QMap<qulonglong, GeneralActionInfo> &);
|
||||
|
||||
void onGetClientActionInfoById(QPair<bool, ClientActionInfo> &, qulonglong);
|
||||
void onGetMethodActionInfoById(QPair<bool, MethodActionInfo> &, qulonglong);
|
||||
void onGetCommandActionInfoById(QPair<bool, CommandActionInfo> &, qulonglong);
|
||||
|
||||
void onGrabShortcut(uint, QString &, bool &, bool &, bool &, const QDBusMessage &);
|
||||
void onCancelShortcutGrab();
|
||||
|
||||
void onQuit();
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__DAEMON_ADAPTOR__INCLUDED
|
@ -0,0 +1,50 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__FIXED_TIMEOUT__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__FIXED_TIMEOUT__INCLUDED
|
||||
|
||||
|
||||
#include "dbus_cpp.hpp"
|
||||
|
||||
namespace DBus
|
||||
{
|
||||
|
||||
class FixedTimeout : public DefaultTimeout
|
||||
{
|
||||
public:
|
||||
FixedTimeout(unsigned int interval, DefaultMainLoop *mainLoop);
|
||||
|
||||
bool isExpired() const;
|
||||
|
||||
private:
|
||||
uint64_t mExpired;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__FIXED_TIMEOUT__INCLUDED
|
@ -0,0 +1,37 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "log_target.h"
|
||||
|
||||
|
||||
LogTarget::LogTarget()
|
||||
{
|
||||
}
|
||||
|
||||
LogTarget::~LogTarget()
|
||||
{
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__LOG_TARGET__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__LOG_TARGET__INCLUDED
|
||||
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
|
||||
class LogTarget
|
||||
{
|
||||
public:
|
||||
LogTarget();
|
||||
virtual ~LogTarget();
|
||||
|
||||
virtual void log(int level, const char *format, ...) const = 0;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__LOG_TARGET__INCLUDED
|
@ -0,0 +1,255 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include <LXQt/Application>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QFile>
|
||||
|
||||
#include "meta_types.h"
|
||||
#include "core.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h> // for basename()
|
||||
|
||||
#define DEFAULT_CONFIG ".config/lxqt/globalkeyshortcuts.conf"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool wrongArgs = false;
|
||||
bool printHelp = false;
|
||||
bool runAsDaemon = false;
|
||||
bool useSyslog = false;
|
||||
bool minLogLevelSet = false;
|
||||
int minLogLevel = LOG_NOTICE;
|
||||
bool multipleActionsBehaviourSet = false;
|
||||
MultipleActionsBehaviour multipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_FIRST;
|
||||
QStringList configFiles;
|
||||
|
||||
static struct option longOptions[] =
|
||||
{
|
||||
{"no-daemon", no_argument, 0, 'n'},
|
||||
{"daemon", no_argument, 0, 'd'},
|
||||
{"use-syslog", no_argument, 0, 's'},
|
||||
{"log-level", required_argument, 0, 'l'},
|
||||
{"multiple-actions-behaviour", required_argument, 0, 'm'},
|
||||
{"config-file", required_argument, 0, 'f'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int optionIndex = 0;
|
||||
|
||||
int c = getopt_long(argc, argv, "h?", longOptions, &optionIndex);
|
||||
|
||||
if (c == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'n':
|
||||
runAsDaemon = false;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
runAsDaemon = true;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
useSyslog = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
if (!strcmp(optarg, "error"))
|
||||
{
|
||||
minLogLevel = LOG_ERR;
|
||||
}
|
||||
else if (!strcmp(optarg, "warning"))
|
||||
{
|
||||
minLogLevel = LOG_WARNING;
|
||||
}
|
||||
else if (!strcmp(optarg, "notice"))
|
||||
{
|
||||
minLogLevel = LOG_NOTICE;
|
||||
}
|
||||
else if (!strcmp(optarg, "info"))
|
||||
{
|
||||
minLogLevel = LOG_INFO;
|
||||
}
|
||||
else if (!strcmp(optarg, "debug"))
|
||||
{
|
||||
minLogLevel = LOG_DEBUG;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid minimal log level: %s\n", optarg);
|
||||
wrongArgs = true;
|
||||
printHelp = true;
|
||||
break;
|
||||
}
|
||||
minLogLevelSet = true;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (!strcmp(optarg, "first"))
|
||||
{
|
||||
multipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_FIRST;
|
||||
}
|
||||
else if (!strcmp(optarg, "last"))
|
||||
{
|
||||
multipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_LAST;
|
||||
}
|
||||
else if (!strcmp(optarg, "all"))
|
||||
{
|
||||
multipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_ALL;
|
||||
}
|
||||
else if (!strcmp(optarg, "none"))
|
||||
{
|
||||
multipleActionsBehaviour = MULTIPLE_ACTIONS_BEHAVIOUR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid multiple actions behaviour: %s\n", optarg);
|
||||
wrongArgs = true;
|
||||
printHelp = true;
|
||||
break;
|
||||
}
|
||||
multipleActionsBehaviourSet = true;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
configFiles.push_back(QString::fromLocal8Bit(optarg));
|
||||
break;
|
||||
|
||||
case '?':
|
||||
case 'h':
|
||||
printHelp = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
wrongArgs = true;
|
||||
printHelp = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (printHelp)
|
||||
{
|
||||
printf("Global key shortcuts daemon\n"
|
||||
"\n"
|
||||
"Version: " LXQT_VERSION "\n"
|
||||
"License: GNU Lesser General Public License version 2.1 or later\n"
|
||||
"Copyright: (c) 2013 Razor team\n"
|
||||
"\n"
|
||||
"Usage %s [OPTIONS]\n"
|
||||
"\n"
|
||||
"Possible options are:\n"
|
||||
"\n"
|
||||
" --no-daemon\n"
|
||||
" Run as a usual application, not a daemon\n"
|
||||
" and print messages to stderr.\n"
|
||||
"\n"
|
||||
" --daemon\n"
|
||||
" Run as a daemon, not a usual application\n"
|
||||
" and print messages to syslog.\n"
|
||||
"\n"
|
||||
" --use-syslog\n"
|
||||
" Print messages to syslog if run as a usual application.\n"
|
||||
"\n"
|
||||
" --log-level=VALUE\n"
|
||||
" Set minimal log level.\n"
|
||||
" Possible values are:\n"
|
||||
" error\n"
|
||||
" warning\n"
|
||||
" notice (default)\n"
|
||||
" info\n"
|
||||
" debug .\n"
|
||||
"\n"
|
||||
" --multiple-actions-behaviour=VALUE\n"
|
||||
" Set the behaviour for the case of multiple actions\n"
|
||||
" assigned to the same shortcut.\n"
|
||||
" Possible values are:\n"
|
||||
" first (default)\n"
|
||||
" last\n"
|
||||
" all\n"
|
||||
" none .\n"
|
||||
"\n"
|
||||
" --config-file=FILENAME\n"
|
||||
" Use config file FILENAME. Can be used several times.\n"
|
||||
" The last loaded file is used to save settings.\n"
|
||||
" Default is: ${HOME}/" DEFAULT_CONFIG "\n"
|
||||
"\n"
|
||||
" --help\n"
|
||||
" -h\n"
|
||||
" -?\n"
|
||||
" This help.\n"
|
||||
, basename(argv[0]));
|
||||
return wrongArgs ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (runAsDaemon)
|
||||
{
|
||||
if (daemon(0, 0) < 0)
|
||||
{
|
||||
fprintf(stderr, "Cannot become a daemon: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
const char* home = getenv("HOME");
|
||||
int ignoreIt = chdir((home && *home) ? home : "/");
|
||||
(void)ignoreIt;
|
||||
|
||||
if (configFiles.empty() && home && *home)
|
||||
{
|
||||
if( ! QFile::exists(QString::fromLocal8Bit(home) + "/" DEFAULT_CONFIG) ) //Load default settings
|
||||
configFiles.push_back("/etc/xdg/lxqt/globalkeyshortcuts.conf");
|
||||
configFiles.push_back(QString::fromLocal8Bit(home) + "/" DEFAULT_CONFIG);
|
||||
}
|
||||
|
||||
LXQt::Application app(argc, argv);
|
||||
|
||||
Core core(runAsDaemon || useSyslog, minLogLevelSet, minLogLevel, configFiles, multipleActionsBehaviourSet, multipleActionsBehaviour);
|
||||
|
||||
if (!core.ready())
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "meta_types.h"
|
||||
|
||||
|
||||
QDBusArgument &operator << (QDBusArgument &argument, const GeneralActionInfo &generalActionInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << generalActionInfo.shortcut << generalActionInfo.description << generalActionInfo.enabled << generalActionInfo.type << generalActionInfo.info;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator >> (const QDBusArgument &argument, GeneralActionInfo &generalActionInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> generalActionInfo.shortcut >> generalActionInfo.description >> generalActionInfo.enabled >> generalActionInfo.type >> generalActionInfo.info;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class TypeRegistrator
|
||||
{
|
||||
public:
|
||||
TypeRegistrator()
|
||||
{
|
||||
qDBusRegisterMetaType<GeneralActionInfo>();
|
||||
qDBusRegisterMetaType<QMap_qulonglong_GeneralActionInfo>();
|
||||
}
|
||||
|
||||
~TypeRegistrator()
|
||||
{}
|
||||
};
|
||||
|
||||
static TypeRegistrator typeRegistrator;
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION__META_TYPES__INCLUDED
|
||||
#define GLOBAL_ACTION__META_TYPES__INCLUDED
|
||||
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
|
||||
typedef enum MultipleActionsBehaviour
|
||||
{
|
||||
MULTIPLE_ACTIONS_BEHAVIOUR_FIRST = 0, // queue
|
||||
MULTIPLE_ACTIONS_BEHAVIOUR_LAST, // stack
|
||||
MULTIPLE_ACTIONS_BEHAVIOUR_NONE, // qtcreator style
|
||||
MULTIPLE_ACTIONS_BEHAVIOUR_ALL, // permissive behaviour
|
||||
MULTIPLE_ACTIONS_BEHAVIOUR__COUNT
|
||||
} MultipleActionsBehaviour;
|
||||
|
||||
typedef struct CommonActionInfo
|
||||
{
|
||||
QString shortcut;
|
||||
QString description;
|
||||
bool enabled;
|
||||
} CommonActionInfo;
|
||||
|
||||
typedef struct GeneralActionInfo : CommonActionInfo
|
||||
{
|
||||
QString type;
|
||||
QString info;
|
||||
} GeneralActionInfo;
|
||||
|
||||
typedef struct ClientActionInfo : CommonActionInfo
|
||||
{
|
||||
QDBusObjectPath path;
|
||||
} ClientActionInfo;
|
||||
|
||||
typedef struct MethodActionInfo : CommonActionInfo
|
||||
{
|
||||
QString service;
|
||||
QDBusObjectPath path;
|
||||
QString interface;
|
||||
QString method;
|
||||
} MethodActionInfo;
|
||||
|
||||
typedef struct CommandActionInfo : CommonActionInfo
|
||||
{
|
||||
QString command;
|
||||
QStringList arguments;
|
||||
} CommandActionInfo;
|
||||
|
||||
|
||||
typedef QMap<qulonglong, GeneralActionInfo> QMap_qulonglong_GeneralActionInfo;
|
||||
|
||||
Q_DECLARE_METATYPE(GeneralActionInfo)
|
||||
Q_DECLARE_METATYPE(QMap_qulonglong_GeneralActionInfo)
|
||||
|
||||
|
||||
QDBusArgument &operator << (QDBusArgument &argument, const GeneralActionInfo &generalActionInfo);
|
||||
const QDBusArgument &operator >> (const QDBusArgument &argument, GeneralActionInfo &generalActionInfo);
|
||||
|
||||
#endif // GLOBAL_ACTION_MANAGER__META_TYPES__INCLUDED
|
@ -0,0 +1,56 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "method_action.h"
|
||||
#include "log_target.h"
|
||||
|
||||
|
||||
MethodAction::MethodAction(LogTarget *logTarget, const QDBusConnection &connection, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description)
|
||||
: BaseAction(logTarget, description)
|
||||
, mConnection(connection)
|
||||
, mService(service)
|
||||
, mPath(path)
|
||||
, mInterface(interface)
|
||||
, mMethodName(method)
|
||||
{
|
||||
}
|
||||
|
||||
bool MethodAction::call()
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = mConnection.call(QDBusMessage::createMethodCall(mService, mPath.path(), mInterface, mMethodName), QDBus::BlockWithGui).type() == QDBusMessage::ReplyMessage;
|
||||
if (!result)
|
||||
{
|
||||
mLogTarget->log(LOG_WARNING, "Failed to call dbus method: service:'%s' path:'%s' interface:'%s' method:'%s'", qPrintable(mService), qPrintable(mPath.path()), qPrintable(mInterface), qPrintable(mMethodName));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#ifndef GLOBAL_ACTION_DAEMON__METHOD_ACTION__INCLUDED
|
||||
#define GLOBAL_ACTION_DAEMON__METHOD_ACTION__INCLUDED
|
||||
|
||||
|
||||
#include "base_action.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusMessage>
|
||||
|
||||
|
||||
class MethodAction : public BaseAction
|
||||
{
|
||||
public:
|
||||
MethodAction(LogTarget *logTarget, const QDBusConnection &connection, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
|
||||
|
||||
static const char *id() { return "method"; }
|
||||
|
||||
virtual const char *type() const { return id(); }
|
||||
|
||||
virtual bool call();
|
||||
|
||||
QString service() const { return mService; }
|
||||
|
||||
QDBusObjectPath path() const { return mPath; }
|
||||
|
||||
QString interface() const { return mInterface; }
|
||||
|
||||
QString method() const { return mMethodName; }
|
||||
|
||||
private:
|
||||
QDBusConnection mConnection;
|
||||
QString mService;
|
||||
QDBusObjectPath mPath;
|
||||
QString mInterface;
|
||||
QString mMethodName;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_ACTION_DAEMON__METHOD_ACTION__INCLUDED
|
@ -0,0 +1,41 @@
|
||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||||
* (c)LGPL2+
|
||||
*
|
||||
* LXDE-Qt - a lightweight, Qt based, desktop toolset
|
||||
* http://razor-qt.org
|
||||
*
|
||||
* Copyright: 2013 Razor team
|
||||
* Authors:
|
||||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||||
*
|
||||
* This program or library is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
* END_COMMON_COPYRIGHT_HEADER */
|
||||
|
||||
#include "mutex.hpp"
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
mInitResult = pthread_mutex_init(&mMutex, NULL);
|
||||
}
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
if (!mInitResult)
|
||||
{
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue