Adding upstream version 0.9.0+20150806.

Signed-off-by: Andrew Lee (李健秋) <ajqlee@debian.org>
upstream/0.9.0+20150806
Andrew Lee (李健秋) 10 years ago
parent 512032c43f
commit c7d5a3ab86
No known key found for this signature in database
GPG Key ID: 9D0633E1B6250985

1
.gitignore vendored

@ -1 +0,0 @@
build

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.11) cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
project(lxqt-globalkeys) project(lxqt-globalkeys)
@ -11,64 +11,85 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
# Set default library installation path
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation directory for libraries")
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
find_package(Qt5DBus REQUIRED) find_package(Qt5DBus REQUIRED)
find_package(Qt5LinguistTools REQUIRED QUIET) find_package(Qt5LinguistTools REQUIRED QUIET)
find_package(lxqt REQUIRED QUIET) find_package(lxqt REQUIRED QUIET)
include(${LXQT_USE_FILE})
include(LXQtTranslate) include(LXQtTranslate)
include(LXQtCreatePkgConfigFile)
include(LXQtCompilerSettings NO_POLICY_SCOPE)
# Standard directories for installation include(GNUInstallDirs) # Standard directories for installation
include(GNUInstallDirs) include(CMakePackageConfigHelpers)
set(LXQT_GLOBALKEYS_LIBRARY_NAME lxqt-globalkeys) set(LXQT_GLOBALKEYS_LIBRARY_NAME lxqt-globalkeys)
set(LXQT_GLOBALKEYS_UI_LIBRARY_NAME lxqt-globalkeys-ui) set(LXQT_GLOBALKEYS_UI_LIBRARY_NAME lxqt-globalkeys-ui)
set(LXQT_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/cmake) set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake")
#************************************************ #************************************************
# Build config.cmake files # Build config.cmake files
#************************************************ #************************************************
#set(LXQT_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/lxqt)
#set(LXQT_TRANSLATIONS_DIR ${LXQT_SHARE_DIR}/translations)
include(cmake/FindInstallConfigPath.cmake)
set(LXQT_GLOBALKEYS_CMAKE_NAME ${LXQT_GLOBALKEYS_LIBRARY_NAME}) set(LXQT_GLOBALKEYS_CMAKE_NAME ${LXQT_GLOBALKEYS_LIBRARY_NAME})
set(LXQT_GLOBALKEYS_UI_CMAKE_NAME ${LXQT_GLOBALKEYS_UI_LIBRARY_NAME}) set(LXQT_GLOBALKEYS_UI_CMAKE_NAME ${LXQT_GLOBALKEYS_UI_LIBRARY_NAME})
set(LXQT_GLOBALKEYS_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${LXQT_GLOBALKEYS_LIBRARY_NAME}") configure_package_config_file(
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys-config.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake" "${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake"
@ONLY INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
) )
set(LXQT_GLOBALKEYS_UI_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/${LXQT_GLOBALKEYS_UI_LIBRARY_NAME}) configure_package_config_file(
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys_ui-config.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys_ui-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake" "${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake"
@ONLY INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
) )
#************************************************ #************************************************
# End of build config.cmake # End of build config.cmake
#************************************************ #************************************************
#************************************************
# Generate config-version.cmake files
#************************************************
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config-version.cmake"
VERSION ${LXQT_VERSION}
COMPATIBILITY AnyNewerVersion
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config-version.cmake"
VERSION ${LXQT_VERSION}
COMPATIBILITY AnyNewerVersion
)
#************************************************
# End of generate config-version.cmake files
#************************************************
set(LXQT_GLOBALKEYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(LXQT_GLOBALKEYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
add_subdirectory(daemon) add_subdirectory(daemon)
add_subdirectory(config) add_subdirectory(config)
add_subdirectory(client) add_subdirectory(client)
add_subdirectory(ui) add_subdirectory(ui)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}) install(FILES
install(FILES cmake/lxqt_globalkeys_use.cmake DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}) "${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake"
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config-version.cmake"
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}) install(FILES
install(FILES cmake/lxqt_globalkeys_ui_use.cmake DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}) "${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake"
"${CMAKE_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config-version.cmake"
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}"
)
# building tarball with CPack ------------------------------------------------- # building tarball with CPack -------------------------------------------------
include(InstallRequiredSystemLibraries) include(InstallRequiredSystemLibraries)

