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
This commit is contained in:
Andrey Butirsky 2020-11-23 23:08:43 +03:00
parent 1755b0fd8b
commit fac29606eb
2 changed files with 14 additions and 17 deletions

View file

@ -77,7 +77,7 @@ void KeyboardLayout::initDBusInterface()
m_dbusInterface = new KeyboardLayoutDBusInterface(m_xkb, this); m_dbusInterface = new KeyboardLayoutDBusInterface(m_xkb, this);
connect(this, &KeyboardLayout::layoutChanged, m_dbusInterface, connect(this, &KeyboardLayout::layoutChanged, m_dbusInterface,
[this] { [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 // 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; return true;
} }
QString KeyboardLayoutDBusInterface::getCurrentLayout() QString KeyboardLayoutDBusInterface::getLayout() const
{ {
return m_xkb->layoutName(); 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()); return translatedLayout(m_xkb->layoutName());
} }
QStringList KeyboardLayoutDBusInterface::getLayoutsList() QStringList KeyboardLayoutDBusInterface::getLayoutsList() const
{ {
const auto layouts = m_xkb->layoutNames(); const auto layouts = m_xkb->layoutNames();
QStringList ret; QStringList ret;
@ -339,12 +344,4 @@ QStringList KeyboardLayoutDBusInterface::getLayoutsList()
return ret; return ret;
} }
QString KeyboardLayoutDBusInterface::getLayoutDisplayName(const QString &layout)
{
// TODO: remove arguments from the DBus API methods
Q_UNUSED(layout)
return m_xkb->layoutShortName();
}
} }

View file

@ -84,13 +84,13 @@ public Q_SLOTS:
void switchToNextLayout(); void switchToNextLayout();
void switchToPreviousLayout(); void switchToPreviousLayout();
bool setLayout(const QString &layout); bool setLayout(const QString &layout);
QString getCurrentLayout(); QString getLayout() const;
QString getCurrentLayoutLongName() const; QString getLayoutDisplayName() const;
QStringList getLayoutsList(); QString getLayoutLongName() const;
QString getLayoutDisplayName(const QString &layout); QStringList getLayoutsList() const;
Q_SIGNALS: Q_SIGNALS:
void currentLayoutChanged(QString layout); void layoutChanged(QString layout);
void layoutListChanged(); void layoutListChanged();
private: private: