Commit bf8f4d89 authored by Andrey Butirsky's avatar Andrey Butirsky

refactor: keyboard layout applet: return to Properties-based QML API

All layouts names are now stored in layoutsList Property and not in
Action applet's menu objects.
There is no need for KeyboardDaemon::getLayoutLongName() DBus method any
more. See corresponding P-W commit.

Also fix "&" symbol in ToolTip text.
parent 9021b3cb
......@@ -13,6 +13,10 @@ import org.kde.plasma.workspace.components 2.0
KeyboardLayoutButton {
id: root
text: layoutNames.displayName || layoutNames.shortName
Plasmoid.toolTipSubText: layoutNames.longName
icon.name: iconURL(layoutNames.shortName)
display: plasmoid.configuration.showFlag && icon.name ? AbstractButton.IconOnly : AbstractButton.TextOnly
Plasmoid.status: hasMultipleKeyboardLayouts ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
......@@ -22,42 +26,30 @@ KeyboardLayoutButton {
"kf5/locale/countries/" + name + "/flag.png")
}
connections.target: null
Connections {
target: keyboardLayout
function onLayoutsChanged(layouts) {
function onLayoutsListChanged() {
plasmoid.clearActions()
layouts.forEach(
keyboardLayout.layoutsList.forEach(
function(layout, index) {
plasmoid.setAction(
index,
layout.longName,
iconURL(layout.shortName).toString().substring(7) // remove file:// scheme
)
const action = plasmoid.action(index)
action.toolTip = layout.displayName || layout.shortName
action.iconText = layout.shortName
}
)
}
function onLayoutChanged(index) {
const action = plasmoid.action(index)
text = action.toolTip
root.Plasmoid.toolTipSubText = action.text
icon.name = iconURL(action.iconText)
function onLayoutChanged() {
root.Plasmoid.activated()
}
}
function actionTriggered(selectedLayout) {
keyboardLayout.setLayout(selectedLayout)
keyboardLayout.layout = selectedLayout
}
// to fit at least 2 letters in systray
......
......@@ -230,11 +230,6 @@ uint KeyboardDaemon::getLayout() const
return X11Helper::getGroup();
}
QString KeyboardDaemon::getLayoutLongName() const
{
return Flags::getLongText(currentLayout, rules);
}
QVector<LayoutNames> KeyboardDaemon::getLayoutsList() const
{
QVector<LayoutNames> ret;
......
......@@ -64,7 +64,6 @@ public Q_SLOTS:
Q_SCRIPTABLE void switchToPreviousLayout();
Q_SCRIPTABLE bool setLayout(uint index);
Q_SCRIPTABLE uint getLayout() const;
Q_SCRIPTABLE QString getLayoutLongName() const;
Q_SCRIPTABLE QVector<LayoutNames> getLayoutsList() const;
Q_SIGNALS:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment