on xenial help sign in
merge lp:~lukas-kde/unity8/osk-indicator-switch
commitbdcd7eba19690520678352519364f6650ed3a936 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 8 Mar 2017, 15:25 (10 years ago) parent16aeee9ca95c92
6 files changed+58−30
data/com.canonical.Unity8.gschema.xml+10 qml/Greeter/GreeterPrompt.qml+29−10 qml/OrientedShell.qml+8−6 qml/Panel/Panel.qml+4−11 qml/Shell.qml+1 tests/qmltests/Panel/tst_Panel.qml+6−3
data/com.canonical.Unity8.gschema.xml+10
@@ -58,6 +58,16 @@
5858 <summary>The uri to the app store</summary>
5959 <description>This will be used whenever the user triggers an action to open the app store.</description>
6060 </key>
61+ <key type="b" name="always-show-osk">
62+ <default>false</default>
63+ <summary>Force showing/hiding the OSK</summary>
64+ <description>Toggle the visibility of the On Screen Keyboard unconditionally</description>
65+ </key>
66+ <key type="b" name="osk-switch-visible">
67+ <default>false</default>
68+ <summary>Whether the OSK switch should be visible</summary>
69+ <description>Toggle the visibility of the OSK switch</description>
70+ </key>
6171 </schema>
6272
6373 <schema path="/com/canonical/unity8/greeter/" id="com.canonical.Unity8.Greeter" gettext-domain="unity8">
qml/Greeter/GreeterPrompt.qml+29−10
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
19+import GSettings 1.0
1920import "../Components"
2021
2122FocusScope {
@@ -43,6 +44,11 @@ FocusScope {
4344 }
4445 }
4546
47+ GSettings {
48+ id: unity8Settings
49+ schema.id: "com.canonical.Unity8"
50+ }
51+
4652 StyledItem {
4753 id: d
4854
@@ -154,14 +160,27 @@ FocusScope {
154160 }
155161
156162 secondaryItem: [
157− Icon {
158− id: capsIcon
159− name: "keyboard-caps-enabled"
160− height: units.gu(3)
161− width: units.gu(3)
162− color: d.textColor
163− visible: root.isSecret && false // TODO: detect when caps lock is on
164− readonly property real visibleWidth: visible ? width + passwordInput.frameSpacing : 0
163+ Row {
164+ id: extraIcons
165+ spacing: passwordInput.frameSpacing
166+ Icon {
167+ name: "keyboard-caps-enabled"
168+ height: units.gu(3)
169+ width: units.gu(3)
170+ color: d.textColor
171+ visible: root.isSecret && false // TODO: detect when caps lock is on
172+ }
173+ Icon {
174+ name: "input-keyboard-symbolic"
175+ height: units.gu(3)
176+ width: units.gu(3)
177+ color: d.textColor
178+ visible: !unity8Settings.alwaysShowOsk
179+ MouseArea {
180+ anchors.fill: parent
181+ onClicked: unity8Settings.alwaysShowOsk = true
182+ }
183+ }
165184 }
166185 ]
167186
@@ -199,7 +218,7 @@ FocusScope {
199218 right: parent.right
200219 verticalCenter: parent.verticalCenter
201220 leftMargin: units.gu(1.5)
202− rightMargin: anchors.leftMargin + capsIcon.visibleWidth
221+ rightMargin: anchors.leftMargin + extraIcons.width
203222 }
204223 text: root.text
205224 visible: passwordInput.text == "" && !passwordInput.inputMethodComposing
@@ -221,7 +240,7 @@ FocusScope {
221240 anchors.left: parent.left
222241 anchors.right: parent.right
223242 anchors.leftMargin: passwordInput.frameSpacing * 2
224− anchors.rightMargin: passwordInput.frameSpacing * 2 + capsIcon.visibleWidth
243+ anchors.rightMargin: passwordInput.frameSpacing * 2 + extraIcons.width
225244 color: d.drawColor
226245 text: passwordInput.displayText
227246 visible: root.isPrompt && !root.interactive
qml/OrientedShell.qml+8−6
@@ -197,6 +197,12 @@ Item {
197197 value: !shell.oskEnabled || shell.usageScenario == "desktop"
198198 }
199199
200+ Binding {
201+ target: unity8Settings
202+ property: "oskSwitchVisible"
203+ value: shell.hasKeyboard
204+ }
205+
200206 readonly property int supportedOrientations: shell.supportedOrientations
201207 & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
202208 ? orientations.native_
@@ -268,12 +274,8 @@ Item {
268274 mode: applicationArguments.mode
269275 hasMouse: pointerInputDevices > 0
270276 hasKeyboard: keyboardsModel.count > 0
271− // TODO: Factor in if the current screen is a touch screen and if the user wants to
272− // have multiple keyboards around. For now we only enable one keyboard at a time
273− // thus hiding it here if there is a physical one around or if we have a second
274− // screen (the virtual touchpad & osk on the phone) attached.
275− oskEnabled: (keyboardsModel.count === 0 && screens.count === 1) ||
276− forceOSKEnabled
277+
278+ oskEnabled: unity8Settings.alwaysShowOsk || !hasKeyboard || forceOSKEnabled
277279
278280 usageScenario: {
279281 if (unity8Settings.usageMode === "Windowed") {
qml/Panel/Panel.qml+4−11
@@ -23,9 +23,6 @@ import Utils 0.1
2323import Unity.ApplicationMenu 0.1
2424
2525import QtQuick.Window 2.2
26−// for indicator-keyboard
27−import AccountsService 0.1
28−import Unity.InputInfo 0.1
2926
3027import "../ApplicationMenus"
3128import "../Components"
@@ -47,6 +44,7 @@ Item {
4744 property bool fullscreenMode: false
4845 property real panelAreaShowProgress: 1.0
4946 property bool greeterShown: false
47+ property bool hasKeyboard: false
5048
5149 property string mode: "staged"
5250
@@ -337,12 +335,12 @@ Item {
337335 objectName: identifier+"-panelItem"
338336
339337 property int ownIndex: index
340− property bool overflow: parent.width - x > __indicators.overFlowWidth
341− property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
338+ readonly property bool overflow: parent.width - x > __indicators.overFlowWidth
339+ readonly property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
342340 // HACK for indicator-session
343341 readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
344342 // HACK for indicator-keyboard
345− readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && (AccountsService.keymaps.length < 2 || keyboardsModel.count == 0)
343+ readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && !hasKeyboard
346344
347345 height: parent.height
348346 expanded: indicators.expanded
@@ -396,11 +394,6 @@ Item {
396394 }
397395 }
398396
399− InputDeviceModel {
400− id: keyboardsModel
401− deviceFilter: InputInfo.Keyboard
402− }
403−
404397 IndicatorsLight {
405398 id: indicatorLights
406399 }
qml/Shell.qml+1
@@ -533,6 +533,7 @@ StyledItem {
533533 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
534534 || greeter.hasLockedApp
535535 greeterShown: greeter && greeter.shown
536+ hasKeyboard: shell.hasKeyboard
536537 }
537538
538539 Launcher {
tests/qmltests/Panel/tst_Panel.qml+6−3
@@ -272,6 +272,7 @@ PanelTest {
272272 }
273273
274274 function cleanup() {
275+ panel.hasKeyboard = false;
275276 panel.indicators.hide();
276277 panel.applicationMenus.hide();
277278 waitForAllAnimationToComplete("initial");
@@ -713,8 +714,8 @@ PanelTest {
713714 { tag: "No keyboard, no keymap", keyboard: false, keymaps: [], hidden: true },
714715 { tag: "No keyboard, one keymap", keyboard: false, keymaps: ["us"], hidden: true },
715716 { tag: "No keyboard, 2 keymaps", keyboard: false, keymaps: ["us", "cs"], hidden: true },
716− { tag: "Keyboard, no keymap", keyboard: true, keymaps: [], hidden: true },
717− { tag: "Keyboard, one keymap", keyboard: true, keymaps: ["us"], hidden: true },
717+ { tag: "Keyboard, no keymap", keyboard: true, keymaps: [], hidden: false },
718+ { tag: "Keyboard, one keymap", keyboard: true, keymaps: ["us"], hidden: false },
718719 { tag: "Keyboard, 2 keymaps", keyboard: true, keymaps: ["us", "cs"], hidden: false }
719720 ];
720721 }
@@ -722,6 +723,7 @@ PanelTest {
722723 function test_hidingKeyboardIndicator(data) {
723724 var item = findChild(panel, "indicator-keyboard-panelItem");
724725 AccountsService.keymaps = data.keymaps;
726+ panel.hasKeyboard = data.keyboard;
725727 if (data.keyboard) {
726728 MockInputDeviceBackend.addMockDevice("/indicator_kbd0", InputInfo.Keyboard);
727729 } else {
@@ -734,11 +736,12 @@ PanelTest {
734736 function test_visibleIndicators_data() {
735737 return [
736738 { visible: [true, false, true, false, true, true, false, true] },
737− { visible: [false, false, false, false, false, false, true, false] }
739+ { visible: [true, false, false, false, false, false, true, false] }
738740 ];
739741 }
740742
741743 function test_visibleIndicators(data) {
744+ panel.hasKeyboard = true;
742745 for (var i = 0; i < data.visible.length; i++) {
743746 var visible = data.visible[i];
744747 root.setIndicatorVisible(i, visible);