From b954852ba97fb9ef7ce09614d30428c0e1ccdf9a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 8 Oct 2016 15:23:11 +1300 Subject: [PATCH] Use temporary copy of keyboard QML file while refactoring --- interface/resources/qml/AddressBarDialog.qml | 2 +- .../resources/qml/controls-uit/Keyboard.qml | 10 + .../qml/controls-uit/KeyboardAlpha.qml | 390 ++++++++++++++++++ interface/resources/qml/controls/WebView.qml | 2 +- .../qml/dialogs/CustomQueryDialog.qml | 2 +- .../resources/qml/dialogs/FileDialog.qml | 2 +- .../resources/qml/dialogs/QueryDialog.qml | 2 +- .../resources/qml/windows/ScrollingWindow.qml | 2 +- 8 files changed, 406 insertions(+), 6 deletions(-) create mode 100644 interface/resources/qml/controls-uit/KeyboardAlpha.qml diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index bb44e2c56e..641229efa6 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -276,7 +276,7 @@ Window { } // virtual keyboard, letters - HifiControls.Keyboard { + HifiControls.KeyboardAlpha { id: keyboard1 y: parent.keyboardRaised ? parent.height : 0 height: parent.keyboardRaised ? 200 : 0 diff --git a/interface/resources/qml/controls-uit/Keyboard.qml b/interface/resources/qml/controls-uit/Keyboard.qml index 1d957ce9cb..e1ce909ecd 100644 --- a/interface/resources/qml/controls-uit/Keyboard.qml +++ b/interface/resources/qml/controls-uit/Keyboard.qml @@ -1,3 +1,13 @@ +// +// FileDialog.qml +// +// Created by Anthony Thibault on 31 Oct 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + import QtQuick 2.0 Item { diff --git a/interface/resources/qml/controls-uit/KeyboardAlpha.qml b/interface/resources/qml/controls-uit/KeyboardAlpha.qml new file mode 100644 index 0000000000..1d957ce9cb --- /dev/null +++ b/interface/resources/qml/controls-uit/KeyboardAlpha.qml @@ -0,0 +1,390 @@ +import QtQuick 2.0 + +Item { + id: keyboardBase + height: 200 + property alias shiftKey: key27 + property bool shiftMode: false + + function resetShiftMode(mode) { + shiftMode = mode; + shiftKey.resetToggledMode(mode); + } + + function toUpper(str) { + if (str === ",") { + return "<"; + } else if (str === ".") { + return ">"; + } else if (str === "/") { + return "?"; + } else { + return str.toUpperCase(str); + } + } + + function toLower(str) { + if (str === "<") { + return ","; + } else if (str === ">") { + return "."; + } else if (str === "?") { + return "/"; + } else { + return str.toLowerCase(str); + } + } + + function forEachKey(func) { + var i, j; + for (i = 0; i < column1.children.length; i++) { + var row = column1.children[i]; + for (j = 0; j < row.children.length; j++) { + var key = row.children[j]; + func(key); + } + } + } + + onShiftModeChanged: { + forEachKey(function (key) { + if (shiftMode) { + key.glyph = keyboardBase.toUpper(key.glyph); + } else { + key.glyph = keyboardBase.toLower(key.glyph); + } + }); + } + + function alphaKeyClickedHandler(mouseArea) { + // reset shift mode to false after first keypress + if (shiftMode) { + resetShiftMode(false); + } + } + + Component.onCompleted: { + // hook up callbacks to every ascii key + forEachKey(function (key) { + if (/^[a-z]+$/i.test(key.glyph)) { + key.mouseArea.onClicked.connect(alphaKeyClickedHandler); + } + }); + } + + Rectangle { + id: leftRect + y: 0 + height: 200 + color: "#252525" + anchors.right: keyboardRect.left + anchors.rightMargin: 0 + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + anchors.left: parent.left + anchors.leftMargin: 0 + } + + Rectangle { + id: keyboardRect + x: 206 + y: 0 + width: 480 + height: 200 + color: "#252525" + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + + Column { + id: column1 + width: 480 + height: 200 + + Row { + id: row1 + width: 480 + height: 50 + anchors.left: parent.left + anchors.leftMargin: 0 + + Key { + id: key1 + width: 44 + glyph: "q" + } + + Key { + id: key2 + width: 44 + glyph: "w" + } + + Key { + id: key3 + width: 44 + glyph: "e" + } + + Key { + id: key4 + width: 43 + glyph: "r" + } + + Key { + id: key5 + width: 43 + glyph: "t" + } + + Key { + id: key6 + width: 44 + glyph: "y" + } + + Key { + id: key7 + width: 44 + glyph: "u" + } + + Key { + id: key8 + width: 43 + glyph: "i" + } + + Key { + id: key9 + width: 42 + glyph: "o" + } + + Key { + id: key10 + width: 44 + glyph: "p" + } + + Key { + id: key28 + width: 45 + glyph: "←" + } + } + + Row { + id: row2 + width: 480 + height: 50 + anchors.left: parent.left + anchors.leftMargin: 18 + + Key { + id: key11 + width: 43 + } + + Key { + id: key12 + width: 43 + glyph: "s" + } + + Key { + id: key13 + width: 43 + glyph: "d" + } + + Key { + id: key14 + width: 43 + glyph: "f" + } + + Key { + id: key15 + width: 43 + glyph: "g" + } + + Key { + id: key16 + width: 43 + glyph: "h" + } + + Key { + id: key17 + width: 43 + glyph: "j" + } + + Key { + id: key18 + width: 43 + glyph: "k" + } + + Key { + id: key19 + width: 43 + glyph: "l" + } + + Key { + id: key32 + width: 75 + glyph: "⏎" + } + } + + Row { + id: row3 + width: 480 + height: 50 + anchors.left: parent.left + anchors.leftMargin: 0 + + Key { + id: key27 + width: 46 + glyph: "⇪" + toggle: true + onToggledChanged: { + shiftMode = toggled; + } + } + + Key { + id: key20 + width: 43 + glyph: "z" + } + + Key { + id: key21 + width: 43 + glyph: "x" + } + + Key { + id: key22 + width: 43 + glyph: "c" + } + + Key { + id: key23 + width: 43 + glyph: "v" + } + + Key { + id: key24 + width: 43 + glyph: "b" + } + + Key { + id: key25 + width: 43 + glyph: "n" + } + + Key { + id: key26 + width: 44 + glyph: "m" + } + + Key { + id: key31 + width: 43 + glyph: "_" + } + + Key { + id: key33 + width: 43 + glyph: "?" + } + + Key { + id: key36 + width: 46 + glyph: "/" + } + + } + + Row { + id: row4 + width: 480 + height: 50 + anchors.left: parent.left + anchors.leftMargin: 19 + + Key { + id: key30 + width: 89 + glyph: "&123" + mouseArea.onClicked: { + keyboardBase.parent.punctuationMode = true; + } + } + + Key { + id: key29 + width: 285 + glyph: " " + } + + Key { + id: key34 + width: 43 + glyph: "⇦" + } + + Key { + id: key35 + x: 343 + width: 43 + glyph: "⇨" + } + + } + } + } + + Rectangle { + id: rightRect + y: 280 + height: 200 + color: "#252525" + border.width: 0 + anchors.left: keyboardRect.right + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + } + + Rectangle { + id: rectangle1 + color: "#ffffff" + anchors.bottom: keyboardRect.top + anchors.bottomMargin: 0 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.top: parent.top + anchors.topMargin: 0 + } + +} diff --git a/interface/resources/qml/controls/WebView.qml b/interface/resources/qml/controls/WebView.qml index c3381ab824..200ffa147f 100644 --- a/interface/resources/qml/controls/WebView.qml +++ b/interface/resources/qml/controls/WebView.qml @@ -106,7 +106,7 @@ Item { } // virtual keyboard, letters - HiFiControls.Keyboard { + HiFiControls.KeyboardAlpha { id: keyboard1 y: keyboardRaised ? parent.height : 0 height: keyboardRaised ? 200 : 0 diff --git a/interface/resources/qml/dialogs/CustomQueryDialog.qml b/interface/resources/qml/dialogs/CustomQueryDialog.qml index 563dfc3099..b23bc835c1 100644 --- a/interface/resources/qml/dialogs/CustomQueryDialog.qml +++ b/interface/resources/qml/dialogs/CustomQueryDialog.qml @@ -165,7 +165,7 @@ ModalWindow { bottomMargin: keyboardRaised ? hifi.dimensions.contentSpacing.y : 0 } - Keyboard { + KeyboardAlpha { id: keyboard1 visible: keyboardRaised && !punctuationMode enabled: keyboardRaised && !punctuationMode diff --git a/interface/resources/qml/dialogs/FileDialog.qml b/interface/resources/qml/dialogs/FileDialog.qml index 0942e728f9..ef49b3c8ff 100644 --- a/interface/resources/qml/dialogs/FileDialog.qml +++ b/interface/resources/qml/dialogs/FileDialog.qml @@ -647,7 +647,7 @@ ModalWindow { KeyNavigation.right: openButton } - Keyboard { + KeyboardAlpha { id: keyboard1 height: parent.keyboardRaised ? 200 : 0 visible: parent.keyboardRaised && !parent.punctuationMode diff --git a/interface/resources/qml/dialogs/QueryDialog.qml b/interface/resources/qml/dialogs/QueryDialog.qml index cf1b1e370a..22e225ba74 100644 --- a/interface/resources/qml/dialogs/QueryDialog.qml +++ b/interface/resources/qml/dialogs/QueryDialog.qml @@ -117,7 +117,7 @@ ModalWindow { } // virtual keyboard, letters - Keyboard { + KeyboardAlpha { id: keyboard1 y: parent.keyboardRaised ? parent.height : 0 height: parent.keyboardRaised ? 200 : 0 diff --git a/interface/resources/qml/windows/ScrollingWindow.qml b/interface/resources/qml/windows/ScrollingWindow.qml index ce4bd45cff..12cf38df72 100644 --- a/interface/resources/qml/windows/ScrollingWindow.qml +++ b/interface/resources/qml/windows/ScrollingWindow.qml @@ -180,7 +180,7 @@ Window { children: [ footer ] } - HiFiControls.Keyboard { + HiFiControls.KeyboardAlpha { id: keyboard1 height: parent.keyboardEnabled && parent.keyboardRaised ? 200 : 0 visible: parent.keyboardEnabled && parent.keyboardRaised && !parent.punctuationMode