fix: [2/2] Keyboard Layout applet doesn't follow actual layout switching

DIGEST:
BUG: 426900
wilder-5.22
Andrey Butirsky 6 years ago committed by David Edmundson
parent 2969719c9d
commit 63e0ba2dfa
  1. 20
      components/keyboardlayout/keyboardlayout.cpp
  2. 1
      components/keyboardlayout/keyboardlayout.h

@ -43,7 +43,7 @@ KeyboardLayout::KeyboardLayout(QObject* parent)
}
connect(mIface, &OrgKdeKeyboardLayoutsInterface::currentLayoutChanged,
this, &KeyboardLayout::setCurrentLayout);
this, &KeyboardLayout::onCurrentLayoutChanged);
connect(mIface, &OrgKdeKeyboardLayoutsInterface::layoutListChanged,
this, &KeyboardLayout::requestLayoutsList);
@ -136,24 +136,32 @@ QString KeyboardLayout::currentLayout() const
return mCurrentLayout;
}
void KeyboardLayout::setCurrentLayout(const QString &layout)
bool KeyboardLayout::onCurrentLayoutChanged(const QString &layout)
{
if (!mIface) {
return;
return false;
}
if (mCurrentLayout == layout) {
return;
return false;
}
if (!mLayouts.contains(layout)) {
qCWarning(KEYBOARD_LAYOUT) << "No such layout" << layout;
return;
return false;
}
mCurrentLayout = layout;
requestCurrentLayoutDisplayName();
mIface->setLayout(layout);
Q_EMIT currentLayoutChanged(layout);
return true;
}
void KeyboardLayout::setCurrentLayout(const QString &layout)
{
if (onCurrentLayoutChanged(layout)) {
mIface->setLayout(layout);
}
}

@ -64,6 +64,7 @@ private Q_SLOTS:
void requestCurrentLayoutDisplayName();
void requestLayoutsList();
bool onCurrentLayoutChanged(const QString &newLayout);
void onCurrentLayoutReceived(QDBusPendingCallWatcher *watcher);
void onCurrentLayoutDisplayNameReceived(QDBusPendingCallWatcher *watcher);
void onLayoutsListReceived(QDBusPendingCallWatcher *watcher);

Loading…
Cancel
Save