Add kglobalacceld recipe with D-Bus service wiring and config entry
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -73,6 +73,7 @@ kf6-kcmutils = {}
|
||||
kf6-kwayland = {}
|
||||
kdecoration = {}
|
||||
kf6-kded6 = {}
|
||||
kglobalacceld = {}
|
||||
|
||||
# KWin Wayland compositor
|
||||
kwin = {}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
[source]
|
||||
tar = "https://invent.kde.org/plasma/kglobalacceld/-/archive/v6.0.0/kglobalacceld-v6.0.0.tar.gz"
|
||||
|
||||
[build]
|
||||
template = "custom"
|
||||
dependencies = [
|
||||
"qtbase",
|
||||
"kf6-extra-cmake-modules",
|
||||
"kf6-kconfig",
|
||||
"kf6-kcoreaddons",
|
||||
"kf6-kcrash",
|
||||
"kf6-kdbusaddons",
|
||||
"kf6-kglobalaccel",
|
||||
"kf6-kservice",
|
||||
"kf6-kwindowsystem",
|
||||
"kf6-kio",
|
||||
"kf6-kjobwidgets",
|
||||
]
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
|
||||
HOST_BUILD="${COOKBOOK_ROOT}/build/qt-host-build"
|
||||
|
||||
for qtdir in plugins mkspecs metatypes modules; do
|
||||
if [ -d "${COOKBOOK_SYSROOT}/usr/${qtdir}" ] && [ ! -e "${COOKBOOK_SYSROOT}/${qtdir}" ]; then
|
||||
ln -s "usr/${qtdir}" "${COOKBOOK_SYSROOT}/${qtdir}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -d "${COOKBOOK_SYSROOT}/usr/plugins" ] && [ ! -e "${COOKBOOK_SYSROOT}/plugins" ]; then
|
||||
ln -s "usr/plugins" "${COOKBOOK_SYSROOT}/plugins"
|
||||
fi
|
||||
|
||||
sed -i "s/^ecm_install_po_files_as_qm/#ecm_install_po_files_as_qm/" \
|
||||
"${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
|
||||
sed -i 's/^ki18n_install(po)/#ki18n_install(po)/' \
|
||||
"${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
|
||||
|
||||
cmake "${COOKBOOK_SOURCE}" \
|
||||
-GNinja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${COOKBOOK_ROOT}/local/recipes/qt/redox-toolchain.cmake" \
|
||||
-DQT_HOST_PATH="${HOST_BUILD}" \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH="${COOKBOOK_SYSROOT}" \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DBUILD_QCH=OFF \
|
||||
-DWITH_X11=OFF \
|
||||
-Wno-dev
|
||||
|
||||
cmake --build . -j${COOKBOOK_MAKE_JOBS}
|
||||
DESTDIR="${COOKBOOK_STAGE}" cmake --install . --prefix /usr
|
||||
|
||||
for lib in "${COOKBOOK_STAGE}/usr/lib/"libK*.so.*; do
|
||||
[ -f "${lib}" ] || continue
|
||||
patchelf --remove-rpath "${lib}" 2>/dev/null || true
|
||||
done
|
||||
"""
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann@kde.org>
|
||||
# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard@absint.com>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# This file got automatically created by ECM, do not edit
|
||||
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options
|
||||
# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting
|
||||
# for clang-format tips & tricks
|
||||
---
|
||||
Language: JavaScript
|
||||
DisableFormat: true
|
||||
---
|
||||
|
||||
# Style for C++
|
||||
Language: Cpp
|
||||
|
||||
# base is WebKit coding style: https://webkit.org/code-style-guidelines/
|
||||
# below are only things set that diverge from this style!
|
||||
BasedOnStyle: WebKit
|
||||
|
||||
# enforce C++11 (e.g. for std::vector<std::vector<lala>>
|
||||
Standard: Cpp11
|
||||
|
||||
# 4 spaces indent
|
||||
TabWidth: 4
|
||||
|
||||
# 2 * 80 wide lines
|
||||
ColumnLimit: 160
|
||||
|
||||
# sort includes inside line separated groups
|
||||
SortIncludes: true
|
||||
|
||||
# break before braces on function, namespace and class definitions.
|
||||
BreakBeforeBraces: Linux
|
||||
|
||||
# CrlInstruction *a;
|
||||
PointerAlignment: Right
|
||||
|
||||
# horizontally aligns arguments after an open bracket.
|
||||
AlignAfterOpenBracket: Align
|
||||
|
||||
# don't move all parameters to new line
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
|
||||
# no single line functions
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
|
||||
# no single line enums
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
|
||||
# always break before you encounter multi line strings
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
|
||||
# don't move arguments to own lines if they are not all on the same
|
||||
BinPackArguments: false
|
||||
|
||||
# don't move parameters to own lines if they are not all on the same
|
||||
BinPackParameters: false
|
||||
|
||||
# In case we have an if statement with multiple lines the operator should be at the beginning of the line
|
||||
# but we do not want to break assignments
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
|
||||
# format C++11 braced lists like function calls
|
||||
Cpp11BracedListStyle: true
|
||||
|
||||
# do not put a space before C++11 braced lists
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
|
||||
# remove empty lines
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
|
||||
# no namespace indentation to keep indent level low
|
||||
NamespaceIndentation: None
|
||||
|
||||
# we use template< without space.
|
||||
SpaceAfterTemplateKeyword: false
|
||||
|
||||
# Always break after template declaration
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
|
||||
# macros for which the opening brace stays attached.
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
|
||||
|
||||
# keep lambda formatting multi-line if not empty
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
|
||||
# We do not want clang-format to put all arguments on a new line
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
@@ -0,0 +1,8 @@
|
||||
# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include:
|
||||
- project: sysadmin/ci-utilities
|
||||
file:
|
||||
- /gitlab-templates/linux-qt6.yml
|
||||
- /gitlab-templates/freebsd-qt6.yml
|
||||
@@ -0,0 +1,16 @@
|
||||
Dependencies:
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
'frameworks/extra-cmake-modules': '@latest-kf6'
|
||||
'frameworks/kconfig' : '@latest-kf6'
|
||||
'frameworks/kcoreaddons' : '@latest-kf6'
|
||||
'frameworks/kcrash' : '@latest-kf6'
|
||||
'frameworks/kdbusaddons' : '@latest-kf6'
|
||||
'frameworks/kwindowsystem' : '@latest-kf6'
|
||||
'frameworks/kglobalaccel' : '@latest-kf6'
|
||||
'frameworks/kio' : '@latest-kf6'
|
||||
'frameworks/kservice' : '@latest-kf6'
|
||||
'frameworks/kjobwidgets' : '@latest-kf6'
|
||||
|
||||
Options:
|
||||
require-passing-tests-on: [ 'Linux', 'FreeBSD' ]
|
||||
@@ -0,0 +1,124 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(kglobalacceld)
|
||||
|
||||
set(PROJECT_VERSION "6.0.0")
|
||||
set(PROJECT_VERSION_MAJOR 6)
|
||||
|
||||
set(QT_MIN_VERSION "6.6.0")
|
||||
set(KF6_MIN_VERSION "6.0.0")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(FeatureSummary)
|
||||
find_package(ECM ${KF6_MIN_VERSION} NO_MODULE)
|
||||
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
|
||||
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(KDEGitCommitHooks)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
include(ECMGenerateExportHeader)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(ECMSetupVersion)
|
||||
include(ECMGenerateHeaders)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMPoQmTools)
|
||||
include(ECMDeprecationSettings)
|
||||
include(KDEClangFormat)
|
||||
include(ECMAddTests)
|
||||
|
||||
# When kglobalacceld was still in frameworks/kglobalaccel and KF5-time deprecated API was dropped there,
|
||||
# some deprecated stuff in kglobalacceld was kept: "needs more consideration since it might break older consumers"
|
||||
# Early build setups for Qt6/KF6-based software externally set EXCLUDE_DEPRECATED_BEFORE_AND_AT to 5.99,
|
||||
# and accidentally for any repos, not just KF modules, so also with other version schemes.
|
||||
# Also should defaults be set by the software itself.
|
||||
# While the deprecated stuff is still around and waiting for being sorted out, set ourselves the
|
||||
# expected czrrent default value for EXCLUDE_DEPRECATED_BEFORE_AND_AT, to achieve consistent builds (and set of available API).
|
||||
# Note the deprecated API also still uses the KF version scheme, which works for now while no additional API is deprecated.
|
||||
# TODO: sort out where KF5-time deprecated API still is needed and undeprecate it, remove the rest, then return to using 0 here
|
||||
if (TRUE)
|
||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 5.99.0 CACHE STRING "Control the range of deprecated API excluded from the build [default=5.99.0].")
|
||||
else() # normal
|
||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||
endif()
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED DBus Gui Widgets)
|
||||
|
||||
find_package(KF6Config ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6CoreAddons ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6Crash ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6DBusAddons ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6WindowSystem ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6GlobalAccel ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6Service ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6KIO ${KF6_MIN_VERSION} REQUIRED)
|
||||
find_package(KF6JobWidgets ${KF6_MIN_VERSION} REQUIRED)
|
||||
|
||||
|
||||
option(WITH_X11 "Build with X11 support." ON)
|
||||
|
||||
if(WITH_X11)
|
||||
find_package(XCB MODULE COMPONENTS XCB KEYSYMS XKB RECORD OPTIONAL_COMPONENTS XTEST)
|
||||
set_package_properties(XCB PROPERTIES DESCRIPTION "X protocol C-language Binding"
|
||||
TYPE REQUIRED
|
||||
)
|
||||
set(HAVE_X11 1)
|
||||
else()
|
||||
set(HAVE_X11 0)
|
||||
endif()
|
||||
|
||||
find_program(qdbus_EXECUTABLE NAMES qdbus qdbus6 qdbus-qt6)
|
||||
|
||||
if (NOT qdbus_EXECUTABLE)
|
||||
message("fall")
|
||||
set(qdbus_EXECUTABLE "qdbus")
|
||||
endif()
|
||||
|
||||
ecm_setup_version(PROJECT VARIABLE_PREFIX KGLOBALACCELD
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KGlobalAccelDConfigVersion.cmake"
|
||||
SOVERSION 0)
|
||||
|
||||
ecm_set_disabled_deprecation_versions(
|
||||
QT 6.6.0
|
||||
KF 5.240.0
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(autotests)
|
||||
endif()
|
||||
|
||||
# create a Config.cmake and a ConfigVersion.cmake file and install them
|
||||
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KGlobalAccelD")
|
||||
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/KGlobalAccelDConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KGlobalAccelDConfig.cmake"
|
||||
PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KGlobalAccelDConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KGlobalAccelDConfigVersion.cmake"
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel )
|
||||
|
||||
install(EXPORT KGlobalAccelDTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KGlobalAccelDTargets.cmake NAMESPACE K:: )
|
||||
|
||||
|
||||
install(FILES ${kglobalaccel_version_header}
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KGlobalAccel COMPONENT Devel)
|
||||
|
||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
||||
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||
@@ -0,0 +1,8 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(Qt6DBus @REQUIRED_QT_VERSION@)
|
||||
find_dependency(Qt6Widgets @REQUIRED_QT_VERSION@)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KGlobalAccelDTargets.cmake")
|
||||
@PACKAGE_INCLUDE_QCHTARGETS@
|
||||
@@ -0,0 +1,121 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -0,0 +1,174 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, 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 library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
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 Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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 or use pieces of it in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the 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 a program 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.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries.
|
||||
|
||||
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, while the latter only works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library 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 compile 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) 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.
|
||||
|
||||
c) 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.
|
||||
|
||||
d) 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 source code 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 to 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 Library 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
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
Copyright (C) year name of author
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
@@ -0,0 +1,175 @@
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
Copyright (C) year name of author
|
||||
|
||||
This 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 Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
That's all there is to it!
|
||||
@@ -0,0 +1,304 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
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 that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU 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 as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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 them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,12 @@
|
||||
This 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 3 of the license or (at your option) any later version
|
||||
that is accepted by the membership of KDE e.V. (or its successor
|
||||
approved by the membership of KDE e.V.), which shall act as a
|
||||
proxy as defined in Section 6 of version 3 of the license.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
@@ -0,0 +1,3 @@
|
||||
find_package(Qt6Test REQUIRED)
|
||||
|
||||
ecm_add_test(migrateconfigtest.cpp LINK_LIBRARIES Qt::Test KF6::ConfigCore KF6::Service KGlobalAccelD)
|
||||
@@ -0,0 +1,309 @@
|
||||
[ActivityManager]
|
||||
_k_friendly_name=Aktivitätenverwaltung
|
||||
switch-to-activity-099fac1d-166b-4392-b303-c3f623c79d77=none,none,Zu Aktivität „Somelongname“ wechseln
|
||||
switch-to-activity-476164d0-23bd-4ecd-94c5-5dba56d12383=none,none,Zu Aktivität „Default“ wechseln
|
||||
switch-to-activity-81b8a0cf-fe64-485e-a83b-a9f76a93cb2c=none,none,Zu Aktivität „Bla“ wechseln
|
||||
switch-to-activity-a467caca-889b-4863-be5b-1c0db58b9de0=none,none,Zu Aktivität „Hallo“ wechseln
|
||||
|
||||
[KDE Keyboard Layout Switcher]
|
||||
Switch to Next Keyboard Layout=Meta+Alt+K,Meta+Alt+K,Auf nächste Tastaturbelegung umschalten
|
||||
_k_friendly_name=Umschaltung der Tastaturbelegung
|
||||
|
||||
[kaccess]
|
||||
Toggle Screen Reader On and Off=Meta+S,Meta+Alt+S,Screenreader ein-/ausschalten
|
||||
_k_friendly_name=Zugangshilfen
|
||||
|
||||
[kcm_touchpad]
|
||||
Disable Touchpad=Touchpad Off,Touchpad Off,Touchpad abschalten
|
||||
Enable Touchpad=Touchpad On,Touchpad On,Touchpad aktivieren
|
||||
Toggle Touchpad=Meta+U,Touchpad Toggle\tMeta+Ctrl+Zenkaku Hankaku,Touchpad umschalten
|
||||
_k_friendly_name=Touchpad
|
||||
|
||||
[kded5]
|
||||
Show System Activity=Ctrl+Esc,Ctrl+Esc,Systemaktivität anzeigen
|
||||
_k_friendly_name=KDE Daemon
|
||||
display=Display\tMeta+P,Display\tMeta+P,Anzeige wechseln
|
||||
|
||||
[khotkeys]
|
||||
_k_friendly_name=Dienst für eigene Kurzbefehle
|
||||
{3c04e4ea-1f6e-430e-82bb-0e4adb79a6a3}=,none,Scan
|
||||
{5d4c37a6-d8b3-40b0-aa6a-92f325302538}=,none,Save Profile 1
|
||||
{81787487-f07d-4111-b1cf-9da1406075ca}=,none,Load Profile 1
|
||||
{96c0b3ae-9d0d-45dd-b275-c11c01424ff7}=,none,Preview
|
||||
{9f894206-fbcf-48f1-9fb3-df9cec37bacb}=,none,Load Profile 2
|
||||
{aaed7bc1-a7bc-4abc-b319-9b95abb5216b}=,none,Cancel Scan
|
||||
{d03619b6-9b3c-48cc-9d9c-a2aadb485550}=,none,Suchen
|
||||
{e74b442f-47db-4314-a0e0-a56e1b753804}=,none,Save Profile 2
|
||||
|
||||
[kmix]
|
||||
_k_friendly_name=Lautstärke
|
||||
decrease_microphone_volume=Microphone Volume Down,Microphone Volume Down,Mikrofonlautstärke verringern
|
||||
decrease_volume=Volume Down,Volume Down,Lautstärke verringern
|
||||
increase_microphone_volume=Microphone Volume Up,Microphone Volume Up,Mikrofonlautstärke erhöhen
|
||||
increase_volume=Volume Up,Volume Up,Lautstärke erhöhen
|
||||
mic_mute=Microphone Mute\tMeta+Volume Mute,Microphone Mute\tMeta+Volume Mute,Mikrofon stummschalten
|
||||
mute=Volume Mute,Volume Mute,Stummschalten
|
||||
|
||||
[ksmserver]
|
||||
Halt Without Confirmation=none,,Ohne Rückfrage herunterfahren
|
||||
Lock Session=Meta+L\tScreensaver,Meta+L\tScreensaver,Lock Session
|
||||
Log Out=Ctrl+Alt+Del,Ctrl+Alt+Del,Abmelden
|
||||
Log Out Without Confirmation=none,,Ohne Rückfrage abmelden
|
||||
Reboot=none,none,Neu starten
|
||||
Reboot Without Confirmation=none,,Ohne Rückfrage neu starten
|
||||
Shut Down=none,none,Herunterfahren
|
||||
_k_friendly_name=Session Management
|
||||
|
||||
[kwin]
|
||||
Activate Window Demanding Attention=Meta+Ctrl+A,Meta+Ctrl+A,Fenster aktivieren\\, das Aufmerksamkeit erfordert
|
||||
Decrease Opacity=none,,Die Deckkraft des aktiven Fensters um 5 % verringern
|
||||
Edit Tiles=Meta+T,Meta+T,Tiling-Editor ein-/ausschalten
|
||||
Expose=Ctrl+F9,Ctrl+F9,Fenster der aktuellen Arbeitsfläche anzeigen
|
||||
ExposeAll=Ctrl+F10\tLaunch (C),Ctrl+F10\tLaunch (C),Fenster aller Arbeitsflächen anzeigen
|
||||
ExposeClass=Ctrl+F7,Ctrl+F7,Fenster der Fensterklasse anzeigen
|
||||
ExposeClassCurrentDesktop=none,none,Fenster der Fensterklasse auf der aktuellen Arbeitsfläche anzeigen
|
||||
Increase Opacity=none,,Die Deckkraft des aktiven Fensters um 5 % erhöhen
|
||||
Kill Window=Meta+Ctrl+Esc,Meta+Ctrl+Esc,Fenster beseitigen
|
||||
Mobile Task Switcher=Meta+C,Meta+C,Toggle Mobile Task Switcher
|
||||
Move Tablet to Next Output=none,none,Move the tablet to the next output
|
||||
MoveMouseToCenter=Meta+F6,Meta+F6,Mauszeiger zentrieren
|
||||
MoveMouseToFocus=Meta+F5,Meta+F5,Mauszeiger in den Fokus verschieben
|
||||
MoveZoomDown=none,none,Vergrößerten Bereich nach unten verschieben
|
||||
MoveZoomLeft=none,none,Vergrößerten Bereich nach links verschieben
|
||||
MoveZoomRight=none,none,Vergrößerten Bereich nach rechts verschieben
|
||||
MoveZoomUp=none,none,Vergrößerten Bereich nach oben verschieben
|
||||
Overview=Meta+W,Meta+W,Übersicht umschalten
|
||||
Setup Window Shortcut=none,,Kurzbefehl für Fenster einrichten
|
||||
Show Desktop=Meta+D,Meta+D,Blick auf die Arbeitsfläche
|
||||
ShowDesktopGrid=Meta+F8,Meta+F8,Arbeitsflächen-Raster anzeigen
|
||||
Suspend Compositing=Alt+Shift+F12,Alt+Shift+F12,Compositing aussetzen
|
||||
Switch One Desktop Down=none,Meta+Ctrl+Down,Eine Arbeitsfläche nach unten
|
||||
Switch One Desktop Up=none,Meta+Ctrl+Up,Eine Arbeitsfläche nach oben
|
||||
Switch One Desktop to the Left=none,Meta+Ctrl+Left,Eine Arbeitsfläche nach links
|
||||
Switch One Desktop to the Right=none,Meta+Ctrl+Right,Eine Arbeitsfläche nach rechts
|
||||
Switch Window Down=Meta+Alt+Down,Meta+Alt+Down,Zum Fenster darunter wechseln
|
||||
Switch Window Left=Meta+Alt+Left,Meta+Alt+Left,Zum Fenster links wechseln
|
||||
Switch Window Right=Meta+Alt+Right,Meta+Alt+Right,Zum Fenster rechts wechseln
|
||||
Switch Window Up=Meta+Alt+Up,Meta+Alt+Up,Zum Fenster darüber wechseln
|
||||
Switch to Desktop 1=Ctrl+F1,Ctrl+F1,Auf Arbeitsfläche 1 umschalten
|
||||
Switch to Desktop 10=none,,Auf Arbeitsfläche 10 umschalten
|
||||
Switch to Desktop 11=none,,Auf Arbeitsfläche 11 umschalten
|
||||
Switch to Desktop 12=none,,Auf Arbeitsfläche 12 umschalten
|
||||
Switch to Desktop 13=none,,Auf Arbeitsfläche 13 umschalten
|
||||
Switch to Desktop 14=none,,Auf Arbeitsfläche 14 umschalten
|
||||
Switch to Desktop 15=none,,Auf Arbeitsfläche 15 umschalten
|
||||
Switch to Desktop 16=none,,Auf Arbeitsfläche 16 umschalten
|
||||
Switch to Desktop 17=none,,Auf Arbeitsfläche 17 umschalten
|
||||
Switch to Desktop 18=none,,Auf Arbeitsfläche 18 umschalten
|
||||
Switch to Desktop 19=none,,Auf Arbeitsfläche 19 umschalten
|
||||
Switch to Desktop 2=Ctrl+F2,Ctrl+F2,Auf Arbeitsfläche 2 umschalten
|
||||
Switch to Desktop 20=none,,Auf Arbeitsfläche 20 umschalten
|
||||
Switch to Desktop 3=Ctrl+F3,Ctrl+F3,Auf Arbeitsfläche 3 umschalten
|
||||
Switch to Desktop 4=Ctrl+F4,Ctrl+F4,Auf Arbeitsfläche 4 umschalten
|
||||
Switch to Desktop 5=none,,Auf Arbeitsfläche 5 umschalten
|
||||
Switch to Desktop 6=none,,Auf Arbeitsfläche 6 umschalten
|
||||
Switch to Desktop 7=none,,Auf Arbeitsfläche 7 umschalten
|
||||
Switch to Desktop 8=none,,Auf Arbeitsfläche 8 umschalten
|
||||
Switch to Desktop 9=none,,Auf Arbeitsfläche 9 umschalten
|
||||
Switch to Next Desktop=none,,Zur nächsten Arbeitsfläche umschalten
|
||||
Switch to Next Screen=none,,Zum nächsten Bildschirm wechseln
|
||||
Switch to Previous Desktop=none,,Zur vorherigen Arbeitsfläche umschalten
|
||||
Switch to Previous Screen=none,,Zum vorherigen Bildschirm wechseln
|
||||
Switch to Screen 0=none,,Zum Bildschirm 0 wechseln
|
||||
Switch to Screen 1=none,,Zum Bildschirm 1 wechseln
|
||||
Switch to Screen 2=none,,Zum Bildschirm 2 wechseln
|
||||
Switch to Screen 3=none,,Zum Bildschirm 3 wechseln
|
||||
Switch to Screen 4=none,,Zum Bildschirm 4 wechseln
|
||||
Switch to Screen 5=none,,Zum Bildschirm 5 wechseln
|
||||
Switch to Screen 6=none,,Zum Bildschirm 6 wechseln
|
||||
Switch to Screen 7=none,,Zum Bildschirm 7 wechseln
|
||||
Switch to Screen Above=none,,Zum Bildschirm oben wechseln
|
||||
Switch to Screen Below=none,,Zum Bildschirm unten wechseln
|
||||
Switch to Screen to the Left=none,,Zum Bildschirm links wechseln
|
||||
Switch to Screen to the Right=none,,Zum Bildschirm rechts wechseln
|
||||
Toggle Night Color=none,none,Nachtfarben umschalten
|
||||
Toggle Window Raise/Lower=none,,Fenster nach vorne/hinten
|
||||
Walk Through Desktop List=,,Nächster Eintrag in Arbeitsflächenliste
|
||||
Walk Through Desktop List (Reverse)=,,Nächster Eintrag in Arbeitsflächenliste (Gegenrichtung)
|
||||
Walk Through Desktops=,,Zwischen Arbeitsflächen umschalten
|
||||
Walk Through Desktops (Reverse)=,,Zwischen Arbeitsflächen umschalten (Gegenrichtung)
|
||||
Walk Through Windows=Alt+Tab,Alt+Tab,Zwischen Fenstern wechseln
|
||||
Walk Through Windows (Reverse)=Alt+Shift+Tab,Alt+Shift+Tab,Zwischen Fenstern wechseln (Gegenrichtung)
|
||||
Walk Through Windows Alternative=none,,Alternatives Wechseln zwischen Fenstern
|
||||
Walk Through Windows Alternative (Reverse)=none,,Alternatives Wechseln zwischen Fenstern (Gegenrichtung)
|
||||
Walk Through Windows of Current Application=Alt+`,Alt+`,Zwischen Fenstern der aktuellen Anwendung wechseln
|
||||
Walk Through Windows of Current Application (Reverse)=Alt+~,Alt+~,Zwischen Fenstern der aktuellen Anwendung wechseln (Gegenrichtung)
|
||||
Walk Through Windows of Current Application Alternative=none,,Alternatives Wechseln zwischen Fenstern der aktuellen Anwendung
|
||||
Walk Through Windows of Current Application Alternative (Reverse)=none,,Alternatives Wechseln zwischen Fenstern der aktuellen Anwendung (Gegenrichtung)
|
||||
Window Above Other Windows=none,,Fenster im Vordergrund halten
|
||||
Window Below Other Windows=none,,Fenster im Hintergrund halten
|
||||
Window Close=Alt+F4,Alt+F4,Fenster schließen
|
||||
Window Fullscreen=none,,Fenster auf Vollbildgröße
|
||||
Window Grow Horizontal=none,,Fenster waagerecht maximieren
|
||||
Window Grow Vertical=none,,Fenster senkrecht maximieren
|
||||
Window Lower=none,,Fenster nach hinten
|
||||
Window Maximize=Meta+PgUp,Meta+PgUp,Fenster maximieren
|
||||
Window Maximize Horizontal=none,,Fenster waagerecht maximieren
|
||||
Window Maximize Vertical=none,,Fenster senkrecht maximieren
|
||||
Window Minimize=Meta+PgDown,Meta+PgDown,Fenster minimieren
|
||||
Window Move=none,,Fenster verschieben
|
||||
Window Move Center=none,,Fenster zentrieren
|
||||
Window No Border=none,,Titelleiste und Rahmen des Fensters ein-/ausschalten
|
||||
Window On All Desktops=none,,Fenster auf allen Arbeitsflächen anzeigen
|
||||
Window One Desktop Down=Meta+Ctrl+Shift+Down,Meta+Ctrl+Shift+Down,Fenster eine Arbeitsfläche nach unten
|
||||
Window One Desktop Up=Meta+Ctrl+Shift+Up,Meta+Ctrl+Shift+Up,Fenster eine Arbeitsfläche nach oben
|
||||
Window One Desktop to the Left=Meta+Ctrl+Shift+Left,Meta+Ctrl+Shift+Left,Fenster eine Arbeitsfläche nach links
|
||||
Window One Desktop to the Right=Meta+Ctrl+Shift+Right,Meta+Ctrl+Shift+Right,Fenster eine Arbeitsfläche nach rechts
|
||||
Window One Screen Down=none,,Fenster einen Bildschirm nach unten
|
||||
Window One Screen Up=none,,Fenster einen Bildschirm nach oben
|
||||
Window One Screen to the Left=none,,Fenster einen Bildschirm nach links
|
||||
Window One Screen to the Right=none,,Fenster einen Bildschirm nach rechts
|
||||
Window Operations Menu=Alt+F3,Alt+F3,Fensteraktionen-Menü
|
||||
Window Pack Down=none,,Fenster nach unten verschieben
|
||||
Window Pack Left=none,,Fenster nach links verschieben
|
||||
Window Pack Right=none,,Fenster nach rechts verschieben
|
||||
Window Pack Up=none,,Fenster nach oben verschieben
|
||||
Window Quick Tile Bottom=Meta+Down,Meta+Down,Fenster am unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Bottom Left=none,,Fenster am linken unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Bottom Right=none,,Fenster am rechten unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Left=Meta+Left,Meta+Left,Fenster am linken Bildschirmrand anordnen
|
||||
Window Quick Tile Right=Meta+Right,Meta+Right,Fenster am rechten Bildschirmrand anordnen
|
||||
Window Quick Tile Top=Meta+Up,Meta+Up,Fenster am oberen Bildschirmrand anordnen
|
||||
Window Quick Tile Top Left=none,,Fenster am linken oberen Bildschirmrand anordnen
|
||||
Window Quick Tile Top Right=none,,Fenster am rechten oberen Bildschirmrand anordnen
|
||||
Window Raise=none,,Fenster nach vorne
|
||||
Window Resize=none,,Fenstergröße ändern
|
||||
Window Shade=none,,Fensterheber betätigen
|
||||
Window Shrink Horizontal=none,,Fenster waagerecht verkleinern
|
||||
Window Shrink Vertical=none,,Fenster senkrecht verkleinern
|
||||
Window to Desktop 1=none,,Fenster auf Arbeitsfläche 1
|
||||
Window to Desktop 10=none,,Fenster auf Arbeitsfläche 10
|
||||
Window to Desktop 11=none,,Fenster auf Arbeitsfläche 11
|
||||
Window to Desktop 12=none,,Fenster auf Arbeitsfläche 12
|
||||
Window to Desktop 13=none,,Fenster auf Arbeitsfläche 13
|
||||
Window to Desktop 14=none,,Fenster auf Arbeitsfläche 14
|
||||
Window to Desktop 15=none,,Fenster auf Arbeitsfläche 15
|
||||
Window to Desktop 16=none,,Fenster auf Arbeitsfläche 16
|
||||
Window to Desktop 17=none,,Fenster auf Arbeitsfläche 17
|
||||
Window to Desktop 18=none,,Fenster auf Arbeitsfläche 18
|
||||
Window to Desktop 19=none,,Fenster auf Arbeitsfläche 19
|
||||
Window to Desktop 2=none,,Fenster auf Arbeitsfläche 2
|
||||
Window to Desktop 20=none,,Fenster auf Arbeitsfläche 20
|
||||
Window to Desktop 3=none,,Fenster auf Arbeitsfläche 3
|
||||
Window to Desktop 4=none,,Fenster auf Arbeitsfläche 4
|
||||
Window to Desktop 5=none,,Fenster auf Arbeitsfläche 5
|
||||
Window to Desktop 6=none,,Fenster auf Arbeitsfläche 6
|
||||
Window to Desktop 7=none,,Fenster auf Arbeitsfläche 7
|
||||
Window to Desktop 8=none,,Fenster auf Arbeitsfläche 8
|
||||
Window to Desktop 9=none,,Fenster auf Arbeitsfläche 9
|
||||
Window to Next Desktop=none,,Fenster auf nächste Arbeitsfläche verschieben
|
||||
Window to Next Screen=Meta+Shift+Right,Meta+Shift+Right,Fenster auf nächsten Bildschirm verschieben
|
||||
Window to Previous Desktop=none,,Fenster auf vorherige Arbeitsfläche verschieben
|
||||
Window to Previous Screen=Meta+Shift+Left,Meta+Shift+Left,Fenster auf vorherigen Bildschirm verschieben
|
||||
Window to Screen 0=none,,Fenster auf Bildschirm 0
|
||||
Window to Screen 1=none,,Fenster auf Bildschirm 1
|
||||
Window to Screen 2=none,,Fenster auf Bildschirm 2
|
||||
Window to Screen 3=none,,Fenster auf Bildschirm 3
|
||||
Window to Screen 4=none,,Fenster auf Bildschirm 4
|
||||
Window to Screen 5=none,,Fenster auf Bildschirm 5
|
||||
Window to Screen 6=none,,Fenster auf Bildschirm 6
|
||||
Window to Screen 7=none,,Fenster auf Bildschirm 7
|
||||
_k_friendly_name=KWin
|
||||
view_actual_size=Meta+0,Meta+0,Auf Originalgröße zoomen
|
||||
view_zoom_in=Meta++\tMeta+=,Meta++,Vergrößern
|
||||
view_zoom_out=Meta+-,Meta+-,Verkleinern
|
||||
|
||||
[mediacontrol]
|
||||
_k_friendly_name=Mediensteuerung
|
||||
mediavolumedown=,,Medienspieler leiser
|
||||
mediavolumeup=,,Medienspieler lauter
|
||||
nextmedia=Media Next,Media Next,Nächstes Medium wiedergeben
|
||||
pausemedia=Media Pause,Media Pause,Medienwiedergabe anhalten
|
||||
playmedia=,,Medienwiedergabe starten
|
||||
playpausemedia=Media Play,Media Play,Medienwiedergabe starten/anhalten
|
||||
previousmedia=Media Previous,Media Previous,Vorheriges Medium wiedergeben
|
||||
stopmedia=Media Stop,Media Stop,Medienwiedergabe anhalten
|
||||
|
||||
[org.kde.dolphin.desktop]
|
||||
_k_friendly_name=Dolphin
|
||||
_launch=Meta+E,Meta+E,Dolphin
|
||||
|
||||
[org.kde.kcalc.desktop]
|
||||
_k_friendly_name=KCalc
|
||||
_launch=Launch (1),Launch (1),KCalc
|
||||
|
||||
[org.kde.krunner.desktop]
|
||||
RunClipboard=Alt+Shift+F2,Alt+Shift+F2,Befehl mit dem Inhalt der Zwischenablage ausführen
|
||||
_k_friendly_name=KRunner
|
||||
_launch=Alt+Space\tAlt+F2\tSearch,Alt+Space\tAlt+F2\tSearch,KRunner
|
||||
|
||||
[org.kde.plasma.emojier.desktop]
|
||||
_k_friendly_name=Emoji-Auswahl
|
||||
_launch=Meta+.\tMeta+Ctrl+Alt+Shift+Space,Meta+.\tMeta+Ctrl+Alt+Shift+Space,Emoji-Auswahl
|
||||
|
||||
[org.kde.spectacle.desktop]
|
||||
ActiveWindowScreenShot=Shift+Print,Meta+Print,Das aktive Fenster aufnehmen
|
||||
CurrentMonitorScreenShot=none,none,Den aktuellen Bildschirm aufnehmen
|
||||
FullScreenScreenShot=Meta+Print,Shift+Print,Die gesamte Arbeitsfläche aufnehmen
|
||||
OpenWithoutScreenshot=none,none,Ohne Aufnahme eines Bildschirmfotos starten
|
||||
RectangularRegionScreenShot=Meta+Shift+Print,Meta+Shift+Print,Einen rechteckigen Bereich aufnehmen
|
||||
WindowUnderCursorScreenShot=Meta+Ctrl+Print,Meta+Ctrl+Print,Fenster unter dem Mauszeiger aufnehmen
|
||||
_k_friendly_name=Spectacle
|
||||
_launch=none,Print,Spectacle
|
||||
|
||||
[org_kde_powerdevil]
|
||||
Decrease Keyboard Brightness=Keyboard Brightness Down,Keyboard Brightness Down,Helligkeit der Tastatur-Hintergrundbeleuchtung verringern
|
||||
Decrease Screen Brightness=Monitor Brightness Down,Monitor Brightness Down,Bildschirmhelligkeit verringern
|
||||
Hibernate=Hibernate,Hibernate,Ruhezustand
|
||||
Increase Keyboard Brightness=Keyboard Brightness Up,Keyboard Brightness Up,Helligkeit der Tastatur-Hintergrundbeleuchtung erhöhen
|
||||
Increase Screen Brightness=Monitor Brightness Up,Monitor Brightness Up,Bildschirmhelligkeit erhöhen
|
||||
PowerDown=Power Down,Power Down,Abschalten
|
||||
PowerOff=Power Off,Power Off,Ausschalten
|
||||
Sleep=Sleep,Sleep,Standby-Modus
|
||||
Toggle Keyboard Backlight=Keyboard Light On/Off,Keyboard Light On/Off,Hintergrundbeleuchtung der Tastatur umschalten
|
||||
Turn Off Screen=none,none,Bildschirm ausschalten
|
||||
_k_friendly_name=Energieverwaltung
|
||||
|
||||
[plasmashell]
|
||||
_k_friendly_name=Plasma
|
||||
activate task manager entry 1=Meta+1,Meta+1,Fensterleisteneintrag 1 aktivieren
|
||||
activate task manager entry 10=none,Meta+0,Fensterleisteneintrag 10 aktivieren
|
||||
activate task manager entry 2=Meta+2,Meta+2,Fensterleisteneintrag 2 aktivieren
|
||||
activate task manager entry 3=Meta+3,Meta+3,Fensterleisteneintrag 3 aktivieren
|
||||
activate task manager entry 4=Meta+4,Meta+4,Fensterleisteneintrag 4 aktivieren
|
||||
activate task manager entry 5=Meta+5,Meta+5,Fensterleisteneintrag 5 aktivieren
|
||||
activate task manager entry 6=Meta+6,Meta+6,Fensterleisteneintrag 6 aktivieren
|
||||
activate task manager entry 7=Meta+7,Meta+7,Fensterleisteneintrag 7 aktivieren
|
||||
activate task manager entry 8=Meta+8,Meta+8,Fensterleisteneintrag 8 aktivieren
|
||||
activate task manager entry 9=Meta+9,Meta+9,Fensterleisteneintrag 9 aktivieren
|
||||
activate widget 3=Alt+F1,none,Miniprogramm Anwendungsstarter aktivieren
|
||||
clear-history=none,,Bisherigen Inhalt der Zwischenablage löschen
|
||||
clipboard_action=Meta+Ctrl+X,Meta+Ctrl+X,Automatisches Aufklappmenü für Aktionen
|
||||
cycle-panels=Meta+Alt+P,Meta+Alt+P,Tastaturfokus zwischen Kontrollleisten umschalten
|
||||
cycleNextAction=none,,Nächstes Element im Verlauf
|
||||
cyclePrevAction=none,,Vorheriges Element im Verlauf
|
||||
edit_clipboard=,,Inhalt bearbeiten ...
|
||||
manage activities=Meta+Q,Meta+Q,Aktivitätenwechsler anzeigen
|
||||
next activity=Meta+Tab,none,Zwischen Aktivitäten wechseln
|
||||
previous activity=Meta+Shift+Tab,none,Zwischen Aktivitäten wechseln (Gegenrichtung)
|
||||
repeat_action=Meta+Ctrl+R,Meta+Ctrl+R,Aktionen der aktuellen Zwischenablage manuell aufrufen
|
||||
show dashboard=Ctrl+F12,Ctrl+F12,Arbeitsfläche anzeigen
|
||||
show-barcode=none,,Strichcode anzeigen ...
|
||||
show-on-mouse-pos=Meta+V\tAlt+K,Meta+V,Elemente an Mausposition anzeigen
|
||||
stop current activity=Meta+S,Meta+S,Aktuelle Aktivität anhalten
|
||||
switch to next activity=none,,Zur nächsten Aktivität wechseln
|
||||
switch to previous activity=none,,Zur vorherigen Aktivität wechseln
|
||||
toggle do not disturb=none,,Nicht stören umschalten
|
||||
|
||||
[systemsettings.desktop]
|
||||
_k_friendly_name=Systemeinstellungen
|
||||
_launch=Tools,Tools,Systemeinstellungen
|
||||
kcm-kscreen=none,none,Anzeige-Einrichtung
|
||||
kcm-lookandfeel=Meta+K,none,Globales Design
|
||||
kcm-users=Meta+B,none,Benutzer
|
||||
powerdevilprofilesconfig=none,Meta+Y,Energiesparen
|
||||
screenlocker=none,none,Bildschirmsperre
|
||||
|
||||
[yakuake]
|
||||
_k_friendly_name=Yakuake
|
||||
toggle-window-state=Meta+Space,F12,Yakuake einfahren/ausfahren
|
||||
@@ -0,0 +1,280 @@
|
||||
[ActivityManager]
|
||||
_k_friendly_name=Aktivitätenverwaltung
|
||||
switch-to-activity-099fac1d-166b-4392-b303-c3f623c79d77=none,none,Zu Aktivität „Somelongname“ wechseln
|
||||
switch-to-activity-476164d0-23bd-4ecd-94c5-5dba56d12383=none,none,Zu Aktivität „Default“ wechseln
|
||||
switch-to-activity-81b8a0cf-fe64-485e-a83b-a9f76a93cb2c=none,none,Zu Aktivität „Bla“ wechseln
|
||||
switch-to-activity-a467caca-889b-4863-be5b-1c0db58b9de0=none,none,Zu Aktivität „Hallo“ wechseln
|
||||
|
||||
[KDE Keyboard Layout Switcher]
|
||||
Switch to Next Keyboard Layout=Meta+Alt+K,Meta+Alt+K,Auf nächste Tastaturbelegung umschalten
|
||||
_k_friendly_name=Umschaltung der Tastaturbelegung
|
||||
|
||||
[kaccess]
|
||||
Toggle Screen Reader On and Off=Meta+S,Meta+Alt+S,Screenreader ein-/ausschalten
|
||||
_k_friendly_name=Zugangshilfen
|
||||
|
||||
[kcm_touchpad]
|
||||
Disable Touchpad=Touchpad Off,Touchpad Off,Touchpad abschalten
|
||||
Enable Touchpad=Touchpad On,Touchpad On,Touchpad aktivieren
|
||||
_k_friendly_name=Touchpad
|
||||
|
||||
[kded5]
|
||||
Show System Activity=Ctrl+Esc,Ctrl+Esc,Systemaktivität anzeigen
|
||||
_k_friendly_name=KDE Daemon
|
||||
|
||||
[khotkeys]
|
||||
_k_friendly_name=Dienst für eigene Kurzbefehle
|
||||
{3c04e4ea-1f6e-430e-82bb-0e4adb79a6a3}=,none,Scan
|
||||
{5d4c37a6-d8b3-40b0-aa6a-92f325302538}=,none,Save Profile 1
|
||||
{81787487-f07d-4111-b1cf-9da1406075ca}=,none,Load Profile 1
|
||||
{96c0b3ae-9d0d-45dd-b275-c11c01424ff7}=,none,Preview
|
||||
{9f894206-fbcf-48f1-9fb3-df9cec37bacb}=,none,Load Profile 2
|
||||
{aaed7bc1-a7bc-4abc-b319-9b95abb5216b}=,none,Cancel Scan
|
||||
{d03619b6-9b3c-48cc-9d9c-a2aadb485550}=,none,Suchen
|
||||
{e74b442f-47db-4314-a0e0-a56e1b753804}=,none,Save Profile 2
|
||||
|
||||
[kmix]
|
||||
_k_friendly_name=Lautstärke
|
||||
decrease_microphone_volume=Microphone Volume Down,Microphone Volume Down,Mikrofonlautstärke verringern
|
||||
decrease_volume=Volume Down,Volume Down,Lautstärke verringern
|
||||
increase_microphone_volume=Microphone Volume Up,Microphone Volume Up,Mikrofonlautstärke erhöhen
|
||||
increase_volume=Volume Up,Volume Up,Lautstärke erhöhen
|
||||
mic_mute=Microphone Mute\tMeta+Volume Mute,Microphone Mute\tMeta+Volume Mute,Mikrofon stummschalten
|
||||
mute=Volume Mute,Volume Mute,Stummschalten
|
||||
|
||||
[ksmserver]
|
||||
Halt Without Confirmation=none,,Ohne Rückfrage herunterfahren
|
||||
Lock Session=Meta+L\tScreensaver,Meta+L\tScreensaver,Lock Session
|
||||
Log Out=Ctrl+Alt+Del,Ctrl+Alt+Del,Abmelden
|
||||
Log Out Without Confirmation=none,,Ohne Rückfrage abmelden
|
||||
Reboot=none,none,Neu starten
|
||||
Reboot Without Confirmation=none,,Ohne Rückfrage neu starten
|
||||
Shut Down=none,none,Herunterfahren
|
||||
_k_friendly_name=Session Management
|
||||
|
||||
[kwin]
|
||||
Activate Window Demanding Attention=Meta+Ctrl+A,Meta+Ctrl+A,Fenster aktivieren\\, das Aufmerksamkeit erfordert
|
||||
Decrease Opacity=none,,Die Deckkraft des aktiven Fensters um 5 % verringern
|
||||
Edit Tiles=Meta+T,Meta+T,Tiling-Editor ein-/ausschalten
|
||||
Expose=Ctrl+F9,Ctrl+F9,Fenster der aktuellen Arbeitsfläche anzeigen
|
||||
ExposeAll=Ctrl+F10\tLaunch (C),Ctrl+F10\tLaunch (C),Fenster aller Arbeitsflächen anzeigen
|
||||
ExposeClass=Ctrl+F7,Ctrl+F7,Fenster der Fensterklasse anzeigen
|
||||
ExposeClassCurrentDesktop=none,none,Fenster der Fensterklasse auf der aktuellen Arbeitsfläche anzeigen
|
||||
Increase Opacity=none,,Die Deckkraft des aktiven Fensters um 5 % erhöhen
|
||||
Kill Window=Meta+Ctrl+Esc,Meta+Ctrl+Esc,Fenster beseitigen
|
||||
Mobile Task Switcher=Meta+C,Meta+C,Toggle Mobile Task Switcher
|
||||
Move Tablet to Next Output=none,none,Move the tablet to the next output
|
||||
MoveMouseToCenter=Meta+F6,Meta+F6,Mauszeiger zentrieren
|
||||
MoveMouseToFocus=Meta+F5,Meta+F5,Mauszeiger in den Fokus verschieben
|
||||
MoveZoomDown=none,none,Vergrößerten Bereich nach unten verschieben
|
||||
MoveZoomLeft=none,none,Vergrößerten Bereich nach links verschieben
|
||||
MoveZoomRight=none,none,Vergrößerten Bereich nach rechts verschieben
|
||||
MoveZoomUp=none,none,Vergrößerten Bereich nach oben verschieben
|
||||
Overview=Meta+W,Meta+W,Übersicht umschalten
|
||||
Setup Window Shortcut=none,,Kurzbefehl für Fenster einrichten
|
||||
Show Desktop=Meta+D,Meta+D,Blick auf die Arbeitsfläche
|
||||
ShowDesktopGrid=Meta+F8,Meta+F8,Arbeitsflächen-Raster anzeigen
|
||||
Suspend Compositing=Alt+Shift+F12,Alt+Shift+F12,Compositing aussetzen
|
||||
Switch One Desktop Down=none,Meta+Ctrl+Down,Eine Arbeitsfläche nach unten
|
||||
Switch One Desktop Up=none,Meta+Ctrl+Up,Eine Arbeitsfläche nach oben
|
||||
Switch One Desktop to the Left=none,Meta+Ctrl+Left,Eine Arbeitsfläche nach links
|
||||
Switch One Desktop to the Right=none,Meta+Ctrl+Right,Eine Arbeitsfläche nach rechts
|
||||
Switch Window Down=Meta+Alt+Down,Meta+Alt+Down,Zum Fenster darunter wechseln
|
||||
Switch Window Left=Meta+Alt+Left,Meta+Alt+Left,Zum Fenster links wechseln
|
||||
Switch Window Right=Meta+Alt+Right,Meta+Alt+Right,Zum Fenster rechts wechseln
|
||||
Switch Window Up=Meta+Alt+Up,Meta+Alt+Up,Zum Fenster darüber wechseln
|
||||
Switch to Desktop 1=Ctrl+F1,Ctrl+F1,Auf Arbeitsfläche 1 umschalten
|
||||
Switch to Desktop 10=none,,Auf Arbeitsfläche 10 umschalten
|
||||
Switch to Desktop 11=none,,Auf Arbeitsfläche 11 umschalten
|
||||
Switch to Desktop 12=none,,Auf Arbeitsfläche 12 umschalten
|
||||
Switch to Desktop 13=none,,Auf Arbeitsfläche 13 umschalten
|
||||
Switch to Desktop 14=none,,Auf Arbeitsfläche 14 umschalten
|
||||
Switch to Desktop 15=none,,Auf Arbeitsfläche 15 umschalten
|
||||
Switch to Desktop 16=none,,Auf Arbeitsfläche 16 umschalten
|
||||
Switch to Desktop 17=none,,Auf Arbeitsfläche 17 umschalten
|
||||
Switch to Desktop 18=none,,Auf Arbeitsfläche 18 umschalten
|
||||
Switch to Desktop 19=none,,Auf Arbeitsfläche 19 umschalten
|
||||
Switch to Desktop 2=Ctrl+F2,Ctrl+F2,Auf Arbeitsfläche 2 umschalten
|
||||
Switch to Desktop 20=none,,Auf Arbeitsfläche 20 umschalten
|
||||
Switch to Desktop 3=Ctrl+F3,Ctrl+F3,Auf Arbeitsfläche 3 umschalten
|
||||
Switch to Desktop 4=Ctrl+F4,Ctrl+F4,Auf Arbeitsfläche 4 umschalten
|
||||
Switch to Desktop 5=none,,Auf Arbeitsfläche 5 umschalten
|
||||
Switch to Desktop 6=none,,Auf Arbeitsfläche 6 umschalten
|
||||
Switch to Desktop 7=none,,Auf Arbeitsfläche 7 umschalten
|
||||
Switch to Desktop 8=none,,Auf Arbeitsfläche 8 umschalten
|
||||
Switch to Desktop 9=none,,Auf Arbeitsfläche 9 umschalten
|
||||
Switch to Next Desktop=none,,Zur nächsten Arbeitsfläche umschalten
|
||||
Switch to Next Screen=none,,Zum nächsten Bildschirm wechseln
|
||||
Switch to Previous Desktop=none,,Zur vorherigen Arbeitsfläche umschalten
|
||||
Switch to Previous Screen=none,,Zum vorherigen Bildschirm wechseln
|
||||
Switch to Screen 0=none,,Zum Bildschirm 0 wechseln
|
||||
Switch to Screen 1=none,,Zum Bildschirm 1 wechseln
|
||||
Switch to Screen 2=none,,Zum Bildschirm 2 wechseln
|
||||
Switch to Screen 3=none,,Zum Bildschirm 3 wechseln
|
||||
Switch to Screen 4=none,,Zum Bildschirm 4 wechseln
|
||||
Switch to Screen 5=none,,Zum Bildschirm 5 wechseln
|
||||
Switch to Screen 6=none,,Zum Bildschirm 6 wechseln
|
||||
Switch to Screen 7=none,,Zum Bildschirm 7 wechseln
|
||||
Switch to Screen Above=none,,Zum Bildschirm oben wechseln
|
||||
Switch to Screen Below=none,,Zum Bildschirm unten wechseln
|
||||
Switch to Screen to the Left=none,,Zum Bildschirm links wechseln
|
||||
Switch to Screen to the Right=none,,Zum Bildschirm rechts wechseln
|
||||
Toggle Night Color=none,none,Nachtfarben umschalten
|
||||
Toggle Window Raise/Lower=none,,Fenster nach vorne/hinten
|
||||
Walk Through Desktop List=,,Nächster Eintrag in Arbeitsflächenliste
|
||||
Walk Through Desktop List (Reverse)=,,Nächster Eintrag in Arbeitsflächenliste (Gegenrichtung)
|
||||
Walk Through Desktops=,,Zwischen Arbeitsflächen umschalten
|
||||
Walk Through Desktops (Reverse)=,,Zwischen Arbeitsflächen umschalten (Gegenrichtung)
|
||||
Walk Through Windows=Alt+Tab,Alt+Tab,Zwischen Fenstern wechseln
|
||||
Walk Through Windows (Reverse)=Alt+Shift+Tab,Alt+Shift+Tab,Zwischen Fenstern wechseln (Gegenrichtung)
|
||||
Walk Through Windows Alternative=none,,Alternatives Wechseln zwischen Fenstern
|
||||
Walk Through Windows Alternative (Reverse)=none,,Alternatives Wechseln zwischen Fenstern (Gegenrichtung)
|
||||
Walk Through Windows of Current Application=Alt+`,Alt+`,Zwischen Fenstern der aktuellen Anwendung wechseln
|
||||
Walk Through Windows of Current Application (Reverse)=Alt+~,Alt+~,Zwischen Fenstern der aktuellen Anwendung wechseln (Gegenrichtung)
|
||||
Walk Through Windows of Current Application Alternative=none,,Alternatives Wechseln zwischen Fenstern der aktuellen Anwendung
|
||||
Walk Through Windows of Current Application Alternative (Reverse)=none,,Alternatives Wechseln zwischen Fenstern der aktuellen Anwendung (Gegenrichtung)
|
||||
Window Above Other Windows=none,,Fenster im Vordergrund halten
|
||||
Window Below Other Windows=none,,Fenster im Hintergrund halten
|
||||
Window Close=Alt+F4,Alt+F4,Fenster schließen
|
||||
Window Fullscreen=none,,Fenster auf Vollbildgröße
|
||||
Window Grow Horizontal=none,,Fenster waagerecht maximieren
|
||||
Window Grow Vertical=none,,Fenster senkrecht maximieren
|
||||
Window Lower=none,,Fenster nach hinten
|
||||
Window Maximize=Meta+PgUp,Meta+PgUp,Fenster maximieren
|
||||
Window Maximize Horizontal=none,,Fenster waagerecht maximieren
|
||||
Window Maximize Vertical=none,,Fenster senkrecht maximieren
|
||||
Window Minimize=Meta+PgDown,Meta+PgDown,Fenster minimieren
|
||||
Window Move=none,,Fenster verschieben
|
||||
Window Move Center=none,,Fenster zentrieren
|
||||
Window No Border=none,,Titelleiste und Rahmen des Fensters ein-/ausschalten
|
||||
Window On All Desktops=none,,Fenster auf allen Arbeitsflächen anzeigen
|
||||
Window One Desktop Down=Meta+Ctrl+Shift+Down,Meta+Ctrl+Shift+Down,Fenster eine Arbeitsfläche nach unten
|
||||
Window One Desktop Up=Meta+Ctrl+Shift+Up,Meta+Ctrl+Shift+Up,Fenster eine Arbeitsfläche nach oben
|
||||
Window One Desktop to the Left=Meta+Ctrl+Shift+Left,Meta+Ctrl+Shift+Left,Fenster eine Arbeitsfläche nach links
|
||||
Window One Desktop to the Right=Meta+Ctrl+Shift+Right,Meta+Ctrl+Shift+Right,Fenster eine Arbeitsfläche nach rechts
|
||||
Window One Screen Down=none,,Fenster einen Bildschirm nach unten
|
||||
Window One Screen Up=none,,Fenster einen Bildschirm nach oben
|
||||
Window One Screen to the Left=none,,Fenster einen Bildschirm nach links
|
||||
Window One Screen to the Right=none,,Fenster einen Bildschirm nach rechts
|
||||
Window Operations Menu=Alt+F3,Alt+F3,Fensteraktionen-Menü
|
||||
Window Pack Down=none,,Fenster nach unten verschieben
|
||||
Window Pack Left=none,,Fenster nach links verschieben
|
||||
Window Pack Right=none,,Fenster nach rechts verschieben
|
||||
Window Pack Up=none,,Fenster nach oben verschieben
|
||||
Window Quick Tile Bottom=Meta+Down,Meta+Down,Fenster am unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Bottom Left=none,,Fenster am linken unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Bottom Right=none,,Fenster am rechten unteren Bildschirmrand anordnen
|
||||
Window Quick Tile Left=Meta+Left,Meta+Left,Fenster am linken Bildschirmrand anordnen
|
||||
Window Quick Tile Right=Meta+Right,Meta+Right,Fenster am rechten Bildschirmrand anordnen
|
||||
Window Quick Tile Top=Meta+Up,Meta+Up,Fenster am oberen Bildschirmrand anordnen
|
||||
Window Quick Tile Top Left=none,,Fenster am linken oberen Bildschirmrand anordnen
|
||||
Window Quick Tile Top Right=none,,Fenster am rechten oberen Bildschirmrand anordnen
|
||||
Window Raise=none,,Fenster nach vorne
|
||||
Window Resize=none,,Fenstergröße ändern
|
||||
Window Shade=none,,Fensterheber betätigen
|
||||
Window Shrink Horizontal=none,,Fenster waagerecht verkleinern
|
||||
Window Shrink Vertical=none,,Fenster senkrecht verkleinern
|
||||
Window to Desktop 1=none,,Fenster auf Arbeitsfläche 1
|
||||
Window to Desktop 10=none,,Fenster auf Arbeitsfläche 10
|
||||
Window to Desktop 11=none,,Fenster auf Arbeitsfläche 11
|
||||
Window to Desktop 12=none,,Fenster auf Arbeitsfläche 12
|
||||
Window to Desktop 13=none,,Fenster auf Arbeitsfläche 13
|
||||
Window to Desktop 14=none,,Fenster auf Arbeitsfläche 14
|
||||
Window to Desktop 15=none,,Fenster auf Arbeitsfläche 15
|
||||
Window to Desktop 16=none,,Fenster auf Arbeitsfläche 16
|
||||
Window to Desktop 17=none,,Fenster auf Arbeitsfläche 17
|
||||
Window to Desktop 18=none,,Fenster auf Arbeitsfläche 18
|
||||
Window to Desktop 19=none,,Fenster auf Arbeitsfläche 19
|
||||
Window to Desktop 2=none,,Fenster auf Arbeitsfläche 2
|
||||
Window to Desktop 20=none,,Fenster auf Arbeitsfläche 20
|
||||
Window to Desktop 3=none,,Fenster auf Arbeitsfläche 3
|
||||
Window to Desktop 4=none,,Fenster auf Arbeitsfläche 4
|
||||
Window to Desktop 5=none,,Fenster auf Arbeitsfläche 5
|
||||
Window to Desktop 6=none,,Fenster auf Arbeitsfläche 6
|
||||
Window to Desktop 7=none,,Fenster auf Arbeitsfläche 7
|
||||
Window to Desktop 8=none,,Fenster auf Arbeitsfläche 8
|
||||
Window to Desktop 9=none,,Fenster auf Arbeitsfläche 9
|
||||
Window to Next Desktop=none,,Fenster auf nächste Arbeitsfläche verschieben
|
||||
Window to Next Screen=Meta+Shift+Right,Meta+Shift+Right,Fenster auf nächsten Bildschirm verschieben
|
||||
Window to Previous Desktop=none,,Fenster auf vorherige Arbeitsfläche verschieben
|
||||
Window to Previous Screen=Meta+Shift+Left,Meta+Shift+Left,Fenster auf vorherigen Bildschirm verschieben
|
||||
Window to Screen 0=none,,Fenster auf Bildschirm 0
|
||||
Window to Screen 1=none,,Fenster auf Bildschirm 1
|
||||
Window to Screen 2=none,,Fenster auf Bildschirm 2
|
||||
Window to Screen 3=none,,Fenster auf Bildschirm 3
|
||||
Window to Screen 4=none,,Fenster auf Bildschirm 4
|
||||
Window to Screen 5=none,,Fenster auf Bildschirm 5
|
||||
Window to Screen 6=none,,Fenster auf Bildschirm 6
|
||||
Window to Screen 7=none,,Fenster auf Bildschirm 7
|
||||
_k_friendly_name=KWin
|
||||
view_actual_size=Meta+0,Meta+0,Auf Originalgröße zoomen
|
||||
view_zoom_in=Meta++\tMeta+=,Meta++,Vergrößern
|
||||
view_zoom_out=Meta+-,Meta+-,Verkleinern
|
||||
|
||||
[mediacontrol]
|
||||
_k_friendly_name=Mediensteuerung
|
||||
mediavolumedown=,,Medienspieler leiser
|
||||
mediavolumeup=,,Medienspieler lauter
|
||||
nextmedia=Media Next,Media Next,Nächstes Medium wiedergeben
|
||||
pausemedia=Media Pause,Media Pause,Medienwiedergabe anhalten
|
||||
playmedia=,,Medienwiedergabe starten
|
||||
playpausemedia=Media Play,Media Play,Medienwiedergabe starten/anhalten
|
||||
previousmedia=Media Previous,Media Previous,Vorheriges Medium wiedergeben
|
||||
stopmedia=Media Stop,Media Stop,Medienwiedergabe anhalten
|
||||
|
||||
[org_kde_powerdevil]
|
||||
Decrease Keyboard Brightness=Keyboard Brightness Down,Keyboard Brightness Down,Helligkeit der Tastatur-Hintergrundbeleuchtung verringern
|
||||
Decrease Screen Brightness=Monitor Brightness Down,Monitor Brightness Down,Bildschirmhelligkeit verringern
|
||||
Hibernate=Hibernate,Hibernate,Ruhezustand
|
||||
Increase Keyboard Brightness=Keyboard Brightness Up,Keyboard Brightness Up,Helligkeit der Tastatur-Hintergrundbeleuchtung erhöhen
|
||||
Increase Screen Brightness=Monitor Brightness Up,Monitor Brightness Up,Bildschirmhelligkeit erhöhen
|
||||
PowerDown=Power Down,Power Down,Abschalten
|
||||
PowerOff=Power Off,Power Off,Ausschalten
|
||||
Sleep=Sleep,Sleep,Standby-Modus
|
||||
Toggle Keyboard Backlight=Keyboard Light On/Off,Keyboard Light On/Off,Hintergrundbeleuchtung der Tastatur umschalten
|
||||
Turn Off Screen=none,none,Bildschirm ausschalten
|
||||
_k_friendly_name=Energieverwaltung
|
||||
|
||||
[plasmashell]
|
||||
_k_friendly_name=Plasma
|
||||
activate task manager entry 1=Meta+1,Meta+1,Fensterleisteneintrag 1 aktivieren
|
||||
activate task manager entry 10=none,Meta+0,Fensterleisteneintrag 10 aktivieren
|
||||
activate task manager entry 2=Meta+2,Meta+2,Fensterleisteneintrag 2 aktivieren
|
||||
activate task manager entry 3=Meta+3,Meta+3,Fensterleisteneintrag 3 aktivieren
|
||||
activate task manager entry 4=Meta+4,Meta+4,Fensterleisteneintrag 4 aktivieren
|
||||
activate task manager entry 5=Meta+5,Meta+5,Fensterleisteneintrag 5 aktivieren
|
||||
activate task manager entry 6=Meta+6,Meta+6,Fensterleisteneintrag 6 aktivieren
|
||||
activate task manager entry 7=Meta+7,Meta+7,Fensterleisteneintrag 7 aktivieren
|
||||
activate task manager entry 8=Meta+8,Meta+8,Fensterleisteneintrag 8 aktivieren
|
||||
activate task manager entry 9=Meta+9,Meta+9,Fensterleisteneintrag 9 aktivieren
|
||||
activate widget 3=Alt+F1,none,Miniprogramm Anwendungsstarter aktivieren
|
||||
clear-history=none,,Bisherigen Inhalt der Zwischenablage löschen
|
||||
clipboard_action=Meta+Ctrl+X,Meta+Ctrl+X,Automatisches Aufklappmenü für Aktionen
|
||||
cycle-panels=Meta+Alt+P,Meta+Alt+P,Tastaturfokus zwischen Kontrollleisten umschalten
|
||||
cycleNextAction=none,,Nächstes Element im Verlauf
|
||||
cyclePrevAction=none,,Vorheriges Element im Verlauf
|
||||
edit_clipboard=,,Inhalt bearbeiten ...
|
||||
manage activities=Meta+Q,Meta+Q,Aktivitätenwechsler anzeigen
|
||||
next activity=Meta+Tab,none,Zwischen Aktivitäten wechseln
|
||||
previous activity=Meta+Shift+Tab,none,Zwischen Aktivitäten wechseln (Gegenrichtung)
|
||||
repeat_action=Meta+Ctrl+R,Meta+Ctrl+R,Aktionen der aktuellen Zwischenablage manuell aufrufen
|
||||
show dashboard=Ctrl+F12,Ctrl+F12,Arbeitsfläche anzeigen
|
||||
show-barcode=none,,Strichcode anzeigen ...
|
||||
show-on-mouse-pos=Meta+V\tAlt+K,Meta+V,Elemente an Mausposition anzeigen
|
||||
stop current activity=Meta+S,Meta+S,Aktuelle Aktivität anhalten
|
||||
switch to next activity=none,,Zur nächsten Aktivität wechseln
|
||||
switch to previous activity=none,,Zur vorherigen Aktivität wechseln
|
||||
toggle do not disturb=none,,Nicht stören umschalten
|
||||
|
||||
[services][org.kde.spectacle.desktop]
|
||||
ActiveWindowScreenShot=Shift+Print
|
||||
FullScreenScreenShot=Meta+Print
|
||||
_launch=none
|
||||
|
||||
[services][systemsettings.desktop]
|
||||
kcm-lookandfeel=Meta+K
|
||||
kcm-users=Meta+B
|
||||
powerdevilprofilesconfig=none
|
||||
|
||||
[services][org.kde.test.desktop]
|
||||
_launch=Meta+U
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "globalshortcutsregistry.h"
|
||||
|
||||
class MigrateConfigTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void compareGroups(const KConfigGroup &a, const KConfigGroup &b)
|
||||
{
|
||||
for (auto [key, value] : a.entryMap().asKeyValueRange()) {
|
||||
QCOMPARE(value, b.readEntry(key));
|
||||
}
|
||||
|
||||
for (auto [key, value] : b.entryMap().asKeyValueRange()) {
|
||||
QCOMPARE(value, a.readEntry(key));
|
||||
}
|
||||
}
|
||||
|
||||
void compareGroupList(const KConfigBase &a, const KConfigBase &b)
|
||||
{
|
||||
QCOMPARE(a.groupList(), b.groupList());
|
||||
|
||||
const QStringList groups = a.groupList();
|
||||
for (const QString &group : groups) {
|
||||
compareGroups(a.group(group), b.group(group));
|
||||
}
|
||||
}
|
||||
|
||||
void testMigrate()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
qunsetenv("XDG_DATA_DIRS");
|
||||
|
||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
||||
configDir.mkpath(QStringLiteral("."));
|
||||
configDir.remove(QStringLiteral("kglobalshortcutsrc"));
|
||||
|
||||
QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
||||
dataDir.mkpath(QStringLiteral("kglobalaccel"));
|
||||
|
||||
QFile::copy(QFINDTESTDATA("kglobalshortcutsrc"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kglobalshortcutsrc"));
|
||||
|
||||
QFile::copy(QFINDTESTDATA("org.kde.test.desktop"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kglobalaccel/org.kde.test.desktop"));
|
||||
|
||||
// Creating the registry will migrate the shortcut config
|
||||
GlobalShortcutsRegistry registry;
|
||||
|
||||
// Compare actual with expected config
|
||||
KConfig actual(QStringLiteral("kglobalshortcutsrc"));
|
||||
KConfig expected(QFINDTESTDATA("kglobalshortcutsrc.expected"));
|
||||
|
||||
compareGroupList(actual, expected);
|
||||
compareGroupList(actual.group(QStringLiteral("services")), expected.group(QStringLiteral("services")));
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(MigrateConfigTest)
|
||||
|
||||
#include "migrateconfigtest.moc"
|
||||
@@ -0,0 +1,20 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Test Service
|
||||
Exec=/bin/false
|
||||
X-KDE-Shortcuts=Meta+T
|
||||
X-KDE-Migrate-Shortcut=kcm_touchpad,Toggle Touchpad
|
||||
Actions=dotest;dotest2;
|
||||
|
||||
[Desktop Action dotest]
|
||||
Name=Testing
|
||||
Exec=/bin/false
|
||||
X-KDE-Shortcuts=Meta+Shift+T
|
||||
X-KDE-Migrate-Shortcut=kded5,display
|
||||
|
||||
[Desktop Action dotest2]
|
||||
Name=Testing 2
|
||||
Exec=/bin/false
|
||||
X-KDE-Shortcuts=Meta+Space
|
||||
X-KDE-Migrate-Shortcut=yakuake,toggle-window-state
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
set(kglobalaccelprivate_SRCS
|
||||
kglobalacceld.cpp
|
||||
kglobalaccel_interface.cpp
|
||||
kserviceactioncomponent.cpp
|
||||
component.cpp
|
||||
logging.cpp
|
||||
globalshortcut.cpp
|
||||
globalshortcutsregistry.cpp
|
||||
globalshortcutcontext.cpp
|
||||
sequencehelpers_p.cpp
|
||||
)
|
||||
|
||||
configure_file(config-kglobalaccel.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kglobalaccel.h )
|
||||
|
||||
add_library(KGlobalAccelD ${kglobalaccelprivate_SRCS})
|
||||
add_library(K::KGlobalAccelD ALIAS KGlobalAccelD)
|
||||
|
||||
ecm_generate_export_header(KGlobalAccelD
|
||||
EXPORT_FILE_NAME kglobalacceld_export.h
|
||||
BASE_NAME KGlobalAccelD
|
||||
VERSION ${PROJECT_VERSION}
|
||||
USE_VERSION_HEADER
|
||||
VERSION_BASE_NAME KGlobalAccel
|
||||
DEPRECATED_BASE_VERSION 0
|
||||
DEPRECATION_VERSIONS 4.3 5.90
|
||||
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
|
||||
)
|
||||
|
||||
target_include_directories(KGlobalAccelD INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR}/KGlobalAccelD>")
|
||||
|
||||
target_link_libraries(KGlobalAccelD
|
||||
PUBLIC
|
||||
KF6::GlobalAccel
|
||||
PRIVATE
|
||||
Qt6::DBus
|
||||
KF6::WindowSystem # KKeyServer
|
||||
KF6::CoreAddons # KAboutData
|
||||
KF6::ConfigCore
|
||||
KF6::Service
|
||||
KF6::KIOCore
|
||||
KF6::JobWidgets
|
||||
)
|
||||
|
||||
set_target_properties(KGlobalAccelD PROPERTIES VERSION ${KGLOBALACCELD_VERSION}
|
||||
SOVERSION ${KGLOBALACCELD_SOVERSION}
|
||||
EXPORT_NAME "KGlobalAccelD"
|
||||
)
|
||||
|
||||
target_compile_definitions(KGlobalAccelD PRIVATE -DQDBUS=${qdbus_EXECUTABLE})
|
||||
|
||||
if(XCB_XCB_FOUND)
|
||||
target_link_libraries(KGlobalAccelD PUBLIC Qt6::GuiPrivate) # qtx11extras_p.h
|
||||
endif()
|
||||
|
||||
add_executable(kglobalacceld main.cpp logging.cpp)
|
||||
|
||||
target_include_directories(kglobalacceld PRIVATE ${CMAKE_BINARY_DIR})
|
||||
|
||||
target_link_libraries(kglobalacceld
|
||||
KGlobalAccelD
|
||||
KF6::CoreAddons
|
||||
KF6::DBusAddons # KDBusService
|
||||
KF6::Crash
|
||||
)
|
||||
|
||||
add_subdirectory(plugins)
|
||||
|
||||
install(TARGETS KGlobalAccelD EXPORT KGlobalAccelDTargets ${KF_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
|
||||
install(TARGETS kglobalacceld DESTINATION ${KDE_INSTALL_LIBEXECDIR})
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/kglobalacceld_export.h
|
||||
kglobalacceld.h
|
||||
kglobalaccel_interface.h
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KGlobalAccelD/ COMPONENT Devel
|
||||
)
|
||||
|
||||
include (ECMConfiguredInstall)
|
||||
ecm_install_configured_files(
|
||||
INPUT plasma-kglobalaccel.service.in
|
||||
DESTINATION ${KDE_INSTALL_SYSTEMDUSERUNITDIR}
|
||||
)
|
||||
|
||||
ecm_install_configured_files(
|
||||
INPUT kglobalacceld.desktop.in
|
||||
DESTINATION ${KDE_INSTALL_AUTOSTARTDIR} @ONLY
|
||||
)
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "component.h"
|
||||
|
||||
#include "globalshortcutcontext.h"
|
||||
#include "globalshortcutsregistry.h"
|
||||
#include "kglobalaccel_interface.h"
|
||||
#include "logging_p.h"
|
||||
#include <config-kglobalaccel.h>
|
||||
|
||||
#include <QKeySequence>
|
||||
#include <QStringList>
|
||||
|
||||
#if HAVE_X11
|
||||
#include <private/qtx11extras_p.h>
|
||||
#endif
|
||||
|
||||
QList<QKeySequence> Component::keysFromString(const QString &str)
|
||||
{
|
||||
QList<QKeySequence> ret;
|
||||
if (str == QLatin1String("none")) {
|
||||
return ret;
|
||||
}
|
||||
const QStringList strList = str.split(QLatin1Char('\t'));
|
||||
for (const QString &s : strList) {
|
||||
QKeySequence key = QKeySequence::fromString(s, QKeySequence::PortableText);
|
||||
if (!key.isEmpty()) { // sanity check just in case
|
||||
ret.append(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString Component::stringFromKeys(const QList<QKeySequence> &keys)
|
||||
{
|
||||
if (keys.isEmpty()) {
|
||||
return QStringLiteral("none");
|
||||
}
|
||||
QString ret;
|
||||
for (const QKeySequence &key : keys) {
|
||||
ret.append(key.toString(QKeySequence::PortableText));
|
||||
ret.append(QLatin1Char('\t'));
|
||||
}
|
||||
ret.chop(1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Component::Component(const QString &uniqueName, const QString &friendlyName)
|
||||
: _uniqueName(uniqueName)
|
||||
, _friendlyName(friendlyName)
|
||||
, _registry(GlobalShortcutsRegistry::self())
|
||||
{
|
||||
// Make sure we do no get uniquenames still containing the context
|
||||
Q_ASSERT(uniqueName.indexOf(QLatin1Char('|')) == -1);
|
||||
|
||||
const QString DEFAULT(QStringLiteral("default"));
|
||||
createGlobalShortcutContext(DEFAULT, QStringLiteral("Default Context"));
|
||||
_current = _contexts.value(DEFAULT);
|
||||
}
|
||||
|
||||
Component::~Component()
|
||||
{
|
||||
// We delete all shortcuts from all contexts
|
||||
qDeleteAll(_contexts);
|
||||
}
|
||||
|
||||
bool Component::activateGlobalShortcutContext(const QString &uniqueName)
|
||||
{
|
||||
if (!_contexts.value(uniqueName)) {
|
||||
createGlobalShortcutContext(uniqueName, QStringLiteral("TODO4"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Deactivate the current contexts shortcuts
|
||||
deactivateShortcuts();
|
||||
|
||||
// Switch the context
|
||||
_current = _contexts.value(uniqueName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Component::activateShortcuts()
|
||||
{
|
||||
for (GlobalShortcut *shortcut : std::as_const(_current->_actionsMap)) {
|
||||
shortcut->setActive();
|
||||
}
|
||||
}
|
||||
|
||||
QList<GlobalShortcut *> Component::allShortcuts(const QString &contextName) const
|
||||
{
|
||||
GlobalShortcutContext *context = _contexts.value(contextName);
|
||||
return context ? context->_actionsMap.values() : QList<GlobalShortcut *>{};
|
||||
}
|
||||
|
||||
QList<KGlobalShortcutInfo> Component::allShortcutInfos(const QString &contextName) const
|
||||
{
|
||||
GlobalShortcutContext *context = _contexts.value(contextName);
|
||||
return context ? context->allShortcutInfos() : QList<KGlobalShortcutInfo>{};
|
||||
}
|
||||
|
||||
bool Component::cleanUp()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
const auto actions = _current->_actionsMap;
|
||||
for (GlobalShortcut *shortcut : actions) {
|
||||
qCDebug(KGLOBALACCELD) << _current->_actionsMap.size();
|
||||
if (!shortcut->isPresent()) {
|
||||
changed = true;
|
||||
shortcut->unRegister();
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
_registry->writeSettings();
|
||||
// We could be destroyed after this call!
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Component::createGlobalShortcutContext(const QString &uniqueName, const QString &friendlyName)
|
||||
{
|
||||
if (_contexts.value(uniqueName)) {
|
||||
qCDebug(KGLOBALACCELD) << "Shortcut Context " << uniqueName << "already exists for component " << _uniqueName;
|
||||
return false;
|
||||
}
|
||||
_contexts.insert(uniqueName, new GlobalShortcutContext(uniqueName, friendlyName, this));
|
||||
return true;
|
||||
}
|
||||
|
||||
GlobalShortcutContext *Component::currentContext()
|
||||
{
|
||||
return _current;
|
||||
}
|
||||
|
||||
QDBusObjectPath Component::dbusPath() const
|
||||
{
|
||||
auto isNonAscii = [](QChar ch) {
|
||||
const char c = ch.unicode();
|
||||
const bool isAscii = c == '_' //
|
||||
|| (c >= 'A' && c <= 'Z') //
|
||||
|| (c >= 'a' && c <= 'z') //
|
||||
|| (c >= '0' && c <= '9');
|
||||
return !isAscii;
|
||||
};
|
||||
|
||||
QString dbusPath = _uniqueName;
|
||||
// DBus path can only contain ASCII characters, any non-alphanumeric char should
|
||||
// be turned into '_'
|
||||
std::replace_if(dbusPath.begin(), dbusPath.end(), isNonAscii, QLatin1Char('_'));
|
||||
|
||||
// QDBusObjectPath could be a little bit easier to handle :-)
|
||||
return QDBusObjectPath(_registry->dbusPath().path() + QLatin1String("component/") + dbusPath);
|
||||
}
|
||||
|
||||
void Component::deactivateShortcuts(bool temporarily)
|
||||
{
|
||||
for (GlobalShortcut *shortcut : std::as_const(_current->_actionsMap)) {
|
||||
if (temporarily //
|
||||
&& _uniqueName == QLatin1String("kwin") //
|
||||
&& shortcut->uniqueName() == QLatin1String("Block Global Shortcuts")) {
|
||||
continue;
|
||||
}
|
||||
shortcut->setInactive();
|
||||
}
|
||||
}
|
||||
|
||||
void Component::emitGlobalShortcutPressed(const GlobalShortcut &shortcut)
|
||||
{
|
||||
#if HAVE_X11
|
||||
// pass X11 timestamp
|
||||
const long timestamp = QX11Info::appTime();
|
||||
#else
|
||||
const long timestamp = 0;
|
||||
#endif
|
||||
|
||||
if (shortcut.context()->component() != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_EMIT globalShortcutPressed(shortcut.context()->component()->uniqueName(), shortcut.uniqueName(), timestamp);
|
||||
}
|
||||
|
||||
void Component::emitGlobalShortcutReleased(const GlobalShortcut &shortcut)
|
||||
{
|
||||
#if HAVE_X11
|
||||
// pass X11 timestamp
|
||||
const long timestamp = QX11Info::appTime();
|
||||
#else
|
||||
const long timestamp = 0;
|
||||
#endif
|
||||
|
||||
if (shortcut.context()->component() != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_EMIT globalShortcutReleased(shortcut.context()->component()->uniqueName(), shortcut.uniqueName(), timestamp);
|
||||
}
|
||||
|
||||
void Component::invokeShortcut(const QString &shortcutName, const QString &context)
|
||||
{
|
||||
GlobalShortcut *shortcut = getShortcutByName(shortcutName, context);
|
||||
if (shortcut) {
|
||||
emitGlobalShortcutPressed(*shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
QString Component::friendlyName() const
|
||||
{
|
||||
return !_friendlyName.isEmpty() ? _friendlyName : _uniqueName;
|
||||
}
|
||||
|
||||
GlobalShortcut *Component::getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
return _current->getShortcutByKey(key, type);
|
||||
}
|
||||
|
||||
QList<GlobalShortcut *> Component::getShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
QList<GlobalShortcut *> rc;
|
||||
for (GlobalShortcutContext *context : std::as_const(_contexts)) {
|
||||
GlobalShortcut *sc = context->getShortcutByKey(key, type);
|
||||
if (sc) {
|
||||
rc.append(sc);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
GlobalShortcut *Component::getShortcutByName(const QString &uniqueName, const QString &context) const
|
||||
{
|
||||
const GlobalShortcutContext *shortcutContext = _contexts.value(context);
|
||||
return shortcutContext ? shortcutContext->_actionsMap.value(uniqueName) : nullptr;
|
||||
}
|
||||
|
||||
QStringList Component::getShortcutContexts() const
|
||||
{
|
||||
return _contexts.keys();
|
||||
}
|
||||
|
||||
bool Component::isActive() const
|
||||
{
|
||||
// The component is active if at least one of it's global shortcuts is
|
||||
// present.
|
||||
for (GlobalShortcut *shortcut : std::as_const(_current->_actionsMap)) {
|
||||
if (shortcut->isPresent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Component::isShortcutAvailable(const QKeySequence &key, const QString &component, const QString &context) const
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << key.toString() << component;
|
||||
|
||||
// if this component asks for the key. only check the keys in the same
|
||||
// context
|
||||
if (component == uniqueName()) {
|
||||
return shortcutContext(context)->isShortcutAvailable(key);
|
||||
} else {
|
||||
for (auto it = _contexts.cbegin(), endIt = _contexts.cend(); it != endIt; ++it) {
|
||||
const GlobalShortcutContext *ctx = it.value();
|
||||
if (!ctx->isShortcutAvailable(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GlobalShortcut *
|
||||
Component::registerShortcut(const QString &uniqueName, const QString &friendlyName, const QString &shortcutString, const QString &defaultShortcutString)
|
||||
{
|
||||
// The shortcut will register itself with us
|
||||
GlobalShortcut *shortcut = new GlobalShortcut(uniqueName, friendlyName, currentContext());
|
||||
|
||||
const QList<QKeySequence> keys = keysFromString(shortcutString);
|
||||
shortcut->setDefaultKeys(keysFromString(defaultShortcutString));
|
||||
shortcut->setIsFresh(false);
|
||||
QList<QKeySequence> newKeys = keys;
|
||||
for (const QKeySequence &key : keys) {
|
||||
if (!key.isEmpty()) {
|
||||
if (_registry->getShortcutByKey(key)) {
|
||||
// The shortcut is already used. The config file is
|
||||
// broken. Ignore the request.
|
||||
newKeys.removeAll(key);
|
||||
qCWarning(KGLOBALACCELD) << "Shortcut found twice in kglobalshortcutsrc." << key;
|
||||
}
|
||||
}
|
||||
}
|
||||
shortcut->setKeys(keys);
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
void Component::loadSettings(KConfigGroup &configGroup)
|
||||
{
|
||||
// GlobalShortcutsRegistry::loadSettings handles contexts.
|
||||
const auto listKeys = configGroup.keyList();
|
||||
for (const QString &confKey : listKeys) {
|
||||
const QStringList entry = configGroup.readEntry(confKey, QStringList());
|
||||
if (entry.size() != 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
registerShortcut(confKey, entry[2], entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void Component::setFriendlyName(const QString &name)
|
||||
{
|
||||
_friendlyName = name;
|
||||
}
|
||||
|
||||
GlobalShortcutContext *Component::shortcutContext(const QString &contextName)
|
||||
{
|
||||
return _contexts.value(contextName);
|
||||
}
|
||||
|
||||
GlobalShortcutContext const *Component::shortcutContext(const QString &contextName) const
|
||||
{
|
||||
return _contexts.value(contextName);
|
||||
}
|
||||
|
||||
QStringList Component::shortcutNames(const QString &contextName) const
|
||||
{
|
||||
const GlobalShortcutContext *context = _contexts.value(contextName);
|
||||
return context ? context->_actionsMap.keys() : QStringList{};
|
||||
}
|
||||
|
||||
QString Component::uniqueName() const
|
||||
{
|
||||
return _uniqueName;
|
||||
}
|
||||
|
||||
void Component::unregisterShortcut(const QString &uniqueName)
|
||||
{
|
||||
// Now wrote all contexts
|
||||
for (GlobalShortcutContext *context : std::as_const(_contexts)) {
|
||||
if (context->_actionsMap.value(uniqueName)) {
|
||||
delete context->takeShortcut(context->_actionsMap.value(uniqueName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Component::writeSettings(KConfigGroup &configGroup) const
|
||||
{
|
||||
// If we don't delete the current content global shortcut
|
||||
// registrations will never not deleted after forgetGlobalShortcut()
|
||||
configGroup.deleteGroup();
|
||||
|
||||
// Now write all contexts
|
||||
for (GlobalShortcutContext *context : std::as_const(_contexts)) {
|
||||
KConfigGroup contextGroup;
|
||||
|
||||
if (context->uniqueName() == QLatin1String("default")) {
|
||||
contextGroup = configGroup;
|
||||
// Write the friendly name
|
||||
contextGroup.writeEntry("_k_friendly_name", friendlyName());
|
||||
} else {
|
||||
contextGroup = KConfigGroup(&configGroup, context->uniqueName());
|
||||
// Write the friendly name
|
||||
contextGroup.writeEntry("_k_friendly_name", context->friendlyName());
|
||||
}
|
||||
|
||||
// qCDebug(KGLOBALACCELD) << "writing group " << _uniqueName << ":" << context->uniqueName();
|
||||
|
||||
for (const GlobalShortcut *shortcut : std::as_const(context->_actionsMap)) {
|
||||
// qCDebug(KGLOBALACCELD) << "writing" << shortcut->uniqueName();
|
||||
|
||||
// We do not write fresh shortcuts.
|
||||
// We do not write session shortcuts
|
||||
if (shortcut->isFresh() || shortcut->isSessionShortcut()) {
|
||||
continue;
|
||||
}
|
||||
// qCDebug(KGLOBALACCELD) << "really writing" << shortcut->uniqueName();
|
||||
|
||||
QStringList entry(stringFromKeys(shortcut->keys()));
|
||||
entry.append(stringFromKeys(shortcut->defaultKeys()));
|
||||
entry.append(shortcut->friendlyName());
|
||||
|
||||
contextGroup.writeEntry(shortcut->uniqueName(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef COMPONENT_H
|
||||
#define COMPONENT_H
|
||||
|
||||
#include "globalshortcut.h"
|
||||
#include "kglobalshortcutinfo.h"
|
||||
|
||||
#include "kconfiggroup.h"
|
||||
|
||||
#include <KGlobalAccel>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
class GlobalShortcut;
|
||||
class GlobalShortcutContext;
|
||||
class GlobalShortcutsRegistry;
|
||||
|
||||
/**
|
||||
* @author Michael Jansen <kde@michael-jansen.biz>
|
||||
*/
|
||||
class Component : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kglobalaccel.Component")
|
||||
|
||||
/* clang-format off */
|
||||
Q_SCRIPTABLE Q_PROPERTY(QString friendlyName READ friendlyName)
|
||||
Q_SCRIPTABLE Q_PROPERTY(QString uniqueName READ uniqueName)
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
~Component() override;
|
||||
/* clang-format on */
|
||||
|
||||
bool activateGlobalShortcutContext(const QString &uniqueName);
|
||||
|
||||
void activateShortcuts();
|
||||
|
||||
//! Returns all shortcuts in context @context
|
||||
QList<GlobalShortcut *> allShortcuts(const QString &context = QStringLiteral("default")) const;
|
||||
|
||||
//! Creates the new global shortcut context @p context
|
||||
bool createGlobalShortcutContext(const QString &context, const QString &friendlyName = QString());
|
||||
|
||||
//! Return the current context
|
||||
GlobalShortcutContext *currentContext();
|
||||
|
||||
//! Return uniqueName converted to a valid dbus path
|
||||
QDBusObjectPath dbusPath() const;
|
||||
|
||||
//! Deactivate all currently active shortcuts
|
||||
void deactivateShortcuts(bool temporarily = false);
|
||||
|
||||
//! Returns the friendly name
|
||||
QString friendlyName() const;
|
||||
|
||||
//! Returns the currently active shortcut for key
|
||||
GlobalShortcut *getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const;
|
||||
|
||||
//! Returns the shortcut context @p name or nullptr
|
||||
GlobalShortcutContext *shortcutContext(const QString &name);
|
||||
GlobalShortcutContext const *shortcutContext(const QString &name) const;
|
||||
|
||||
/**
|
||||
* Returns the list of shortcuts (different context) registered with @p
|
||||
* key.
|
||||
*/
|
||||
QList<GlobalShortcut *> getShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const;
|
||||
|
||||
//! Returns the shortcut by unique name. Only the active context is
|
||||
//! searched.
|
||||
GlobalShortcut *getShortcutByName(const QString &uniqueName, const QString &context = QStringLiteral("default")) const;
|
||||
|
||||
/**
|
||||
* Check if @a key is available for component @p component
|
||||
*/
|
||||
bool isShortcutAvailable(const QKeySequence &key, const QString &component, const QString &context) const;
|
||||
|
||||
//! Load the settings from config group @p config
|
||||
virtual void loadSettings(KConfigGroup &config);
|
||||
|
||||
//! Sets the human readable name for this component.
|
||||
void setFriendlyName(const QString &);
|
||||
|
||||
QString uniqueName() const;
|
||||
|
||||
//! Unregister @a shortcut. This will remove its siblings from all contexts
|
||||
void unregisterShortcut(const QString &uniqueName);
|
||||
|
||||
virtual void writeSettings(KConfigGroup &config) const;
|
||||
|
||||
protected:
|
||||
friend class ::GlobalShortcutsRegistry;
|
||||
|
||||
//! Constructs a component. This is a private constructor, to create a component
|
||||
//! use GlobalShortcutsRegistry::self()->createComponent().
|
||||
Component(const QString &uniqueName, const QString &friendlyName);
|
||||
|
||||
/**
|
||||
* Create a new globalShortcut by its name
|
||||
* @param uniqueName internal unique name to identify the shortcut
|
||||
* @param friendlyName name for the shortcut to be presented to the user
|
||||
* @param shortcutString string representation of the shortcut, such as "CTRL+S"
|
||||
* @param defaultShortcutString string representation of the default shortcut,
|
||||
* such as "CTRL+S", when the user choses to reset to default
|
||||
* the keyboard shortcut will return to this one.
|
||||
*/
|
||||
GlobalShortcut *
|
||||
registerShortcut(const QString &uniqueName, const QString &friendlyName, const QString &shortcutString, const QString &defaultShortcutString);
|
||||
|
||||
static QString stringFromKeys(const QList<QKeySequence> &keys);
|
||||
static QList<QKeySequence> keysFromString(const QString &str);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
// For dbus Q_SCRIPTABLE has to be on slots. Scriptable methods are not
|
||||
// exported.
|
||||
|
||||
/**
|
||||
* Remove all currently not used global shortcuts registrations for this
|
||||
* component and if nothing is left the component too.
|
||||
*
|
||||
* If the method returns true consider all information previously acquired
|
||||
* from this component as void.
|
||||
*
|
||||
* The method will cleanup in all contexts.
|
||||
*
|
||||
* @return @c true if a change was made, @c false if not.
|
||||
*/
|
||||
Q_SCRIPTABLE virtual bool cleanUp();
|
||||
|
||||
/**
|
||||
* Check if the component is currently active.
|
||||
*
|
||||
* A component is active if at least one of it's global shortcuts is
|
||||
* currently present.
|
||||
*/
|
||||
Q_SCRIPTABLE bool isActive() const;
|
||||
|
||||
//! Get all shortcutnames living in @a context
|
||||
Q_SCRIPTABLE QStringList shortcutNames(const QString &context = QStringLiteral("default")) const;
|
||||
|
||||
//! Returns all shortcut in @a context
|
||||
Q_SCRIPTABLE QList<KGlobalShortcutInfo> allShortcutInfos(const QString &context = QStringLiteral("default")) const;
|
||||
|
||||
//! Returns the shortcut contexts available for the component.
|
||||
Q_SCRIPTABLE QStringList getShortcutContexts() const;
|
||||
|
||||
virtual void emitGlobalShortcutPressed(const GlobalShortcut &shortcut);
|
||||
virtual void emitGlobalShortcutReleased(const GlobalShortcut &shortcut);
|
||||
|
||||
Q_SCRIPTABLE void invokeShortcut(const QString &shortcutName, const QString &context = QStringLiteral("default"));
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
//! Signals that a action for this component was triggered
|
||||
Q_SCRIPTABLE void globalShortcutPressed(const QString &componentUnique, const QString &shortcutUnique, qlonglong timestamp);
|
||||
|
||||
//! Signals that a action for this component is not triggered anymore
|
||||
Q_SCRIPTABLE void globalShortcutReleased(const QString &componentUnique, const QString &shortcutUnique, qlonglong timestamp);
|
||||
|
||||
protected:
|
||||
QString _uniqueName;
|
||||
// the name as it would be found in a magazine article about the application,
|
||||
// possibly localized if a localized name exists.
|
||||
QString _friendlyName;
|
||||
|
||||
GlobalShortcutsRegistry *_registry;
|
||||
|
||||
GlobalShortcutContext *_current;
|
||||
QHash<QString, GlobalShortcutContext *> _contexts;
|
||||
};
|
||||
|
||||
#endif /* #ifndef COMPONENT_H */
|
||||
@@ -0,0 +1 @@
|
||||
#cmakedefine01 HAVE_X11
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "globalshortcut.h"
|
||||
|
||||
#include "kglobalshortcutinfo_p.h"
|
||||
|
||||
#include "component.h"
|
||||
#include "globalshortcutcontext.h"
|
||||
#include "globalshortcutsregistry.h"
|
||||
#include "logging_p.h"
|
||||
|
||||
#include <QKeySequence>
|
||||
|
||||
GlobalShortcut::GlobalShortcut()
|
||||
: GlobalShortcut(QString{}, QString{}, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
GlobalShortcut::GlobalShortcut(const QString &uniqueName, const QString &friendlyName, GlobalShortcutContext *context)
|
||||
: _isPresent(false)
|
||||
, _isRegistered(false)
|
||||
, _isFresh(true)
|
||||
, _registry(GlobalShortcutsRegistry::self())
|
||||
, _context(context)
|
||||
, _uniqueName(uniqueName)
|
||||
, _friendlyName(friendlyName)
|
||||
{
|
||||
if (_context) {
|
||||
_context->addShortcut(this);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut::~GlobalShortcut()
|
||||
{
|
||||
setInactive();
|
||||
}
|
||||
|
||||
GlobalShortcut::operator KGlobalShortcutInfo() const
|
||||
{
|
||||
KGlobalShortcutInfo info;
|
||||
info.d->uniqueName = _uniqueName;
|
||||
info.d->friendlyName = _friendlyName;
|
||||
info.d->contextUniqueName = context()->uniqueName();
|
||||
info.d->contextFriendlyName = context()->friendlyName();
|
||||
info.d->componentUniqueName = context()->component()->uniqueName();
|
||||
info.d->componentFriendlyName = context()->component()->friendlyName();
|
||||
for (const QKeySequence &key : std::as_const(_keys)) {
|
||||
info.d->keys.append(key);
|
||||
}
|
||||
for (const QKeySequence &key : std::as_const(_defaultKeys)) {
|
||||
info.d->defaultKeys.append(key);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
bool GlobalShortcut::isActive() const
|
||||
{
|
||||
return _isRegistered;
|
||||
}
|
||||
|
||||
bool GlobalShortcut::isFresh() const
|
||||
{
|
||||
return _isFresh;
|
||||
}
|
||||
|
||||
bool GlobalShortcut::isPresent() const
|
||||
{
|
||||
return _isPresent;
|
||||
}
|
||||
|
||||
bool GlobalShortcut::isSessionShortcut() const
|
||||
{
|
||||
return uniqueName().startsWith(QLatin1String("_k_session:"));
|
||||
}
|
||||
|
||||
void GlobalShortcut::setIsFresh(bool value)
|
||||
{
|
||||
_isFresh = value;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setIsPresent(bool value)
|
||||
{
|
||||
// (de)activate depending on old/new value
|
||||
_isPresent = value;
|
||||
if (_isPresent) {
|
||||
setActive();
|
||||
} else {
|
||||
setInactive();
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcutContext *GlobalShortcut::context()
|
||||
{
|
||||
return _context;
|
||||
}
|
||||
|
||||
GlobalShortcutContext const *GlobalShortcut::context() const
|
||||
{
|
||||
return _context;
|
||||
}
|
||||
|
||||
QString GlobalShortcut::uniqueName() const
|
||||
{
|
||||
return _uniqueName;
|
||||
}
|
||||
|
||||
void GlobalShortcut::unRegister()
|
||||
{
|
||||
return _context->component()->unregisterShortcut(uniqueName());
|
||||
}
|
||||
|
||||
QString GlobalShortcut::friendlyName() const
|
||||
{
|
||||
return _friendlyName;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setFriendlyName(const QString &name)
|
||||
{
|
||||
_friendlyName = name;
|
||||
}
|
||||
|
||||
QList<QKeySequence> GlobalShortcut::keys() const
|
||||
{
|
||||
return _keys;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setKeys(const QList<QKeySequence> &newKeys)
|
||||
{
|
||||
bool active = _isRegistered;
|
||||
if (active) {
|
||||
setInactive();
|
||||
}
|
||||
|
||||
_keys.clear();
|
||||
|
||||
auto getKey = [this](const QKeySequence &key) {
|
||||
if (key.isEmpty()) {
|
||||
qCDebug(KGLOBALACCELD) << _uniqueName << "skipping because key is empty";
|
||||
return QKeySequence{};
|
||||
}
|
||||
|
||||
if (_registry->getShortcutByKey(key) //
|
||||
|| _registry->getShortcutByKey(key, KGlobalAccel::MatchType::Shadowed) //
|
||||
|| _registry->getShortcutByKey(key, KGlobalAccel::MatchType::Shadows) //
|
||||
) {
|
||||
qCDebug(KGLOBALACCELD) << _uniqueName << "skipping because key" << QKeySequence(key).toString() << "is already taken";
|
||||
return QKeySequence{};
|
||||
}
|
||||
|
||||
return key;
|
||||
};
|
||||
|
||||
std::transform(newKeys.cbegin(), newKeys.cend(), std::back_inserter(_keys), getKey);
|
||||
|
||||
if (active) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QKeySequence> GlobalShortcut::defaultKeys() const
|
||||
{
|
||||
return _defaultKeys;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setDefaultKeys(const QList<QKeySequence> &newKeys)
|
||||
{
|
||||
_defaultKeys = newKeys;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setActive()
|
||||
{
|
||||
if (!_isPresent || _isRegistered) {
|
||||
// The corresponding application is not present or the keys are
|
||||
// already grabbed
|
||||
return;
|
||||
}
|
||||
|
||||
for (const QKeySequence &key : std::as_const(_keys)) {
|
||||
if (!key.isEmpty() && !_registry->registerKey(key, this)) {
|
||||
qCDebug(KGLOBALACCELD) << uniqueName() << ": Failed to register " << QKeySequence(key).toString();
|
||||
}
|
||||
}
|
||||
|
||||
_isRegistered = true;
|
||||
}
|
||||
|
||||
void GlobalShortcut::setInactive()
|
||||
{
|
||||
if (!_isRegistered) {
|
||||
// The keys are not grabbed currently
|
||||
return;
|
||||
}
|
||||
|
||||
for (const QKeySequence &key : std::as_const(_keys)) {
|
||||
if (!key.isEmpty() && !_registry->unregisterKey(key, this)) {
|
||||
qCDebug(KGLOBALACCELD) << uniqueName() << ": Failed to unregister " << QKeySequence(key).toString();
|
||||
}
|
||||
}
|
||||
|
||||
_isRegistered = false;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef GLOBALSHORTCUT_H
|
||||
#define GLOBALSHORTCUT_H
|
||||
|
||||
#include <KGlobalShortcutInfo>
|
||||
|
||||
class GlobalShortcutContext;
|
||||
class GlobalShortcutsRegistry;
|
||||
|
||||
/**
|
||||
* Represents a global shortcut.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* \note This class can handle multiple keys (default and active). This
|
||||
* feature isn't used currently. kde4 only allows setting one key per global
|
||||
* shortcut.
|
||||
*
|
||||
* @author Michael Jansen <kde@michael-jansen.biz>
|
||||
*/
|
||||
class GlobalShortcut
|
||||
{
|
||||
public:
|
||||
GlobalShortcut(const QString &uniqueName, const QString &friendlyName, GlobalShortcutContext *context);
|
||||
GlobalShortcut();
|
||||
|
||||
~GlobalShortcut();
|
||||
|
||||
//! Returns the context the shortcuts belongs to
|
||||
GlobalShortcutContext *context();
|
||||
GlobalShortcutContext const *context() const;
|
||||
|
||||
//! Returns the default keys for this shortcut.
|
||||
QList<QKeySequence> defaultKeys() const;
|
||||
|
||||
//! Return the friendly display name for this shortcut.
|
||||
QString friendlyName() const;
|
||||
|
||||
//! Check if the shortcut is active. It's keys are grabbed
|
||||
bool isActive() const;
|
||||
|
||||
//! Check if the shortcut is fresh/new. Is an internal state
|
||||
bool isFresh() const;
|
||||
|
||||
//! Check if the shortcut is present. It application is running.
|
||||
bool isPresent() const;
|
||||
|
||||
//! Returns true if the shortcut is a session shortcut
|
||||
bool isSessionShortcut() const;
|
||||
|
||||
//! Returns a list of keys associated with this shortcut.
|
||||
QList<QKeySequence> keys() const;
|
||||
|
||||
//! Activates the shortcut. The keys are grabbed.
|
||||
void setActive();
|
||||
|
||||
//! Sets the default keys for this shortcut.
|
||||
void setDefaultKeys(const QList<QKeySequence> &);
|
||||
|
||||
//! Sets the friendly name for the shortcut. For display.
|
||||
void setFriendlyName(const QString &);
|
||||
|
||||
//! Sets the shortcut inactive. No longer grabs the keys.
|
||||
void setInactive();
|
||||
|
||||
void setIsPresent(bool);
|
||||
void setIsFresh(bool);
|
||||
|
||||
//! Sets the keys activated with this shortcut. The old keys are freed.
|
||||
void setKeys(const QList<QKeySequence> &);
|
||||
|
||||
//! Returns the unique name aka id for the shortcuts.
|
||||
QString uniqueName() const;
|
||||
|
||||
operator KGlobalShortcutInfo() const;
|
||||
|
||||
//! Remove this shortcut and it's siblings
|
||||
void unRegister();
|
||||
|
||||
private:
|
||||
//! means the associated application is present.
|
||||
bool _isPresent : 1;
|
||||
|
||||
//! means the shortcut is registered with GlobalShortcutsRegistry
|
||||
bool _isRegistered : 1;
|
||||
|
||||
//! means the shortcut is new
|
||||
bool _isFresh : 1;
|
||||
|
||||
GlobalShortcutsRegistry *_registry = nullptr;
|
||||
|
||||
//! The context the shortcut belongs too
|
||||
GlobalShortcutContext *_context = nullptr;
|
||||
|
||||
QString _uniqueName;
|
||||
QString _friendlyName; // usually localized
|
||||
|
||||
QList<QKeySequence> _keys;
|
||||
QList<QKeySequence> _defaultKeys;
|
||||
};
|
||||
|
||||
#endif /* #ifndef GLOBALSHORTCUT_H */
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "globalshortcutcontext.h"
|
||||
|
||||
#include "globalshortcut.h"
|
||||
|
||||
#include "kglobalaccel.h"
|
||||
#include "sequencehelpers_p.h"
|
||||
|
||||
GlobalShortcutContext::GlobalShortcutContext(const QString &uniqueName, const QString &friendlyName, Component *component)
|
||||
|
||||
: _uniqueName(uniqueName)
|
||||
, _friendlyName(friendlyName)
|
||||
, _component(component)
|
||||
{
|
||||
}
|
||||
|
||||
GlobalShortcutContext::~GlobalShortcutContext()
|
||||
{
|
||||
qDeleteAll(_actionsMap);
|
||||
_actionsMap.clear();
|
||||
}
|
||||
|
||||
void GlobalShortcutContext::addShortcut(GlobalShortcut *shortcut)
|
||||
{
|
||||
_actionsMap.insert(shortcut->uniqueName(), shortcut);
|
||||
}
|
||||
|
||||
QList<KGlobalShortcutInfo> GlobalShortcutContext::allShortcutInfos() const
|
||||
{
|
||||
QList<KGlobalShortcutInfo> rc;
|
||||
for (GlobalShortcut *shortcut : std::as_const(_actionsMap)) {
|
||||
rc.append(static_cast<KGlobalShortcutInfo>(*shortcut));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Component const *GlobalShortcutContext::component() const
|
||||
{
|
||||
return _component;
|
||||
}
|
||||
|
||||
Component *GlobalShortcutContext::component()
|
||||
{
|
||||
return _component;
|
||||
}
|
||||
|
||||
QString GlobalShortcutContext::friendlyName() const
|
||||
{
|
||||
return _friendlyName;
|
||||
}
|
||||
|
||||
GlobalShortcut *GlobalShortcutContext::getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
if (key.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
QKeySequence keyMangled = Utils::mangleKey(key);
|
||||
for (GlobalShortcut *sc : std::as_const(_actionsMap)) {
|
||||
const auto keys = sc->keys();
|
||||
for (const QKeySequence &other : keys) {
|
||||
QKeySequence otherMangled = Utils::mangleKey(other);
|
||||
switch (type) {
|
||||
case KGlobalAccel::MatchType::Equal:
|
||||
if (otherMangled == keyMangled) {
|
||||
return sc;
|
||||
}
|
||||
break;
|
||||
case KGlobalAccel::MatchType::Shadows:
|
||||
if (!other.isEmpty() && Utils::contains(keyMangled, otherMangled)) {
|
||||
return sc;
|
||||
}
|
||||
break;
|
||||
case KGlobalAccel::MatchType::Shadowed:
|
||||
if (!other.isEmpty() && Utils::contains(otherMangled, keyMangled)) {
|
||||
return sc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GlobalShortcut *GlobalShortcutContext::takeShortcut(GlobalShortcut *shortcut)
|
||||
{
|
||||
// Try to take the shortcut. Result could be nullptr if the shortcut doesn't
|
||||
// belong to this component.
|
||||
return _actionsMap.take(shortcut->uniqueName());
|
||||
}
|
||||
|
||||
QString GlobalShortcutContext::uniqueName() const
|
||||
{
|
||||
return _uniqueName;
|
||||
}
|
||||
|
||||
bool GlobalShortcutContext::isShortcutAvailable(const QKeySequence &key) const
|
||||
{
|
||||
for (auto it = _actionsMap.cbegin(), endIt = _actionsMap.cend(); it != endIt; ++it) {
|
||||
const GlobalShortcut *sc = it.value();
|
||||
if (Utils::matchSequences(key, sc->keys())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef GLOBALSHORTCUTCONTEXT_H
|
||||
#define GLOBALSHORTCUTCONTEXT_H
|
||||
|
||||
#include "kglobalshortcutinfo.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include <kglobalaccel.h>
|
||||
|
||||
class Component;
|
||||
class GlobalShortcut;
|
||||
|
||||
/**
|
||||
* @author Michael Jansen <kde@michael-jansen.biz>
|
||||
*/
|
||||
class GlobalShortcutContext
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
GlobalShortcutContext(const QString &uniqueName, const QString &friendlyName, Component *component);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~GlobalShortcutContext();
|
||||
|
||||
//! Adds @p shortcut to the context
|
||||
void addShortcut(GlobalShortcut *shortcut);
|
||||
|
||||
//! Return KGlobalShortcutInfos for all shortcuts
|
||||
QList<KGlobalShortcutInfo> allShortcutInfos() const;
|
||||
|
||||
/**
|
||||
* Get the name for the context
|
||||
*/
|
||||
QString uniqueName() const;
|
||||
QString friendlyName() const;
|
||||
|
||||
Component *component();
|
||||
Component const *component() const;
|
||||
|
||||
//! Get shortcut for @p key or nullptr
|
||||
GlobalShortcut *getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const;
|
||||
|
||||
//! Remove @p shortcut from the context. The shortcut is not deleted.
|
||||
GlobalShortcut *takeShortcut(GlobalShortcut *shortcut);
|
||||
|
||||
// Returns true if key is not used by any global shortcuts in this context,
|
||||
// otherwise returns false
|
||||
bool isShortcutAvailable(const QKeySequence &key) const;
|
||||
|
||||
private:
|
||||
friend class Component;
|
||||
friend class KServiceActionComponent;
|
||||
|
||||
//! The unique name for this context
|
||||
QString _uniqueName;
|
||||
|
||||
//! The unique name for this context
|
||||
QString _friendlyName;
|
||||
|
||||
//! The component the context belongs to
|
||||
Component *_component = nullptr;
|
||||
|
||||
//! The actions associated with this context
|
||||
QHash<QString, GlobalShortcut *> _actionsMap;
|
||||
};
|
||||
|
||||
#endif /* #ifndef GLOBALSHORTCUTCONTEXT_H */
|
||||
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
SPDX-FileCopyrightText: 2022 Ahmad Samir <a.samirh78@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "globalshortcutsregistry.h"
|
||||
#include "component.h"
|
||||
#include "globalshortcut.h"
|
||||
#include "globalshortcutcontext.h"
|
||||
#include "kglobalaccel_interface.h"
|
||||
#include "kglobalshortcutinfo_p.h"
|
||||
#include "kserviceactioncomponent.h"
|
||||
#include "logging_p.h"
|
||||
#include <config-kglobalaccel.h>
|
||||
|
||||
#include <KDesktopFile>
|
||||
#include <KFileUtils>
|
||||
#include <KPluginMetaData>
|
||||
|
||||
#include <KApplicationTrader>
|
||||
#include <QDBusConnection>
|
||||
#include <QDir>
|
||||
#include <QGuiApplication>
|
||||
#include <QJsonArray>
|
||||
#include <QPluginLoader>
|
||||
#include <QStandardPaths>
|
||||
|
||||
static bool checkPlatform(const QJsonObject &metadata, const QString &platformName)
|
||||
{
|
||||
const QJsonArray platforms = metadata.value(QStringLiteral("MetaData")).toObject().value(QStringLiteral("platforms")).toArray();
|
||||
return std::any_of(platforms.begin(), platforms.end(), [&platformName](const QJsonValue &value) {
|
||||
return QString::compare(platformName, value.toString(), Qt::CaseInsensitive) == 0;
|
||||
});
|
||||
}
|
||||
|
||||
static KGlobalAccelInterface *loadPlugin(GlobalShortcutsRegistry *parent)
|
||||
{
|
||||
QString platformName = QString::fromLocal8Bit(qgetenv("KGLOBALACCELD_PLATFORM"));
|
||||
if (platformName.isEmpty()) {
|
||||
platformName = QGuiApplication::platformName();
|
||||
}
|
||||
|
||||
const QList<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins();
|
||||
for (const QStaticPlugin &staticPlugin : staticPlugins) {
|
||||
const QJsonObject metadata = staticPlugin.metaData();
|
||||
if (metadata.value(QLatin1String("IID")) != QLatin1String(KGlobalAccelInterface_iid)) {
|
||||
continue;
|
||||
}
|
||||
if (checkPlatform(metadata, platformName)) {
|
||||
KGlobalAccelInterface *interface = qobject_cast<KGlobalAccelInterface *>(staticPlugin.instance());
|
||||
if (interface) {
|
||||
qCDebug(KGLOBALACCELD) << "Loaded a static plugin for platform" << platformName;
|
||||
interface->setRegistry(parent);
|
||||
return interface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QList<KPluginMetaData> candidates = KPluginMetaData::findPlugins(QStringLiteral("org.kde.kglobalacceld.platforms"));
|
||||
for (const KPluginMetaData &candidate : candidates) {
|
||||
QPluginLoader loader(candidate.fileName());
|
||||
if (checkPlatform(loader.metaData(), platformName)) {
|
||||
KGlobalAccelInterface *interface = qobject_cast<KGlobalAccelInterface *>(loader.instance());
|
||||
if (interface) {
|
||||
qCDebug(KGLOBALACCELD) << "Loaded plugin" << candidate.fileName() << "for platform" << platformName;
|
||||
interface->setRegistry(parent);
|
||||
return interface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCWarning(KGLOBALACCELD) << "Could not find any platform plugin";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static QString getConfigFile()
|
||||
{
|
||||
return qEnvironmentVariableIsSet("KGLOBALACCEL_TEST_MODE") ? QString() : QStringLiteral("kglobalshortcutsrc");
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::migrateKHotkeys()
|
||||
{
|
||||
KConfig hotkeys(QStringLiteral("khotkeysrc"));
|
||||
|
||||
int dataCount = hotkeys.group(QStringLiteral("Data")).readEntry("DataCount", 0);
|
||||
|
||||
for (int i = 1; i <= dataCount; ++i) {
|
||||
const QString groupName = QStringLiteral("Data_") + QString::number(i);
|
||||
|
||||
KConfigGroup dataGroup(&hotkeys, groupName);
|
||||
|
||||
if (dataGroup.readEntry("Type") != QLatin1String("SIMPLE_ACTION_DATA")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString name = dataGroup.readEntry("Name");
|
||||
|
||||
QString exec;
|
||||
QString uuid;
|
||||
|
||||
int actionsCount = KConfigGroup(&hotkeys, groupName + QLatin1String("Actions")).readEntry("ActionsCount", 0);
|
||||
|
||||
for (int i = 0; i < actionsCount; ++i) {
|
||||
KConfigGroup actionGroup = KConfigGroup(&hotkeys, groupName + QLatin1String("Actions") + QString::number(i));
|
||||
const QString type = actionGroup.readEntry("Type");
|
||||
|
||||
if (type == QLatin1String("COMMAND_URL")) {
|
||||
exec = actionGroup.readEntry("CommandURL");
|
||||
} else if (type == QLatin1String("DBUS")) {
|
||||
exec = QStringLiteral(QT_STRINGIFY(QDBUS) " %1 %2 %3")
|
||||
.arg(actionGroup.readEntry("RemoteApp"), actionGroup.readEntry("RemoteObj"), actionGroup.readEntry("Call"));
|
||||
|
||||
const QString args = actionGroup.readEntry("Arguments");
|
||||
|
||||
if (!args.isEmpty()) {
|
||||
exec += QLatin1Char(' ') + args;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exec.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int triggerCount = KConfigGroup(&hotkeys, groupName + QLatin1String("Triggers")).readEntry("TriggersCount", 0);
|
||||
|
||||
for (int i = 0; i < triggerCount; ++i) {
|
||||
KConfigGroup triggerGroup = KConfigGroup(&hotkeys, groupName + QLatin1String("Triggers") + QString::number(i));
|
||||
if (triggerGroup.readEntry("Type") != QLatin1String("SHORTCUT")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uuid = triggerGroup.readEntry("Uuid");
|
||||
}
|
||||
|
||||
const QString kglobalaccelEntry = _config.group(QStringLiteral("khotkeys")).readEntry(uuid);
|
||||
|
||||
if (kglobalaccelEntry.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString key = kglobalaccelEntry.split(QLatin1Char(',')).first();
|
||||
|
||||
KDesktopFile file(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kglobalaccel/") + uuid
|
||||
+ QLatin1String(".desktop"));
|
||||
file.desktopGroup().writeEntry("Type", "Application");
|
||||
file.desktopGroup().writeEntry("Name", name);
|
||||
file.desktopGroup().writeEntry("Exec", exec);
|
||||
file.desktopGroup().writeEntry("X-KDE-GlobalAccel-CommandShortcut", true);
|
||||
file.desktopGroup().writeEntry("StartupNotify", false);
|
||||
|
||||
_config.group(QStringLiteral("services")).group(uuid + QLatin1String(".desktop")).writeEntry("_launch", kglobalaccelEntry);
|
||||
_config.group(QStringLiteral("khotkeys")).revertToDefault(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Migrate the config for service actions to a new format that only stores the actual shortcut if not default.
|
||||
* All other information is read from the desktop file.
|
||||
* Keep the old data for compatibility with KF5-based kglobalaccel.
|
||||
* Once Plasma 6 settles down consider dropping this data
|
||||
*/
|
||||
void GlobalShortcutsRegistry::migrateConfig()
|
||||
{
|
||||
const QStringList groups = _config.groupList();
|
||||
|
||||
KConfigGroup services = _config.group(QStringLiteral("services"));
|
||||
|
||||
for (const QString &componentName : groups) {
|
||||
if (!componentName.endsWith(QLatin1String(".desktop"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KConfigGroup component = _config.group(componentName);
|
||||
KConfigGroup newGroup = services.group(componentName);
|
||||
|
||||
for (auto [key, value] : component.entryMap().asKeyValueRange()) {
|
||||
if (key == QLatin1String("_k_friendly_name")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString shortcut = value.split(QLatin1Char(','))[0];
|
||||
const QString defaultShortcut = value.split(QLatin1Char(','))[1];
|
||||
|
||||
if (shortcut != defaultShortcut) {
|
||||
newGroup.writeEntry(key, shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
component.deleteGroup();
|
||||
}
|
||||
|
||||
// Migrate dynamic shortcuts to service-based shortcuts
|
||||
const QStringList desktopPaths =
|
||||
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kglobalaccel"), QStandardPaths::LocateDirectory);
|
||||
|
||||
const QStringList desktopFiles = KFileUtils::findAllUniqueFiles(desktopPaths, {QStringLiteral("*.desktop")});
|
||||
|
||||
for (const QString &fileName : desktopFiles) {
|
||||
KDesktopFile file(fileName);
|
||||
const QString componentName = QFileInfo(fileName).fileName();
|
||||
|
||||
auto migrateTo = [this, componentName](KConfigGroup &group, const QString &actionName, const QString displayName) {
|
||||
QString migrateFrom = group.readEntry<QString>(QStringLiteral("X-KDE-Migrate-Shortcut"), QString());
|
||||
|
||||
if (migrateFrom.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QStringList migrateFromParts = migrateFrom.split(QLatin1Char(','));
|
||||
|
||||
if (!_config.group(migrateFromParts[0]).hasKey(migrateFromParts[1])) {
|
||||
// Probably already migrated
|
||||
return;
|
||||
}
|
||||
|
||||
const QStringList shortcutTriple = _config.group(migrateFromParts[0]).readEntry<QStringList>(migrateFromParts[1], QStringList());
|
||||
const QString oldShortcut = shortcutTriple[0];
|
||||
const QString oldDefaultShortcut = shortcutTriple[1];
|
||||
const QString newDefaultShortcut = group.readEntry<QString>("X-KDE-Shortcuts", QString());
|
||||
|
||||
// Only write value if it is not the old or new default
|
||||
if (oldShortcut != oldDefaultShortcut && oldShortcut != newDefaultShortcut) {
|
||||
_config.group(QStringLiteral("services")).group(componentName).writeEntry(actionName, oldShortcut);
|
||||
}
|
||||
|
||||
_config.group(migrateFromParts[0]).deleteEntry(migrateFromParts[1]);
|
||||
|
||||
if (_config.group(migrateFromParts[0]).entryMap().size() == 1) {
|
||||
// only _k_friendly_name left, remove the group
|
||||
_config.deleteGroup(migrateFromParts[0]);
|
||||
}
|
||||
};
|
||||
|
||||
KConfigGroup desktopGroup = file.desktopGroup();
|
||||
migrateTo(desktopGroup, QStringLiteral("_launch"), file.readName());
|
||||
|
||||
const QStringList actions = file.readActions();
|
||||
for (const QString &action : actions) {
|
||||
KConfigGroup actionGroup = file.actionGroup(action);
|
||||
migrateTo(actionGroup, action, file.actionGroup(action).readEntry<QString>("Name", QString()));
|
||||
}
|
||||
}
|
||||
|
||||
_config.sync();
|
||||
}
|
||||
|
||||
GlobalShortcutsRegistry::GlobalShortcutsRegistry()
|
||||
: QObject()
|
||||
, _manager(loadPlugin(this))
|
||||
, _config(getConfigFile(), KConfig::SimpleConfig)
|
||||
{
|
||||
migrateKHotkeys();
|
||||
migrateConfig();
|
||||
|
||||
if (_manager) {
|
||||
_manager->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcutsRegistry::~GlobalShortcutsRegistry()
|
||||
{
|
||||
m_components.clear();
|
||||
|
||||
if (_manager) {
|
||||
_manager->setEnabled(false);
|
||||
|
||||
// Ungrab all keys. We don't go over GlobalShortcuts because
|
||||
// GlobalShortcutsRegistry::self() doesn't work anymore.
|
||||
const auto listKeys = _active_keys.keys();
|
||||
for (const QKeySequence &key : listKeys) {
|
||||
for (int i = 0; i < key.count(); i++) {
|
||||
_manager->grabKey(key[i].toCombined(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
_active_keys.clear();
|
||||
_keys_count.clear();
|
||||
}
|
||||
|
||||
Component *GlobalShortcutsRegistry::registerComponent(ComponentPtr component)
|
||||
{
|
||||
m_components.push_back(std::move(component));
|
||||
auto *comp = m_components.back().get();
|
||||
Q_ASSERT(!comp->dbusPath().path().isEmpty());
|
||||
QDBusConnection conn(QDBusConnection::sessionBus());
|
||||
conn.registerObject(comp->dbusPath().path(), comp, QDBusConnection::ExportScriptableContents);
|
||||
return comp;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::activateShortcuts()
|
||||
{
|
||||
for (auto &component : m_components) {
|
||||
component->activateShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> GlobalShortcutsRegistry::componentsDbusPaths() const
|
||||
{
|
||||
QList<QDBusObjectPath> dbusPaths;
|
||||
dbusPaths.reserve(m_components.size());
|
||||
std::transform(m_components.cbegin(), m_components.cend(), std::back_inserter(dbusPaths), [](const auto &comp) {
|
||||
return comp->dbusPath();
|
||||
});
|
||||
return dbusPaths;
|
||||
}
|
||||
|
||||
QList<QStringList> GlobalShortcutsRegistry::allComponentNames() const
|
||||
{
|
||||
QList<QStringList> ret;
|
||||
ret.reserve(m_components.size());
|
||||
std::transform(m_components.cbegin(), m_components.cend(), std::back_inserter(ret), [](const auto &component) {
|
||||
// A string for each enumerator in KGlobalAccel::actionIdFields
|
||||
return QStringList{component->uniqueName(), component->friendlyName(), {}, {}};
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::clear()
|
||||
{
|
||||
m_components.clear();
|
||||
|
||||
// The shortcuts should have deregistered themselves
|
||||
Q_ASSERT(_active_keys.isEmpty());
|
||||
}
|
||||
|
||||
QDBusObjectPath GlobalShortcutsRegistry::dbusPath() const
|
||||
{
|
||||
return _dbusPath;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::deactivateShortcuts(bool temporarily)
|
||||
{
|
||||
for (ComponentPtr &component : m_components) {
|
||||
component->deactivateShortcuts(temporarily);
|
||||
}
|
||||
}
|
||||
|
||||
Component *GlobalShortcutsRegistry::getComponent(const QString &uniqueName)
|
||||
{
|
||||
auto it = findByName(uniqueName);
|
||||
return it != m_components.cend() ? (*it).get() : nullptr;
|
||||
}
|
||||
|
||||
GlobalShortcut *GlobalShortcutsRegistry::getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
for (const ComponentPtr &component : m_components) {
|
||||
GlobalShortcut *rc = component->getShortcutByKey(key, type);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<GlobalShortcut *> GlobalShortcutsRegistry::getShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
QList<GlobalShortcut *> rc;
|
||||
for (const ComponentPtr &component : m_components) {
|
||||
rc = component->getShortcutsByKey(key, type);
|
||||
if (!rc.isEmpty()) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
bool GlobalShortcutsRegistry::isShortcutAvailable(const QKeySequence &shortcut, const QString &componentName, const QString &contextName) const
|
||||
{
|
||||
return std::all_of(m_components.cbegin(), m_components.cend(), [&shortcut, &componentName, &contextName](const ComponentPtr &component) {
|
||||
return component->isShortcutAvailable(shortcut, componentName, contextName);
|
||||
});
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(GlobalShortcutsRegistry, _self)
|
||||
GlobalShortcutsRegistry *GlobalShortcutsRegistry::self()
|
||||
{
|
||||
return _self;
|
||||
}
|
||||
|
||||
static void correctKeyEvent(int &keyQt)
|
||||
{
|
||||
// When we are provided just a Shift key press, interpret it as "Shift" not as "Shift+Shift"
|
||||
switch (keyQt) {
|
||||
case (Qt::ShiftModifier | Qt::Key_Shift).toCombined():
|
||||
keyQt = Qt::Key_Shift;
|
||||
break;
|
||||
case (Qt::ControlModifier | Qt::Key_Control).toCombined():
|
||||
keyQt = Qt::Key_Control;
|
||||
break;
|
||||
case (Qt::AltModifier | Qt::Key_Alt).toCombined():
|
||||
keyQt = Qt::Key_Alt;
|
||||
break;
|
||||
case (Qt::MetaModifier | Qt::Key_Meta).toCombined():
|
||||
keyQt = Qt::Key_Meta;
|
||||
break;
|
||||
}
|
||||
// Known limitation:
|
||||
// When shortcut is Mod(s)+Alt+Print, only works when Alt is released before Mod(s),
|
||||
// Does not work with multikey shortcuts.
|
||||
// When the user presses Mod(s)+Alt+Print, the SysReq event is fired only
|
||||
// when the Alt key is released. Before we get the Mod(s)+SysReq event, we
|
||||
// first get a Mod(s)+Alt event, breaking multikey shortcuts.
|
||||
if ((keyQt & ~Qt::KeyboardModifierMask) == Qt::Key_SysReq) {
|
||||
keyQt = Qt::Key_Print | (keyQt & Qt::KeyboardModifierMask) | Qt::AltModifier;
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalShortcutsRegistry::keyPressed(int keyQt)
|
||||
{
|
||||
correctKeyEvent(keyQt);
|
||||
int keys[maxSequenceLength] = {0, 0, 0, 0};
|
||||
int count = _active_sequence.count();
|
||||
if (count == maxSequenceLength) {
|
||||
// buffer is full, rotate it
|
||||
for (int i = 1; i < count; i++) {
|
||||
keys[i - 1] = _active_sequence[i].toCombined();
|
||||
}
|
||||
keys[maxSequenceLength - 1] = keyQt;
|
||||
} else {
|
||||
// just append the new key
|
||||
for (int i = 0; i < count; i++) {
|
||||
keys[i] = _active_sequence[i].toCombined();
|
||||
}
|
||||
keys[count] = keyQt;
|
||||
}
|
||||
|
||||
_active_sequence = QKeySequence(keys[0], keys[1], keys[2], keys[3]);
|
||||
|
||||
GlobalShortcut *shortcut = nullptr;
|
||||
QKeySequence tempSequence;
|
||||
for (int length = 1; length <= _active_sequence.count(); length++) {
|
||||
// We have to check all possible matches from the end since we're rotating active sequence
|
||||
// instead of cleaning it when it's full
|
||||
int sequenceToCheck[maxSequenceLength] = {0, 0, 0, 0};
|
||||
for (int i = 0; i < length; i++) {
|
||||
sequenceToCheck[i] = _active_sequence[_active_sequence.count() - length + i].toCombined();
|
||||
}
|
||||
tempSequence = QKeySequence(sequenceToCheck[0], sequenceToCheck[1], sequenceToCheck[2], sequenceToCheck[3]);
|
||||
shortcut = getShortcutByKey(tempSequence);
|
||||
|
||||
if (shortcut) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qCDebug(KGLOBALACCELD) << "Pressed key" << QKeySequence(keyQt).toString() << ", current sequence" << _active_sequence.toString() << "="
|
||||
<< (shortcut ? shortcut->uniqueName() : QStringLiteral("(no shortcut found)"));
|
||||
if (!shortcut) {
|
||||
// This can happen for example with the ALT-Print shortcut of kwin.
|
||||
// ALT+PRINT is SYSREQ on my keyboard. So we grab something we think
|
||||
// is ALT+PRINT but symXToKeyQt and modXToQt make ALT+SYSREQ of it
|
||||
// when pressed (correctly). We can't match that.
|
||||
qCDebug(KGLOBALACCELD) << "Got unknown key" << QKeySequence(keyQt).toString();
|
||||
|
||||
// In production mode just do nothing.
|
||||
return false;
|
||||
} else if (!shortcut->isActive()) {
|
||||
qCDebug(KGLOBALACCELD) << "Got inactive key" << QKeySequence(keyQt).toString();
|
||||
|
||||
// In production mode just do nothing.
|
||||
return false;
|
||||
}
|
||||
|
||||
qCDebug(KGLOBALACCELD) << QKeySequence(keyQt).toString() << "=" << shortcut->uniqueName();
|
||||
|
||||
// shortcut is found, reset active sequence
|
||||
_active_sequence = QKeySequence();
|
||||
|
||||
QStringList data(shortcut->context()->component()->uniqueName());
|
||||
data.append(shortcut->uniqueName());
|
||||
data.append(shortcut->context()->component()->friendlyName());
|
||||
data.append(shortcut->friendlyName());
|
||||
|
||||
if (m_lastShortcut && m_lastShortcut != shortcut) {
|
||||
m_lastShortcut->context()->component()->emitGlobalShortcutReleased(*m_lastShortcut);
|
||||
}
|
||||
|
||||
// Invoke the action
|
||||
shortcut->context()->component()->emitGlobalShortcutPressed(*shortcut);
|
||||
m_lastShortcut = shortcut;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GlobalShortcutsRegistry::keyReleased(int keyQt)
|
||||
{
|
||||
Q_UNUSED(keyQt)
|
||||
if (m_lastShortcut) {
|
||||
m_lastShortcut->context()->component()->emitGlobalShortcutReleased(*m_lastShortcut);
|
||||
m_lastShortcut = nullptr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Component *GlobalShortcutsRegistry::createComponent(const QString &uniqueName, const QString &friendlyName)
|
||||
{
|
||||
auto it = findByName(uniqueName);
|
||||
if (it != m_components.cend()) {
|
||||
Q_ASSERT_X(false, //
|
||||
"GlobalShortcutsRegistry::createComponent",
|
||||
QLatin1String("A Component with the name: %1, already exists").arg(uniqueName).toUtf8().constData());
|
||||
return (*it).get();
|
||||
}
|
||||
|
||||
auto *c = registerComponent(ComponentPtr(new Component(uniqueName, friendlyName), &unregisterComponent));
|
||||
return c;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::unregisterComponent(Component *component)
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterObject(component->dbusPath().path());
|
||||
delete component;
|
||||
}
|
||||
|
||||
KServiceActionComponent *GlobalShortcutsRegistry::createServiceActionComponent(KService::Ptr service)
|
||||
{
|
||||
auto it = findByName(service->storageId());
|
||||
if (it != m_components.cend()) {
|
||||
Q_ASSERT_X(false, //
|
||||
"GlobalShortcutsRegistry::createServiceActionComponent",
|
||||
QLatin1String("A KServiceActionComponent with the name: %1, already exists").arg(service->storageId()).toUtf8().constData());
|
||||
return static_cast<KServiceActionComponent *>((*it).get());
|
||||
}
|
||||
|
||||
auto *c = registerComponent(ComponentPtr(new KServiceActionComponent(service), &unregisterComponent));
|
||||
return static_cast<KServiceActionComponent *>(c);
|
||||
}
|
||||
|
||||
KServiceActionComponent *GlobalShortcutsRegistry::createServiceActionComponent(const QString &uniqueName)
|
||||
|
||||
{
|
||||
auto it = findByName(uniqueName);
|
||||
if (it != m_components.cend()) {
|
||||
Q_ASSERT_X(false, //
|
||||
"GlobalShortcutsRegistry::createServiceActionComponent",
|
||||
QLatin1String("A KServiceActionComponent with the name: %1, already exists").arg(uniqueName).toUtf8().constData());
|
||||
return static_cast<KServiceActionComponent *>((*it).get());
|
||||
}
|
||||
|
||||
KService::Ptr service = KService::serviceByStorageId(uniqueName);
|
||||
|
||||
if (!service) {
|
||||
const QString filePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kglobalaccel/") + uniqueName);
|
||||
if (filePath.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
service = new KService(filePath);
|
||||
}
|
||||
|
||||
auto *c = registerComponent(ComponentPtr(new KServiceActionComponent(service), &unregisterComponent));
|
||||
|
||||
return static_cast<KServiceActionComponent *>(c);
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::loadSettings()
|
||||
{
|
||||
if (!m_components.empty()) {
|
||||
qCDebug(KGLOBALACCELD) << "Registry settings already loaded. Skipped loading again.";
|
||||
return;
|
||||
}
|
||||
|
||||
auto groupList = _config.groupList();
|
||||
for (const QString &groupName : groupList) {
|
||||
if (groupName == QLatin1String("services")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (groupName.endsWith(QLatin1String(".desktop"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
qCDebug(KGLOBALACCELD) << "Loading group " << groupName;
|
||||
|
||||
Q_ASSERT(groupName.indexOf(QLatin1Char('\x1d')) == -1);
|
||||
|
||||
// loadSettings isn't designed to be called in between. Only at the
|
||||
// beginning.
|
||||
Q_ASSERT(!getComponent(groupName));
|
||||
|
||||
KConfigGroup configGroup(&_config, groupName);
|
||||
|
||||
const QString friendlyName = configGroup.readEntry("_k_friendly_name");
|
||||
|
||||
Component *component = createComponent(groupName, friendlyName);
|
||||
|
||||
// Now load the contexts
|
||||
const auto groupList = configGroup.groupList();
|
||||
for (const QString &context : groupList) {
|
||||
// Skip the friendly name group, this was previously used instead of _k_friendly_name
|
||||
if (context == QLatin1String("Friendly Name")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KConfigGroup contextGroup(&configGroup, context);
|
||||
QString contextFriendlyName = contextGroup.readEntry("_k_friendly_name");
|
||||
component->createGlobalShortcutContext(context, contextFriendlyName);
|
||||
component->activateGlobalShortcutContext(context);
|
||||
component->loadSettings(contextGroup);
|
||||
}
|
||||
|
||||
// Load the default context
|
||||
component->activateGlobalShortcutContext(QStringLiteral("default"));
|
||||
component->loadSettings(configGroup);
|
||||
}
|
||||
|
||||
groupList = _config.group(QStringLiteral("services")).groupList();
|
||||
for (const QString &groupName : groupList) {
|
||||
qCDebug(KGLOBALACCELD) << "Loading group " << groupName;
|
||||
|
||||
Q_ASSERT(groupName.indexOf(QLatin1Char('\x1d')) == -1);
|
||||
|
||||
// loadSettings isn't designed to be called in between. Only at the
|
||||
// beginning.
|
||||
Q_ASSERT(!getComponent(groupName));
|
||||
|
||||
KConfigGroup configGroup = _config.group(QStringLiteral("services")).group(groupName);
|
||||
|
||||
Component *component = createServiceActionComponent(groupName);
|
||||
|
||||
if (!component) {
|
||||
qDebug() << "could not create a component for " << groupName;
|
||||
continue;
|
||||
}
|
||||
Q_ASSERT(!component->uniqueName().isEmpty());
|
||||
|
||||
// Now load the contexts
|
||||
const auto groupList = configGroup.groupList();
|
||||
for (const QString &context : groupList) {
|
||||
// Skip the friendly name group, this was previously used instead of _k_friendly_name
|
||||
if (context == QLatin1String("Friendly Name")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KConfigGroup contextGroup(&configGroup, context);
|
||||
QString contextFriendlyName = contextGroup.readEntry("_k_friendly_name");
|
||||
component->createGlobalShortcutContext(context, contextFriendlyName);
|
||||
component->activateGlobalShortcutContext(context);
|
||||
component->loadSettings(contextGroup);
|
||||
}
|
||||
|
||||
// Load the default context
|
||||
component->activateGlobalShortcutContext(QStringLiteral("default"));
|
||||
component->loadSettings(configGroup);
|
||||
}
|
||||
|
||||
// Load the configured KServiceActions
|
||||
const QStringList desktopPaths =
|
||||
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kglobalaccel"), QStandardPaths::LocateDirectory);
|
||||
|
||||
const QStringList desktopFiles = KFileUtils::findAllUniqueFiles(desktopPaths, {QStringLiteral("*.desktop")});
|
||||
|
||||
for (const QString &file : desktopFiles) {
|
||||
const QString fileName = QFileInfo(file).fileName();
|
||||
auto it = findByName(fileName);
|
||||
if (it != m_components.cend()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KService::Ptr service(new KService(file));
|
||||
if (service->noDisplay()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto *actionComp = createServiceActionComponent(service);
|
||||
actionComp->activateGlobalShortcutContext(QStringLiteral("default"));
|
||||
actionComp->loadFromService();
|
||||
}
|
||||
|
||||
auto appsWithShortcuts = KApplicationTrader::query([](const KService::Ptr &service) {
|
||||
return !service->property<QString>(QStringLiteral("X-KDE-Shortcuts")).isEmpty();
|
||||
});
|
||||
|
||||
for (auto service : appsWithShortcuts) {
|
||||
auto it = findByName(service->storageId());
|
||||
if (it != m_components.cend()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto *actionComp = createServiceActionComponent(service);
|
||||
actionComp->activateGlobalShortcutContext(QStringLiteral("default"));
|
||||
actionComp->loadFromService();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::grabKeys()
|
||||
{
|
||||
activateShortcuts();
|
||||
}
|
||||
|
||||
bool GlobalShortcutsRegistry::registerKey(const QKeySequence &key, GlobalShortcut *shortcut)
|
||||
{
|
||||
if (!_manager) {
|
||||
return false;
|
||||
}
|
||||
if (key.isEmpty()) {
|
||||
qCDebug(KGLOBALACCELD) << shortcut->uniqueName() << ": Key '" << QKeySequence(key).toString() << "' already taken by "
|
||||
<< _active_keys.value(key)->uniqueName() << ".";
|
||||
return false;
|
||||
} else if (_active_keys.value(key)) {
|
||||
qCDebug(KGLOBALACCELD) << shortcut->uniqueName() << ": Attempt to register key 0.";
|
||||
return false;
|
||||
}
|
||||
|
||||
qCDebug(KGLOBALACCELD) << "Registering key" << QKeySequence(key).toString() << "for" << shortcut->context()->component()->uniqueName() << ":"
|
||||
<< shortcut->uniqueName();
|
||||
|
||||
bool error = false;
|
||||
int i;
|
||||
for (i = 0; i < key.count(); i++) {
|
||||
const int combined = key[i].toCombined();
|
||||
if (!_manager->grabKey(combined, true)) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
++_keys_count[combined];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
// Last key was not registered, rewind index by 1
|
||||
for (--i; i >= 0; i--) {
|
||||
const int combined = key[i].toCombined();
|
||||
auto it = _keys_count.find(combined);
|
||||
if (it == _keys_count.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (it.value() == 1) {
|
||||
_keys_count.erase(it);
|
||||
_manager->grabKey(combined, false);
|
||||
} else {
|
||||
--(it.value());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_active_keys.insert(key, shortcut);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::setDBusPath(const QDBusObjectPath &path)
|
||||
{
|
||||
_dbusPath = path;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::ungrabKeys()
|
||||
{
|
||||
deactivateShortcuts();
|
||||
}
|
||||
|
||||
bool GlobalShortcutsRegistry::unregisterKey(const QKeySequence &key, GlobalShortcut *shortcut)
|
||||
{
|
||||
if (!_manager) {
|
||||
return false;
|
||||
}
|
||||
if (_active_keys.value(key) != shortcut) {
|
||||
// The shortcut doesn't own the key or the key isn't grabbed
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < key.count(); i++) {
|
||||
auto iter = _keys_count.find(key[i].toCombined());
|
||||
if ((iter == _keys_count.end()) || (iter.value() <= 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unregister if there's only one ref to given key
|
||||
// We should fail earlier when key is not registered
|
||||
if (iter.value() == 1) {
|
||||
qCDebug(KGLOBALACCELD) << "Unregistering key" << QKeySequence(key[i]).toString() << "for" << shortcut->context()->component()->uniqueName() << ":"
|
||||
<< shortcut->uniqueName();
|
||||
|
||||
_manager->grabKey(key[i].toCombined(), false);
|
||||
_keys_count.erase(iter);
|
||||
} else {
|
||||
qCDebug(KGLOBALACCELD) << "Refused to unregister key" << QKeySequence(key[i]).toString() << ": used by another global shortcut";
|
||||
--(iter.value());
|
||||
}
|
||||
}
|
||||
|
||||
if (shortcut && shortcut == m_lastShortcut) {
|
||||
m_lastShortcut->context()->component()->emitGlobalShortcutReleased(*m_lastShortcut);
|
||||
m_lastShortcut = nullptr;
|
||||
}
|
||||
|
||||
_active_keys.remove(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GlobalShortcutsRegistry::writeSettings()
|
||||
{
|
||||
auto it = std::remove_if(m_components.begin(), m_components.end(), [this](const ComponentPtr &component) {
|
||||
bool isService = component->uniqueName().endsWith(QLatin1String(".desktop"));
|
||||
|
||||
KConfigGroup configGroup =
|
||||
isService ? _config.group(QStringLiteral("services")).group(component->uniqueName()) : _config.group(component->uniqueName());
|
||||
|
||||
if (component->allShortcuts().isEmpty()) {
|
||||
configGroup.deleteGroup();
|
||||
return true;
|
||||
} else {
|
||||
component->writeSettings(configGroup);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
m_components.erase(it, m_components.end());
|
||||
_config.sync();
|
||||
}
|
||||
|
||||
#include "moc_globalshortcutsregistry.cpp"
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef GLOBALSHORTCUTSREGISTRY_H
|
||||
#define GLOBALSHORTCUTSREGISTRY_H
|
||||
|
||||
#include "kglobalaccel.h"
|
||||
|
||||
#include "component.h"
|
||||
#include "kserviceactioncomponent.h"
|
||||
|
||||
#include <KSharedConfig>
|
||||
|
||||
#include <QDBusObjectPath>
|
||||
#include <QHash>
|
||||
#include <QKeySequence>
|
||||
#include <QObject>
|
||||
|
||||
#include "kglobalaccel_export.h"
|
||||
|
||||
class Component;
|
||||
class GlobalShortcut;
|
||||
class KGlobalAccelInterface;
|
||||
|
||||
/**
|
||||
* Global Shortcut Registry.
|
||||
*
|
||||
* Shortcuts are registered by component. A component is for example kmail or
|
||||
* amarok.
|
||||
*
|
||||
* A component can have contexts. Currently on plasma is planned to support
|
||||
* that feature. A context enables plasma to keep track of global shortcut
|
||||
* settings when switching containments.
|
||||
*
|
||||
* A shortcut (WIN+x) can be registered by one component only. The component
|
||||
* is allowed to register it more than once in different contexts.
|
||||
*
|
||||
* @author Michael Jansen <kde@michael-jansen.biz>
|
||||
*/
|
||||
class KGLOBALACCEL_EXPORT GlobalShortcutsRegistry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.KdedGlobalAccel.GlobalShortcutsRegistry")
|
||||
|
||||
public:
|
||||
/**
|
||||
* Use GlobalShortcutsRegistry::self()
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
GlobalShortcutsRegistry();
|
||||
~GlobalShortcutsRegistry() override;
|
||||
|
||||
/**
|
||||
* Activate all shortcuts having their application present.
|
||||
*/
|
||||
void activateShortcuts();
|
||||
|
||||
/**
|
||||
* Returns a list of D-Bus paths of registered Components.
|
||||
*
|
||||
* The returned paths are absolute (i.e. no need to prepend anything).
|
||||
*/
|
||||
QList<QDBusObjectPath> componentsDbusPaths() const;
|
||||
|
||||
/**
|
||||
* Returns a list of QStringLists (one string list per registered component,
|
||||
* with each string list containing four strings, one for each enumerator in
|
||||
* KGlobalAccel::actionIdFields).
|
||||
*/
|
||||
QList<QStringList> allComponentNames() const;
|
||||
|
||||
/**
|
||||
* Return the root dbus path for the registry.
|
||||
*/
|
||||
QDBusObjectPath dbusPath() const;
|
||||
|
||||
/**
|
||||
* Deactivate all currently active shortcuts.
|
||||
*/
|
||||
void deactivateShortcuts(bool temporarily = false);
|
||||
|
||||
/**
|
||||
*/
|
||||
Component *getComponent(const QString &uniqueName);
|
||||
|
||||
/**
|
||||
* Get the shortcut corresponding to key. Active and inactive shortcuts
|
||||
* are considered. But if the matching application uses contexts only one
|
||||
* shortcut is returned.
|
||||
*
|
||||
* @see getShortcutsByKey(int key)
|
||||
*/
|
||||
GlobalShortcut *getShortcutByKey(const QKeySequence &key, KGlobalAccel::MatchType type = KGlobalAccel::MatchType::Equal) const;
|
||||
|
||||
/**
|
||||
* Get the shortcuts corresponding to key. Active and inactive shortcuts
|
||||
* are considered.
|
||||
*
|
||||
* @see getShortcutsByKey(int key)
|
||||
*/
|
||||
QList<GlobalShortcut *> getShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const;
|
||||
|
||||
/**
|
||||
* Checks if @p shortcut is available for @p component.
|
||||
*
|
||||
* It is available if not used by another component in any context or used
|
||||
* by @p component only in not active contexts.
|
||||
*/
|
||||
bool isShortcutAvailable(const QKeySequence &shortcut, const QString &component, const QString &context) const;
|
||||
|
||||
static GlobalShortcutsRegistry *self();
|
||||
|
||||
bool registerKey(const QKeySequence &key, GlobalShortcut *shortcut);
|
||||
|
||||
void setDBusPath(const QDBusObjectPath &path);
|
||||
|
||||
bool unregisterKey(const QKeySequence &key, GlobalShortcut *shortcut);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void clear();
|
||||
|
||||
void loadSettings();
|
||||
|
||||
void writeSettings();
|
||||
|
||||
// Grab the keys
|
||||
void grabKeys();
|
||||
|
||||
// Ungrab the keys
|
||||
void ungrabKeys();
|
||||
|
||||
private:
|
||||
friend struct KGlobalAccelDPrivate;
|
||||
friend class Component;
|
||||
friend class KGlobalAccelInterface;
|
||||
|
||||
Component *createComponent(const QString &uniqueName, const QString &friendlyName);
|
||||
KServiceActionComponent *createServiceActionComponent(const QString &uniqueName);
|
||||
KServiceActionComponent *createServiceActionComponent(KService::Ptr service);
|
||||
void migrateConfig();
|
||||
void migrateKHotkeys();
|
||||
|
||||
static void unregisterComponent(Component *component);
|
||||
using ComponentPtr = std::unique_ptr<Component, decltype(&unregisterComponent)>;
|
||||
|
||||
Component *registerComponent(ComponentPtr component);
|
||||
|
||||
// called by the implementation to inform us about key presses
|
||||
// returns true if the key was handled
|
||||
bool keyPressed(int keyQt);
|
||||
bool keyReleased(int keyQt);
|
||||
|
||||
QHash<QKeySequence, GlobalShortcut *> _active_keys;
|
||||
QKeySequence _active_sequence;
|
||||
QHash<int, int> _keys_count;
|
||||
|
||||
using ComponentVec = std::vector<ComponentPtr>;
|
||||
ComponentVec m_components;
|
||||
ComponentVec::const_iterator findByName(const QString &name) const
|
||||
{
|
||||
return std::find_if(m_components.cbegin(), m_components.cend(), [&name](const ComponentPtr &comp) {
|
||||
return comp->uniqueName() == name;
|
||||
});
|
||||
}
|
||||
|
||||
KGlobalAccelInterface *_manager = nullptr;
|
||||
|
||||
mutable KConfig _config;
|
||||
|
||||
QDBusObjectPath _dbusPath;
|
||||
GlobalShortcut *m_lastShortcut = nullptr;
|
||||
};
|
||||
|
||||
#endif /* #ifndef GLOBALSHORTCUTSREGISTRY_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kglobalaccel_interface.h"
|
||||
#include "globalshortcutsregistry.h"
|
||||
|
||||
class KGlobalAccelInterface::Private
|
||||
{
|
||||
public:
|
||||
Private(GlobalShortcutsRegistry *owner)
|
||||
: owner(owner)
|
||||
{
|
||||
}
|
||||
GlobalShortcutsRegistry *owner;
|
||||
};
|
||||
|
||||
KGlobalAccelInterface::KGlobalAccelInterface(QObject *owner)
|
||||
: QObject(owner)
|
||||
, d(new Private(qobject_cast<GlobalShortcutsRegistry *>(owner)))
|
||||
{
|
||||
}
|
||||
|
||||
KGlobalAccelInterface::~KGlobalAccelInterface() = default;
|
||||
|
||||
void KGlobalAccelInterface::setRegistry(GlobalShortcutsRegistry *registry)
|
||||
{
|
||||
setParent(registry);
|
||||
d->owner = registry;
|
||||
}
|
||||
|
||||
bool KGlobalAccelInterface::keyPressed(int keyQt)
|
||||
{
|
||||
return d->owner->keyPressed(keyQt);
|
||||
}
|
||||
|
||||
void KGlobalAccelInterface::grabKeys()
|
||||
{
|
||||
d->owner->grabKeys();
|
||||
}
|
||||
|
||||
void KGlobalAccelInterface::ungrabKeys()
|
||||
{
|
||||
d->owner->ungrabKeys();
|
||||
}
|
||||
|
||||
bool KGlobalAccelInterface::keyReleased(int keyQt)
|
||||
{
|
||||
return d->owner->keyReleased(keyQt);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org>
|
||||
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KGLOBALACCEL_INTERFACE_H
|
||||
#define KGLOBALACCEL_INTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "kglobalacceld_export.h"
|
||||
|
||||
class GlobalShortcutsRegistry;
|
||||
|
||||
#define KGlobalAccelInterface_iid "org.kde.kglobalaccel5.KGlobalAccelInterface"
|
||||
|
||||
/**
|
||||
* Abstract interface for plugins to implement
|
||||
*/
|
||||
class KGLOBALACCELD_EXPORT KGlobalAccelInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KGlobalAccelInterface(QObject *parent);
|
||||
~KGlobalAccelInterface() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This function registers or unregisters a certain key for global capture,
|
||||
* depending on \b grab.
|
||||
*
|
||||
* Before destruction, every grabbed key will be released, so this
|
||||
* object does not need to do any tracking.
|
||||
*
|
||||
* \param key the Qt keycode to grab or release.
|
||||
* \param grab true to grab they key, false to release the key.
|
||||
*
|
||||
* \return true if successful, otherwise false.
|
||||
*/
|
||||
virtual bool grabKey(int key, bool grab) = 0;
|
||||
|
||||
/*
|
||||
* Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
|
||||
*/
|
||||
virtual void setEnabled(bool) = 0;
|
||||
|
||||
void setRegistry(GlobalShortcutsRegistry *registry);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* called by the implementation to inform us about key presses
|
||||
* @returns @c true if the key was handled
|
||||
**/
|
||||
bool keyPressed(int keyQt);
|
||||
void grabKeys();
|
||||
void ungrabKeys();
|
||||
/**
|
||||
* Called by the implementation to inform us about key releases
|
||||
*
|
||||
* @param keyQt the key that was just released
|
||||
*
|
||||
* @returns @c true if the key was handled
|
||||
**/
|
||||
bool keyReleased(int keyQt);
|
||||
|
||||
class Private;
|
||||
QScopedPointer<Private> d;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(KGlobalAccelInterface, KGlobalAccelInterface_iid)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
|
||||
SPDX-FileCopyrightText: 2007 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kglobalacceld.h"
|
||||
|
||||
#include "component.h"
|
||||
#include "globalshortcut.h"
|
||||
#include "globalshortcutcontext.h"
|
||||
#include "globalshortcutsregistry.h"
|
||||
#include "kglobalaccel.h"
|
||||
#include "kserviceactioncomponent.h"
|
||||
#include "logging_p.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMetaType>
|
||||
#include <QMetaMethod>
|
||||
#include <QTimer>
|
||||
|
||||
struct KGlobalAccelDPrivate {
|
||||
KGlobalAccelDPrivate(KGlobalAccelD *qq)
|
||||
: q(qq)
|
||||
{
|
||||
}
|
||||
|
||||
GlobalShortcut *findAction(const QStringList &actionId) const;
|
||||
|
||||
/**
|
||||
* Find the action @a shortcutUnique in @a componentUnique.
|
||||
*
|
||||
* @return the action or @c nullptr if doesn't exist
|
||||
*/
|
||||
GlobalShortcut *findAction(const QString &componentUnique, const QString &shortcutUnique) const;
|
||||
|
||||
GlobalShortcut *addAction(const QStringList &actionId);
|
||||
Component *component(const QStringList &actionId) const;
|
||||
|
||||
void splitComponent(QString &component, QString &context) const
|
||||
{
|
||||
context = QStringLiteral("default");
|
||||
const int index = component.indexOf(QLatin1Char('|'));
|
||||
if (index != -1) {
|
||||
Q_ASSERT(component.indexOf(QLatin1Char('|'), index + 1) == -1); // Only one '|' character
|
||||
context = component.mid(index + 1);
|
||||
component.truncate(index);
|
||||
}
|
||||
}
|
||||
|
||||
//! Timer for delayed writing to kglobalshortcutsrc
|
||||
QTimer writeoutTimer;
|
||||
|
||||
//! Our holder
|
||||
KGlobalAccelD *q;
|
||||
|
||||
GlobalShortcutsRegistry *m_registry = nullptr;
|
||||
};
|
||||
|
||||
GlobalShortcut *KGlobalAccelDPrivate::findAction(const QStringList &actionId) const
|
||||
{
|
||||
// Check if actionId is valid
|
||||
if (actionId.size() != 4) {
|
||||
qCDebug(KGLOBALACCELD) << "Invalid! '" << actionId << "'";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return findAction(actionId.at(KGlobalAccel::ComponentUnique), actionId.at(KGlobalAccel::ActionUnique));
|
||||
}
|
||||
|
||||
GlobalShortcut *KGlobalAccelDPrivate::findAction(const QString &_componentUnique, const QString &shortcutUnique) const
|
||||
{
|
||||
QString componentUnique = _componentUnique;
|
||||
|
||||
Component *component;
|
||||
QString contextUnique;
|
||||
if (componentUnique.indexOf(QLatin1Char('|')) == -1) {
|
||||
component = m_registry->getComponent(componentUnique);
|
||||
if (component) {
|
||||
contextUnique = component->currentContext()->uniqueName();
|
||||
}
|
||||
} else {
|
||||
splitComponent(componentUnique, contextUnique);
|
||||
component = m_registry->getComponent(componentUnique);
|
||||
}
|
||||
|
||||
if (!component) {
|
||||
qCDebug(KGLOBALACCELD) << componentUnique << "not found";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GlobalShortcut *shortcut = component->getShortcutByName(shortcutUnique, contextUnique);
|
||||
|
||||
if (shortcut) {
|
||||
qCDebug(KGLOBALACCELD) << componentUnique << contextUnique << shortcut->uniqueName();
|
||||
} else {
|
||||
qCDebug(KGLOBALACCELD) << "No match for" << shortcutUnique;
|
||||
}
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
Component *KGlobalAccelDPrivate::component(const QStringList &actionId) const
|
||||
{
|
||||
const QString uniqueName = actionId.at(KGlobalAccel::ComponentUnique);
|
||||
|
||||
// If a component for action already exists, use that...
|
||||
if (Component *c = m_registry->getComponent(uniqueName)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// ... otherwise, create a new one
|
||||
const QString friendlyName = actionId.at(KGlobalAccel::ComponentFriendly);
|
||||
if (uniqueName.endsWith(QLatin1String(".desktop"))) {
|
||||
auto *actionComp = m_registry->createServiceActionComponent(uniqueName);
|
||||
if (!actionComp) {
|
||||
return nullptr;
|
||||
}
|
||||
actionComp->activateGlobalShortcutContext(QStringLiteral("default"));
|
||||
actionComp->loadFromService();
|
||||
return actionComp;
|
||||
} else {
|
||||
return m_registry->createComponent(uniqueName, friendlyName);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut *KGlobalAccelDPrivate::addAction(const QStringList &actionId)
|
||||
{
|
||||
Q_ASSERT(actionId.size() >= 4);
|
||||
|
||||
QString componentUnique = actionId.at(KGlobalAccel::ComponentUnique);
|
||||
QString contextUnique;
|
||||
splitComponent(componentUnique, contextUnique);
|
||||
|
||||
QStringList actionIdTmp = actionId;
|
||||
actionIdTmp.replace(KGlobalAccel::ComponentUnique, componentUnique);
|
||||
|
||||
// Create the component if necessary
|
||||
Component *component = this->component(actionIdTmp);
|
||||
if (!component) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Create the context if necessary
|
||||
if (component->getShortcutContexts().count(contextUnique) == 0) {
|
||||
component->createGlobalShortcutContext(contextUnique);
|
||||
}
|
||||
|
||||
Q_ASSERT(!component->getShortcutByName(componentUnique, contextUnique));
|
||||
|
||||
return new GlobalShortcut(actionId.at(KGlobalAccel::ActionUnique), actionId.at(KGlobalAccel::ActionFriendly), component->shortcutContext(contextUnique));
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QStringList)
|
||||
|
||||
KGlobalAccelD::KGlobalAccelD(QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(new KGlobalAccelDPrivate(this))
|
||||
{
|
||||
}
|
||||
|
||||
bool KGlobalAccelD::init()
|
||||
{
|
||||
qDBusRegisterMetaType<QKeySequence>();
|
||||
qDBusRegisterMetaType<QList<QKeySequence>>();
|
||||
qDBusRegisterMetaType<QList<QDBusObjectPath>>();
|
||||
qDBusRegisterMetaType<QList<QStringList>>();
|
||||
qDBusRegisterMetaType<QStringList>();
|
||||
qDBusRegisterMetaType<KGlobalShortcutInfo>();
|
||||
qDBusRegisterMetaType<QList<KGlobalShortcutInfo>>();
|
||||
qDBusRegisterMetaType<KGlobalAccel::MatchType>();
|
||||
|
||||
d->m_registry = GlobalShortcutsRegistry::self();
|
||||
Q_ASSERT(d->m_registry);
|
||||
|
||||
d->writeoutTimer.setSingleShot(true);
|
||||
connect(&d->writeoutTimer, &QTimer::timeout, d->m_registry, &GlobalShortcutsRegistry::writeSettings);
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerService(QLatin1String("org.kde.kglobalaccel"))) {
|
||||
qCWarning(KGLOBALACCELD) << "Failed to register service org.kde.kglobalaccel";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerObject(QStringLiteral("/kglobalaccel"), this, QDBusConnection::ExportScriptableContents)) {
|
||||
qCWarning(KGLOBALACCELD) << "Failed to register object kglobalaccel in org.kde.kglobalaccel";
|
||||
return false;
|
||||
}
|
||||
|
||||
d->m_registry->setDBusPath(QDBusObjectPath("/"));
|
||||
d->m_registry->loadSettings();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
KGlobalAccelD::~KGlobalAccelD()
|
||||
{
|
||||
if (d->writeoutTimer.isActive()) {
|
||||
d->writeoutTimer.stop();
|
||||
d->m_registry->writeSettings();
|
||||
}
|
||||
d->m_registry->deactivateShortcuts();
|
||||
delete d;
|
||||
}
|
||||
|
||||
QList<QStringList> KGlobalAccelD::allMainComponents() const
|
||||
{
|
||||
return d->m_registry->allComponentNames();
|
||||
}
|
||||
|
||||
QList<QStringList> KGlobalAccelD::allActionsForComponent(const QStringList &actionId) const
|
||||
{
|
||||
// ### Would it be advantageous to sort the actions by unique name?
|
||||
QList<QStringList> ret;
|
||||
|
||||
Component *const component = d->m_registry->getComponent(actionId[KGlobalAccel::ComponentUnique]);
|
||||
if (!component) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList partialId(actionId[KGlobalAccel::ComponentUnique]); // ComponentUnique
|
||||
partialId.append(QString()); // ActionUnique
|
||||
// Use our internal friendlyName, not the one passed in. We should have the latest data.
|
||||
partialId.append(component->friendlyName()); // ComponentFriendly
|
||||
partialId.append(QString()); // ActionFriendly
|
||||
|
||||
const auto listShortcuts = component->allShortcuts();
|
||||
for (const GlobalShortcut *const shortcut : listShortcuts) {
|
||||
if (shortcut->isFresh()) {
|
||||
// isFresh is only an intermediate state, not to be reported outside.
|
||||
continue;
|
||||
}
|
||||
QStringList actionId(partialId);
|
||||
actionId[KGlobalAccel::ActionUnique] = shortcut->uniqueName();
|
||||
actionId[KGlobalAccel::ActionFriendly] = shortcut->friendlyName();
|
||||
ret.append(actionId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
QStringList KGlobalAccelD::action(int key) const
|
||||
{
|
||||
return actionList(key);
|
||||
}
|
||||
#endif
|
||||
|
||||
QStringList KGlobalAccelD::actionList(const QKeySequence &key) const
|
||||
{
|
||||
GlobalShortcut *shortcut = d->m_registry->getShortcutByKey(key);
|
||||
QStringList ret;
|
||||
if (shortcut) {
|
||||
ret.append(shortcut->context()->component()->uniqueName());
|
||||
ret.append(shortcut->uniqueName());
|
||||
ret.append(shortcut->context()->component()->friendlyName());
|
||||
ret.append(shortcut->friendlyName());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void KGlobalAccelD::activateGlobalShortcutContext(const QString &component, const QString &uniqueName)
|
||||
{
|
||||
Component *const comp = d->m_registry->getComponent(component);
|
||||
if (comp) {
|
||||
comp->activateGlobalShortcutContext(uniqueName);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> KGlobalAccelD::allComponents() const
|
||||
{
|
||||
return d->m_registry->componentsDbusPaths();
|
||||
}
|
||||
|
||||
void KGlobalAccelD::blockGlobalShortcuts(bool block)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << "Block global shortcuts?" << block;
|
||||
if (block) {
|
||||
d->m_registry->deactivateShortcuts(true);
|
||||
} else {
|
||||
d->m_registry->activateShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
QList<int> KGlobalAccelD::shortcut(const QStringList &action) const
|
||||
{
|
||||
GlobalShortcut *shortcut = d->findAction(action);
|
||||
if (shortcut) {
|
||||
QList<int> ret;
|
||||
for (auto i : shortcut->keys()) {
|
||||
ret << i[0].toCombined();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return QList<int>();
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<QKeySequence> KGlobalAccelD::shortcutKeys(const QStringList &action) const
|
||||
{
|
||||
GlobalShortcut *shortcut = d->findAction(action);
|
||||
if (shortcut) {
|
||||
return shortcut->keys();
|
||||
}
|
||||
return QList<QKeySequence>();
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
QList<int> KGlobalAccelD::defaultShortcut(const QStringList &action) const
|
||||
{
|
||||
GlobalShortcut *shortcut = d->findAction(action);
|
||||
if (shortcut) {
|
||||
QList<int> ret;
|
||||
for (auto i : shortcut->keys()) {
|
||||
ret << i[0].toCombined();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return QList<int>();
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<QKeySequence> KGlobalAccelD::defaultShortcutKeys(const QStringList &action) const
|
||||
{
|
||||
GlobalShortcut *shortcut = d->findAction(action);
|
||||
if (shortcut) {
|
||||
return shortcut->defaultKeys();
|
||||
}
|
||||
return QList<QKeySequence>();
|
||||
}
|
||||
|
||||
// This method just registers the action. Nothing else. Shortcut has to be set
|
||||
// later.
|
||||
void KGlobalAccelD::doRegister(const QStringList &actionId)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << actionId;
|
||||
|
||||
// Check because we would not want to add a action for an invalid
|
||||
// actionId. findAction returns nullptr in that case.
|
||||
if (actionId.size() < 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalShortcut *shortcut = d->findAction(actionId);
|
||||
if (!shortcut) {
|
||||
shortcut = d->addAction(actionId);
|
||||
} else {
|
||||
// a switch of locales is one common reason for a changing friendlyName
|
||||
if ((!actionId[KGlobalAccel::ActionFriendly].isEmpty()) && shortcut->friendlyName() != actionId[KGlobalAccel::ActionFriendly]) {
|
||||
shortcut->setFriendlyName(actionId[KGlobalAccel::ActionFriendly]);
|
||||
scheduleWriteSettings();
|
||||
}
|
||||
if ((!actionId[KGlobalAccel::ComponentFriendly].isEmpty())
|
||||
&& shortcut->context()->component()->friendlyName() != actionId[KGlobalAccel::ComponentFriendly]) {
|
||||
shortcut->context()->component()->setFriendlyName(actionId[KGlobalAccel::ComponentFriendly]);
|
||||
scheduleWriteSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QDBusObjectPath KGlobalAccelD::getComponent(const QString &componentUnique) const
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << componentUnique;
|
||||
|
||||
Component *component = d->m_registry->getComponent(componentUnique);
|
||||
|
||||
if (component) {
|
||||
return component->dbusPath();
|
||||
} else {
|
||||
sendErrorReply(QStringLiteral("org.kde.kglobalaccel.NoSuchComponent"), QStringLiteral("The component '%1' doesn't exist.").arg(componentUnique));
|
||||
return QDBusObjectPath("/");
|
||||
}
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
QList<KGlobalShortcutInfo> KGlobalAccelD::getGlobalShortcutsByKey(int key) const
|
||||
{
|
||||
return globalShortcutsByKey(key, KGlobalAccel::MatchType::Equal);
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<KGlobalShortcutInfo> KGlobalAccelD::globalShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << key;
|
||||
const QList<GlobalShortcut *> shortcuts = d->m_registry->getShortcutsByKey(key, type);
|
||||
|
||||
QList<KGlobalShortcutInfo> rc;
|
||||
rc.reserve(shortcuts.size());
|
||||
for (const GlobalShortcut *sc : shortcuts) {
|
||||
qCDebug(KGLOBALACCELD) << sc->context()->uniqueName() << sc->uniqueName();
|
||||
rc.append(static_cast<KGlobalShortcutInfo>(*sc));
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
bool KGlobalAccelD::isGlobalShortcutAvailable(int shortcut, const QString &component) const
|
||||
{
|
||||
return globalShortcutAvailable(shortcut, component);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool KGlobalAccelD::globalShortcutAvailable(const QKeySequence &shortcut, const QString &component) const
|
||||
{
|
||||
QString realComponent = component;
|
||||
QString context;
|
||||
d->splitComponent(realComponent, context);
|
||||
return d->m_registry->isShortcutAvailable(shortcut, realComponent, context);
|
||||
}
|
||||
|
||||
void KGlobalAccelD::setInactive(const QStringList &actionId)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << actionId;
|
||||
|
||||
GlobalShortcut *shortcut = d->findAction(actionId);
|
||||
if (shortcut) {
|
||||
shortcut->setIsPresent(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool KGlobalAccelD::unregister(const QString &componentUnique, const QString &shortcutUnique)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << componentUnique << shortcutUnique;
|
||||
|
||||
// Stop grabbing the key
|
||||
GlobalShortcut *shortcut = d->findAction(componentUnique, shortcutUnique);
|
||||
if (shortcut) {
|
||||
shortcut->unRegister();
|
||||
scheduleWriteSettings();
|
||||
}
|
||||
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(4, 3)
|
||||
void KGlobalAccelD::unRegister(const QStringList &actionId)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << actionId;
|
||||
|
||||
// Stop grabbing the key
|
||||
GlobalShortcut *shortcut = d->findAction(actionId);
|
||||
if (shortcut) {
|
||||
shortcut->unRegister();
|
||||
scheduleWriteSettings();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
QList<int> KGlobalAccelD::setShortcut(const QStringList &actionId, const QList<int> &keys, uint flags)
|
||||
{
|
||||
QList<QKeySequence> input;
|
||||
input.reserve(keys.size());
|
||||
for (auto i : keys) {
|
||||
input << i;
|
||||
}
|
||||
|
||||
const QList<QKeySequence> list = setShortcutKeys(actionId, input, flags);
|
||||
QList<int> ret;
|
||||
ret.reserve(list.size());
|
||||
for (auto i : list) {
|
||||
ret << i[0].toCombined();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<QKeySequence> KGlobalAccelD::setShortcutKeys(const QStringList &actionId, const QList<QKeySequence> &keys, uint flags)
|
||||
{
|
||||
// spare the DBus framework some work
|
||||
const bool setPresent = (flags & SetPresent);
|
||||
const bool isAutoloading = !(flags & NoAutoloading);
|
||||
const bool isDefault = (flags & IsDefault);
|
||||
|
||||
GlobalShortcut *shortcut = d->findAction(actionId);
|
||||
if (!shortcut) {
|
||||
return QList<QKeySequence>();
|
||||
}
|
||||
|
||||
// default shortcuts cannot clash because they don't do anything
|
||||
if (isDefault) {
|
||||
if (shortcut->defaultKeys() != keys) {
|
||||
shortcut->setDefaultKeys(keys);
|
||||
scheduleWriteSettings();
|
||||
}
|
||||
return keys; // doesn't matter
|
||||
}
|
||||
|
||||
if (isAutoloading && !shortcut->isFresh()) {
|
||||
// the trivial and common case - synchronize the action from our data
|
||||
// and exit.
|
||||
if (!shortcut->isPresent() && setPresent) {
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
// We are finished here. Return the list of current active keys.
|
||||
return shortcut->keys();
|
||||
}
|
||||
|
||||
// now we are actually changing the shortcut of the action
|
||||
shortcut->setKeys(keys);
|
||||
|
||||
if (setPresent) {
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
|
||||
// maybe isFresh should really only be set if setPresent, but only two things should use !setPresent:
|
||||
//- the global shortcuts KCM: very unlikely to catch KWin/etc.'s actions in isFresh state
|
||||
//- KGlobalAccel::stealGlobalShortcutSystemwide(): only applies to actions with shortcuts
|
||||
// which can never be fresh if created the usual way
|
||||
shortcut->setIsFresh(false);
|
||||
|
||||
scheduleWriteSettings();
|
||||
|
||||
return shortcut->keys();
|
||||
}
|
||||
|
||||
#if KGLOBALACCELD_BUILD_DEPRECATED_SINCE(5, 90)
|
||||
void KGlobalAccelD::setForeignShortcut(const QStringList &actionId, const QList<int> &keys)
|
||||
{
|
||||
QList<QKeySequence> input;
|
||||
for (auto i : keys) {
|
||||
input << i;
|
||||
}
|
||||
return setForeignShortcutKeys(actionId, input);
|
||||
}
|
||||
#endif
|
||||
|
||||
void KGlobalAccelD::setForeignShortcutKeys(const QStringList &actionId, const QList<QKeySequence> &keys)
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << actionId;
|
||||
|
||||
GlobalShortcut *shortcut = d->findAction(actionId);
|
||||
if (!shortcut) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QKeySequence> newKeys = setShortcutKeys(actionId, keys, NoAutoloading);
|
||||
|
||||
Q_EMIT yourShortcutsChanged(actionId, newKeys);
|
||||
}
|
||||
|
||||
void KGlobalAccelD::scheduleWriteSettings() const
|
||||
{
|
||||
if (!d->writeoutTimer.isActive()) {
|
||||
d->writeoutTimer.start(500);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_kglobalacceld.cpp"
|
||||
@@ -0,0 +1,41 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Global Shortcuts
|
||||
Name[ar]=اختصارات عامة
|
||||
Name[ast]=Atayos globales
|
||||
Name[bg]=Глобални клавишни комбинации
|
||||
Name[ca]=Dreceres globals
|
||||
Name[ca@valencia]=Dreceres globals
|
||||
Name[cs]=Globální zkratky
|
||||
Name[de]=Globale Kurzbefehle
|
||||
Name[en_GB]=Global Shortcuts
|
||||
Name[eo]=Ĉieaj Ŝparvojoj
|
||||
Name[es]=Atajo de teclado globales
|
||||
Name[eu]=Lasterbide globalak
|
||||
Name[fa]=میانبر های چهانی
|
||||
Name[fi]=Työpöydänlaajuiset pikanäppäimet
|
||||
Name[fr]=Raccourcis globaux
|
||||
Name[gl]=Atallos globais
|
||||
Name[hu]=Globális gyorsbillentyűk
|
||||
Name[ia]=Vias Breve Global
|
||||
Name[it]=Scorciatoie globali
|
||||
Name[ka]=გლობალური მალსახმობები
|
||||
Name[ko]=전역 단축키
|
||||
Name[nl]=Globale sneltoetsen
|
||||
Name[nn]=Globale snarvegar
|
||||
Name[pl]=Skróty globalne
|
||||
Name[pt_BR]=Atalhos globais
|
||||
Name[ru]=Глобальные комбинации клавиш
|
||||
Name[sa]=वैश्विक संक्षिप्तमार्गाः
|
||||
Name[sk]=Globálne skratky
|
||||
Name[sl]=Globalne bližnjice
|
||||
Name[ta]=முழுதளாவிய சுருக்குவழிகள்
|
||||
Name[tr]=Global Kısayollar
|
||||
Name[uk]=Загальні скорочення
|
||||
Name[x-test]=xxGlobal Shortcutsxx
|
||||
Name[zh_CN]=全局快捷键
|
||||
Name[zh_TW]=全域快捷鍵
|
||||
Exec=@KDE_INSTALL_FULL_LIBEXECDIR@/kglobalacceld
|
||||
NoDisplay=true
|
||||
OnlyShowIn=KDE;
|
||||
X-systemd-skip=true
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
#ifndef KGLOBALACCELD_H
|
||||
#define KGLOBALACCELD_H
|
||||
|
||||
#include "kglobalacceld_export.h"
|
||||
|
||||
#include <kglobalshortcutinfo.h>
|
||||
|
||||
#include <KGlobalAccel>
|
||||
#include <QDBusContext>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
|
||||
struct KGlobalAccelDPrivate;
|
||||
|
||||
/**
|
||||
* @note: Even though this is private API, KWin creates an object
|
||||
* of this type, check in KWin to see which methods are used before
|
||||
* removing them from here.
|
||||
*
|
||||
* @todo get rid of all of those QStringList parameters.
|
||||
*/
|
||||
class KGLOBALACCELD_EXPORT KGlobalAccelD : public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.KGlobalAccel")
|
||||
|
||||
public:
|
||||
enum SetShortcutFlag {
|
||||
SetPresent = 2,
|
||||
NoAutoloading = 4,
|
||||
IsDefault = 8,
|
||||
};
|
||||
Q_ENUM(SetShortcutFlag)
|
||||
Q_DECLARE_FLAGS(SetShortcutFlags, SetShortcutFlag)
|
||||
Q_FLAG(SetShortcutFlags)
|
||||
|
||||
explicit KGlobalAccelD(QObject *parent = nullptr);
|
||||
~KGlobalAccelD() override;
|
||||
|
||||
bool init();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
/**
|
||||
* Get the dbus path for all known components.
|
||||
*
|
||||
* The returned path is absolute. No need to prepend anything.
|
||||
*/
|
||||
Q_SCRIPTABLE QList<QDBusObjectPath> allComponents() const;
|
||||
|
||||
/**
|
||||
* Returns a list of QStringLists (one string list per known component,
|
||||
* with each string list containing four strings, one for each enumerator
|
||||
* in KGlobalAccel::actionIdFields).
|
||||
*/
|
||||
Q_SCRIPTABLE QList<QStringList> allMainComponents() const;
|
||||
|
||||
Q_SCRIPTABLE QList<QStringList> allActionsForComponent(const QStringList &actionId) const;
|
||||
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use actionList(const QKeySequence&, int) instead.")
|
||||
Q_SCRIPTABLE QStringList action(int key) const;
|
||||
#endif
|
||||
Q_SCRIPTABLE QStringList actionList(const QKeySequence &key) const;
|
||||
|
||||
// to be called by main components not owning the action
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use shortcutKeys(const QStringList &) instead.")
|
||||
Q_SCRIPTABLE QList<int> shortcut(const QStringList &actionId) const;
|
||||
#endif
|
||||
Q_SCRIPTABLE QList<QKeySequence> shortcutKeys(const QStringList &actionId) const;
|
||||
|
||||
// to be called by main components not owning the action
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use defaultShortcutKeys(const QStringList &) instead.")
|
||||
Q_SCRIPTABLE QList<int> defaultShortcut(const QStringList &actionId) const;
|
||||
#endif
|
||||
Q_SCRIPTABLE QList<QKeySequence> defaultShortcutKeys(const QStringList &actionId) const;
|
||||
|
||||
/**
|
||||
* Get the dbus path for @ componentUnique
|
||||
*
|
||||
* @param componentUnique the components unique identifier
|
||||
*
|
||||
* @return the absolute dbus path
|
||||
*/
|
||||
Q_SCRIPTABLE QDBusObjectPath getComponent(const QString &componentUnique) const;
|
||||
|
||||
// to be called by main components owning the action
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use setShortcutKeys(const QStringList &, const QList<QKeySequence> &, uint) instead.")
|
||||
Q_SCRIPTABLE QList<int> setShortcut(const QStringList &actionId, const QList<int> &keys, uint flags);
|
||||
#endif
|
||||
Q_SCRIPTABLE QList<QKeySequence> setShortcutKeys(const QStringList &actionId, const QList<QKeySequence> &keys, uint flags);
|
||||
|
||||
// this is used if application A wants to change shortcuts of application B
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use setForeignShortcutKeys(const QStringList &, const QList<QKeySequence> &) instead.")
|
||||
Q_SCRIPTABLE void setForeignShortcut(const QStringList &actionId, const QList<int> &keys);
|
||||
#endif
|
||||
Q_SCRIPTABLE void setForeignShortcutKeys(const QStringList &actionId, const QList<QKeySequence> &keys);
|
||||
|
||||
// to be called when a KAction is destroyed. The shortcut stays in the data structures for
|
||||
// conflict resolution but won't trigger.
|
||||
Q_SCRIPTABLE void setInactive(const QStringList &actionId);
|
||||
|
||||
Q_SCRIPTABLE void doRegister(const QStringList &actionId);
|
||||
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(4, 3)
|
||||
//! @deprecated Since 4.3, use KGlobalAccelD::unregister
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(4, 3, "Use KGlobalAccelD::unregister(const QString&, const QString&")
|
||||
Q_SCRIPTABLE void unRegister(const QStringList &actionId);
|
||||
#endif
|
||||
|
||||
Q_SCRIPTABLE void activateGlobalShortcutContext(const QString &component, const QString &context);
|
||||
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
/**
|
||||
* Returns the shortcuts registered for @p key.
|
||||
*
|
||||
* If there is more than one shortcut they are guaranteed to be from the
|
||||
* same component but different contexts. All shortcuts are searched.
|
||||
*
|
||||
* @deprecated Since 5.90, use globalShortcutsByKey(const QKeySequence &, int) instead.
|
||||
*/
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use globalShortcutsByKey(const QKeySequence &, int) instead.")
|
||||
Q_SCRIPTABLE QList<KGlobalShortcutInfo> getGlobalShortcutsByKey(int key) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the shortcuts registered for @p key.
|
||||
*
|
||||
* If there is more than one shortcut they are guaranteed to be from the
|
||||
* same component but different contexts. All shortcuts are searched.
|
||||
*
|
||||
* @since 5.90
|
||||
*/
|
||||
Q_SCRIPTABLE QList<KGlobalShortcutInfo> globalShortcutsByKey(const QKeySequence &key, KGlobalAccel::MatchType type) const;
|
||||
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
/**
|
||||
* Returns true if the @p shortcut is available for @p component.
|
||||
*
|
||||
* @deprecated Since 5.90, use globalShortcutAvailable(const QKeySequence &, const QString &) instead.
|
||||
*/
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use globalShortcutAvailable(const QKeySequence &, const QString &) instead.")
|
||||
Q_SCRIPTABLE bool isGlobalShortcutAvailable(int key, const QString &component) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns true if the @p shortcut is available for @p component.
|
||||
*
|
||||
* @since 5.90
|
||||
*/
|
||||
Q_SCRIPTABLE bool globalShortcutAvailable(const QKeySequence &key, const QString &component) const;
|
||||
|
||||
/**
|
||||
* Delete the shortcut with @a component and @name.
|
||||
*
|
||||
* The shortcut is removed from the registry even if it is currently
|
||||
* present. It is removed from all contexts.
|
||||
*
|
||||
* @param componentUnique the components unique identifier
|
||||
* @param shortcutUnique the shortcut id
|
||||
*
|
||||
* @return @c true if the shortcuts was deleted, @c false if it didn't * exist.
|
||||
*/
|
||||
Q_SCRIPTABLE bool unregister(const QString &componentUnique, const QString &shortcutUnique);
|
||||
|
||||
Q_SCRIPTABLE void blockGlobalShortcuts(bool);
|
||||
|
||||
Q_SIGNALS:
|
||||
#if KGLOBALACCELD_ENABLE_DEPRECATED_SINCE(5, 90)
|
||||
KGLOBALACCELD_DEPRECATED_VERSION(5, 90, "Use the yourShortcutsChanged(const QStringList &, const QList<QKeySequence> &) signal instead.")
|
||||
Q_SCRIPTABLE void yourShortcutGotChanged(const QStringList &actionId, const QList<int> &newKeys);
|
||||
#endif
|
||||
|
||||
Q_SCRIPTABLE void yourShortcutsChanged(const QStringList &actionId, const QList<QKeySequence> &newKeys);
|
||||
|
||||
private:
|
||||
void scheduleWriteSettings() const;
|
||||
|
||||
KGlobalAccelDPrivate *const d;
|
||||
};
|
||||
|
||||
#endif // KGLOBALACCELD_H
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KGLOBALSHORTCUTINFO_P_H
|
||||
#define KGLOBALSHORTCUTINFO_P_H
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
||||
static const int maxSequenceLength = 4;
|
||||
|
||||
#include "kglobalaccel.h"
|
||||
#include "kglobalshortcutinfo.h"
|
||||
|
||||
class KGlobalShortcutInfoPrivate
|
||||
{
|
||||
public:
|
||||
QString contextUniqueName;
|
||||
QString contextFriendlyName;
|
||||
QString componentUniqueName;
|
||||
QString componentFriendlyName;
|
||||
QString uniqueName;
|
||||
QString friendlyName;
|
||||
QList<QKeySequence> keys;
|
||||
QList<QKeySequence> defaultKeys;
|
||||
};
|
||||
|
||||
#endif /* #ifndef KGLOBALSHORTCUTINFO_P_H */
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
|
||||
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kserviceactioncomponent.h"
|
||||
#include "globalshortcutcontext.h"
|
||||
#include "logging_p.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
|
||||
#include <KService>
|
||||
|
||||
#include "config-kglobalaccel.h"
|
||||
#if HAVE_X11
|
||||
#include <KStartupInfo>
|
||||
#include <private/qtx11extras_p.h>
|
||||
#endif
|
||||
|
||||
QString makeUniqueName(const KService::Ptr &service)
|
||||
{
|
||||
if (service->storageId().startsWith(QLatin1Char('/'))) {
|
||||
return QFileInfo(service->storageId()).fileName();
|
||||
}
|
||||
|
||||
return service->storageId();
|
||||
}
|
||||
|
||||
KServiceActionComponent::KServiceActionComponent(KService::Ptr service)
|
||||
: Component(makeUniqueName(service), service->name())
|
||||
, m_service(service)
|
||||
{
|
||||
}
|
||||
|
||||
KServiceActionComponent::~KServiceActionComponent() = default;
|
||||
|
||||
void KServiceActionComponent::emitGlobalShortcutPressed(const GlobalShortcut &shortcut)
|
||||
{
|
||||
QString exec;
|
||||
|
||||
if (shortcut.uniqueName() == QLatin1String("_launch")) {
|
||||
exec = m_service->exec();
|
||||
} else {
|
||||
const auto actions = m_service->actions();
|
||||
const auto it = std::find_if(actions.cbegin(), actions.cend(), [&shortcut](const KServiceAction &action) {
|
||||
return action.name() == shortcut.uniqueName();
|
||||
});
|
||||
if (it == actions.cend()) {
|
||||
qCCritical(KGLOBALACCELD, "failed to find an action matching the '%s' name", qPrintable(shortcut.uniqueName()));
|
||||
return;
|
||||
}
|
||||
exec = it->exec();
|
||||
}
|
||||
|
||||
if (exec.isEmpty()) {
|
||||
qCWarning(KGLOBALACCELD) << "No exec line for service" << m_service->desktopEntryName();
|
||||
return;
|
||||
}
|
||||
|
||||
QProcess::startDetached(QStringLiteral("/bin/sh"), {QStringLiteral("-c"), exec});
|
||||
}
|
||||
|
||||
void KServiceActionComponent::loadFromService()
|
||||
{
|
||||
const QString type = m_service->property<QString>(QStringLiteral("X-KDE-GlobalShortcutType"));
|
||||
|
||||
// Type can be Application or Service
|
||||
// For applications add a lauch shortcut
|
||||
// If no type is set assume Application
|
||||
if (type.isEmpty() || type == QLatin1String("Application")) {
|
||||
const QString shortcutString = m_service->property<QStringList>(QStringLiteral("X-KDE-Shortcuts")).join(QLatin1Char('\t'));
|
||||
GlobalShortcut *shortcut = registerShortcut(QStringLiteral("_launch"), m_service->name(), shortcutString, shortcutString);
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
|
||||
const auto lstActions = m_service->actions();
|
||||
for (const KServiceAction &action : lstActions) {
|
||||
const QString shortcutString = action.property<QStringList>(QStringLiteral("X-KDE-Shortcuts")).join(QLatin1Char('\t'));
|
||||
GlobalShortcut *shortcut = registerShortcut(action.name(), action.text(), shortcutString, shortcutString);
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool KServiceActionComponent::cleanUp()
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << "Disabling desktop file";
|
||||
|
||||
const auto shortcuts = allShortcuts();
|
||||
for (GlobalShortcut *shortcut : shortcuts) {
|
||||
shortcut->setIsPresent(false);
|
||||
}
|
||||
|
||||
return Component::cleanUp();
|
||||
}
|
||||
|
||||
void KServiceActionComponent::writeSettings(KConfigGroup &config) const
|
||||
{
|
||||
// Clear the config so we remove entries after forgetGlobalShortcut
|
||||
config.deleteGroup();
|
||||
|
||||
// Now write all contexts
|
||||
for (GlobalShortcutContext *context : std::as_const(_contexts)) {
|
||||
KConfigGroup contextGroup;
|
||||
|
||||
if (context->uniqueName() == QLatin1String("default")) {
|
||||
contextGroup = config;
|
||||
} else {
|
||||
contextGroup = KConfigGroup(&config, context->uniqueName());
|
||||
}
|
||||
|
||||
for (const GlobalShortcut *shortcut : std::as_const(context->_actionsMap)) {
|
||||
// We do not write fresh shortcuts.
|
||||
// We do not write session shortcuts
|
||||
if (shortcut->isFresh() || shortcut->isSessionShortcut()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shortcut->keys() != shortcut->defaultKeys()) {
|
||||
contextGroup.writeEntry(shortcut->uniqueName(), stringFromKeys(shortcut->keys()));
|
||||
} else {
|
||||
contextGroup.revertToDefault(shortcut->uniqueName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KServiceActionComponent::loadSettings(KConfigGroup &configGroup)
|
||||
{
|
||||
// Action shortcuts
|
||||
const auto actions = m_service->actions();
|
||||
for (const KServiceAction &action : actions) {
|
||||
const QString defaultShortcutString = action.property<QString>(QStringLiteral("X-KDE-Shortcuts")).replace(QLatin1Char(','), QLatin1Char('\t'));
|
||||
const QString shortcutString = configGroup.readEntry(action.name(), defaultShortcutString);
|
||||
|
||||
GlobalShortcut *shortcut = registerShortcut(action.name(), action.text(), shortcutString, defaultShortcutString);
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
|
||||
const QString type = m_service->property<QString>(QStringLiteral("X-KDE-GlobalShortcutType"));
|
||||
|
||||
// Type can be Application or Service
|
||||
// For applications add a lauch shortcut
|
||||
// If no type is set assume Application
|
||||
if (type.isEmpty() || type == QLatin1String("Application")) {
|
||||
const QString defaultShortcutString = m_service->property<QString>(QStringLiteral("X-KDE-Shortcuts")).replace(QLatin1Char(','), QLatin1Char('\t'));
|
||||
const QString shortcutString = configGroup.readEntry("_launch", defaultShortcutString);
|
||||
GlobalShortcut *shortcut = registerShortcut(QStringLiteral("_launch"), m_service->name(), shortcutString, defaultShortcutString);
|
||||
shortcut->setIsPresent(true);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_kserviceactioncomponent.cpp"
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KSERVICEACTIONCOMPONENT_H
|
||||
#define KSERVICEACTIONCOMPONENT_H
|
||||
|
||||
#include "component.h"
|
||||
|
||||
#include <KService>
|
||||
|
||||
#include <memory>
|
||||
|
||||
/**
|
||||
* @author Michael Jansen <kde@michael-jansen.biz>
|
||||
*/
|
||||
class KServiceActionComponent : public Component
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~KServiceActionComponent() override;
|
||||
|
||||
void loadFromService();
|
||||
void emitGlobalShortcutPressed(const GlobalShortcut &shortcut) override;
|
||||
void writeSettings(KConfigGroup &config) const override;
|
||||
void loadSettings(KConfigGroup &config) override;
|
||||
bool cleanUp() override;
|
||||
|
||||
private:
|
||||
friend class ::GlobalShortcutsRegistry;
|
||||
//! Constructs a KServiceActionComponent. This is a private constuctor, to create
|
||||
//! a KServiceActionComponent, use GlobalShortcutsRegistry::self()->createServiceActionComponent().
|
||||
KServiceActionComponent(KService::Ptr service);
|
||||
|
||||
KService::Ptr m_service;
|
||||
};
|
||||
|
||||
#endif /* #ifndef KSERVICEACTIONCOMPONENT_H */
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include "logging_p.h"
|
||||
|
||||
// logging category for this framework, default: log stuff >= warning
|
||||
Q_LOGGING_CATEGORY(KGLOBALACCELD, "kf.globalaccel.kglobalacceld", QtWarningMsg)
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#ifndef KGLOBALACCELD_LOGGING_P_H
|
||||
#define KGLOBALACCELD_LOGGING_P_H
|
||||
#include <QLoggingCategory>
|
||||
Q_DECLARE_LOGGING_CATEGORY(KGLOBALACCELD)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
|
||||
SPDX-FileCopyrightText: 2007 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kglobalaccel_version.h"
|
||||
#include "kglobalacceld.h"
|
||||
#include "logging_p.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KCrash>
|
||||
#include <KDBusService>
|
||||
#include <QCommandLineParser>
|
||||
#include <QGuiApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// On Wayland the shortcuts are ran as part of kwin_wayland
|
||||
// no-op when started on Wayland
|
||||
if (qEnvironmentVariable("XDG_SESSION_TYPE") == QLatin1String("wayland")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto sessionManager = qgetenv("SESSION_MANAGER");
|
||||
// Disable Session Management the right way (C)
|
||||
//
|
||||
// ksmserver has global shortcuts. disableSessionManagement() does not prevent Qt from
|
||||
// registering the app with the session manager. We remove the address to make sure we do not
|
||||
// get a hang on kglobalaccel restart (kglobalaccel tries to register with ksmserver,
|
||||
// ksmserver tries to register with kglobalaccel).
|
||||
qunsetenv("SESSION_MANAGER");
|
||||
|
||||
QGuiApplication::setDesktopSettingsAware(false);
|
||||
QGuiApplication::setQuitLockEnabled(false);
|
||||
QGuiApplication app(argc, argv);
|
||||
KAboutData aboutdata(QStringLiteral("kglobalaccel"),
|
||||
QObject::tr("KDE Global Shortcuts Service"),
|
||||
QStringLiteral(KGLOBALACCEL_VERSION_STRING),
|
||||
QObject::tr("KDE Global Shortcuts Service"),
|
||||
KAboutLicense::LGPL,
|
||||
QStringLiteral("(C) 2007-2009 Andreas Hartmetz, Michael Jansen"));
|
||||
aboutdata.addAuthor(QStringLiteral("Andreas Hartmetz"), QObject::tr("Maintainer"), QStringLiteral("ahartmetz@gmail.com"));
|
||||
aboutdata.addAuthor(QStringLiteral("Michael Jansen"), QObject::tr("Maintainer"), QStringLiteral("kde@michael-jansen.biz"));
|
||||
|
||||
KAboutData::setApplicationData(aboutdata);
|
||||
|
||||
{
|
||||
QCommandLineParser parser;
|
||||
aboutdata.setupCommandLine(&parser);
|
||||
parser.process(app);
|
||||
aboutdata.processCommandLine(&parser);
|
||||
}
|
||||
|
||||
KDBusService service(KDBusService::Unique);
|
||||
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
if (!sessionManager.isEmpty()) {
|
||||
qputenv("SESSION_MANAGER", sessionManager);
|
||||
}
|
||||
|
||||
// Restart on a crash
|
||||
KCrash::setFlags(KCrash::AutoRestart);
|
||||
|
||||
KGlobalAccelD globalaccel;
|
||||
if (!globalaccel.init()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=KDE Global Shortcuts Server
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@KDE_INSTALL_FULL_LIBEXECDIR@/kglobalacceld
|
||||
BusName=org.kde.kglobalaccel
|
||||
Slice=background.slice
|
||||
TimeoutSec=5sec
|
||||
Restart=on-failure
|
||||
# Exit status 1 is used when the X11 connection drops
|
||||
RestartPreventExitStatus=1
|
||||
@@ -0,0 +1,3 @@
|
||||
if (XCB_XCB_FOUND AND XCB_KEYSYMS_FOUND AND XCB_XKB_FOUND)
|
||||
add_subdirectory(xcb)
|
||||
endif()
|
||||
@@ -0,0 +1,22 @@
|
||||
set(xcb_plugin_SRCS
|
||||
kglobalaccel_x11.cpp
|
||||
kglobalaccel_x11.h
|
||||
../../logging.cpp
|
||||
)
|
||||
|
||||
add_library(KGlobalAccelDXcb MODULE ${xcb_plugin_SRCS})
|
||||
target_link_libraries(KGlobalAccelDXcb
|
||||
KGlobalAccelD
|
||||
KF6::WindowSystem
|
||||
XCB::XCB
|
||||
XCB::KEYSYMS
|
||||
XCB::XKB
|
||||
XCB::RECORD
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
KGlobalAccelDXcb
|
||||
DESTINATION
|
||||
${KDE_INSTALL_PLUGINDIR}/org.kde.kglobalacceld.platforms/
|
||||
)
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org>
|
||||
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kglobalaccel_x11.h"
|
||||
|
||||
#include "logging_p.h"
|
||||
#include <KKeyServer>
|
||||
#include <netwm.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <private/qtx11extras_p.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
// xcb
|
||||
|
||||
// It uses "explicit" as a variable name, which is not allowed in C++
|
||||
#define explicit xcb_explicit
|
||||
#include <xcb/record.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#include <xcb/xcbext.h>
|
||||
#include <xcb/xkb.h>
|
||||
#undef explicit
|
||||
|
||||
// g_keyModMaskXAccel
|
||||
// mask of modifiers which can be used in shortcuts
|
||||
// (meta, alt, ctrl, shift)
|
||||
// g_keyModMaskXOnOrOff
|
||||
// mask of modifiers where we don't care whether they are on or off
|
||||
// (caps lock, num lock, scroll lock)
|
||||
static uint g_keyModMaskXAccel = 0;
|
||||
static uint g_keyModMaskXOnOrOff = 0;
|
||||
|
||||
static void calculateGrabMasks()
|
||||
{
|
||||
g_keyModMaskXAccel = KKeyServer::accelModMaskX();
|
||||
g_keyModMaskXOnOrOff = KKeyServer::modXLock() | KKeyServer::modXNumLock() | KKeyServer::modXScrollLock() | KKeyServer::modXModeSwitch();
|
||||
// qCDebug(KGLOBALACCELD) << "g_keyModMaskXAccel = " << g_keyModMaskXAccel
|
||||
// << "g_keyModMaskXOnOrOff = " << g_keyModMaskXOnOrOff << endl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
KGlobalAccelImpl::KGlobalAccelImpl(QObject *parent)
|
||||
: KGlobalAccelInterface(parent)
|
||||
, m_keySymbols(nullptr)
|
||||
, m_xkb_first_event(0)
|
||||
{
|
||||
Q_ASSERT(QX11Info::connection());
|
||||
|
||||
int events = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE;
|
||||
xcb_change_window_attributes(QX11Info::connection(), QX11Info::appRootWindow(), XCB_CW_EVENT_MASK, &events);
|
||||
|
||||
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(QX11Info::connection(), &xcb_xkb_id);
|
||||
if (reply && reply->present) {
|
||||
m_xkb_first_event = reply->first_event;
|
||||
}
|
||||
|
||||
// We use XRecord to get the released keys because we need a way to get notified about
|
||||
// them without needing to hold a grab
|
||||
// Holding a grab would be a problem for the cases when a process (looking at you KWin's
|
||||
// toolbox) replies to a global shortcut trigger with another grab
|
||||
m_display = XOpenDisplay(nullptr);
|
||||
auto connection = xcb_connect(XDisplayString((Display *)m_display), nullptr);
|
||||
auto context = xcb_generate_id(connection);
|
||||
xcb_record_range_t range;
|
||||
memset(&range, 0, sizeof(range));
|
||||
range.device_events.first = XCB_KEY_RELEASE;
|
||||
range.device_events.last = XCB_KEY_RELEASE;
|
||||
xcb_record_client_spec_t cs = XCB_RECORD_CS_ALL_CLIENTS;
|
||||
xcb_record_create_context(connection, context, 0, 1, 1, &cs, &range);
|
||||
auto cookie = xcb_record_enable_context(connection, context);
|
||||
xcb_flush(connection);
|
||||
|
||||
m_xrecordCookieSequence = cookie.sequence;
|
||||
|
||||
auto m_notifier = new QSocketNotifier(xcb_get_file_descriptor(connection), QSocketNotifier::Read, this);
|
||||
connect(m_notifier, &QSocketNotifier::activated, this, [this, connection] {
|
||||
xcb_generic_event_t *event;
|
||||
while ((event = xcb_poll_for_event(connection))) {
|
||||
std::free(event);
|
||||
}
|
||||
|
||||
xcb_record_enable_context_reply_t *reply = nullptr;
|
||||
xcb_generic_error_t *error = nullptr;
|
||||
while (m_xrecordCookieSequence && xcb_poll_for_reply(connection, m_xrecordCookieSequence, (void **)&reply, &error)) {
|
||||
// xcb_poll_for_reply may set both reply and error to null if connection has error.
|
||||
// break if xcb_connection has error, no point to continue anyway.
|
||||
if (xcb_connection_has_error(connection)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
std::free(error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!reply) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QScopedPointer<xcb_record_enable_context_reply_t, QScopedPointerPodDeleter> data(reinterpret_cast<xcb_record_enable_context_reply_t *>(reply));
|
||||
xcb_key_press_event_t *events = reinterpret_cast<xcb_key_press_event_t *>(xcb_record_enable_context_data(reply));
|
||||
int nEvents = xcb_record_enable_context_data_length(reply) / sizeof(xcb_key_press_event_t);
|
||||
for (xcb_key_press_event_t *e = events; e < events + nEvents; e++) {
|
||||
Q_ASSERT(e->response_type == XCB_KEY_RELEASE);
|
||||
qCDebug(KGLOBALACCELD) << "Got XKeyRelease event";
|
||||
x11KeyRelease(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
m_notifier->setEnabled(true);
|
||||
|
||||
calculateGrabMasks();
|
||||
}
|
||||
|
||||
KGlobalAccelImpl::~KGlobalAccelImpl()
|
||||
{
|
||||
XCloseDisplay((Display *)m_display);
|
||||
if (m_keySymbols) {
|
||||
xcb_key_symbols_free(m_keySymbols);
|
||||
}
|
||||
}
|
||||
|
||||
bool KGlobalAccelImpl::grabKey(int keyQt, bool grab)
|
||||
{
|
||||
// grabKey is called during shutdown
|
||||
// shutdown might be due to the X server being killed
|
||||
// if so, fail immediately before trying to make other xcb calls
|
||||
if (!QX11Info::connection() || xcb_connection_has_error(QX11Info::connection())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_keySymbols) {
|
||||
m_keySymbols = xcb_key_symbols_alloc(QX11Info::connection());
|
||||
if (!m_keySymbols) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!keyQt) {
|
||||
qCDebug(KGLOBALACCELD) << "Tried to grab key with null code.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint keyModX;
|
||||
|
||||
// Resolve the modifier
|
||||
if (!KKeyServer::keyQtToModX(keyQt, &keyModX)) {
|
||||
qCDebug(KGLOBALACCELD) << "keyQt (0x" << Qt::hex << keyQt << ") failed to resolve to x11 modifier";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resolve the X symbol
|
||||
const QList<int> keySymXs(KKeyServer::keyQtToSymXs(keyQt));
|
||||
if (keySymXs.empty()) {
|
||||
qCDebug(KGLOBALACCELD) << "keyQt (0x" << Qt::hex << keyQt << ") failed to resolve to x11 keycode";
|
||||
return false;
|
||||
}
|
||||
xcb_keycode_t *keyCodes = nullptr;
|
||||
xcb_keysym_t keySymX;
|
||||
for (xcb_keysym_t sym : keySymXs) {
|
||||
keyCodes = xcb_key_symbols_get_keycode(m_keySymbols, sym);
|
||||
if (keyCodes) {
|
||||
keySymX = sym;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!keyCodes) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
bool success = !grab;
|
||||
while (keyCodes[i] != XCB_NO_SYMBOL) {
|
||||
xcb_keycode_t keyCodeX = keyCodes[i++];
|
||||
|
||||
// Check if shift needs to be added to the grab since KKeySequenceWidget
|
||||
// can remove shift for some keys. (all the %&* and such)
|
||||
/* clang-format off */
|
||||
if (!(keyQt & Qt::SHIFT)
|
||||
&& !KKeyServer::isShiftAsModifierAllowed(keyQt)
|
||||
&& !(keyQt & Qt::KeypadModifier)
|
||||
&& keySymX != xcb_key_symbols_get_keysym(m_keySymbols, keyCodeX, 0)
|
||||
&& keySymX == xcb_key_symbols_get_keysym(m_keySymbols, keyCodeX, 1)) { /* clang-format on */
|
||||
qCDebug(KGLOBALACCELD) << "adding shift to the grab";
|
||||
keyModX |= KKeyServer::modXShift();
|
||||
}
|
||||
|
||||
keyModX &= g_keyModMaskXAccel; // Get rid of any non-relevant bits in mod
|
||||
|
||||
if (!keyCodeX) {
|
||||
qCDebug(KGLOBALACCELD) << "keyQt (0x" << Qt::hex << keyQt << ") was resolved to x11 keycode 0";
|
||||
continue;
|
||||
}
|
||||
|
||||
// We'll have to grab 8 key modifier combinations in order to cover all
|
||||
// combinations of CapsLock, NumLock, ScrollLock.
|
||||
// Does anyone with more X-savvy know how to set a mask on QX11Info::appRootWindow so that
|
||||
// the irrelevant bits are always ignored and we can just make one XGrabKey
|
||||
// call per accelerator? -- ellis
|
||||
#ifndef NDEBUG
|
||||
QString sDebug = QStringLiteral("\tcode: 0x%1 state: 0x%2 | ").arg(keyCodeX, 0, 16).arg(keyModX, 0, 16);
|
||||
#endif
|
||||
uint keyModMaskX = ~g_keyModMaskXOnOrOff;
|
||||
QList<xcb_void_cookie_t> cookies;
|
||||
for (uint irrelevantBitsMask = 0; irrelevantBitsMask <= 0xff; irrelevantBitsMask++) {
|
||||
if ((irrelevantBitsMask & keyModMaskX) == 0) {
|
||||
#ifndef NDEBUG
|
||||
sDebug += QStringLiteral("0x%3, ").arg(irrelevantBitsMask, 0, 16);
|
||||
#endif
|
||||
if (grab) {
|
||||
cookies << xcb_grab_key_checked(QX11Info::connection(),
|
||||
true,
|
||||
QX11Info::appRootWindow(),
|
||||
keyModX | irrelevantBitsMask,
|
||||
keyCodeX,
|
||||
XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_SYNC);
|
||||
} else {
|
||||
/* clang-format off */
|
||||
cookies << xcb_ungrab_key_checked(QX11Info::connection(),
|
||||
keyCodeX, QX11Info::appRootWindow(),
|
||||
keyModX | irrelevantBitsMask);
|
||||
/* clang-format on */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool failed = false;
|
||||
if (grab) {
|
||||
for (int i = 0; i < cookies.size(); ++i) {
|
||||
QScopedPointer<xcb_generic_error_t, QScopedPointerPodDeleter> error(xcb_request_check(QX11Info::connection(), cookies.at(i)));
|
||||
if (!error.isNull()) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
if (failed) {
|
||||
qCDebug(KGLOBALACCELD) << "grab failed!\n";
|
||||
for (uint m = 0; m <= 0xff; m++) {
|
||||
if ((m & keyModMaskX) == 0) {
|
||||
xcb_ungrab_key(QX11Info::connection(), keyCodeX, QX11Info::appRootWindow(), keyModX | m);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(keyCodes);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool KGlobalAccelImpl::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *)
|
||||
{
|
||||
if (eventType != "xcb_generic_event_t") {
|
||||
return false;
|
||||
}
|
||||
xcb_generic_event_t *event = reinterpret_cast<xcb_generic_event_t *>(message);
|
||||
const uint8_t responseType = event->response_type & ~0x80;
|
||||
if (responseType == XCB_MAPPING_NOTIFY) {
|
||||
x11MappingNotify();
|
||||
|
||||
// Make sure to let Qt handle it as well
|
||||
return false;
|
||||
} else if (responseType == XCB_KEY_PRESS) {
|
||||
qCDebug(KGLOBALACCELD) << "Got XKeyPress event";
|
||||
return x11KeyPress(reinterpret_cast<xcb_key_press_event_t *>(event));
|
||||
} else if (m_xkb_first_event && responseType == m_xkb_first_event) {
|
||||
const uint8_t xkbEvent = event->pad0;
|
||||
switch (xkbEvent) {
|
||||
case XCB_XKB_MAP_NOTIFY:
|
||||
x11MappingNotify();
|
||||
break;
|
||||
case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
|
||||
const xcb_xkb_new_keyboard_notify_event_t *ev = reinterpret_cast<xcb_xkb_new_keyboard_notify_event_t *>(event);
|
||||
if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES) {
|
||||
x11MappingNotify();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure to let Qt handle it as well
|
||||
return false;
|
||||
} else {
|
||||
// We get all XEvents. Just ignore them.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void KGlobalAccelImpl::x11MappingNotify()
|
||||
{
|
||||
qCDebug(KGLOBALACCELD) << "Got XMappingNotify event";
|
||||
|
||||
// Maybe the X modifier map has been changed.
|
||||
// uint oldKeyModMaskXAccel = g_keyModMaskXAccel;
|
||||
// uint oldKeyModMaskXOnOrOff = g_keyModMaskXOnOrOff;
|
||||
|
||||
// First ungrab all currently grabbed keys. This is needed because we
|
||||
// store the keys as qt keycodes and use KKeyServer to map them to x11 key
|
||||
// codes. After calling KKeyServer::initializeMods() they could map to
|
||||
// different keycodes.
|
||||
ungrabKeys();
|
||||
|
||||
if (m_keySymbols) {
|
||||
// Force reloading of the keySym mapping
|
||||
xcb_key_symbols_free(m_keySymbols);
|
||||
m_keySymbols = nullptr;
|
||||
}
|
||||
|
||||
KKeyServer::initializeMods();
|
||||
calculateGrabMasks();
|
||||
|
||||
grabKeys();
|
||||
}
|
||||
|
||||
bool KGlobalAccelImpl::x11KeyPress(xcb_key_press_event_t *pEvent)
|
||||
{
|
||||
if (QWidget::keyboardGrabber() || QApplication::activePopupWidget()) {
|
||||
qCWarning(KGLOBALACCELD) << "kglobalacceld should be popup and keyboard grabbing free!";
|
||||
}
|
||||
|
||||
// Keyboard needs to be ungrabed after XGrabKey() activates the grab,
|
||||
// otherwise it becomes frozen.
|
||||
xcb_connection_t *c = QX11Info::connection();
|
||||
xcb_void_cookie_t cookie = xcb_ungrab_keyboard_checked(c, XCB_TIME_CURRENT_TIME);
|
||||
xcb_flush(c);
|
||||
// xcb_flush() only makes sure that the ungrab keyboard request has been
|
||||
// sent, but is not enough to make sure that request has been fulfilled. Use
|
||||
// xcb_request_check() to make sure that the request has been processed.
|
||||
xcb_request_check(c, cookie);
|
||||
|
||||
int keyQt;
|
||||
if (!KKeyServer::xcbKeyPressEventToQt(pEvent, &keyQt)) {
|
||||
qCWarning(KGLOBALACCELD) << "KKeyServer::xcbKeyPressEventToQt failed";
|
||||
return false;
|
||||
}
|
||||
// qDebug() << "keyQt=" << QString::number(keyQt, 16);
|
||||
|
||||
// All that work for this hey... argh...
|
||||
if (NET::timestampCompare(pEvent->time, QX11Info::appTime()) > 0) {
|
||||
QX11Info::setAppTime(pEvent->time);
|
||||
}
|
||||
return keyPressed(keyQt);
|
||||
}
|
||||
|
||||
bool KGlobalAccelImpl::x11KeyRelease(xcb_key_press_event_t *pEvent)
|
||||
{
|
||||
if (QWidget::keyboardGrabber() || QApplication::activePopupWidget()) {
|
||||
qCWarning(KGLOBALACCELD) << "kglobalacceld should be popup and keyboard grabbing free!";
|
||||
}
|
||||
|
||||
int keyQt;
|
||||
if (!KKeyServer::xcbKeyPressEventToQt(pEvent, &keyQt)) {
|
||||
return false;
|
||||
}
|
||||
return keyReleased(keyQt);
|
||||
}
|
||||
|
||||
void KGlobalAccelImpl::setEnabled(bool enable)
|
||||
{
|
||||
if (enable && qApp->platformName() == QLatin1String("xcb")) {
|
||||
qApp->installNativeEventFilter(this);
|
||||
} else {
|
||||
qApp->removeNativeEventFilter(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _KGLOBALACCEL_X11_H
|
||||
#define _KGLOBALACCEL_X11_H
|
||||
|
||||
#include "../../kglobalaccel_interface.h"
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QObject>
|
||||
|
||||
struct xcb_key_press_event_t;
|
||||
typedef xcb_key_press_event_t xcb_key_release_event_t;
|
||||
typedef struct _XCBKeySymbols xcb_key_symbols_t;
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* The KGlobalAccel private class handles grabbing of global keys,
|
||||
* and notification of when these keys are pressed.
|
||||
*/
|
||||
class KGlobalAccelImpl : public KGlobalAccelInterface, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.kde.kglobalaccel5.KGlobalAccelInterface" FILE "xcb.json")
|
||||
Q_INTERFACES(KGlobalAccelInterface)
|
||||
|
||||
public:
|
||||
KGlobalAccelImpl(QObject *parent = nullptr);
|
||||
~KGlobalAccelImpl() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This function registers or unregisters a certain key for global capture,
|
||||
* depending on \b grab.
|
||||
*
|
||||
* Before destruction, every grabbed key will be released, so this
|
||||
* object does not need to do any tracking.
|
||||
*
|
||||
* \param key the Qt keycode to grab or release.
|
||||
* \param grab true to grab they key, false to release the key.
|
||||
*
|
||||
* \return true if successful, otherwise false.
|
||||
*/
|
||||
bool grabKey(int key, bool grab) override;
|
||||
|
||||
/// Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
|
||||
void setEnabled(bool) override;
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Filters X11 events ev for key bindings in the accelerator dictionary.
|
||||
* If a match is found the activated activated is emitted and the function
|
||||
* returns true. Return false if the event is not processed.
|
||||
*
|
||||
* This is public for compatibility only. You do not need to call it.
|
||||
*/
|
||||
void x11MappingNotify();
|
||||
bool x11KeyPress(xcb_key_press_event_t *event);
|
||||
bool x11KeyRelease(xcb_key_press_event_t *event);
|
||||
|
||||
xcb_key_symbols_t *m_keySymbols;
|
||||
uint8_t m_xkb_first_event;
|
||||
void *m_display;
|
||||
unsigned int m_xrecordCookieSequence;
|
||||
};
|
||||
|
||||
#endif // _KGLOBALACCEL_X11_H
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"platforms": ["xcb"]
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "kglobalshortcutinfo_p.h"
|
||||
#include "sequencehelpers_p.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
QKeySequence reverseKey(const QKeySequence &key)
|
||||
{
|
||||
int k[maxSequenceLength] = {0, 0, 0, 0};
|
||||
int count = key.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
k[count - i - 1] = key[i].toCombined();
|
||||
}
|
||||
|
||||
return QKeySequence(k[0], k[1], k[2], k[3]);
|
||||
}
|
||||
|
||||
QKeySequence cropKey(const QKeySequence &key, int count)
|
||||
{
|
||||
if (count < 1) {
|
||||
return key;
|
||||
}
|
||||
|
||||
// Key is shorter than count we want to cut off
|
||||
if (key.count() < count) {
|
||||
return QKeySequence();
|
||||
}
|
||||
|
||||
int k[maxSequenceLength] = {0, 0, 0, 0};
|
||||
// cut from beginning
|
||||
for (int i = count; i < key.count(); i++) {
|
||||
k[i - count] = key[i].toCombined();
|
||||
}
|
||||
|
||||
return QKeySequence(k[0], k[1], k[2], k[3]);
|
||||
}
|
||||
|
||||
bool contains(const QKeySequence &key, const QKeySequence &other)
|
||||
{
|
||||
int minLength = std::min(key.count(), other.count());
|
||||
|
||||
// There's an empty key, assume it matches nothing
|
||||
if (!minLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
for (int i = 0; i <= other.count() - minLength; i++) {
|
||||
QKeySequence otherCropped = cropKey(other, i);
|
||||
if (key.matches(otherCropped) == QKeySequence::PartialMatch || reverseKey(key).matches(reverseKey(otherCropped)) == QKeySequence::PartialMatch) {
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool matchSequences(const QKeySequence &key, const QList<QKeySequence> &keys)
|
||||
{
|
||||
// Since we're testing sequences, we need to check for all possible matches
|
||||
// between existing and new sequences.
|
||||
|
||||
// Let's assume we have (Alt+B, Alt+F, Alt+G) assigned. Examples of bad shortcuts are:
|
||||
// 1) Exact matching: (Alt+B, Alt+F, Alt+G)
|
||||
// 2) Sequence shadowing: (Alt+B, Alt+F)
|
||||
// 3) Sequence being shadowed: (Alt+B, Alt+F, Alt+G, <any key>)
|
||||
// 4) Shadowing at the end: (Alt+F, Alt+G)
|
||||
// 5) Being shadowed from the end: (<any key>, Alt+B, Alt+F, Alt+G)
|
||||
|
||||
for (const QKeySequence &otherKey : keys) {
|
||||
if (otherKey.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (key.matches(otherKey) == QKeySequence::ExactMatch || contains(key, otherKey) || contains(otherKey, key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QKeySequence mangleKey(const QKeySequence &key)
|
||||
{
|
||||
// Qt triggers both shortcuts that include Shift+Backtab and Shift+Tab
|
||||
// when user presses Shift+Tab. Make no difference here.
|
||||
int k[maxSequenceLength] = {0, 0, 0, 0};
|
||||
for (int i = 0; i < key.count(); i++) {
|
||||
// Qt triggers both shortcuts that include Shift+Backtab and Shift+Tab
|
||||
// when user presses Shift+Tab. Make no difference here.
|
||||
int keySym = key[i].toCombined() & ~Qt::KeyboardModifierMask;
|
||||
int keyMod = key[i].toCombined() & Qt::KeyboardModifierMask;
|
||||
if ((keyMod & Qt::SHIFT) && (keySym == Qt::Key_Backtab || keySym == Qt::Key_Tab)) {
|
||||
k[i] = keyMod | Qt::Key_Tab;
|
||||
} else {
|
||||
k[i] = key[i].toCombined();
|
||||
}
|
||||
}
|
||||
|
||||
return QKeySequence(k[0], k[1], k[2], k[3]);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef SEQUENCEHELPERS_H
|
||||
#define SEQUENCEHELPERS_H
|
||||
|
||||
#include <kglobalaccel_export.h>
|
||||
|
||||
#include <QKeySequence>
|
||||
|
||||
// Some methods are exported for the unittest
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
KGLOBALACCEL_EXPORT QKeySequence reverseKey(const QKeySequence &key);
|
||||
|
||||
KGLOBALACCEL_EXPORT QKeySequence cropKey(const QKeySequence &key, int count);
|
||||
|
||||
bool contains(const QKeySequence &key, const QKeySequence &other);
|
||||
|
||||
KGLOBALACCEL_EXPORT bool matchSequences(const QKeySequence &key, const QList<QKeySequence> &keys);
|
||||
|
||||
KGLOBALACCEL_EXPORT QKeySequence mangleKey(const QKeySequence &key);
|
||||
}
|
||||
|
||||
#endif // SEQUENCEHELPERS_H
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
#TODO: kglobalaccel daemon not yet built for Redox — D-Bus activation will fail until it exists
|
||||
[D-BUS Service]
|
||||
Name=org.kde.kglobalaccel
|
||||
Exec=/usr/bin/kglobalaccel
|
||||
Exec=/usr/bin/kglobalacceld
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../local/recipes/kde/kglobalacceld
|
||||
Reference in New Issue
Block a user