@ -5,15 +5,8 @@ set(QT_DBUS_PREFIX "org.qtproject")
set(${PROJECT_NAME}_HEADER_NAMESPACE "LXQtGlobalKeys") set(${PROJECT_NAME}_HEADER_NAMESPACE "LXQtGlobalKeys")
include_directories(
${PROJECT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon") set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon")
add_definitions(-DSHARED_EXPORT=Q_DECL_EXPORT)
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
client.cpp client.cpp
action.cpp action.cpp
@ -21,7 +14,7 @@ set(${PROJECT_NAME}_SOURCES
# #
# WARNING: Changing stuff here implies changing this: # WARNING: Changing stuff here implies changing this:
# install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT development RENAME "lxqtglobalkeys.h") # install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT Devel RENAME "lxqtglobalkeys.h")
# #
set(${PROJECT_NAME}_MAIN_HEADER set(${PROJECT_NAME}_MAIN_HEADER
lxqt-globalkeys.h lxqt-globalkeys.h
@ -53,10 +46,10 @@ set(${PROJECT_NAME}_TRANSLATIONS
) )
set(${PROJECT_NAME}_DBUS_ADAPTORS set(${PROJECT_NAME}_DBUS_ADAPTORS
${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml "${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml"
) )
set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml PROPERTIES set_source_files_properties("${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml" PROPERTIES
INCLUDE action_p.h INCLUDE action_p.h
PARENT_CLASSNAME GlobalKeyShortcut::ActionImpl PARENT_CLASSNAME GlobalKeyShortcut::ActionImpl
BASENAME org.lxqt.global_key_shortcuts.client BASENAME org.lxqt.global_key_shortcuts.client
@ -64,10 +57,10 @@ set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_ke
) )
set(${PROJECT_NAME}_DBUS_INTERFACES set(${PROJECT_NAME}_DBUS_INTERFACES
${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml "${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml"
) )
set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml PROPERTIES set_source_files_properties("${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml" PROPERTIES
BASENAME org.lxqt.global_key_shortcuts.native BASENAME org.lxqt.global_key_shortcuts.native
) )
@ -128,16 +121,15 @@ foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE) get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME) get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE) get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} PROPERTIES set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
INCLUDE ${DBUS_INTERFACE_INCLUDE} INCLUDE ${DBUS_INTERFACE_INCLUDE}
CLASSNAME ${DBUS_INTERFACE_CLASSNAME} CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE} NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
) )
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} ${DBUS_INTERFACE_BASENAME}) qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
endforeach() endforeach()
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES}) qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_FORM_FILES ${${PROJECT_NAME}_FORMS})
set(${PROJECT_NAME}_GENERATED_FILES set(${PROJECT_NAME}_GENERATED_FILES
${${PROJECT_NAME}_FORM_FILES} ${${PROJECT_NAME}_FORM_FILES}
@ -153,13 +145,32 @@ set(${PROJECT_NAME}_ALL_FILES
${${PROJECT_NAME}_GENERATED_FILES} ${${PROJECT_NAME}_GENERATED_FILES}
) )
set(${PROJECT_NAME}_PKG_CONFIG_REQUIRES "Qt5Widget, Qt5DBus")
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES}) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::DBus) target_link_libraries(${PROJECT_NAME}
PUBLIC
Qt5::Widgets
Qt5::DBus
)
set_target_properties(${PROJECT_NAME} set_target_properties(${PROJECT_NAME}
PROPERTIES PROPERTIES
VERSION ${LXQT_VERSION} VERSION ${LXQT_VERSION}
SOVERSION ${LXQT_MAJOR_VERSION} SOVERSION ${LXQT_MAJOR_VERSION}
) )
target_include_directories(${PROJECT_NAME}
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_GLOBALKEYS_LIBRARY_NAME}>"
)
target_include_directories(${PROJECT_NAME}
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include>"
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}>"
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "SHARED_EXPORT=Q_DECL_EXPORT"
)
export(TARGETS ${PROJECT_NAME} FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}-targets.cmake")
include(create_portable_headers) include(create_portable_headers)
@ -167,11 +178,75 @@ create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS
NAMESPACE "${${PROJECT_NAME}_NAMESPACE}/" NAMESPACE "${${PROJECT_NAME}_NAMESPACE}/"
FILENAMES ${${PROJECT_NAME}_PUBLIC_CLASSES} FILENAMES ${${PROJECT_NAME}_PUBLIC_CLASSES}
) )
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT runtime)
install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT development)
install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT development RENAME "lxqtglobalkeys.h")
install(FILES ${${PROJECT_NAME}_PORTABLE_HEADERS} DESTINATION include/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE} COMPONENT development)
install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION include/${PROJECT_NAME} COMPONENT development)
include(create_pkgconfig_file) # Copy public headers for intree building
create_pkgconfig_file(${PROJECT_NAME} "LXQt global key shortcuts client library") foreach(h ${${PROJECT_NAME}_PUBLIC_HEADERS})
get_filename_component(bh ${h} NAME)
configure_file(${h} "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${bh}" COPYONLY)
endforeach()
foreach(h ${${PROJECT_NAME}_PORTABLE_HEADERS})
get_filename_component(bh ${h} NAME)
configure_file(${h} "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}/${bh}" COPYONLY)
endforeach()
configure_file(
"${${PROJECT_NAME}_MAIN_HEADER}"
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${${PROJECT_NAME}_MAIN_HEADER}"
COPYONLY
)
configure_file(
"${${PROJECT_NAME}_MAIN_HEADER}"
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/lxqtglobalkeys.h"
COPYONLY
)
install(TARGETS
${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
EXPORT ${PROJECT_NAME}-targets
COMPONENT Runtime
)
install(EXPORT
${PROJECT_NAME}-targets
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}"
COMPONENT Devel
)
install(FILES
${${PROJECT_NAME}_MAIN_HEADER}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT Devel
)
install(FILES
${${PROJECT_NAME}_MAIN_HEADER}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT Devel
RENAME "lxqtglobalkeys.h"
)
install(FILES
${${PROJECT_NAME}_PORTABLE_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}"
COMPONENT Devel
)
install(FILES
${${PROJECT_NAME}_PUBLIC_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT Devel
)
lxqt_create_pkgconfig_file(
PACKAGE_NAME ${PROJECT_NAME}
DESCRIPTIVE_NAME ${PROJECT_NAME}
DESCRIPTION "LXQt global key shortcuts client library"
INCLUDEDIRS ${PROJECT_NAME}
LIBS ${PROJECT_NAME}
REQUIRES ${${PROJECT_NAME}_PKG_CONFIG_REQUIRES}
VERSION ${LXQT_VERSION}
INSTALL
)

@ -41,9 +41,11 @@ ActionImpl::ActionImpl(ClientImpl *client, Action *interface, const QString &pat
, mInterface(interface) , mInterface(interface)
, mPath(path) , mPath(path)
, mDescription(description) , mDescription(description)
, mRegistrationPending(false)
{ {
new OrgLxqtActionClientAdaptor(this); new OrgLxqtActionClientAdaptor(this);
connect(this, SIGNAL(emitRegistrationFinished()), mInterface, SIGNAL(registrationFinished()));
connect(this, SIGNAL(emitActivated()), mInterface, SIGNAL(activated())); connect(this, SIGNAL(emitActivated()), mInterface, SIGNAL(activated()));
connect(this, SIGNAL(emitShortcutChanged(QString, QString)), mInterface, SIGNAL(shortcutChanged(QString, QString))); connect(this, SIGNAL(emitShortcutChanged(QString, QString)), mInterface, SIGNAL(shortcutChanged(QString, QString)));
} }
@ -55,12 +57,18 @@ ActionImpl::~ActionImpl()
QString ActionImpl::changeShortcut(const QString &shortcut) QString ActionImpl::changeShortcut(const QString &shortcut)
{ {
if (mRegistrationPending)
return mShortcut;
mShortcut = mClient->changeClientActionShortcut(mPath, shortcut); mShortcut = mClient->changeClientActionShortcut(mPath, shortcut);
return mShortcut; return mShortcut;
} }
bool ActionImpl::changeDescription(const QString &description) bool ActionImpl::changeDescription(const QString &description)
{ {
if (mRegistrationPending)
return false;
bool result = mClient->modifyClientAction(mPath, description); bool result = mClient->modifyClientAction(mPath, description);
if (result) if (result)
{ {
@ -99,6 +107,19 @@ bool ActionImpl::isValid() const
return mValid; return mValid;
} }
void ActionImpl::setRegistrationPending(bool registrationPending)
{
mRegistrationPending = registrationPending;
if (!mRegistrationPending)
emit emitRegistrationFinished();
}
bool ActionImpl::isRegistrationPending() const
{
return mRegistrationPending;
}
void ActionImpl::activated() void ActionImpl::activated()
{ {
emit emitActivated(); emit emitActivated();

@ -62,8 +62,10 @@ public:
QString description() const; QString description() const;
bool isValid() const; bool isValid() const;
bool isRegistrationPending() const;
signals: signals:
void registrationFinished();
void activated(); void activated();
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut); void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);

@ -60,11 +60,15 @@ public:
void setValid(bool valid); void setValid(bool valid);
bool isValid() const; bool isValid() const;
void setRegistrationPending(bool registrationPending);
bool isRegistrationPending() const;
public slots: public slots:
void activated(); void activated();
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut); void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
signals: signals:
void emitRegistrationFinished();
void emitActivated(); void emitActivated();
void emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut); void emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut);
@ -76,6 +80,7 @@ private:
QString mShortcut; QString mShortcut;
QString mDescription; QString mDescription;
bool mValid; bool mValid;
bool mRegistrationPending;
}; };
} }

