From fac29606eb8cf9899c843ed79e5fbc859d982eb2 Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Mon, 23 Nov 2020 23:08:43 +0300 Subject: [PATCH] impr: Keyboard Layout DBus API: drop excessive method arguments It's enough to give info about current layout only or all the layouts altogether, so no need to pass layout to asqure in an argument. P-W part: impr: Keyboard Layout plugin: drop excessive DBus API method arguments --- keyboard_layout.cpp | 21 +++++++++------------ keyboard_layout.h | 10 +++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/keyboard_layout.cpp b/keyboard_layout.cpp index 99bf9b63ec..e8c2ea698b 100644 --- a/keyboard_layout.cpp +++ b/keyboard_layout.cpp @@ -77,7 +77,7 @@ void KeyboardLayout::initDBusInterface() m_dbusInterface = new KeyboardLayoutDBusInterface(m_xkb, this); connect(this, &KeyboardLayout::layoutChanged, m_dbusInterface, [this] { - emit m_dbusInterface->currentLayoutChanged(m_xkb->layoutName()); + emit m_dbusInterface->layoutChanged(m_xkb->layoutName()); } ); // TODO: the signal might be emitted even if the list didn't change @@ -319,17 +319,22 @@ bool KeyboardLayoutDBusInterface::setLayout(const QString &layout) return true; } -QString KeyboardLayoutDBusInterface::getCurrentLayout() +QString KeyboardLayoutDBusInterface::getLayout() const { return m_xkb->layoutName(); } -QString KeyboardLayoutDBusInterface::getCurrentLayoutLongName() const +QString KeyboardLayoutDBusInterface::getLayoutDisplayName() const +{ + return m_xkb->layoutShortName(); +} + +QString KeyboardLayoutDBusInterface::getLayoutLongName() const { return translatedLayout(m_xkb->layoutName()); } -QStringList KeyboardLayoutDBusInterface::getLayoutsList() +QStringList KeyboardLayoutDBusInterface::getLayoutsList() const { const auto layouts = m_xkb->layoutNames(); QStringList ret; @@ -339,12 +344,4 @@ QStringList KeyboardLayoutDBusInterface::getLayoutsList() return ret; } -QString KeyboardLayoutDBusInterface::getLayoutDisplayName(const QString &layout) -{ - // TODO: remove arguments from the DBus API methods - Q_UNUSED(layout) - - return m_xkb->layoutShortName(); -} - } diff --git a/keyboard_layout.h b/keyboard_layout.h index 19541c1b69..2d8674a7f9 100644 --- a/keyboard_layout.h +++ b/keyboard_layout.h @@ -84,13 +84,13 @@ public Q_SLOTS: void switchToNextLayout(); void switchToPreviousLayout(); bool setLayout(const QString &layout); - QString getCurrentLayout(); - QString getCurrentLayoutLongName() const; - QStringList getLayoutsList(); - QString getLayoutDisplayName(const QString &layout); + QString getLayout() const; + QString getLayoutDisplayName() const; + QString getLayoutLongName() const; + QStringList getLayoutsList() const; Q_SIGNALS: - void currentLayoutChanged(QString layout); + void layoutChanged(QString layout); void layoutListChanged(); private: