Commit 512032c4 authored by Andrew Lee (李健秋)'s avatar Andrew Lee (李健秋)

Adding upstream version 0.9.0.

Signed-off-by: Andrew Lee (李健秋)'s avatarAndrew Lee (李健秋) <ajqlee@debian.org>
parents
Upstream Authors:
LXQt team: http://lxqt.org
Razor team: http://razor-qt.org
Copyright:
Copyright (c) 2010-2012 Razor team
Copyright (c) 2012-2014 LXQt team
License: GPL-2 and LGPL-2.1+
The full text of the licenses can be found in the 'COPYING' file.
cmake_minimum_required(VERSION 2.8.11)
project(lxqt-globalkeys)
# additional cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Set 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_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5DBus REQUIRED)
find_package(Qt5LinguistTools REQUIRED QUIET)
find_package(lxqt REQUIRED QUIET)
include(${LXQT_USE_FILE})
include(LXQtTranslate)
# Standard directories for installation
include(GNUInstallDirs)
set(LXQT_GLOBALKEYS_LIBRARY_NAME lxqt-globalkeys)
set(LXQT_GLOBALKEYS_UI_LIBRARY_NAME lxqt-globalkeys-ui)
set(LXQT_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
#************************************************
# 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_UI_CMAKE_NAME ${LXQT_GLOBALKEYS_UI_LIBRARY_NAME})
set(LXQT_GLOBALKEYS_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${LXQT_GLOBALKEYS_LIBRARY_NAME}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_CMAKE_NAME}-config.cmake"
@ONLY
)
set(LXQT_GLOBALKEYS_UI_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/${LXQT_GLOBALKEYS_UI_LIBRARY_NAME})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_globalkeys_ui-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME}-config.cmake"
@ONLY
)
#************************************************
# End of build config.cmake
#************************************************
set(LXQT_GLOBALKEYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
add_subdirectory(daemon)
add_subdirectory(config)
add_subdirectory(client)
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 cmake/lxqt_globalkeys_use.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 cmake/lxqt_globalkeys_ui_use.cmake DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_GLOBALKEYS_UI_CMAKE_NAME})
# building tarball with CPack -------------------------------------------------
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
set(CPACK_GENERATOR TBZ2)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include(CPack)
This diff is collapsed.
set(PROJECT_NAME ${LXQT_GLOBALKEYS_LIBRARY_NAME})
project(${PROJECT_NAME})
set(QT_DBUS_PREFIX "org.qtproject")
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")
add_definitions(-DSHARED_EXPORT=Q_DECL_EXPORT)
set(${PROJECT_NAME}_SOURCES
client.cpp
action.cpp
)
#
# WARNING: Changing stuff here implies changing this:
# install(FILES ${${PROJECT_NAME}_MAIN_HEADER} DESTINATION include/${PROJECT_NAME} COMPONENT development RENAME "lxqtglobalkeys.h")
#
set(${PROJECT_NAME}_MAIN_HEADER
lxqt-globalkeys.h
)
set(${PROJECT_NAME}_PUBLIC_CPP_HEADERS
client.h
action.h
)
set(${PROJECT_NAME}_PUBLIC_CLASSES
Client
Action
LXQtGlobalKeys
)
set(${PROJECT_NAME}_PRIVATE_CPP_HEADERS
client_p.h
action_p.h
)
set(${PROJECT_NAME}_FORMS
)
set(${PROJECT_NAME}_RESOURCES
)
set(${PROJECT_NAME}_TRANSLATIONS
)
set(${PROJECT_NAME}_DBUS_ADAPTORS
${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml
)
set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.client.xml PROPERTIES
INCLUDE action_p.h
PARENT_CLASSNAME GlobalKeyShortcut::ActionImpl
BASENAME org.lxqt.global_key_shortcuts.client
CLASSNAME OrgLxqtActionClientAdaptor
)
set(${PROJECT_NAME}_DBUS_INTERFACES
${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml
)
set_source_files_properties(${${PROJECT_NAME}_PATH_TO_DAEMON}/org.lxqt.global_key_shortcuts.native.xml PROPERTIES
BASENAME org.lxqt.global_key_shortcuts.native
)
set(${PROJECT_NAME}_PUBLIC_HEADERS
${${PROJECT_NAME}_PUBLIC_CPP_HEADERS}
)
set(${PROJECT_NAME}_PRIVATE_HEADERS
${${PROJECT_NAME}_PRIVATE_CPP_HEADERS}
)
set(${PROJECT_NAME}_CPP_HEADERS
${${PROJECT_NAME}_PUBLIC_CPP_HEADERS}
${${PROJECT_NAME}_PRIVATE_CPP_HEADERS}
)
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_PUBLIC_HEADERS}
${${PROJECT_NAME}_PRIVATE_HEADERS}
)
set(${PROJECT_NAME}_TRANSLATABLE
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
${${PROJECT_NAME}_FORMS}
)
foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
configure_file(
${DBUS_ADAPTOR}
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}"
@ONLY
)
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
get_source_file_property(DBUS_ADAPTOR_PARENT_CLASSNAME ${DBUS_ADAPTOR} PARENT_CLASSNAME)
get_source_file_property(DBUS_ADAPTOR_BASENAME ${DBUS_ADAPTOR} BASENAME)
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
if(DBUS_ADAPTOR_BASENAME)
if(DBUS_ADAPTOR_CLASSNAME)
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
else()
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
endif()
else()
qt5_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}" ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
endif()
endforeach()
foreach(DBUS_INTERFACE ${${PROJECT_NAME}_DBUS_INTERFACES})
get_filename_component(DBUS_INTERFACE_FILENAME ${DBUS_INTERFACE} NAME)
configure_file(
${DBUS_INTERFACE}
"${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME}"
@ONLY
)
get_source_file_property(DBUS_INTERFACE_BASENAME ${DBUS_INTERFACE} BASENAME)
get_source_file_property(DBUS_INTERFACE_INCLUDE ${DBUS_INTERFACE} INCLUDE)
get_source_file_property(DBUS_INTERFACE_CLASSNAME ${DBUS_INTERFACE} CLASSNAME)
get_source_file_property(DBUS_INTERFACE_NO_NAMESPACE ${DBUS_INTERFACE} NO_NAMESPACE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} PROPERTIES
INCLUDE ${DBUS_INTERFACE_INCLUDE}
CLASSNAME ${DBUS_INTERFACE_CLASSNAME}
NO_NAMESPACE ${DBUS_INTERFACE_NO_NAMESPACE}
)
qt5_add_dbus_interface(${PROJECT_NAME}_DBUS_INTERFACE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_INTERFACE_FILENAME} ${DBUS_INTERFACE_BASENAME})
endforeach()
qt5_add_resources(${PROJECT_NAME}_RESOURCE_FILES ${${PROJECT_NAME}_RESOURCES})
qt5_wrap_ui(${PROJECT_NAME}_FORM_FILES ${${PROJECT_NAME}_FORMS})
set(${PROJECT_NAME}_GENERATED_FILES
${${PROJECT_NAME}_FORM_FILES}
${${PROJECT_NAME}_RESOURCE_FILES}
${${PROJECT_NAME}_QM_FILES}
${${PROJECT_NAME}_DBUS_INTERFACE_FILES}
${${PROJECT_NAME}_DBUS_ADAPTOR_FILES}
)
set(${PROJECT_NAME}_ALL_FILES
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
${${PROJECT_NAME}_GENERATED_FILES}
)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_ALL_FILES})
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::DBus)
set_target_properties(${PROJECT_NAME}
PROPERTIES
VERSION ${LXQT_VERSION}
SOVERSION ${LXQT_MAJOR_VERSION}
)
include(create_portable_headers)
create_portable_headers(${PROJECT_NAME}_PORTABLE_HEADERS
NAMESPACE "${${PROJECT_NAME}_NAMESPACE}/"
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)
create_pkgconfig_file(${PROJECT_NAME} "LXQt global key shortcuts client library")
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2013 Razor team
* Authors:
* Kuzma Shapran <kuzma.shapran@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "action.h"
#include "action_p.h"
#include "client_p.h"
#include "org.lxqt.global_key_shortcuts.client.h"
namespace GlobalKeyShortcut
{
ActionImpl::ActionImpl(ClientImpl *client, Action *interface, const QString &path, const QString &description, QObject *parent)
: QObject(parent)
, mClient(client)
, mInterface(interface)
, mPath(path)
, mDescription(description)
{
new OrgLxqtActionClientAdaptor(this);
connect(this, SIGNAL(emitActivated()), mInterface, SIGNAL(activated()));
connect(this, SIGNAL(emitShortcutChanged(QString, QString)), mInterface, SIGNAL(shortcutChanged(QString, QString)));
}
ActionImpl::~ActionImpl()
{
mClient->removeAction(this);
}
QString ActionImpl::changeShortcut(const QString &shortcut)
{
mShortcut = mClient->changeClientActionShortcut(mPath, shortcut);
return mShortcut;
}
bool ActionImpl::changeDescription(const QString &description)
{
bool result = mClient->modifyClientAction(mPath, description);
if (result)
{
mDescription = description;
}
return result;
}
void ActionImpl::setShortcut(const QString &shortcut)
{
mShortcut = shortcut;
}
QString ActionImpl::path() const
{
return mPath;
}
QString ActionImpl::shortcut() const
{
return mShortcut;
}
QString ActionImpl::description() const
{
return mDescription;
}
void ActionImpl::setValid(bool valid)
{
mValid = valid;
}
bool ActionImpl::isValid() const
{
return mValid;
}
void ActionImpl::activated()
{
emit emitActivated();
}
void ActionImpl::shortcutChanged(const QString &oldShortcut, const QString &newShortcut)
{
emit emitShortcutChanged(oldShortcut, newShortcut);
}
Action::Action(QObject *parent)
: QObject(parent)
, impl(0)
{
}
Action::~Action()
{
}
QString Action::changeShortcut(const QString &shortcut) { return impl->changeShortcut(shortcut); }
bool Action::changeDescription(const QString &description) { return impl->changeDescription(description); }
QString Action::path() const { return impl->path(); }
QString Action::shortcut() const { return impl->shortcut(); }
QString Action::description() const { return impl->description(); }
bool Action::isValid() const { return impl->isValid(); }
}
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2013 Razor team
* Authors:
* Kuzma Shapran <kuzma.shapran@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
#define GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
#include <QtGlobal>
#include <QObject>
#include <QString>
namespace GlobalKeyShortcut
{
class ActionImpl;
class ClientImpl;
#ifndef SHARED_EXPORT
#define SHARED_EXPORT Q_DECL_IMPORT
#endif
class SHARED_EXPORT Action : public QObject
{
Q_OBJECT
friend class ActionImpl;
friend class ClientImpl;
public:
~Action();
QString changeShortcut(const QString &shortcut);
bool changeDescription(const QString &description);
QString path() const;
QString shortcut() const;
QString description() const;
bool isValid() const;
signals:
void activated();
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
private:
Action(QObject *parent = 0);
ActionImpl *impl;
};
}
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__INCLUDED
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2013 Razor team
* Authors:
* Kuzma Shapran <kuzma.shapran@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
#define GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
#include <QObject>
#include <QString>
#include <QMap>
#include <QSharedPointer>
namespace GlobalKeyShortcut
{
class Action;
class ClientImpl;
class ActionImpl : public QObject
{
Q_OBJECT
public:
ActionImpl(ClientImpl *client, Action *interface, const QString &path, const QString &description, QObject *parent = 0);
~ActionImpl();
QString changeShortcut(const QString &shortcut);
bool changeDescription(const QString &description);
void setShortcut(const QString &shortcut);
QString path() const;
QString shortcut() const;
QString description() const;
void setValid(bool valid);
bool isValid() const;
public slots:
void activated();
void shortcutChanged(const QString &oldShortcut, const QString &newShortcut);
signals:
void emitActivated();
void emitShortcutChanged(const QString &oldShortcut, const QString &newShortcut);
private:
ClientImpl *mClient;
Action *mInterface;
QString mAlias;
QString mPath;
QString mShortcut;
QString mDescription;
bool mValid;
};
}
#endif // GLOBAL_KEY_SHORTCUT_CLIENT__ACTION__IMPL__INCLUDED
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXDE-Qt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2013 Razor team
* Authors:
* Kuzma Shapran <kuzma.shapran@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "client.h"
#include "client_p.h"
#include "action_p.h"
#include "org.lxqt.global_key_shortcuts.native.h"
#include <QDBusConnection>
namespace GlobalKeyShortcut
{
ClientImpl::ClientImpl(Client *interface, QObject *parent)
: QObject(parent)
, mInterface(interface)
, mServiceWatcher(new QDBusServiceWatcher("org.lxqt.global_key_shortcuts", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
, mDaemonPresent(false)
{
connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(daemonDisappeared(QString)));
connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(daemonAppeared(QString)));
mProxy = new org::lxqt::global_key_shortcuts::native("org.lxqt.global_key_shortcuts", "/native", QDBusConnection::sessionBus(), this);
mDaemonPresent = mProxy->isValid();
connect(this, SIGNAL(emitShortcutGrabbed(QString)), mInterface, SIGNAL(shortcutGrabbed(QString)));
connect(this, SIGNAL(emitGrabShortcutFailed()), mInterface, SIGNAL(grabShortcutFailed()));
connect(this, SIGNAL(emitGrabShortcutCancelled()), mInterface, SIGNAL(grabShortcutCancelled()));
connect(this, SIGNAL(emitGrabShortcutTimedout()), mInterface, SIGNAL(grabShortcutTimedout()));
connect(this, SIGNAL(emitDaemonDisappeared()), mInterface, SIGNAL(daemonDisappeared()));
connect(this, SIGNAL(emitDaemonAppeared()), mInterface, SIGNAL(daemonAppeared()));
connect(this, SIGNAL(emitDaemonPresenceChanged(bool)), mInterface, SIGNAL(daemonPresenceChanged(bool)));
}
ClientImpl::~ClientImpl()
{
QMap<QString, Action*>::iterator M = mActions.end();
for (QMap<QString, Action*>::iterator I = mActions.begin(); I != M; ++I)
{
QDBusConnection::sessionBus().unregisterObject(QString("/global_key_shortcuts") + I.key());
delete I.value();
}
mActions.clear();
}
void ClientImpl::daemonDisappeared(const QString &)
{
mDaemonPresent = false;
emit emitDaemonDisappeared();
emit emitDaemonPresenceChanged(mDaemonPresent);
}
void ClientImpl::daemonAppeared(const QString &)
{
QMap<QString, Action*>::iterator last = mActions.end();
for (QMap<QString, Action*>::iterator I = mActions.begin(); I != last; ++I)
{
ActionImpl *globalActionImpl = I.value()->impl;
QDBusPendingReply<QString, qulonglong> reply = mProxy->addClientAction(globalActionImpl->shortcut(), QDBusObjectPath(globalActionImpl->path()), globalActionImpl->description());
reply.waitForFinished();
globalActionImpl->setValid(!reply.isError() && reply.argumentAt<1>());
if (globalActionImpl->isValid())
{
globalActionImpl->setShortcut(reply.argumentAt<0>());
}
}
mDaemonPresent = true;
emit emitDaemonAppeared();
emit emitDaemonPresenceChanged(mDaemonPresent);
}
bool ClientImpl::isDaemonPresent() const
{
return mDaemonPresent;
}
Action *ClientImpl::addClientAction(const QString &shortcut, const QString &path, const QString &description, QObject *parent)
{
if (!QRegExp("(/[A-Za-z0-9_]+){2,}").exactMatch(path))
{
return 0;
}
if (mActions.contains(path))
{
return 0;
}
Action *globalAction = new Action(parent);
ActionImpl *globalActionImpl = new ActionImpl(this, globalAction, path, description, globalAction);
globalAction->impl = globalActionImpl;
if (!QDBusConnection::sessionBus().registerObject(QString("/global_key_shortcuts") + path, globalActionImpl))
{
return 0;
}