@ -82,14 +82,11 @@ void ClientImpl::daemonAppeared(const QString &)
{ {
ActionImpl *globalActionImpl = I.value()->impl; ActionImpl *globalActionImpl = I.value()->impl;
QDBusPendingReply<QString, qulonglong> reply = mProxy->addClientAction(globalActionImpl->shortcut(), QDBusObjectPath(globalActionImpl->path()), globalActionImpl->description()); QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(mProxy->addClientAction(globalActionImpl->shortcut(), QDBusObjectPath(globalActionImpl->path()), globalActionImpl->description()));
reply.waitForFinished(); connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(registrationFinished(QDBusPendingCallWatcher *)));
globalActionImpl->setValid(!reply.isError() && reply.argumentAt<1>()); mPendingRegistrationsActions[watcher] = globalActionImpl;
mPendingRegistrationsWatchers[globalActionImpl] = watcher;
if (globalActionImpl->isValid()) globalActionImpl->setRegistrationPending(true);
{
globalActionImpl->setShortcut(reply.argumentAt<0>());
}
} }
mDaemonPresent = true; mDaemonPresent = true;
emit emitDaemonAppeared(); emit emitDaemonAppeared();
@ -101,6 +98,29 @@ bool ClientImpl::isDaemonPresent() const
return mDaemonPresent; return mDaemonPresent;
} }
void ClientImpl::registrationFinished(QDBusPendingCallWatcher *watcher)
{
QMap<QDBusPendingCallWatcher*, ActionImpl*>::Iterator I = mPendingRegistrationsActions.find(watcher);
if (I != mPendingRegistrationsActions.end())
{
ActionImpl *globalActionImpl = I.value();
QDBusPendingReply<QString, qulonglong> reply = *watcher;
globalActionImpl->setValid(!reply.isError() && reply.argumentAt<1>());
if (globalActionImpl->isValid())
{
globalActionImpl->setShortcut(reply.argumentAt<0>());
}
mPendingRegistrationsWatchers.remove(globalActionImpl);
mPendingRegistrationsActions.erase(I);
watcher->deleteLater();
globalActionImpl->setRegistrationPending(false);
}
}
Action *ClientImpl::addClientAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent) Action *ClientImpl::addClientAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent)
{ {
if (!QRegExp("(/[A-Za-z0-9_]+){2,}").exactMatch(path)) if (!QRegExp("(/[A-Za-z0-9_]+){2,}").exactMatch(path))
@ -125,13 +145,11 @@ Action *ClientImpl::addClientAction(const QString &shortcut, const QString &path
if (mDaemonPresent) if (mDaemonPresent)
{ {
QDBusPendingReply<QString, qulonglong> reply = mProxy->addClientAction(shortcut, QDBusObjectPath(path), description); QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(mProxy->addClientAction(shortcut, QDBusObjectPath(path), description));
reply.waitForFinished(); connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(registrationFinished(QDBusPendingCallWatcher *)));
globalActionImpl->setValid(!reply.isError() && reply.argumentAt<1>()); mPendingRegistrationsActions[watcher] = globalActionImpl;
if (globalActionImpl->isValid()) mPendingRegistrationsWatchers[globalActionImpl] = watcher;
{ globalActionImpl->setRegistrationPending(true);
globalActionImpl->setShortcut(reply.argumentAt<0>());
}
} }
else else
{ {
@ -204,6 +222,21 @@ bool ClientImpl::removeClientAction(const QString &path)
void ClientImpl::removeAction(ActionImpl *actionImpl) void ClientImpl::removeAction(ActionImpl *actionImpl)
{ {
if (actionImpl->isRegistrationPending())
{
QMap<ActionImpl*, QDBusPendingCallWatcher*>::Iterator I = mPendingRegistrationsWatchers.find(actionImpl);
if (I != mPendingRegistrationsWatchers.end())
{
QDBusPendingCallWatcher *watcher = I.value();
watcher->disconnect();
mPendingRegistrationsActions.remove(watcher);
mPendingRegistrationsWatchers.erase(I);
watcher->deleteLater();
}
}
QString path = actionImpl->path(); QString path = actionImpl->path();
if (!mActions.contains(path)) if (!mActions.contains(path))
{ {

@ -81,6 +81,7 @@ public slots:
void grabShortcutFinished(QDBusPendingCallWatcher *call); void grabShortcutFinished(QDBusPendingCallWatcher *call);
void daemonDisappeared(const QString &); void daemonDisappeared(const QString &);
void daemonAppeared(const QString &); void daemonAppeared(const QString &);
void registrationFinished(QDBusPendingCallWatcher *call);
signals: signals:
void emitShortcutGrabbed(const QString &); void emitShortcutGrabbed(const QString &);
@ -98,6 +99,9 @@ private:
QMap<QString, Action*> mActions; QMap<QString, Action*> mActions;
QDBusServiceWatcher *mServiceWatcher; QDBusServiceWatcher *mServiceWatcher;
bool mDaemonPresent; bool mDaemonPresent;
QMap<QDBusPendingCallWatcher*, ActionImpl*> mPendingRegistrationsActions;
QMap<ActionImpl*, QDBusPendingCallWatcher*> mPendingRegistrationsWatchers;
}; };
} }

@ -1,20 +0,0 @@
# XDG standards expects system-wide configuration files in the /etc/xdg/lxqt location.
# Unfortunately QSettings we are using internally can be overriden in the Qt compilation
# time to use different path for system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
# This path can be found calling Qt4's qmake:
# qmake -query QT_INSTALL_CONFIGURATION
#
if(NOT DEFINED LXQT_ETC_XDG_DIR)
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "LXQT_ETC_XDG_DIR: qmake not found or wrongly detected (inlude before qt configured?)")
endif()
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_CONFIGURATION
OUTPUT_VARIABLE LXQT_ETC_XDG_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "LXQT_ETC_XDG_DIR autodetected as '${LXQT_ETC_XDG_DIR}'")
message(STATUS "You can set it manually with -DLXQT_ETC_XDG_DIR=<value>")
message(STATUS "")
endif ()

@ -1,33 +0,0 @@
#
# Write a pkg-config pc file for given "name" with "decription"
# Arguments:
# name: a library name (withoud "lib" prefix and "so" suffixes
# desc: a desription string
#
macro (create_pkgconfig_file name desc)
set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
#message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
file(WRITE "${_pkgfname}"
"# file generated by LXQt cmake build\n"
"prefix=${CMAKE_INSTALL_PREFIX}\n"
"libdir=\${prefix}/lib${LIB_SUFFIX}\n"
"includedir=\${prefix}/include\n"
"\n"
"Name: ${name}\n"
"Description: ${desc}\n"
"Version: ${LXQT_VERSION}\n"
"Libs: -L\${libdir} -l${name}\n"
"Cflags: -I\${includedir}\n"
"\n"
)
# FreeBSD loves to install files to different locations
# http://www.freebsd.org/doc/handbook/dirstructure.html
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
install(FILES ${_pkgfname} DESTINATION libdata/pkgconfig)
else()
install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig)
endif()
endmacro()

@ -3,41 +3,24 @@
# The module defines the following variables # The module defines the following variables
# LXQT_GLOBALKEYS_FOUND - Set to TRUE if all of the above has been found # LXQT_GLOBALKEYS_FOUND - Set to TRUE if all of the above has been found
# #
# LXQT_GLOBALKEYS_INCLUDE_DIR - The lxqt-globalkeys include directory
#
# LXQT_GLOBALKEYS_INCLUDE_DIRS - The lxqt-globalkeys include directory
#
# LXQT_GLOBALKEYS_LIBRARY_DIRS - The lxqt-globalkeys include directory
#
# LXQT_GLOBALKEYS_LIBRARIES - The libraries needed to use lxqt-globalkeys
#
# LXQT_GLOBALKEYS_USE_FILE - The variable LXQT_GLOBALKEYS_USE_FILE is set which is the path
# to a CMake file that can be included to compile lxqt-globalkeys
# applications and libraries. It sets up the compilation
# environment for include directories and populates a
# LXQT_GLOBALKEYS_LIBRARIES variable.
#
# LXQT_GLOBALKEYS_QT_LIBRARIES - The Qt libraries needed by lxqt-globalkeys
#
# Typical usage: # Typical usage:
# find_package(lxqt-globalkeys) # find_package(lxqt-globalkeys)
# include(${LXQT_GLOBALKEYS_USE_FILE})
# add_executable(use-lxqt-globalkeys main.cpp) # add_executable(use-lxqt-globalkeys main.cpp)
# target_link_libraries(use-qtxdg ${LXQT_GLOBALKEYS_QT_LIBRARIES} ${LXQT_GLOBALKEYS_LIBRARIES}) # target_link_libraries(use-lxqt-globalkeys lxqt-globalkeys)
set(LXQT_GLOBALKEYS_INCLUDE_DIR @LXQT_GLOBALKEYS_INCLUDE_DIR@) @PACKAGE_INIT@
set(LXQT_GLOBALKEYS_LIBRARY @LXQT_GLOBALKEYS_LIBRARY_NAME@)
set(LXQT_GLOBALKEYS_LIBRARIES "${LXQT_GLOBALKEYS_LIBRARY}") include(CMakeFindDependencyMacro)
set(LXQT_GLOBALKEYS_INCLUDE_DIRS "${LXQT_GLOBALKEYS_INCLUDE_DIR}")
set(LXQT_GLOBALKEYS_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@)
set(LXQT_GLOBALKEYS_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/lxqt_globalkeys_use.cmake")
set(LXQT_GLOBALKEYS_FOUND 1)
set(LXQT_GLOBALKEYS_MAJOR_VERSION @LXQT_MAJOR_VERSION@) set(LXQT_GLOBALKEYS_MAJOR_VERSION @LXQT_MAJOR_VERSION@)
set(LXQT_GLOBALKEYS_MINOR_VERSION @LXQT_MINOR_VERSION@) set(LXQT_GLOBALKEYS_MINOR_VERSION @LXQT_MINOR_VERSION@)
set(LXQT_GLOBALKEYS_PATCH_VERSION @LXQT_PATCH_VERSION@) set(LXQT_GLOBALKEYS_PATCH_VERSION @LXQT_PATCH_VERSION@)
set(LXQT_GLOBALKEYS_VERSION @LXQT_VERSION@) set(LXQT_GLOBALKEYS_VERSION @LXQT_VERSION@)
mark_as_advanced(LXQT_GLOBALKEYS_LIBRARY LXQT_GLOBALKEYS_INCLUDE_DIR) find_dependency(Qt5Widgets)
find_dependency(Qt5DBus)
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
cmake_policy(SET CMP0024 OLD)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/lxqt-globalkeys-targets.cmake")

@ -3,41 +3,25 @@
# The module defines the following variables # The module defines the following variables
# LXQT_GLOBALKEYS_UI_FOUND - Set to TRUE if all of the above has been found # LXQT_GLOBALKEYS_UI_FOUND - Set to TRUE if all of the above has been found
# #
# LXQT_GLOBALKEYS_UI_INCLUDE_DIR - The lxqt-globalkeys-ui include directory
#
# LXQT_GLOBALKEYS_UI_INCLUDE_DIRS - The lxqt-globalkeys-ui include directory
#
# LXQT_GLOBALKEYS_LIBRARY_DIRS - The lxqt-globalkeys include directory
#
# LXQT_GLOBALKEYS_UI_LIBRARIES - The libraries needed to use lxqt-globalkeys-ui
#
# LXQT_GLOBALKEYS_UI_USE_FILE - The variable LXQT_GLOBALKEYS_UI_USE_FILE is set which is the path
# to a CMake file that can be included to compile lxqt-globalkeys-ui
# applications and libraries. It sets up the compilation
# environment for include directories and populates a
# LXQT_GLOBALKEYS_UI_LIBRARIES variable.
#
# LXQT_GLOBALKEYS_UI_QT_LIBRARIES - The Qt libraries needed by lxqt-globalkeys-ui
#
# Typical usage: # Typical usage:
# find_package(lxqt-globalkeys-ui) # find_package(lxqt-globalkeys-ui)
# include(${LXQT_GLOBALKEYS_UI_USE_FILE})
# add_executable(use-lxqt-globalkeys-ui main.cpp) # add_executable(use-lxqt-globalkeys-ui main.cpp)
# target_link_libraries(use-qtxdg ${LXQT_GLOBALKEYS_UI_QT_LIBRARIES} ${LXQT_GLOBALKEYS_UI_LIBRARIES}) # target_link_libraries(use-lxqt-globalkeys-ui lxqt-globalkeys-ui)
set(LXQT_GLOBALKEYS_UI_INCLUDE_DIR @LXQT_GLOBALKEYS_UI_INCLUDE_DIR@) @PACKAGE_INIT@
set(LXQT_GLOBALKEYS_UI_LIBRARY @LXQT_GLOBALKEYS_UI_LIBRARY_NAME@)
set(LXQT_GLOBALKEYS_UI_LIBRARIES "${LXQT_GLOBALKEYS_UI_LIBRARY}") include(CMakeFindDependencyMacro)
set(LXQT_GLOBALKEYS_UI_INCLUDE_DIRS "${LXQT_GLOBALKEYS_UI_INCLUDE_DIR}")
set(LXQT_GLOBALKEYS_UI_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@)
set(LXQT_GLOBALKEYS_UI_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/lxqt_globalkeys_ui_use.cmake")
set(LXQT_GLOBALKEYS_UI_FOUND 1)
set(LXQT_GLOBALKEYS_UI_MAJOR_VERSION @LXQT_MAJOR_VERSION@) set(LXQT_GLOBALKEYS_UI_MAJOR_VERSION @LXQT_MAJOR_VERSION@)
set(LXQT_GLOBALKEYS_UI_MINOR_VERSION @LXQT_MINOR_VERSION@) set(LXQT_GLOBALKEYS_UI_MINOR_VERSION @LXQT_MINOR_VERSION@)
set(LXQT_GLOBALKEYS_UI_PATCH_VERSION @LXQT_PATCH_VERSION@) set(LXQT_GLOBALKEYS_UI_PATCH_VERSION @LXQT_PATCH_VERSION@)
set(LXQT_GLOBALKEYS_UI_VERSION @LXQT_VERSION@) set(LXQT_GLOBALKEYS_UI_VERSION @LXQT_VERSION@)
mark_as_advanced(LXQT_GLOBALKEYS_UI_LIBRARY LXQT_GLOBALKEYS_UI_INCLUDE_DIR) find_dependency(Qt5Widgets)
find_dependency(Qt5DBus)
find_dependency(lxqt-globalkeys)
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
cmake_policy(SET CMP0024 OLD)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/lxqt-globalkeys-ui-targets.cmake")

@ -1,2 +0,0 @@
include_directories(${LXQT_GLOBALKEYS_UI_INCLUDE_DIRS})
link_directories(${LXQT_GLOBALKEYS_UI_LIBRARY_DIRS})

@ -1,2 +0,0 @@
include_directories(${LXQT_GLOBALKEYS_INCLUDE_DIRS})
link_directories(${LXQT_GLOBALKEYS_LIBRARY_DIRS})

@ -7,18 +7,8 @@ endif()
find_package(KF5WindowSystem REQUIRED QUIET) find_package(KF5WindowSystem REQUIRED QUIET)
set(QTX_INCLUDE_DIRS "")
set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus)
set(QT_DBUS_PREFIX "org.qtproject") set(QT_DBUS_PREFIX "org.qtproject")
include_directories(
"${PROJECT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${QTX_INCLUDE_DIRS}
${LXQT_INCLUDE_DIRS}
)
set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon") set(${PROJECT_NAME}_PATH_TO_DAEMON "${LXQT_GLOBALKEYS_SOURCE_DIR}/daemon")
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
@ -94,23 +84,22 @@ foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME) get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
configure_file( configure_file(
${DBUS_INTERFACE} ${DBUS_INTERFACE}
${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
@ONLY @ONLY
) )
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME) get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE) get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME) get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE) get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} PROPERTIES set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
INCLUDE ${DBUS_INTERFACE_INCLUDE} INCLUDE ${DBUS_INTERFACE_INCLUDE}
CLASSNAME ${DBUS_INTERFACE_CLASSNAME} CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE} NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
) )
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} ${DBUS_INTERFACE_BASENAME}) qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
endforeach() endforeach()
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES}) qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_FORM_FILES ${${PROJECT_NAME}_FORMS})
# Translations ********************************** # Translations **********************************
lxqt_translate_ts(${PROJECT_NAME}_QM_FILES lxqt_translate_ts(${PROJECT_NAME}_QM_FILES
@ -145,7 +134,16 @@ set(${PROJECT_NAME}_ALL_FILES
) )
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES}) add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES})
target_link_libraries(${PROJECT_NAME} KF5::WindowSystem ${QTX_LIBRARIES} ${LXQT_LIBRARIES}) target_link_libraries(${PROJECT_NAME} KF5::WindowSystem lxqt)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) install(TARGETS
install(FILES ${${PROJECT_NAME}_DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT Runtime
)
install(FILES
${${PROJECT_NAME}_DESKTOP_FILES}
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
COMPONENT Runtime
)

@ -0,0 +1,4 @@
# Translations
Name[hu]=LxQt gyorsbillentyűk
Comment[hu]=LXQt általános forróbillentyűinek beállítása
GenericName[hu]=LXQt gyorsbillentyűk beállítása

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="hu_HU">
<context>
<name>CommandFinder</name>
<message>
<source>...</source>
<translation>...</translation>
</message>
<message>
<source>Find a command</source>
<translation>Parancs keresés</translation>
</message>
</context>
<context>
<name>ShortcutConfigWindow</name>
<message>
<source>LxQt Shortcut Editor</source>
<translation>LXQt forróbillentyű szerkesztés</translation>
</message>
<message>
<source>Description</source>
<translation>Leírás</translation>
</message>
<message>
<source>Shortcut</source>
<translation>Forróbillentyű</translation>
</message>
<message>
<source>Command</source>
<translation>Parancs</translation>
</message>
<message>
<source>Add New</source>
<translation>Új</translation>
</message>
<message>
<source>Remove</source>
<translation>Törlés</translation>
</message>
<message>
<source>Add Group</source>
<translation>Csoport</translation>
</message>
<message>
<source>Reset</source>
<translation>Visszavon</translation>
</message>
<message>
<source>Close</source>
<translation>Bezár</translation>
</message>
</context>
<context>
<name>ShortcutEditor</name>
<message>
<source>None</source>
<translation>Nincs</translation>
</message>
<message>
<source>Add Shortcut</source>
<translation>Forróbillentyű adás</translation>
</message>
<message>
<source>Remove</source>
<translation>Törlés</translation>
</message>
<message>
<source>New Group</source>
<translation>Új csoport</translation>
</message>
<message>
<source>Reset Changes</source>
<translation>Visszavonás</translation>
</message>
<message>
<source>Question</source>
<translation>Kérdés</translation>
</message>
<message>
<source>Delete group: %1? (everything inside will be removed altogether)</source>
<translation>A %1 csoport törlése? (Minden kapcsolata is törlődik)</translation>
</message>
<message>
<source>Delete %1?</source>
<translation>%1 törlése?</translation>
</message>
<message>
<source>Binding for %1 already exists. Replace old one?</source>
<translation>A %1 már foglalt. Felváltsuk az újjal?</translation>
</message>
</context>
</TS>

@ -1,4 +1,3 @@
# Translations # Translations
Name[it_IT]=Configurazione delle scorciatoie di LxQt Name[it_IT]=Scorciatoie globali
Comment[it_IT]=Configura le scorciatoie globali del desktop LxQt Comment[it_IT]=Configura le scorciatoie globali di LXQt
GenericName[it_IT]=Configurazione delle scorciatoie globali di LxQt

@ -6,15 +6,10 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
find_package(X11) find_package(X11)
include_directories(${X11_INCLUDE_DIR}) include_directories("${X11_INCLUDE_DIR}")
set(QT_DBUS_PREFIX "org.qtproject") set(QT_DBUS_PREFIX "org.qtproject")
include_directories(
${PROJECT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
main.cpp main.cpp
core.cpp core.cpp
@ -92,7 +87,7 @@ foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME) get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
configure_file( configure_file(
${DBUS_ADAPTOR} ${DBUS_ADAPTOR}
${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}"
@ONLY @ONLY
) )
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE) get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
@ -101,12 +96,12 @@ foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME) get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
if(DBUS_ADAPTOR_BASENAME) if(DBUS_ADAPTOR_BASENAME)
if(DBUS_ADAPTOR_CLASSNAME) if(DBUS_ADAPTOR_CLASSNAME)
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME}) qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
else() else()
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME}) qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
endif() endif()
else() else()
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME}) qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
endif() endif()
endforeach() endforeach()
@ -114,23 +109,22 @@ foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME) get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
configure_file( configure_file(
${DBUS_INTERFACE} ${DBUS_INTERFACE}
${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
@ONLY @ONLY
) )
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME) get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE) get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME) get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE) get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} PROPERTIES set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" PROPERTIES
INCLUDE ${DBUS_INTERFACE_INCLUDE} INCLUDE ${DBUS_INTERFACE_INCLUDE}
CLASSNAME ${DBUS_INTERFACE_CLASSNAME} CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE} NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
) )
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} ${DBUS_INTERFACE_BASENAME}) qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
endforeach() endforeach()
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES}) qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_FORM_FILES ${${PROJECT_NAME}_FORMS})
set(${PROJECT_NAME}_GENERATED_FILES set(${PROJECT_NAME}_GENERATED_FILES
${${PROJECT_NAME}_FORM_FILES} ${${PROJECT_NAME}_FORM_FILES}
@ -147,6 +141,11 @@ set(${PROJECT_NAME}_ALL_FILES
) )
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES}) add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_ALL_FILES})
target_link_libraries(${PROJECT_NAME} ${X11_LIBRARIES} Qt5::Widgets Qt5::DBus) target_link_libraries(${PROJECT_NAME} ${X11_LIBRARIES} lxqt Qt5::Widgets Qt5::DBus)
lxqt_enable_target_exceptions(${PROJECT_NAME} PRIVATE)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) install(TARGETS
${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT Runtime
)

@ -25,8 +25,9 @@
* *
* END_COMMON_COPYRIGHT_HEADER */ * END_COMMON_COPYRIGHT_HEADER */
#include <QCoreApplication> #include <LXQt/Application>
#include <QScopedArrayPointer>
#include <QSettings> #include <QSettings>
#include <QTimer> #include <QTimer>
#include <QDBusConnectionInterface> #include <QDBusConnectionInterface>
@ -69,14 +70,6 @@ enum
static Core *s_Core = 0; static Core *s_Core = 0;
void unixSignalHandler(int signalNumber)
{
if (s_Core)
{
s_Core->unixSignalHandler(signalNumber);
}
}
int x11ErrorHandler(Display *display, XErrorEvent *errorEvent) int x11ErrorHandler(Display *display, XErrorEvent *errorEvent)
{ {
if (s_Core) if (s_Core)
@ -411,8 +404,8 @@ Core::Core(bool useSyslog, bool minLogLevelSet, int minLogLevel, const QStringLi
openlog("lxqt-global-action-daemon", LOG_PID, LOG_USER); openlog("lxqt-global-action-daemon", LOG_PID, LOG_USER);
::signal(SIGTERM, ::unixSignalHandler); connect(lxqtApp, &LxQt::Application::unixSignal, this, &Core::unixSignalHandler);
::signal(SIGINT, ::unixSignalHandler); lxqtApp->listenToUnixSignals(QList<int>() << SIGTERM << SIGINT);
if (!QDBusConnection::sessionBus().registerService("org.lxqt.global_key_shortcuts")) if (!QDBusConnection::sessionBus().registerService("org.lxqt.global_key_shortcuts"))
@ -581,7 +574,7 @@ Core::Core(bool useSyslog, bool minLogLevelSet, int minLogLevel, const QStringLi
} }
if (id) if (id)
{ {
mShortcutAndActionById[id].second->setEnabled(enabled); enableActionNonGuarded(id, enabled);
} }
settings.endGroup(); settings.endGroup();
@ -828,7 +821,7 @@ int Core::x11ErrorHandler(Display */*display*/, XErrorEvent *errorEvent)
bool Core::waitForX11Error(int level, uint timeout) bool Core::waitForX11Error(int level, uint timeout)
{ {
pollfd *fds = new pollfd[1]; pollfd fds[1];
fds[0].fd = mX11ErrorPipe[STDIN_FILENO]; fds[0].fd = mX11ErrorPipe[STDIN_FILENO];
fds[0].events = POLLIN | POLLERR | POLLHUP; fds[0].events = POLLIN | POLLERR | POLLHUP;
if (poll(fds, 1, timeout) < 0) if (poll(fds, 1, timeout) < 0)
@ -1367,7 +1360,7 @@ void Core::run()
default: default:
{ {
pollfd *fds = new pollfd[1]; pollfd fds[1];
fds[0].fd = mX11RequestPipe[STDIN_FILENO]; fds[0].fd = mX11RequestPipe[STDIN_FILENO];
fds[0].events = POLLIN | POLLERR | POLLHUP; fds[0].events = POLLIN | POLLERR | POLLHUP;
if (poll(fds, 1, 0) >= 0) if (poll(fds, 1, 0) >= 0)
@ -1400,17 +1393,16 @@ void Core::run()
} }
if (length) if (length)
{ {
char *str = new char[length + 1]; QScopedArrayPointer<char> str(new char[length + 1]);
str[length] = '\0'; str[length] = '\0';
if (error_t error = readAll(mX11RequestPipe[STDIN_FILENO], str, length)) if (error_t error = readAll(mX11RequestPipe[STDIN_FILENO], str.data(), length))
{ {
log(LOG_CRIT, "Cannot read from X11 request pipe: %s", strerror(error)); log(LOG_CRIT, "Cannot read from X11 request pipe: %s", strerror(error));
close(mX11ResponsePipe[STDIN_FILENO]); close(mX11ResponsePipe[STDIN_FILENO]);
mX11EventLoopActive = false; mX11EventLoopActive = false;
break; break;
} }
KeySym keySym = XStringToKeysym(str); KeySym keySym = XStringToKeysym(str.data());
delete[] str;
lockX11Error(); lockX11Error();
keyCode = XKeysymToKeycode(mDisplay, keySym); keyCode = XKeysymToKeycode(mDisplay, keySym);
x11Error = checkX11Error(); x11Error = checkX11Error();
@ -1682,11 +1674,14 @@ void Core::serviceDisappeared(const QString &sender)
{ {
const QString &shortcut = shortcutAndActionById.value().first; const QString &shortcut = shortcutAndActionById.value().first;
dynamic_cast<ClientAction *>(shortcutAndActionById.value().second)->disappeared(); ClientAction * action = dynamic_cast<ClientAction *>(shortcutAndActionById.value().second);
action->disappeared();
mDaemonAdaptor->emit_clientActionSenderChanged(id, QString()); mDaemonAdaptor->emit_clientActionSenderChanged(id, QString());
X11Shortcut X11shortcut = mX11ByShortcut[shortcut]; X11Shortcut X11shortcut = mX11ByShortcut[shortcut];
if (action->isEnabled())
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut); IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end()) if (idsByShortcut != mIdsByShortcut.end())
{ {
@ -1702,6 +1697,19 @@ void Core::serviceDisappeared(const QString &sender)
} }
} }
} }
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(shortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
}
}
} }
mSenderByClientPath.remove(path); mSenderByClientPath.remove(path);
} }
@ -1798,17 +1806,15 @@ QString Core::remoteKeycodeToString(KeyCode keyCode)
} }
if (length) if (length)
{ {
char *str = new char[length + 1]; QScopedArrayPointer<char> str(new char[length + 1]);
str[length] = '\0'; str[length] = '\0';
if (error_t error = readAll(mX11ResponsePipe[STDIN_FILENO], str, length)) if (error_t error = readAll(mX11ResponsePipe[STDIN_FILENO], str.data(), length))
{ {
log(LOG_CRIT, "Cannot read from X11 response pipe: %s", strerror(error)); log(LOG_CRIT, "Cannot read from X11 response pipe: %s", strerror(error));
qApp->quit(); qApp->quit();
return QString(); return QString();
} }
result = str; result = str.data();
delete[] str;
} }
return result; return result;
@ -2389,7 +2395,7 @@ void Core::enableClientAction(bool &result, const QDBusObjectPath &path, bool en
qulonglong id = idByNativeClient.value(); qulonglong id = idByNativeClient.value();
mShortcutAndActionById[id].second->setEnabled(enabled); enableActionNonGuarded(id, enabled);
saveConfig(); saveConfig();
@ -2429,24 +2435,75 @@ void Core::isClientActionEnabled(bool &enabled, const QDBusObjectPath &path, con
} }
void Core::enableAction(bool &result, qulonglong id, bool enabled) void Core::enableAction(bool &result, qulonglong id, bool enabled)
{
QMutexLocker lock(&mDataMutex);
result = enableActionNonGuarded(id, enabled);
}
bool Core::enableActionNonGuarded(qulonglong id, bool enabled)
{ {
log(LOG_INFO, "enableAction id:%llu enabled:%s", id, enabled ? "true" : " false"); log(LOG_INFO, "enableAction id:%llu enabled:%s", id, enabled ? "true" : " false");
QMutexLocker lock(&mDataMutex);
ShortcutAndActionById::iterator shortcutAndActionById = mShortcutAndActionById.find(id); ShortcutAndActionById::iterator shortcutAndActionById = mShortcutAndActionById.find(id);
if (shortcutAndActionById == mShortcutAndActionById.end()) if (shortcutAndActionById == mShortcutAndActionById.end())
{ {
log(LOG_WARNING, "No action registered with id #%llu", id); log(LOG_WARNING, "No action registered with id #%llu", id);
result = false; return false;
return;
} }
BaseAction * action = shortcutAndActionById.value().second;
QString const & shortcut = shortcutAndActionById.value().first;
if (action->isEnabled() != enabled)
{
shortcutAndActionById.value().second->setEnabled(enabled); shortcutAndActionById.value().second->setEnabled(enabled);
if (enabled)
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end())
{
if (idsByShortcut.value().isEmpty())
{
if (!remoteXGrabKey(mX11ByShortcut[shortcut]))
{
log(LOG_WARNING, "Cannot grab shortcut '%s'", qPrintable(shortcut));
}
}
}
idsByShortcut = mDisabledIdsByShortcut.find(shortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
mIdsByShortcut[shortcut].insert(id);
}
else
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mIdsByShortcut.erase(idsByShortcut);
if (!remoteXUngrabKey(mX11ByShortcut[shortcut]))
{
log(LOG_WARNING, "Cannot ungrab shortcut '%s'", qPrintable(shortcut));
}
}
}
mDisabledIdsByShortcut[shortcut].insert(id);
}
saveConfig(); saveConfig();
}
result = true; return true;
} }
void Core::isActionEnabled(bool &enabled, qulonglong id) void Core::isActionEnabled(bool &enabled, qulonglong id)
@ -2539,6 +2596,10 @@ void Core::changeClientActionShortcut(QPair<QString, qulonglong> &result, const
QString oldShortcut = shortcutAndActionById.value().first; QString oldShortcut = shortcutAndActionById.value().first;
if (oldShortcut != newShortcut) if (oldShortcut != newShortcut)
{
BaseAction const * const action = shortcutAndActionById.value().second;
if (action->isEnabled())
{ {
newShortcut = grabOrReuseKey(X11shortcut, newShortcut); newShortcut = grabOrReuseKey(X11shortcut, newShortcut);
if (newShortcut.isEmpty()) if (newShortcut.isEmpty())
@ -2563,6 +2624,21 @@ void Core::changeClientActionShortcut(QPair<QString, qulonglong> &result, const
} }
mIdsByShortcut[newShortcut].insert(id); mIdsByShortcut[newShortcut].insert(id);
}
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(oldShortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
mDisabledIdsByShortcut[newShortcut].insert(id);
}
shortcutAndActionById.value().first = newShortcut; shortcutAndActionById.value().first = newShortcut;
} }
@ -2606,6 +2682,10 @@ void Core::changeShortcut(QString &result, const qulonglong &id, const QString &
QString oldShortcut = shortcutAndActionById.value().first; QString oldShortcut = shortcutAndActionById.value().first;
if (oldShortcut != newShortcut) if (oldShortcut != newShortcut)
{
BaseAction const * const action = shortcutAndActionById.value().second;
if (action->isEnabled())
{ {
newShortcut = grabOrReuseKey(X11shortcut, newShortcut); newShortcut = grabOrReuseKey(X11shortcut, newShortcut);
if (newShortcut.isEmpty()) if (newShortcut.isEmpty())
@ -2630,6 +2710,21 @@ void Core::changeShortcut(QString &result, const qulonglong &id, const QString &
} }
mIdsByShortcut[newShortcut].insert(id); mIdsByShortcut[newShortcut].insert(id);
}
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(oldShortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
mDisabledIdsByShortcut[newShortcut].insert(id);
}
shortcutAndActionById.value().first = newShortcut; shortcutAndActionById.value().first = newShortcut;
if (!strcmp(shortcutAndActionById.value().second->type(), ClientAction::id())) if (!strcmp(shortcutAndActionById.value().second->type(), ClientAction::id()))
@ -2715,10 +2810,14 @@ void Core::removeClientAction(bool &result, const QDBusObjectPath &path, const Q
X11Shortcut X11shortcut = mX11ByShortcut[shortcut]; X11Shortcut X11shortcut = mX11ByShortcut[shortcut];
delete shortcutAndActionById.value().second; BaseAction * action = shortcutAndActionById.value().second;
const bool enabled = action->isEnabled();
delete action;
mShortcutAndActionById.erase(shortcutAndActionById); mShortcutAndActionById.erase(shortcutAndActionById);
mIdByClientPath.remove(path); mIdByClientPath.remove(path);
if (enabled)
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut); IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end()) if (idsByShortcut != mIdsByShortcut.end())
{ {
@ -2733,6 +2832,19 @@ void Core::removeClientAction(bool &result, const QDBusObjectPath &path, const Q
} }
} }
} }
}
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(shortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
}
mSenderByClientPath.remove(path); mSenderByClientPath.remove(path);
@ -2791,10 +2903,12 @@ void Core::removeAction(bool &result, const qulonglong &id)
QString shortcut = shortcutAndActionById.value().first; QString shortcut = shortcutAndActionById.value().first;
X11Shortcut X11shortcut = mX11ByShortcut[shortcut]; X11Shortcut X11shortcut = mX11ByShortcut[shortcut];
const bool enabled = action->isEnabled();
delete action; delete action;
mShortcutAndActionById.erase(shortcutAndActionById); mShortcutAndActionById.erase(shortcutAndActionById);
if (enabled)
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut); IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end()) if (idsByShortcut != mIdsByShortcut.end())
{ {
@ -2803,12 +2917,25 @@ void Core::removeAction(bool &result, const qulonglong &id)
{ {
mIdsByShortcut.erase(idsByShortcut); mIdsByShortcut.erase(idsByShortcut);
if (!remoteXUngrabKey(X11shortcut)) if (enabled && !remoteXUngrabKey(X11shortcut))
{ {
log(LOG_WARNING, "Cannot ungrab shortcut '%s'", qPrintable(shortcut)); log(LOG_WARNING, "Cannot ungrab shortcut '%s'", qPrintable(shortcut));
} }
} }
} }
}
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(shortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
}
saveConfig(); saveConfig();
@ -2849,8 +2976,11 @@ void Core::deactivateClientAction(bool &result, const QDBusObjectPath &path, con
ShortcutAndActionById::iterator shortcutAndActionById = mShortcutAndActionById.find(id); ShortcutAndActionById::iterator shortcutAndActionById = mShortcutAndActionById.find(id);
QString shortcut = shortcutAndActionById.value().first; QString shortcut = shortcutAndActionById.value().first;
dynamic_cast<ClientAction*>(shortcutAndActionById.value().second)->disappeared(); ClientAction * const action = dynamic_cast<ClientAction*>(shortcutAndActionById.value().second);
action->disappeared();
if (action->isEnabled())
{
IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut); IdsByShortcut::iterator idsByShortcut = mIdsByShortcut.find(shortcut);
if (idsByShortcut != mIdsByShortcut.end()) if (idsByShortcut != mIdsByShortcut.end())
{ {
@ -2865,6 +2995,19 @@ void Core::deactivateClientAction(bool &result, const QDBusObjectPath &path, con
} }
} }
} }
}
else
{
IdsByShortcut::iterator idsByShortcut = mDisabledIdsByShortcut.find(shortcut);
if (idsByShortcut != mDisabledIdsByShortcut.end())
{
idsByShortcut.value().remove(id);
if (idsByShortcut.value().isEmpty())
{
mDisabledIdsByShortcut.erase(idsByShortcut);
}
}
}
mSenderByClientPath.remove(path); mSenderByClientPath.remove(path);
@ -3174,17 +3317,15 @@ void Core::shortcutGrabbed()
} }
if (length) if (length)
{ {
char *str = new char[length + 1]; QScopedArrayPointer<char> str(new char[length + 1]);
str[length] = '\0'; str[length] = '\0';
if (error_t error = readAll(mX11ResponsePipe[STDIN_FILENO], str, length)) if (error_t error = readAll(mX11ResponsePipe[STDIN_FILENO], str.data(), length))
{ {
log(LOG_CRIT, "Cannot read from X11 response pipe: %s", strerror(error)); log(LOG_CRIT, "Cannot read from X11 response pipe: %s", strerror(error));
qApp->quit(); qApp->quit();
return; return;
} }
shortcut = str; shortcut = str.data();
delete[] str;
} }
} }

