diff --git a/components/keyboardlayout/CMakeLists.txt b/components/keyboardlayout/CMakeLists.txt --- a/components/keyboardlayout/CMakeLists.txt +++ b/components/keyboardlayout/CMakeLists.txt @@ -8,6 +8,8 @@ CATEGORY_NAME kde.keyboardlayout DEFAULT_SEVERITY Info) +qt5_add_dbus_interface(keyboardlayoutplugin_SRCS "org.kde.KeyboardLayouts.xml" keyboard_layout_interface) + add_library(keyboardlayoutplugin SHARED ${keyboardlayoutplugin_SRCS}) target_link_libraries(keyboardlayoutplugin Qt5::Core diff --git a/components/keyboardlayout/keyboardlayout.h b/components/keyboardlayout/keyboardlayout.h --- a/components/keyboardlayout/keyboardlayout.h +++ b/components/keyboardlayout/keyboardlayout.h @@ -23,7 +23,7 @@ #include #include -class QDBusInterface; +class OrgKdeKeyboardLayoutsInterface; class QDBusPendingCallWatcher; class KeyboardLayout : public QObject @@ -72,7 +72,7 @@ QStringList mLayouts; QString mCurrentLayout; QString mCurrentLayoutDisplayName; - QDBusInterface *mIface; + OrgKdeKeyboardLayoutsInterface *mIface; }; diff --git a/components/keyboardlayout/keyboardlayout.cpp b/components/keyboardlayout/keyboardlayout.cpp --- a/components/keyboardlayout/keyboardlayout.cpp +++ b/components/keyboardlayout/keyboardlayout.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Daniel Vratil + * Copyright (C) 2019 David Edmundson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,25 +26,26 @@ #include #include "debug.h" +#include "keyboard_layout_interface.h" + KeyboardLayout::KeyboardLayout(QObject* parent) : QObject(parent) , mIface(nullptr) { - mIface = new QDBusInterface(QStringLiteral("org.kde.keyboard"), + mIface = new OrgKdeKeyboardLayoutsInterface(QStringLiteral("org.kde.keyboard"), QStringLiteral("/Layouts"), - QStringLiteral("org.kde.KeyboardLayouts"), QDBusConnection::sessionBus(), this); if (!mIface->isValid()) { delete mIface; mIface = nullptr; return; } - connect(mIface, SIGNAL(currentLayoutChanged(QString)), - this, SLOT(setCurrentLayout(QString))); - connect(mIface, SIGNAL(layoutListChanged()), - this, SLOT(requestLayoutsList())); + connect(mIface, &OrgKdeKeyboardLayoutsInterface::currentLayoutChanged, + this, &KeyboardLayout::setCurrentLayout); + connect(mIface, &OrgKdeKeyboardLayoutsInterface::layoutListChanged, + this, &KeyboardLayout::requestLayoutsList); requestCurrentLayout(); requestLayoutsList(); @@ -60,7 +62,7 @@ return; } - QDBusPendingCall pendingLayout = mIface->asyncCall(QStringLiteral("getCurrentLayout")); + QDBusPendingReply pendingLayout = mIface->getCurrentLayout(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingLayout, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, &KeyboardLayout::onCurrentLayoutReceived); @@ -81,7 +83,7 @@ void KeyboardLayout::requestCurrentLayoutDisplayName() { - QDBusPendingCall pendingDisplayName = mIface->asyncCallWithArgumentList(QStringLiteral("getLayoutDisplayName"), {mCurrentLayout}); + QDBusPendingReply pendingDisplayName = mIface->getLayoutDisplayName(mCurrentLayout); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingDisplayName, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, &KeyboardLayout::onCurrentLayoutDisplayNameReceived); } @@ -109,7 +111,7 @@ return; } - QDBusPendingCall pendingLayout = mIface->asyncCall(QStringLiteral("getLayoutsList")); + QDBusPendingReply pendingLayout = mIface->getLayoutsList(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingLayout, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, &KeyboardLayout::onLayoutsListReceived); @@ -150,7 +152,7 @@ mCurrentLayout = layout; requestCurrentLayoutDisplayName(); - mIface->asyncCall(QStringLiteral("setLayout"), layout); + mIface->setLayout(layout); Q_EMIT currentLayoutChanged(layout); } diff --git a/components/keyboardlayout/org.kde.KeyboardLayouts.xml b/components/keyboardlayout/org.kde.KeyboardLayouts.xml new file mode 100644 --- /dev/null +++ b/components/keyboardlayout/org.kde.KeyboardLayouts.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + +