LockScreen: Use layout display name in KeyboardLayoutButton

Use display name (can be changed by user) instead of full layout name.
This matches the behavior of keyboard layout osd and systray.

REVIEW: 126944
wilder-5.14
David Rosca 10 years ago
parent 4c00e6f286
commit 39327c21b8
  1. 32
      components/keyboardlayout/keyboardlayout.cpp
  2. 11
      components/keyboardlayout/keyboardlayout.h
  3. 5
      lookandfeel/contents/components/KeyboardLayoutButton.qml

@ -74,11 +74,36 @@ void KeyboardLayout::onCurrentLayoutReceived(QDBusPendingCallWatcher *watcher)
qCWarning(KEYBOARD_LAYOUT) << reply.error().message();
} else {
mCurrentLayout = reply.value();
requestCurrentLayoutDisplayName();
Q_EMIT currentLayoutChanged(mCurrentLayout);
}
watcher->deleteLater();
}
void KeyboardLayout::requestCurrentLayoutDisplayName()
{
QDBusPendingCall pendingDisplayName = mIface->asyncCallWithArgumentList(QStringLiteral("getLayoutDisplayName"), {mCurrentLayout});
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingDisplayName, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, &KeyboardLayout::onCurrentLayoutDisplayNameReceived);
}
void KeyboardLayout::onCurrentLayoutDisplayNameReceived(QDBusPendingCallWatcher *watcher)
{
QDBusPendingReply<QString> reply = *watcher;
if (reply.isError()) {
qCWarning(KEYBOARD_LAYOUT) << reply.error().message();
} else {
mCurrentLayoutDisplayName = reply.value();
Q_EMIT currentLayoutDisplayNameChanged(mCurrentLayoutDisplayName);
}
watcher->deleteLater();
}
QString KeyboardLayout::currentLayoutDisplayName() const
{
return mCurrentLayoutDisplayName;
}
void KeyboardLayout::requestLayoutsList()
{
if (!mIface) {
@ -125,6 +150,7 @@ void KeyboardLayout::setCurrentLayout(const QString &layout)
}
mCurrentLayout = layout;
requestCurrentLayoutDisplayName();
mIface->asyncCall(QStringLiteral("setLayout"), layout);
Q_EMIT currentLayoutChanged(layout);
}
@ -135,9 +161,3 @@ QStringList KeyboardLayout::layouts() const
return mLayouts;
}
void KeyboardLayout::onCurrentLayoutChanged(const QString &newLayout)
{
mCurrentLayout = newLayout;
Q_EMIT currentLayoutChanged(newLayout);
}

@ -36,6 +36,10 @@ class KeyboardLayout : public QObject
WRITE setCurrentLayout
NOTIFY currentLayoutChanged)
Q_PROPERTY(QString currentLayoutDisplayName
READ currentLayoutDisplayName
NOTIFY currentLayoutDisplayNameChanged)
Q_PROPERTY(QStringList layouts
READ layouts
NOTIFY layoutsChanged)
@ -45,6 +49,7 @@ public:
~KeyboardLayout();
QString currentLayout() const;
QString currentLayoutDisplayName() const;
QStringList layouts() const;
public Q_SLOTS:
@ -52,20 +57,22 @@ public Q_SLOTS:
Q_SIGNALS:
void currentLayoutChanged(const QString &newLayout);
void currentLayoutDisplayNameChanged(const QString &newLayout);
void layoutsChanged();
private Q_SLOTS:
void requestCurrentLayout();
void requestCurrentLayoutDisplayName();
void requestLayoutsList();
void onCurrentLayoutReceived(QDBusPendingCallWatcher *watcher);
void onCurrentLayoutDisplayNameReceived(QDBusPendingCallWatcher *watcher);
void onLayoutsListReceived(QDBusPendingCallWatcher *watcher);
void onCurrentLayoutChanged(const QString &newLayout);
private:
QStringList mLayouts;
QString mCurrentLayout;
QString mCurrentLayoutDisplayName;
QDBusInterface *mIface;
};

@ -25,11 +25,8 @@ import org.kde.plasma.workspace.keyboardlayout 1.0
PlasmaComponents.Button {
id: kbLayoutButton
// flat: false
// checkable: false
activeFocusOnTab: true
implicitWidth: minimumWidth
text: layout.currentLayout
text: layout.currentLayoutDisplayName
Accessible.name: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout")

Loading…
Cancel
Save