@ -150,6 +150,7 @@ private slots:
void shortcutGrabTimedout(); void shortcutGrabTimedout();
private: private:
bool enableActionNonGuarded(qulonglong id, bool enabled);
QPair<QString, qulonglong> addOrRegisterClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description, const QString &sender); QPair<QString, qulonglong> addOrRegisterClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description, const QString &sender);
qulonglong registerClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description); qulonglong registerClientAction(const QString &shortcut, const QDBusObjectPath &path, const QString &description);
qulonglong registerMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description); qulonglong registerMethodAction(const QString &shortcut, const QString &service, const QDBusObjectPath &path, const QString &interface, const QString &method, const QString &description);
@ -218,6 +219,7 @@ private:
X11ByShortcut mX11ByShortcut; X11ByShortcut mX11ByShortcut;
ShortcutByX11 mShortcutByX11; ShortcutByX11 mShortcutByX11;
IdsByShortcut mIdsByShortcut; IdsByShortcut mIdsByShortcut;
IdsByShortcut mDisabledIdsByShortcut;
ShortcutAndActionById mShortcutAndActionById; ShortcutAndActionById mShortcutAndActionById;
IdByClientPath mIdByClientPath; IdByClientPath mIdByClientPath;
SenderByClientPath mSenderByClientPath; // add: path->sender SenderByClientPath mSenderByClientPath; // add: path->sender

