From 4bbf78a20c7bdf1e327e8b5c25b6986cd6d71cba Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Thu, 17 Dec 2020 13:20:53 +0300 Subject: [PATCH] feat: context menu for Keyboard Layout applet Counterpart commit with the same title is in P-D --- components/keyboardlayout/keyboardlayout.cpp | 5 +++++ components/keyboardlayout/keyboardlayout.h | 5 +++++ components/workspace/KeyboardLayoutButton.qml | 5 ++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/keyboardlayout/keyboardlayout.cpp b/components/keyboardlayout/keyboardlayout.cpp index 8b7377b9e..5980771cd 100644 --- a/components/keyboardlayout/keyboardlayout.cpp +++ b/components/keyboardlayout/keyboardlayout.cpp @@ -68,6 +68,11 @@ void KeyboardLayout::switchToPreviousLayout() if (mIface) mIface->switchToPreviousLayout(); } +void KeyboardLayout::setLayout(const QString &layout) +{ + if (mIface) mIface->setLayout(layout); +} + template void KeyboardLayout::requestDBusData(QDBusPendingReply pendingReply, T &out, void (KeyboardLayout::*notify)()) { diff --git a/components/keyboardlayout/keyboardlayout.h b/components/keyboardlayout/keyboardlayout.h index 74b210a46..7c985fe2c 100644 --- a/components/keyboardlayout/keyboardlayout.h +++ b/components/keyboardlayout/keyboardlayout.h @@ -18,6 +18,9 @@ class KeyboardLayout : public QObject { Q_OBJECT + Q_PROPERTY(QString layout + WRITE setLayout) + Q_PROPERTY(QString layoutDisplayName MEMBER mLayoutDisplayName NOTIFY layoutDisplayNameChanged) @@ -44,6 +47,8 @@ protected Q_SLOTS: void switchToPreviousLayout(); private: + void setLayout(const QString &layout); + enum DBusData {LayoutDisplayName, LayoutLongName, Layouts}; template diff --git a/components/workspace/KeyboardLayoutButton.qml b/components/workspace/KeyboardLayoutButton.qml index b56f5583a..119de8012 100644 --- a/components/workspace/KeyboardLayoutButton.qml +++ b/components/workspace/KeyboardLayoutButton.qml @@ -11,11 +11,10 @@ import org.kde.plasma.workspace.keyboardlayout 1.0 PlasmaComponents3.ToolButton { id: kbLayoutButton - property alias layoutShortName: layout.layoutDisplayName - property alias layoutLongName: layout.layoutLongName + property alias layout: layout readonly property bool hasMultipleKeyboardLayouts: layout.layouts.length > 1 - text: layoutLongName + text: layout.layoutLongName visible: hasMultipleKeyboardLayouts Accessible.name: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout")