on xenial help sign in
properly show/hide the keyboard indicator when a HW (dis)appears and/or the keymap count changes
commitfbb4f8a1332af8262aeb2e5ff07617a5ebc2c5dd authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 21 Jun 2016, 18:21 (10 years ago) parent0386293
3 files changed+26−3
qml/Components/KeymapSwitcher.qml+21−2 qml/OrientedShell.qml+1 qml/Shell.qml+4−1
qml/Components/KeymapSwitcher.qml+21−2
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.4
1818import AccountsService 0.1
19+import GSettings 1.0
1920import GlobalShortcut 1.0
2021import QMenuModel 0.1
2122import Unity.Application 0.1
@@ -23,6 +24,9 @@ import Unity.Application 0.1
2324Item {
2425 id: root
2526
27+ // to be set from Shell.qml
28+ property bool hasKeyboard
29+
2630 GlobalShortcut {
2731 shortcut: Qt.MetaModifier|Qt.Key_Space
2832 onTriggered: root.nextKeymap()
@@ -79,16 +83,31 @@ Item {
7983 }
8084
8185 onCurrentKeymapIndexChanged: {
82− print("!!! Current keymap index changed:", currentKeymapIndex)
8386 actionGroup.currentAction.updateState(currentKeymapIndex);
8487 }
8588
8689 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
8790
8891 onActiveActionStateChanged: {
89− print("!!! Active keymap changed (via indicator) to:", activeActionState);
9092 if (activeActionState != -1) {
9193 currentKeymapIndex = activeActionState;
9294 }
9395 }
96+
97+ // indicator visibility
98+ GSettings {
99+ id: settings
100+ schema.id: "com.canonical.indicator.keyboard"
101+ }
102+
103+ function updateIndicatorVisibility() {
104+ settings.visible = keymapCount > 1 && hasKeyboard;
105+ }
106+
107+ onHasKeyboardChanged: updateIndicatorVisibility();
108+ onKeymapCountChanged: updateIndicatorVisibility();
109+
110+ Component.onCompleted: {
111+ updateIndicatorVisibility();
112+ }
94113}
qml/OrientedShell.qml+1
@@ -254,6 +254,7 @@ Item {
254254 nativeHeight: root.height
255255 mode: applicationArguments.mode
256256 hasMouse: miceModel.count + touchPadModel.count > 0
257+ hasKeyboard: keyboardsModel.count > 0
257258 // TODO: Factor in if the current screen is a touch screen and if the user wants to
258259 // have multiple keyboards around. For now we only enable one keyboard at a time
259260 // thus hiding it here if there is a physical one around or if we have a second
qml/Shell.qml+4−1
@@ -68,6 +68,7 @@ StyledItem {
6868 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
6969 }
7070 property bool hasMouse: false
71+ property bool hasKeyboard: false
7172
7273 // to be read from outside
7374 readonly property int mainAppWindowOrientationAngle:
@@ -780,7 +781,9 @@ StyledItem {
780781 }
781782
782783 // non-visual object
783− KeymapSwitcher {}
784+ KeymapSwitcher {
785+ hasKeyboard: shell.hasKeyboard
786+ }
784787
785788 Rectangle {
786789 id: shutdownFadeOutRectangle