diff options
author | Kimmo Ollila <kimmo.ollila@theqtcompany.com> | 2016-03-11 12:09:26 +0200 |
---|---|---|
committer | Kimmo Ollila <kimmo.ollila@theqtcompany.com> | 2016-03-16 13:45:02 +0000 |
commit | 0aab56ca5eea0ba4df48258f1a1c866d21bb9bce (patch) | |
tree | 22c6ec0121a70403efe114c13408637609ccede4 /src/settingsui | |
parent | d873745b783ed6a9c582055058ed8a1f1506bf20 (diff) |
Migrate VirtualKeyboard 2.0 to settings UI.
Change-Id: I0be16db0d2bcc8ef3408916e1f708e270f4a9f8b
Reviewed-by: Teemu Holappa <teemu.holappa@theqtcompany.com>
Diffstat (limited to 'src/settingsui')
-rw-r--r-- | src/settingsui/common/HandwritingModeButton.qml | 171 | ||||
-rw-r--r-- | src/settingsui/icons.qrc | 3 | ||||
-rwxr-xr-x | src/settingsui/icons/FloatingButton_Active.png | bin | 0 -> 3584 bytes | |||
-rwxr-xr-x | src/settingsui/icons/FloatingButton_Available.png | bin | 0 -> 3554 bytes | |||
-rwxr-xr-x | src/settingsui/icons/FloatingButton_Unavailable.png | bin | 0 -> 3134 bytes | |||
-rw-r--r-- | src/settingsui/main.qml | 84 | ||||
-rw-r--r-- | src/settingsui/network/WifiSettings.qml | 2 |
7 files changed, 256 insertions, 4 deletions
diff --git a/src/settingsui/common/HandwritingModeButton.qml b/src/settingsui/common/HandwritingModeButton.qml new file mode 100644 index 0000000..0dfe775 --- /dev/null +++ b/src/settingsui/common/HandwritingModeButton.qml @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.6 + +Item { + id: handwritingModeButton + state: "unavailable" + property bool floating + property bool flipable + readonly property real __minWidthHeight: Math.min(width, height) + + signal clicked() + signal doubleClicked() + + Flipable { + id: flipableImage + anchors.fill: parent + + property bool flipped + + front: Image { + sourceSize.width: handwritingModeButton.__minWidthHeight + sourceSize.height: handwritingModeButton.__minWidthHeight + smooth: false + source: "qrc:/icons/FloatingButton_Unavailable.png" + } + + back: Image { + id: buttonImage + sourceSize.width: handwritingModeButton.__minWidthHeight + sourceSize.height: handwritingModeButton.__minWidthHeight + smooth: false + source: "qrc:/icons/FloatingButton_Available.png" + } + + states: State { + PropertyChanges { target: rotation; angle: 180 } + when: flipableImage.flipped + } + + transform: Rotation { + id: rotation + origin.x: flipableImage.width / 2 + origin.y: flipableImage.height / 2 + axis { x: 0; y: 1; z: 0 } + angle: 0 + } + + transitions: Transition { + enabled: handwritingModeButton.flipable + NumberAnimation { target: rotation; property: "angle"; duration: 400 } + } + } + + states: [ + State { + name: "available" + PropertyChanges { target: flipableImage; flipped: true } + }, + State { + name: "active" + PropertyChanges { target: flipableImage; flipped: true } + PropertyChanges { target: buttonImage; source: "qrc:/icons/FloatingButton_Active.png" } + } + ] + + function snapHorizontal() { + if (!floating) + return + if (mouseArea.drag.maximumX > mouseArea.drag.minimumX) { + if (x + 20 >= mouseArea.drag.maximumX) { + anchors.left = undefined + anchors.right = parent.right + } else if (x - 20 <= mouseArea.drag.minimumX) { + anchors.right = undefined + anchors.left = parent.left + } + } + } + + function snapVertical() { + if (!floating) + return + if (mouseArea.drag.maximumY > mouseArea.drag.minimumY) { + if (y + 20 >= mouseArea.drag.maximumY) { + anchors.top = undefined + anchors.bottom = parent.bottom + } else if (y - 20 <= mouseArea.drag.minimumY) { + anchors.bottom = undefined + anchors.top = parent.top + } + } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + drag { + target: handwritingModeButton.floating ? handwritingModeButton : undefined + axis: Drag.XAxis | Drag.YAxis + minimumX: 0 + maximumX: handwritingModeButton.parent.width - handwritingModeButton.width + onMaximumXChanged: !mouseArea.drag.active && handwritingModeButton.snapHorizontal() + minimumY: 0 + maximumY: handwritingModeButton.parent.height - handwritingModeButton.height + onMaximumYChanged: !mouseArea.drag.active && handwritingModeButton.snapVertical() + } + onPressed: { + if (!handwritingModeButton.floating) + return + handwritingModeButton.anchors.left = undefined + handwritingModeButton.anchors.top = undefined + handwritingModeButton.anchors.right = undefined + handwritingModeButton.anchors.bottom = undefined + } + onReleased: { + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + } + onClicked: { + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + clickTimer.restart() + } + onDoubleClicked: { + clickTimer.stop() + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + handwritingModeButton.doubleClicked() + } + Timer { + id: clickTimer + interval: Qt.styleHints ? Qt.styleHints.mouseDoubleClickInterval / 3 : 0 + repeat: false + onTriggered: handwritingModeButton.clicked() + } + } +} diff --git a/src/settingsui/icons.qrc b/src/settingsui/icons.qrc index c616ead..29d0e1a 100644 --- a/src/settingsui/icons.qrc +++ b/src/settingsui/icons.qrc @@ -14,5 +14,8 @@ <file>icons/Laptop_qt_1x.png</file> <file>icons/Microphone_qt_1x.png</file> <file>icons/Mouse_qt_1x.png</file> + <file>icons/FloatingButton_Active.png</file> + <file>icons/FloatingButton_Available.png</file> + <file>icons/FloatingButton_Unavailable.png</file> </qresource> </RCC> diff --git a/src/settingsui/icons/FloatingButton_Active.png b/src/settingsui/icons/FloatingButton_Active.png Binary files differnew file mode 100755 index 0000000..9b55146 --- /dev/null +++ b/src/settingsui/icons/FloatingButton_Active.png diff --git a/src/settingsui/icons/FloatingButton_Available.png b/src/settingsui/icons/FloatingButton_Available.png Binary files differnew file mode 100755 index 0000000..1479881 --- /dev/null +++ b/src/settingsui/icons/FloatingButton_Available.png diff --git a/src/settingsui/icons/FloatingButton_Unavailable.png b/src/settingsui/icons/FloatingButton_Unavailable.png Binary files differnew file mode 100755 index 0000000..33aa87d --- /dev/null +++ b/src/settingsui/icons/FloatingButton_Unavailable.png diff --git a/src/settingsui/main.qml b/src/settingsui/main.qml index 9129ff5..1ed1138 100644 --- a/src/settingsui/main.qml +++ b/src/settingsui/main.qml @@ -33,6 +33,9 @@ import Qt.labs.controls.material 1.0 import Qt.labs.controls.universal 1.0 import Qt.labs.settings 1.0 import QtQuick.XmlListModel 2.0 +import QtQuick.Enterprise.VirtualKeyboard 2.0 +import com.theqtcompany.localdevice 1.0 +import "common" ApplicationWindow { id: root @@ -82,17 +85,16 @@ ApplicationWindow { MenuItem { text: qsTr("Reboot") - onTriggered: B2QtDevice.reboot() + onTriggered: LocalDevice.reboot() } MenuItem { text: qsTr("Shutdown") - onTriggered: B2QtDevice.powerOff() + onTriggered: LocalDevice.powerOff() } } } } } - StackView { id: stackView initialItem: mainView @@ -101,6 +103,8 @@ ApplicationWindow { anchors.left: parent.left anchors.right: parent.right + Behavior on anchors.topMargin { NumberAnimation { duration: 250; easing.type: Easing.InOutQuad }} + Component { id: mainView @@ -160,4 +164,78 @@ ApplicationWindow { } } } + + property var inputItem: InputContext.inputItem + + HandwritingInputPanel { + + id: handwritingInputPanel + anchors.fill: parent + inputPanel: inputPanel + + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + opacity: 0.10 + } + + onAvailableChanged: { + if (!available) + inputPanel.ensureVisible() + } + } + Item { + visible: handwritingInputPanel.enabled && Qt.inputMethod.visible + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: inputPanel.top; } + + HandwritingModeButton { + id: handwritingModeButton + anchors.top: parent.top + anchors.right: parent.right + anchors.margins: 10 + floating: true + flipable: true + width: 76 + height: width + state: handwritingInputPanel.state + onClicked: handwritingInputPanel.active = !handwritingInputPanel.active + onDoubleClicked: handwritingInputPanel.available = !handwritingInputPanel.available + } + } + InputPanel { + id: inputPanel + y: active ? parent.height - inputPanel.height : parent.height + anchors.left: parent.left + anchors.right: parent.right + + Behavior on y { NumberAnimation {duration: 250; easing.type: Easing.InOutQuad}} + + property var inputItem: InputContext.inputItem + + onInputItemChanged: { + if (handwritingInputPanel.available) + return; + + if (inputItem) { + ensureVisible() + } + } + + onActiveChanged: { + if (!active) { + stackView.anchors.topMargin = 0 + + if (!handwritingInputPanel.available && inputItem) + inputItem.focus = false + } + } + + function ensureVisible() { + var mapped = inputItem.mapToItem(handwritingInputPanel, 0,0) + if (mapped.y > (handwritingInputPanel.height-inputPanel.height-40)) { + stackView.anchors.topMargin = -inputPanel.height + } + } + } } diff --git a/src/settingsui/network/WifiSettings.qml b/src/settingsui/network/WifiSettings.qml index b51452d..8ad1517 100644 --- a/src/settingsui/network/WifiSettings.qml +++ b/src/settingsui/network/WifiSettings.qml @@ -149,7 +149,7 @@ Item { id: password text: "" echoMode: TextInput.Password - inputMethodHints: Qt.ImhNoPredictiveText + inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase | Qt.ImhSensitiveData Layout.alignment: Qt.AlignVCenter Layout.fillWidth: true } |