@ -25,7 +25,7 @@
* *
* END_COMMON_COPYRIGHT_HEADER */ * END_COMMON_COPYRIGHT_HEADER */
#include <QCoreApplication> #include <LXQt/Application>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
@ -230,15 +230,16 @@ int main(int argc, char *argv[])
} }
} }
int ignoreIt = chdir("/"); const char* home = getenv("HOME");
int ignoreIt = chdir((home && *home) ? home : "/");
(void)ignoreIt; (void)ignoreIt;
if (configFiles.empty()) if (configFiles.empty() && home && *home)
{ {
configFiles.push_back(QString::fromLocal8Bit(getenv("HOME")) + "/" DEFAULT_CONFIG); configFiles.push_back(QString::fromLocal8Bit(home) + "/" DEFAULT_CONFIG);
} }
QCoreApplication app(argc, argv); LxQt::Application app(argc, argv);
Core core(runAsDaemon || useSyslog, minLogLevelSet, minLogLevel, configFiles, multipleActionsBehaviourSet, multipleActionsBehaviour); Core core(runAsDaemon || useSyslog, minLogLevelSet, minLogLevel, configFiles, multipleActionsBehaviourSet, multipleActionsBehaviour);

@ -6,14 +6,6 @@ set(QT_DBUS_PREFIX "org.qtproject")
set(LXQT_GLOBALKEYS_LIBRARY lxqt-globalkeys) set(LXQT_GLOBALKEYS_LIBRARY lxqt-globalkeys)
set(${PROJECT_NAME}_HEADER_NAMESPACE "LXQtGlobalKeysUi") set(${PROJECT_NAME}_HEADER_NAMESPACE "LXQtGlobalKeysUi")
include_directories(
"${PROJECT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${LXQT_INCLUDE_DIRS}
)
add_definitions(-DSHARED_EXPORT=Q_DECL_EXPORT)
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
shortcut_selector.cpp shortcut_selector.cpp
) )
@ -23,7 +15,7 @@ set(${PROJECT_NAME}_MAIN_HEADER
# #
# WARNING: Changing stuff here implies changing this: # WARNING: Changing stuff here implies changing this:
#install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION include/${PROJECT_NAME} COMPONENT development RENAME "shortcutselector.h") #install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION include/${PROJECT_NAME} COMPONENT Devel RENAME "shortcutselector.h")
# #
set(${PROJECT_NAME}_PUBLIC_CPP_HEADERS set(${PROJECT_NAME}_PUBLIC_CPP_HEADERS
shortcut_selector.h shortcut_selector.h
@ -101,7 +93,7 @@ foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME) get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
configure_file( configure_file(
${DBUS_INTERFACE} ${DBUS_INTERFACE}
${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
@ONLY @ONLY
) )
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME) get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
@ -113,11 +105,10 @@ foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
CLASSNAME ${DBUS_INTERFACE_CLASSNAME} CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE} NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
) )
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} ${DBUS_INTERFACE_BASENAME}) qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}" ${DBUS_INTERFACE_BASENAME})
endforeach() endforeach()
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES}) qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_FORM_FILES ${${PROJECT_NAME}_FORMS})
set(${PROJECT_NAME}_GENERATED_FILES set(${PROJECT_NAME}_GENERATED_FILES
${${PROJECT_NAME}_FORM_FILES} ${${PROJECT_NAME}_FORM_FILES}
@ -133,8 +124,11 @@ set(${PROJECT_NAME}_ALL_FILES
${${PROJECT_NAME}_GENERATED_FILES} ${${PROJECT_NAME}_GENERATED_FILES}
) )
set(${PROJECT_NAME}_PKG_CONFIG_REQUIRES "Qt5Widgets, Qt5DBus, ${LXQT_GLOBALKEYS_LIBRARY}")
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES}) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES})
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
PUBLIC
Qt5::Widgets Qt5::Widgets
Qt5::DBus Qt5::DBus
${LXQT_GLOBALKEYS_LIBRARY} ${LXQT_GLOBALKEYS_LIBRARY}
@ -144,6 +138,20 @@ set_target_properties(${PROJECT_NAME}
VERSION ${LXQT_VERSION} VERSION ${LXQT_VERSION}
SOVERSION ${LXQT_MAJOR_VERSION} SOVERSION ${LXQT_MAJOR_VERSION}
) )
target_include_directories(${PROJECT_NAME}
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_GLOBALKEYS_UI_LIBRARY_NAME}>"
)
target_include_directories(${PROJECT_NAME}
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include>"
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}>"
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "SHARED_EXPORT=Q_DECL_EXPORT"
)
export(TARGETS ${PROJECT_NAME} APPEND FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}-targets.cmake")
include(create_portable_headers) include(create_portable_headers)
create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS
@ -151,11 +159,62 @@ create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS
FILENAMES ${${PROJECT_NAME}_PUBLIC_CLASSES} FILENAMES ${${PROJECT_NAME}_PUBLIC_CLASSES}
) )
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT runtime) # Copy public headers for intree building
install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION include/${PROJECT_NAME} COMPONENT development) foreach(h ${${PROJECT_NAME}_PUBLIC_HEADERS})
install(FILES ${${PROJECT_NAME}_PUBLIC_HEADERS} DESTINATION include/${PROJECT_NAME} COMPONENT development RENAME "shortcutselector.h") get_filename_component(bh ${h} NAME)
install(FILES ${${PROJECT_NAME}_PORTABLE_HEADERS} DESTINATION include/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE} COMPONENT development) configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${bh}" COPYONLY)
endforeach()
foreach(h ${${PROJECT_NAME}_PORTABLE_HEADERS})
get_filename_component(bh ${h} NAME)
configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}/${bh}" COPYONLY)
endforeach()
include(create_pkgconfig_file) foreach(h ${${PROJECT_NAME}_PUBLIC_HEADERS})
create_pkgconfig_file(${PROJECT_NAME} "LXQt global key shortcuts GUI support library") get_filename_component(bh ${h} NAME)
configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/${PROJECT_NAME}/shortcutselector.h" COPYONLY)
endforeach()
install(TARGETS
${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
EXPORT ${PROJECT_NAME}-targets
COMPONENT Runtime
)
install(EXPORT
${PROJECT_NAME}-targets
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}"
COMPONENT Devel
)
install(FILES
${${PROJECT_NAME}_PUBLIC_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT Devel
)
install(FILES
${${PROJECT_NAME}_PUBLIC_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT Devel
RENAME "shortcutselector.h"
)
install(FILES
${${PROJECT_NAME}_PORTABLE_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${${PROJECT_NAME}_HEADER_NAMESPACE}"
COMPONENT Devel
)
lxqt_create_pkgconfig_file(
PACKAGE_NAME ${PROJECT_NAME}
DESCRIPTIVE_NAME ${PROJECT_NAME}
DESCRIPTION "LXQt global key shortcuts GUI support library"
INCLUDEDIRS ${PROJECT_NAME}
LIBS ${PROJECT_NAME}
REQUIRES ${${PROJECT_NAME}_PKG_CONFIG_REQUIRES}
VERSION ${LXQT_VERSION}
INSTALL
)

@ -40,7 +40,11 @@ namespace GlobalKeyShortcut
class Client; class Client;
} }
class ShortcutSelector : public QToolButton #ifndef SHARED_EXPORT
#define SHARED_EXPORT Q_DECL_IMPORT
#endif
class SHARED_EXPORT ShortcutSelector : public QToolButton
{ {
Q_OBJECT Q_OBJECT
public: public:

Loading…
Cancel
Save