Commit bc1e9920 authored by Yuriy Saurov's avatar Yuriy Saurov Committed by Andrey Butirsky
Browse files

[keyboard layout applet] Fix auto-opening fullRepresentation on start

BUG: 438460


(cherry picked from commit 948fb7d5)
parent 842ded1a
......@@ -10,63 +10,65 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.workspace.components 2.0
KeyboardLayoutSwitcher {
Item {
id: root
Plasmoid.toolTipSubText: layoutNames.longName
Plasmoid.status: hasMultipleKeyboardLayouts ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
function iconURL(name) {
return StandardPaths.locate(StandardPaths.GenericDataLocation,
"kf5/locale/countries/" + name + "/flag.png")
"kf5/locale/countries/" + name + "/flag.png")
}
Connections {
target: keyboardLayout
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
function onLayoutsListChanged() {
plasmoid.clearActions()
Plasmoid.compactRepresentation: KeyboardLayoutSwitcher {
Plasmoid.toolTipSubText: layoutNames.longName
Plasmoid.status: hasMultipleKeyboardLayouts ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus
keyboardLayout.layoutsList.forEach(
function(layout, index) {
plasmoid.setAction(
index,
layout.longName,
iconURL(layout.shortName).toString().substring(7) // remove file:// scheme
)
}
)
}
Connections {
target: keyboardLayout
function onLayoutChanged() {
root.Plasmoid.activated()
function onLayoutsListChanged() {
plasmoid.clearActions()
keyboardLayout.layoutsList.forEach(
function(layout, index) {
plasmoid.setAction(
index,
layout.longName,
iconURL(layout.shortName).toString().substring(7) // remove file:// scheme
)
}
)
}
function onLayoutChanged() {
root.Plasmoid.activated()
}
}
}
function actionTriggered(selectedLayout) {
keyboardLayout.layout = selectedLayout
}
function actionTriggered(selectedLayout) {
keyboardLayout.layout = selectedLayout
}
hoverEnabled: true
hoverEnabled: true
PlasmaCore.IconItem {
id: icon
PlasmaCore.IconItem {
id: icon
source: iconURL(layoutNames.shortName)
visible: plasmoid.configuration.showFlag && source
anchors.fill: parent
active: containsMouse
}
source: iconURL(layoutNames.shortName)
visible: plasmoid.configuration.showFlag && source
anchors.fill: parent
active: containsMouse
}
PlasmaComponents3.Label {
text: layoutNames.displayName || layoutNames.shortName
visible: !icon.visible
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
fontSizeMode: Text.Fit
font.pointSize: height
PlasmaComponents3.Label {
text: layoutNames.displayName || layoutNames.shortName
visible: !icon.visible
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
fontSizeMode: Text.Fit
font.pointSize: height
}
}
}
Supports Markdown
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