From 9d3f20ff59c6d0868464681697cf5699ed09526f Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 14 Nov 2013 09:23:28 +0100 Subject: Make it clean where to configure the network settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7f03d3734e9b1f7761614a01c6a43e288fef544d Reviewed-by: Topi Reiniö --- src/doc/src/b2qt.qdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index e2cec14..dde3f18 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -156,7 +156,8 @@ \b{Configuring VirtualBox} - Open VirtualBox network settings: Select \b{File > Preferences...} + Open the VirtualBox user interface. + Open the network settings: Select \b{File > Preferences...} and click on the \b{Network} tab. Create a new network named \e{vboxnet0} and edit its properties: -- cgit v1.2.3 From 67e2838be9799821e0ac605ea5177e660e4be925 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Mon, 18 Nov 2013 13:20:52 +0100 Subject: Doc: Add note about firewall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifad434e8b9c17b11f1aee2bd608293cdb09c597a Reviewed-by: Topi Reiniö --- src/doc/src/b2qt.qdoc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index dde3f18..7c643a6 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -168,6 +168,9 @@ \li Change both the lower and upper address bounds to 192.168.56.101. \endlist + Configure your system firewall to allow TCP and UDP packets between your host and + the virtual machine. + \section1 3. Installing \SDK If you have not already installed \SDK, do it as follows. -- cgit v1.2.3 From bd9e9d0d12536b26adf8ee212dadc4b939871dfe Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 21 Nov 2013 13:40:22 +0100 Subject: Doc: Match QtCreator 3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99a4a09ccc3eb0ef0efddf38691f070e9e36d3c1 Reviewed-by: Topi Reiniö --- src/doc/src/b2qt.qdoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index 7c643a6..2e85688 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -566,7 +566,9 @@ \list 1 \li Open \b{File > New File or Project}, select - \b{Qt Quick 2 Application (Built-in Types)} and click \b{Choose...}. + \b{Qt Quick 2 Application} and click \b{Choose...}. + \li Choose a location for your new project. + \li In \b{Qt Quick Component Set} dialog, select \b{Qt Quick 2.0}. \li In \b{Kit Selection} dialog, select the kit(s) for your devices. You can also select the emulator kit to test running the project in the emulator. -- cgit v1.2.3 From 8b3b2a9f1ad81a8c94874eefe92d59eec7ed1d53 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 12 Nov 2013 16:05:53 +0100 Subject: Fix compilation with gnustl on eAndroid Change-Id: I8ade110ad1869e9fbad28a73a57939ad986ceb17 Reviewed-by: Eirik Aavitsland --- src/utils/qdroidutils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index f2194c4..81a50ed 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -1,6 +1,7 @@ #include "qdroidutils.h" #include #include +#include #ifdef Q_OS_ANDROID_NO_SDK #include -- cgit v1.2.3 From bdc860eef15403f929df449a9c04f4e612bab46e Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Fri, 10 Jan 2014 14:14:54 +0100 Subject: Remove virtual keyboard Change-Id: I2e28ef84e5c71c46924fd2b62bc9b199a0c6c7a9 Reviewed-by: Eirik Aavitsland --- src/imports/imports.pro | 2 +- src/imports/virtualkeyboard/Keyboard.qml | 242 ---------------- .../virtualkeyboard/components/AlternativeKeys.qml | 122 -------- .../virtualkeyboard/components/AutoScroller.qml | 115 -------- .../virtualkeyboard/components/BackspaceKey.qml | 54 ---- src/imports/virtualkeyboard/components/BaseKey.qml | 77 ----- .../components/ChangeLanguageKey.qml | 52 ---- .../components/CharacterPreviewBubble.qml | 87 ------ .../virtualkeyboard/components/EnterKey.qml | 74 ----- .../virtualkeyboard/components/HideKeyboardKey.qml | 53 ---- src/imports/virtualkeyboard/components/Icon.qml | 64 ----- .../virtualkeyboard/components/InputEngine.qml | 179 ------------ src/imports/virtualkeyboard/components/Key.qml | 64 ----- .../virtualkeyboard/components/NumberKey.qml | 47 ---- .../virtualkeyboard/components/PressedKey.qml | 66 ----- .../virtualkeyboard/components/ShiftKey.qml | 73 ----- .../virtualkeyboard/components/SpaceKey.qml | 63 ----- .../virtualkeyboard/components/SymbolModeKey.qml | 50 ---- src/imports/virtualkeyboard/images/arrow.png | Bin 264 -> 0 bytes src/imports/virtualkeyboard/images/backspace.png | Bin 515 -> 0 bytes src/imports/virtualkeyboard/images/enter.png | Bin 584 -> 0 bytes .../virtualkeyboard/images/hidekeyboard.png | Bin 251 -> 0 bytes src/imports/virtualkeyboard/images/keypad.png | Bin 14899 -> 0 bytes src/imports/virtualkeyboard/images/shift.png | Bin 310 -> 0 bytes src/imports/virtualkeyboard/images/space.png | Bin 240 -> 0 bytes src/imports/virtualkeyboard/layouts/ar_AR.qml | 85 ------ src/imports/virtualkeyboard/layouts/en_GB.qml | 184 ------------ src/imports/virtualkeyboard/layouts/fi_FI.qml | 203 -------------- src/imports/virtualkeyboard/layouts/numbers.qml | 103 ------- src/imports/virtualkeyboard/layouts/symbols.qml | 186 ------------- .../declarativeinputcontext.cpp | 309 --------------------- .../platforminputcontext/declarativeinputcontext.h | 149 ---------- .../platforminputcontext/platforminputcontext.cpp | 162 ----------- .../platforminputcontext/platforminputcontext.h | 89 ------ .../platforminputcontext/platforminputcontext.json | 3 - .../platforminputcontext/platforminputcontext.pro | 21 -- .../platforminputcontext/plugin.cpp | 85 ------ src/imports/virtualkeyboard/qmldir | 2 - src/imports/virtualkeyboard/qmlmodule.pro | 34 --- src/imports/virtualkeyboard/virtualkeyboard.pro | 2 - 40 files changed, 1 insertion(+), 3100 deletions(-) delete mode 100644 src/imports/virtualkeyboard/Keyboard.qml delete mode 100644 src/imports/virtualkeyboard/components/AlternativeKeys.qml delete mode 100644 src/imports/virtualkeyboard/components/AutoScroller.qml delete mode 100644 src/imports/virtualkeyboard/components/BackspaceKey.qml delete mode 100644 src/imports/virtualkeyboard/components/BaseKey.qml delete mode 100644 src/imports/virtualkeyboard/components/ChangeLanguageKey.qml delete mode 100644 src/imports/virtualkeyboard/components/CharacterPreviewBubble.qml delete mode 100644 src/imports/virtualkeyboard/components/EnterKey.qml delete mode 100644 src/imports/virtualkeyboard/components/HideKeyboardKey.qml delete mode 100644 src/imports/virtualkeyboard/components/Icon.qml delete mode 100644 src/imports/virtualkeyboard/components/InputEngine.qml delete mode 100644 src/imports/virtualkeyboard/components/Key.qml delete mode 100644 src/imports/virtualkeyboard/components/NumberKey.qml delete mode 100644 src/imports/virtualkeyboard/components/PressedKey.qml delete mode 100644 src/imports/virtualkeyboard/components/ShiftKey.qml delete mode 100644 src/imports/virtualkeyboard/components/SpaceKey.qml delete mode 100644 src/imports/virtualkeyboard/components/SymbolModeKey.qml delete mode 100644 src/imports/virtualkeyboard/images/arrow.png delete mode 100644 src/imports/virtualkeyboard/images/backspace.png delete mode 100644 src/imports/virtualkeyboard/images/enter.png delete mode 100644 src/imports/virtualkeyboard/images/hidekeyboard.png delete mode 100644 src/imports/virtualkeyboard/images/keypad.png delete mode 100644 src/imports/virtualkeyboard/images/shift.png delete mode 100644 src/imports/virtualkeyboard/images/space.png delete mode 100644 src/imports/virtualkeyboard/layouts/ar_AR.qml delete mode 100644 src/imports/virtualkeyboard/layouts/en_GB.qml delete mode 100644 src/imports/virtualkeyboard/layouts/fi_FI.qml delete mode 100644 src/imports/virtualkeyboard/layouts/numbers.qml delete mode 100644 src/imports/virtualkeyboard/layouts/symbols.qml delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.cpp delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.h delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.cpp delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.h delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.json delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.pro delete mode 100644 src/imports/virtualkeyboard/platforminputcontext/plugin.cpp delete mode 100644 src/imports/virtualkeyboard/qmldir delete mode 100644 src/imports/virtualkeyboard/qmlmodule.pro delete mode 100644 src/imports/virtualkeyboard/virtualkeyboard.pro (limited to 'src') diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 0802ad0..92eddcd 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = utils virtualkeyboard +SUBDIRS = utils diff --git a/src/imports/virtualkeyboard/Keyboard.qml b/src/imports/virtualkeyboard/Keyboard.qml deleted file mode 100644 index c626dbc..0000000 --- a/src/imports/virtualkeyboard/Keyboard.qml +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "components" -import Boot2Qt.InputContext 1.0 -import Qt.labs.folderlistmodel 2.0 - -Image { - id: keyboard - - property var activeKey: 0 - property int localeIndex: 1 - property string locale: layoutsModel.count > 0 ? layoutsModel.get(localeIndex, "fileBaseName") : "en_GB" - property bool active: Qt.inputMethod.visible - property bool uppercased: uppercaseOnly ? true : (lowercaseOnly ? false : InputContext.shift || InputContext.capsLock) - property bool uppercaseOnly: InputContext.inputMethodHints & Qt.ImhUppercaseOnly - property bool lowercaseOnly: InputContext.inputMethodHints & Qt.ImhLowercaseOnly - property bool numberMode: InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly) - property bool symbolMode - - z: 1 - source: "images/keypad.png" - fillMode: Image.Stretch - width: parent.width - height: keyboardLayout.height+10 - y: Qt.inputMethod.visible ? parent.height - height : parent.height - visible: Qt.inputMethod.visible || Qt.inputMethod.animating; - - onLocaleChanged: InputContext.setLocale(locale) - onUppercasedChanged: if (Qt.inputMethod.visible) InputContext.handleUppercasing(uppercased) - - function changeInputLanguage() { - localeIndex = (localeIndex+1) % layoutsModel.count - } - - Behavior on y { - SequentialAnimation { - ScriptAction { - script: { - if (Qt.inputMethod.visible) { - keyboard.symbolMode = false - InputContext.handleUppercasing(uppercased) - } - InputContext.setAnimating(true) - } - } - NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } - ScriptAction { script: InputContext.setAnimating(false) } - } - } - AutoScroller {} - FolderListModel { - id: layoutsModel - folder: "layouts" - nameFilters: ["*_*.qml"] - } - PressedKey {} - InputEngine { id: inputEngine } - AlternativeKeys { id: alternativeKeys } - Timer { id: releaseInaccuracyTimer; interval: 500 } - CharacterPreviewBubble { enabled: keyboardMouse.pressed && !alternativeKeys.active } - Binding { - target: InputContext - property: "keyboardRectangle" - value: Qt.rect(keyboard.x, keyboard.y, keyboard.width, keyboard.height) - } - Column { - id: keyboardLayout - anchors.centerIn: parent - Loader { - active: false - visible: keyboard.symbolMode && !keyboard.numberMode - source: "layouts/symbols.qml" - onVisibleChanged: if (visible) active = true - Component.onCompleted: if (visible) active = true - anchors.horizontalCenter: parent.horizontalCenter - } - Loader { - active: false - visible: keyboard.numberMode - source: "layouts/numbers.qml" - onVisibleChanged: if (visible) active = true - Component.onCompleted: if (visible) active = true - anchors.horizontalCenter: parent.horizontalCenter - } - Loader { - visible: !keyboard.symbolMode && !keyboard.numberMode - source: "layouts/" + keyboard.locale +".qml" - } - } - MouseArea { - id: keyboardMouse - - property var initialKey - property var previousKey - property bool dragSymbolMode - property real pressAndHoldMargin: 6 - property real releaseMargin: 18 - - anchors.fill: keyboardLayout - - function press(key) { - if (key && key.enabled) { - if (key.key != Qt.Key_unknown || key.text.length > 0) - inputEngine.sendKeyPress(key.key, keyboard.uppercased ? key.text.toUpperCase() : key.text, keyboard.uppercased ? Qt.ShiftModifier : 0, key.repeat) - } - } - function release(key) { - if (key && key.enabled) { - if (key.key != Qt.Key_unknown || key.text.length > 0) - inputEngine.sendKeyRelease(key.key, keyboard.uppercased ? key.text.toUpperCase() : key.text, keyboard.uppercased ? Qt.ShiftModifier : 0) - key.clicked() - } else if (initialKey !== undefined) // rollback - InputContext.preeditText = InputContext.preeditText.substr(0, InputContext.preeditText.length-1) - } - function click(key) { - if (key && key.enabled) { - if (key.key != Qt.Key_unknown || key.text.length > 0) - inputEngine.sendKeyClick(key.key, keyboard.uppercased ? key.text.toUpperCase() : key.text, keyboard.uppercased ? Qt.ShiftModifier : 0, key.repeat) - key.clicked() - } - } - function setActiveKey(activeKey) { - if (keyboard.activeKey) - keyboard.activeKey.active = false - keyboard.activeKey = activeKey - if (keyboard.activeKey) - keyboard.activeKey.active = true - } - function keyOnMouse(mx, my) { - var parentItem = keyboardLayout - var child = parentItem.childAt(mx, my) - while (child != null) { - var position = parentItem.mapToItem(child, mx, my) - mx = position.x; my = position.y - parentItem = child - child = parentItem.childAt(mx, my) - if (child && child.key != undefined) - return child - } - return undefined - } - function hitInitialKey(mouseX, mouseY, margin) { - if (!initialKey) - return false - var position = initialKey.mapFromItem(keyboardMouse, mouseX, mouseY) - return (position.x > -margin - && position.y > -margin - && position.x < initialKey.width + margin - && position.y < initialKey.height + margin) - } - function reset() { - alternativeKeys.close() - previousKey = keyboard.activeKey - setActiveKey(0) - if (dragSymbolMode) - keyboard.symbolMode = false - dragSymbolMode = false - } - - onPressed: { - releaseInaccuracyTimer.start() - initialKey = keyOnMouse(mouseX, mouseY) - setActiveKey(initialKey ? initialKey : 0) - press(initialKey) - } - onPositionChanged: { - if (alternativeKeys.active) { - alternativeKeys.move(mouseX) - } else { - var key = keyOnMouse(mouseX, mouseY) - if (key !== keyboard.activeKey) { - setActiveKey(key ? key : 0) - } - } - } - onPressAndHold: { - var key = hitInitialKey(mouseX, mouseY, pressAndHoldMargin) ? initialKey : keyboard.activeKey - if (key != undefined && key == initialKey) { - alternativeKeys.open(key) - if (!alternativeKeys.active && key.key == Qt.Key_Context1) { - dragSymbolMode = true - keyboard.symbolMode = true - } - } - } - onClicked: {} - onReleased: { - var key = keyOnMouse(mouseX, mouseY) - if (alternativeKeys.active) { - alternativeKeys.move(mouseX) - alternativeKeys.clicked() - } else if (dragSymbolMode) { - var key = keyOnMouse(mouseX, mouseY) - release(initialKey) - click(key) - } else { - release(releaseInaccuracyTimer.running && hitInitialKey(mouseX, mouseY, releaseMargin) ? initialKey : keyOnMouse(mouseX, mouseY)) - } - reset() - } - onCanceled: reset() - } -} diff --git a/src/imports/virtualkeyboard/components/AlternativeKeys.qml b/src/imports/virtualkeyboard/components/AlternativeKeys.qml deleted file mode 100644 index 2465fa5..0000000 --- a/src/imports/virtualkeyboard/components/AlternativeKeys.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - property bool active: activeKey != null - property string keys - property int primaryKeyCode - property var activeKey: null - property real keyWidth: 36 - property real keyMargin: 5 - - z: 1 - radius: 4 - height: 60 - parent: keyboard - visible: active - width: keyRow.width - - signal clicked - - onClicked: { - if (active) - inputEngine.sendKeyRelease(primaryKeyCode, - keyboard.uppercased ? activeKey.text.toUpperCase() : activeKey.text, - keyboard.uppercased ? Qt.ShiftModifier : 0) - } - - function open(key) { - keys = key.alternativeKeys - primaryKeyCode = key.key - if (keys.length > 0) { - var position = keyboard.mapFromItem(key, 0, -23) - var primaryKeyIndex = 0 - while (primaryKeyIndex < keys.length) { - if (keys.charAt(primaryKeyIndex) == key.text) { - break - } - primaryKeyIndex++ - } - if (primaryKeyIndex == keys.length) { - console.log("AlternativeKeys: active key \"" + key.text + "\" not found in alternativeKeys \"" + keys + ".\"") - primaryKeyIndex = 0 - } - x = Math.min(Math.max(keyMargin, position.x-primaryKeyIndex*keyWidth+(key.width-keyWidth)/2-1), keyboard.width-width-keyMargin) - y = Math.min(position.y-height+keyMargin, keyboard.height-height-keyMargin) - activeKey = keyRow.children[primaryKeyIndex] - arrow.x = mapFromItem(key, key.width/2, 0).x - arrow.width/2 - } - } - function close() { - activeKey = null - } - function move(mouseX) { - var oldKey = activeKey - activeKey = keyRow.children[Math.max(0, Math.min(keys.length-1, Math.floor((mouseX-keyRow.x-x)/keyWidth)))] - } - - Image { - id: arrow - source: "../images/arrow.png" - anchors.top: parent.bottom - } - Row { - id: keyRow - anchors.centerIn: parent - Repeater { - model: keys.length - Text { - id: key - color: activeKey === key ? "#f04b67" : "black" - width: keyWidth - height: keyWidth + 5 - text: keys.charAt(index) - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font { - pixelSize: 40 - capitalization: keyboard.uppercased ? Font.AllUppercase : Font.MixedCase - } - } - } - } -} diff --git a/src/imports/virtualkeyboard/components/AutoScroller.qml b/src/imports/virtualkeyboard/components/AutoScroller.qml deleted file mode 100644 index bbdc5da..0000000 --- a/src/imports/virtualkeyboard/components/AutoScroller.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 - -Item { - property var innerFlickable - property var outerFlickable - property var inputItem: Qt.inputMethod.inputItem - - onInputItemChanged: { - if (inputItem) { - var parent_ = inputItem.parent - while (parent_) { - if (parent_.maximumFlickVelocity) { - if (innerFlickable) { - outerFlickable = parent_ - break - } else { - innerFlickable = parent_ - } - } - parent_ = parent_.parent - } - delayedLoading.triggered() - } - } - - function ensureVisible(flickable) { - if (Qt.inputMethod.visible && inputItem && flickable && flickable.visible && flickable.interactive) { - - var verticallyFlickable = (flickable.flickableDirection == Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection == Flickable.VerticalFlick - || (flickable.flickableDirection == Flickable.AutoFlickDirection && flickable.contentHeight > flickable.height)) - var horizontallyFlickable = (flickable.flickableDirection == Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection == Flickable.HorizontalFlick - || (flickable.flickableDirection == Flickable.AutoFlickDirection && flickable.contentWidth > flickable.width)) - - if (!verticallyFlickable && !horizontallyFlickable) - return - - var cursorRectangle = flickable.contentItem.mapFromItem(inputItem, inputItem.cursorRectangle.x, inputItem.cursorRectangle.y) - - var oldContentY = flickable.contentY - if (verticallyFlickable) { - var scrollMarginVertical = (flickable && flickable.scrollMarginVertical) ? flickable.scrollMarginVertical : 10 - if (flickable.contentY >= cursorRectangle.y - scrollMarginVertical) - flickable.contentY = Math.max(0, cursorRectangle.y - scrollMarginVertical) - else if (flickable.contentY + flickable.height <= cursorRectangle.y + inputItem.cursorRectangle.height + scrollMarginVertical) - flickable.contentY = Math.min(flickable.contentHeight - flickable.height, cursorRectangle.y + inputItem.cursorRectangle.height - flickable.height + scrollMarginVertical) - } - if (horizontallyFlickable) { - var scrollMarginHorizontal = (flickable && flickable.scrollMarginHorizontal) ? flickable.scrollMarginHorizontal : 10 - if (flickable.contentX >= cursorRectangle.x - scrollMarginHorizontal) - flickable.contentX = Math.max(0, cursorRectangle.x - scrollMarginHorizontal) - else if (flickable.contentX + flickable.width <= cursorRectangle.x + inputItem.cursorRectangle.width + scrollMarginHorizontal) - flickable.contentX = Math.min(flickable.contentWidth - flickable.width, cursorRectangle.x + inputItem.cursorRectangle.width - flickable.width + scrollMarginHorizontal) - } - } - } - Timer { - id: delayedLoading - interval: 10 - onTriggered: { - ensureVisible(innerFlickable) - ensureVisible(outerFlickable) - } - } - Connections { - ignoreUnknownSignals: true - target: Qt.inputMethod.inputItem && Qt.inputMethod.animating ? Qt.inputMethod : null - onKeyboardRectangleChanged: delayedLoading.triggered() - } - Connections { - ignoreUnknownSignals: true - target: Qt.inputMethod.inputItem && Qt.inputMethod.inputItem.activeFocus ? Qt.inputMethod.inputItem : null - onCursorRectangleChanged: delayedLoading.triggered() - } -} diff --git a/src/imports/virtualkeyboard/components/BackspaceKey.qml b/src/imports/virtualkeyboard/components/BackspaceKey.qml deleted file mode 100644 index 760372c..0000000 --- a/src/imports/virtualkeyboard/components/BackspaceKey.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BaseKey { - key: Qt.Key_Backspace - width: 47 - repeat: true - functionKey: true - Icon { - invert: pressed - opacity: parent.enabled ? 1.0 : 0.6 - source: "../images/backspace.png" - anchors { centerIn: parent; verticalCenterOffset: 1 } - } -} diff --git a/src/imports/virtualkeyboard/components/BaseKey.qml b/src/imports/virtualkeyboard/components/BaseKey.qml deleted file mode 100644 index 3f982c6..0000000 --- a/src/imports/virtualkeyboard/components/BaseKey.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: keyItem - - property string text - property string displayText: text - property string alternativeKeys - property int key: Qt.Key_unknown - property bool active - property bool repeat - property bool highlighted - property bool functionKey - property bool showPreview: !functionKey - property bool enabled: true - property bool pressed: enabled && active - property color textColor: pressed ? "#EEEEEE" : (enabled ? "black" : "black") - - width: 31 - height: 55 - z: pressed ? 1 : 0 - y: pressed ? 1 : 0 - scale: pressed ? (width > 40 ? 0.98 : 0.96) : 1.0 - - signal clicked - - Rectangle { - id: background - - z: -1 - radius: 4 - visible: !pressed - opacity: highlighted ? 0.6 : 0.2 - color: keyItem.enabled ? "#EEEEEE" : "black" - anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 2; rightMargin: 2 } - } -} diff --git a/src/imports/virtualkeyboard/components/ChangeLanguageKey.qml b/src/imports/virtualkeyboard/components/ChangeLanguageKey.qml deleted file mode 100644 index d6c89d3..0000000 --- a/src/imports/virtualkeyboard/components/ChangeLanguageKey.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BaseKey { - functionKey: true - Text { - text: keyboard.locale.split("_")[0] - color: textColor - font { pixelSize: 16; capitalization: Font.AllUppercase } - anchors { centerIn: parent; verticalCenterOffset: parent.textPixelSize > 35 ? 2 : 0 } - } - onClicked: keyboard.changeInputLanguage() -} diff --git a/src/imports/virtualkeyboard/components/CharacterPreviewBubble.qml b/src/imports/virtualkeyboard/components/CharacterPreviewBubble.qml deleted file mode 100644 index db0abdd..0000000 --- a/src/imports/virtualkeyboard/components/CharacterPreviewBubble.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - property bool enabled - property bool sideBackground - property real sideMargin: 46 - property real sideBackgroundOffset: 10 - property var activeKey: keyboard.activeKey - - z: 1 - radius: 4 - height: 60 - width: Math.max(previewCharacter.width+20, 55) - visible: false - parent: keyboard - opacity: (activeKey && enabled) ? 1.0 : 0.0 - - onActiveKeyChanged: { - visible = activeKey && activeKey.showPreview - if (activeKey) { - previewCharacter.text = activeKey.text - var position = keyboard.mapFromItem(activeKey, activeKey.width/2, 10) - var onLeft = position.x < sideMargin - var onRight = position.x > keyboard.width - sideMargin - x = position.x - width/2 - + (onLeft ? sideBackgroundOffset : 0) - - (onRight ? sideBackgroundOffset : 0) - y = position.y - height - 25 - arrow.anchors.horizontalCenterOffset = onLeft ? -sideBackgroundOffset - : (onRight ? sideBackgroundOffset : 0) - } - } - Image { - id: arrow - source: "../images/arrow.png" - anchors { top: parent.bottom; horizontalCenter: parent.horizontalCenter } - } - Text { - id: previewCharacter - color: "black" - font { - pixelSize: previewCharacter.text.length == 1 ? 50 : 40 - capitalization: keyboard.uppercased ? Font.AllUppercase : Font.MixedCase - } - anchors { centerIn: parent; verticalCenterOffset: -2 } - } -} diff --git a/src/imports/virtualkeyboard/components/EnterKey.qml b/src/imports/virtualkeyboard/components/EnterKey.qml deleted file mode 100644 index d321e34..0000000 --- a/src/imports/virtualkeyboard/components/EnterKey.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BaseKey { - - property string enterKeyText: Qt.inputMethod.inputItem ? Qt.inputMethod.inputItem.enterKeyText : "" - - width: 78 - text: "\n" - key: Qt.Key_Return - functionKey: true - highlighted: enabled && enterKeyText.length > 0 - enabled: Qt.inputMethod.inputItem ? Qt.inputMethod.inputItem.enterKeyEnabled : true - - Icon { - invert: pressed - visible: enterKeyText.length == 0 - source: "../images/enter.png" - anchors { centerIn: parent; verticalCenterOffset: 2 } - } - Text { - visible: enterKeyText.length > 0 - text: enterKeyText - fontSizeMode: Text.HorizontalFit - color: textColor - font { pixelSize: 20; capitalization: Font.AllUppercase } - horizontalAlignment: Text.AlignHCenter - anchors { - left: parent.left - right: parent.right - verticalCenter: parent.verticalCenter - margins: 5 - } - } -} diff --git a/src/imports/virtualkeyboard/components/HideKeyboardKey.qml b/src/imports/virtualkeyboard/components/HideKeyboardKey.qml deleted file mode 100644 index 411307a..0000000 --- a/src/imports/virtualkeyboard/components/HideKeyboardKey.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BaseKey { - functionKey: true - onClicked: { - Qt.inputMethod.hide(); - } - Icon { - invert: pressed - source: "../images/hidekeyboard.png" - anchors { centerIn: parent; verticalCenterOffset: 4 } - } -} diff --git a/src/imports/virtualkeyboard/components/Icon.qml b/src/imports/virtualkeyboard/components/Icon.qml deleted file mode 100644 index 089090d..0000000 --- a/src/imports/virtualkeyboard/components/Icon.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ShaderEffect { - property bool invert - property alias source: image.source - property variant texture: Image { id: image } - - width: image.implicitWidth - height: image.implicitHeight - - fragmentShader: " - uniform bool invert; - uniform lowp float qt_Opacity; - uniform lowp sampler2D texture; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 color = texture2D(texture, qt_TexCoord0) * qt_Opacity; - if (invert) - gl_FragColor = vec4(vec3(1.0) - color.rgb, 1.0) * color.a; - else - gl_FragColor = color; - } - " -} diff --git a/src/imports/virtualkeyboard/components/InputEngine.qml b/src/imports/virtualkeyboard/components/InputEngine.qml deleted file mode 100644 index b47f9ed..0000000 --- a/src/imports/virtualkeyboard/components/InputEngine.qml +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 - -Item { - property int lastKey - property string sentenceEndingCharacters: ".;!?" - - Timer { - // key repeater - repeat: true - interval: 600 - running: keyboard.activeKey !== 0 && keyboard.activeKey.repeat - - onRunningChanged: if (!running) interval = 600 - onTriggered: { - interval = 150 - keyboardMouse.click(keyboard.activeKey) - } - } - Timer { - id: multiTapTimer - - property int index - - interval: 1200 - onTriggered: { - index = 0 - InputContext.commit(InputContext.preeditText) - } - } - Item { - id: shiftHandling - - property bool autoCapitalization: !(InputContext.inputMethodHints & (Qt.ImhNoAutoUppercase | Qt.ImhUppercaseOnly - | Qt.ImhLowercaseOnly | Qt.ImhEmailCharactersOnly - | Qt.ImhUrlCharactersOnly | Qt.ImhDialableCharactersOnly - | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - function reset() { - if (Qt.inputMethod.inputItem) { - var preferUpperCase = InputContext.inputMethodHints & Qt.ImhPreferUppercase - InputContext.shift = preferUpperCase - InputContext.capsLock = preferUpperCase - } - } - function autoCapitalize() { - if (!Qt.inputMethod.inputItem || !autoCapitalization || InputContext.capsLock) - return - var preferLowerCase = InputContext.inputMethodHints & Qt.ImhPreferLowercase - if (InputContext.cursorPosition == 0) - InputContext.shift = !preferLowerCase - else { - var text = (InputContext.surroundingText + InputContext.preeditText).substr(0, InputContext.cursorPosition).trim() - if (text.length == 0) - InputContext.shift = !preferLowerCase - else if (text.length > 1 && sentenceEndingCharacters.indexOf(text.charAt(text.length-1)) >= 0) - InputContext.shift = !preferLowerCase - else - InputContext.shift = false - } - } - Timer { - id: delayedLoading - interval: 10 - onTriggered: { - shiftHandling.reset() - shiftHandling.autoCapitalize() - } - } - Connections { - target: InputContext - onInputMethodHintsChanged: delayedLoading.restart() - onFocusEditorChanged: { - keyboard.symbolMode = false - delayedLoading.restart() - } - onPreeditTextChanged: { - if (shiftHandling.autoCapitalization && !InputContext.capsLock) - InputContext.shift = false - } - onCursorPositionChanged: shiftHandling.autoCapitalize() - } - } - function sendKeyClick(key, text, modifiers) { - sendKeyPress(key, text, modifiers) - sendKeyRelease(key, text, modifiers) - } - function sendKeyPress(key, text, modifiers) { - lastKey = key - } - function sendKeyRelease(key, text, modifiers) { - var accept = false - switch (key) { - case Qt.Key_Enter: - case Qt.Key_Return: - break - case Qt.Key_Space: - InputContext.commit(" ") - var text = InputContext.surroundingText.trim() - if (sentenceEndingCharacters.indexOf(text.charAt(text.length-1)) >= 0) - keyboard.symbolMode = false - accept = true - break - case Qt.Key_Tab: - case Qt.Key_Backspace: - if (InputContext.cursorPosition > 0) { - if (InputContext.selectedText.length == 0) - InputContext.commit("", -1, 1) - else - InputContext.commit("") - } - break - default: - if (key === Qt.Key_Asterisk && InputContext.inputMethodHints & Qt.ImhDialableCharactersOnly) { - if (key != lastKey) { - multiTapTimer.index = 0 - InputContext.commit(InputContext.preeditText) - multiTapTimer.running = false - } - multiTapTimer.index = multiTapTimer.running ? (multiTapTimer.index+1) % text.length : 0 - var character = text.charAt(multiTapTimer.index) - if (multiTapTimer.running) - InputContext.preeditText = InputContext.preeditText.substr(0, InputContext.preeditText.length - 1) + character - else - InputContext.preeditText += character - multiTapTimer.restart() - } else if (multiTapTimer.running) { - InputContext.commit(InputContext.preeditText) - multiTapTimer.stop() - } - if (!multiTapTimer.running) - InputContext.commit(text) - accept = true - break - } - if (!accept) { - InputContext.sendKeyClick(key, text, modifiers) - } - } -} diff --git a/src/imports/virtualkeyboard/components/Key.qml b/src/imports/virtualkeyboard/components/Key.qml deleted file mode 100644 index b2d08b3..0000000 --- a/src/imports/virtualkeyboard/components/Key.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 - -BaseKey { - id: keyItem - - property bool uppercased - property int textPixelSize: 24 - - Component.onCompleted: InputContext.registerCharacterKey(keyItem) - Component.onDestruction: InputContext.unregisterCharacterKey(keyItem) - - Text { - id: text - - text: displayText - color: textColor - anchors { centerIn: parent; verticalCenterOffset: pressed ? 1 : 0 } - font { - pixelSize: textPixelSize - capitalization: uppercased ? Font.AllUppercase : Font.MixedCase - } - } -} diff --git a/src/imports/virtualkeyboard/components/NumberKey.qml b/src/imports/virtualkeyboard/components/NumberKey.qml deleted file mode 100644 index f521f7f..0000000 --- a/src/imports/virtualkeyboard/components/NumberKey.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Key { - width: 77 - showPreview: false - textPixelSize: 38 -} diff --git a/src/imports/virtualkeyboard/components/PressedKey.qml b/src/imports/virtualkeyboard/components/PressedKey.qml deleted file mode 100644 index 1f2925d..0000000 --- a/src/imports/virtualkeyboard/components/PressedKey.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property bool active - property var activeKey: keyboard.activeKey - - visible: active - - onActiveKeyChanged: { - var activeKey = keyboard.activeKey - active = activeKey !== 0 && activeKey.enabled - if (active) { - var position = parent.mapFromItem(activeKey, 0, 0) - width = activeKey.width - height = activeKey.height - x = position.x - y = position.y + 1 - } - } - - Rectangle { - radius: 6 - color: "#f13c57" - anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 2; rightMargin: 2 } - } -} diff --git a/src/imports/virtualkeyboard/components/ShiftKey.qml b/src/imports/virtualkeyboard/components/ShiftKey.qml deleted file mode 100644 index 16f463f..0000000 --- a/src/imports/virtualkeyboard/components/ShiftKey.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 - -BaseKey { - id: shiftKey - width: 47 - key: Qt.Key_Shift - enabled: !keyboard.uppercaseOnly && !keyboard.lowercaseOnly - visible: enabled - highlighted: InputContext.capsLock - functionKey: true - property bool shiftChanged: true - onClicked: { - if (InputContext.inputMethodHints & Qt.ImhNoAutoUppercase) { - InputContext.capsLock = !InputContext.capsLock - InputContext.shift = !InputContext.shift - } else { - InputContext.capsLock = !InputContext.capsLock && (InputContext.shift && !shiftChanged) - InputContext.shift = InputContext.capsLock || !InputContext.shift ? true : false - shiftChanged = false - } - } - Connections { - target: keyboard - onUppercasedChanged: shiftKey.shiftChanged = true - } - Icon { - invert: pressed - smooth: shiftKey.pressed - anchors.centerIn: parent - source: "../images/shift.png" - } -} diff --git a/src/imports/virtualkeyboard/components/SpaceKey.qml b/src/imports/virtualkeyboard/components/SpaceKey.qml deleted file mode 100644 index d9a8a4e..0000000 --- a/src/imports/virtualkeyboard/components/SpaceKey.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Key { - id: spaceKey - - text: " " - repeat: true - width: keyboard.symbolMode ? 124 : 93 - showPreview: false - key: Qt.Key_Space - - Rectangle { - color: pressed ? "white" : "black" - height: 4 - visible: spaceKey.displayText === " " - width: parent.width-30 - anchors { - horizontalCenter: spaceKey.horizontalCenter - bottom: spaceKey.bottom - bottomMargin: 18 - } - } -} diff --git a/src/imports/virtualkeyboard/components/SymbolModeKey.qml b/src/imports/virtualkeyboard/components/SymbolModeKey.qml deleted file mode 100644 index d18447c..0000000 --- a/src/imports/virtualkeyboard/components/SymbolModeKey.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Key { - width: 78 - key: Qt.Key_Context1 - displayText: "&123" - textPixelSize: 20 - functionKey: true - onClicked: keyboard.symbolMode = !keyboard.symbolMode -} diff --git a/src/imports/virtualkeyboard/images/arrow.png b/src/imports/virtualkeyboard/images/arrow.png deleted file mode 100644 index 8d01aa2..0000000 Binary files a/src/imports/virtualkeyboard/images/arrow.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/backspace.png b/src/imports/virtualkeyboard/images/backspace.png deleted file mode 100644 index 4141872..0000000 Binary files a/src/imports/virtualkeyboard/images/backspace.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/enter.png b/src/imports/virtualkeyboard/images/enter.png deleted file mode 100644 index c611ebe..0000000 Binary files a/src/imports/virtualkeyboard/images/enter.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/hidekeyboard.png b/src/imports/virtualkeyboard/images/hidekeyboard.png deleted file mode 100644 index aecdfe5..0000000 Binary files a/src/imports/virtualkeyboard/images/hidekeyboard.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/keypad.png b/src/imports/virtualkeyboard/images/keypad.png deleted file mode 100644 index fd8fa55..0000000 Binary files a/src/imports/virtualkeyboard/images/keypad.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/shift.png b/src/imports/virtualkeyboard/images/shift.png deleted file mode 100644 index eded926..0000000 Binary files a/src/imports/virtualkeyboard/images/shift.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/images/space.png b/src/imports/virtualkeyboard/images/space.png deleted file mode 100644 index 4a5e847..0000000 Binary files a/src/imports/virtualkeyboard/images/space.png and /dev/null differ diff --git a/src/imports/virtualkeyboard/layouts/ar_AR.qml b/src/imports/virtualkeyboard/layouts/ar_AR.qml deleted file mode 100644 index dc7c6d9..0000000 --- a/src/imports/virtualkeyboard/layouts/ar_AR.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 -import "../components" - -Column { - property var keys: ["ضصقفغعهخحج", "شسيبلاتنمك", "ظطذدزوةث"] - Row { - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: keys[0].length - Key { - text: keys[0][index] - textPixelSize: index > 1 ? 24 : 22 - } - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: keys[1].length - Key { - text: keys[1][index] - textPixelSize: index > 0 ? 24 : 23 - } - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: keys[2].length - Key { - text: keys[2][index] - } - } - BackspaceKey { width: 62 } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - SymbolModeKey {} - ChangeLanguageKey {} - SpaceKey {} - HideKeyboardKey {} - EnterKey {} - } -} diff --git a/src/imports/virtualkeyboard/layouts/en_GB.qml b/src/imports/virtualkeyboard/layouts/en_GB.qml deleted file mode 100644 index 5fb34be..0000000 --- a/src/imports/virtualkeyboard/layouts/en_GB.qml +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 -import "../components" - -Column { - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: Qt.Key_Q - text: "q" - } - Key { - key: Qt.Key_W - text: "w" - } - Key { - key: Qt.Key_E - text: "e" - alternativeKeys: "êeëèé" - } - Key { - key: Qt.Key_R - text: "r" - alternativeKeys: "ŕrř" - } - Key { - key: Qt.Key_T - text: "t" - alternativeKeys: "ţtŧť" - } - Key { - key: Qt.Key_Y - text: "y" - alternativeKeys: "ÿyýŷ" - } - Key { - key: Qt.Key_U - text: "u" - alternativeKeys: "űūũûüuùú" - } - Key { - key: Qt.Key_I - text: "i" - alternativeKeys: "îïīĩiìí" - } - Key { - key: Qt.Key_O - text: "o" - alternativeKeys: "œøõôöòóo" - } - Key { - key: Qt.Key_P - text: "p" - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: Qt.Key_A - text: "a" - alternativeKeys: "aäåãâàá" - } - Key { - key: Qt.Key_S - text: "s" - alternativeKeys: "šsşś" - } - Key { - key: Qt.Key_D - text: "d" - alternativeKeys: "đdƌď" - } - Key { - key: Qt.Key_F - text: "f" - } - Key { - key: Qt.Key_G - text: "g" - alternativeKeys: "ġǥgģǧĝğ" - } - Key { - key: Qt.Key_H - text: "h" - } - Key { - key: Qt.Key_J - text: "j" - } - Key { - key: Qt.Key_K - text: "k" - } - Key { - key: Qt.Key_L - text: "l" - alternativeKeys: "ĺŀłļľl" - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - ShiftKey {} - Key { - key: Qt.Key_Z - text: "z" - alternativeKeys: "zžż" - } - Key { - key: Qt.Key_X - text: "x" - } - Key { - key: Qt.Key_C - text: "c" - alternativeKeys: "çcċčć" - } - Key { - key: Qt.Key_V - text: "v" - } - Key { - key: Qt.Key_B - text: "b" - } - Key { - key: Qt.Key_N - text: "n" - alternativeKeys: "ņńnň" - } - Key { - key: Qt.Key_M - text: "m" - } - BackspaceKey {} - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - SymbolModeKey {} - ChangeLanguageKey {} - SpaceKey {} - HideKeyboardKey {} - EnterKey {} - } -} diff --git a/src/imports/virtualkeyboard/layouts/fi_FI.qml b/src/imports/virtualkeyboard/layouts/fi_FI.qml deleted file mode 100644 index db1d644..0000000 --- a/src/imports/virtualkeyboard/layouts/fi_FI.qml +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Boot2Qt.InputContext 1.0 -import "../components" - -Column { - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: Qt.Key_Q - text: "q" - } - Key { - key: Qt.Key_W - text: "w" - } - Key { - key: Qt.Key_E - text: "e" - alternativeKeys: "êeëèé" - } - Key { - key: Qt.Key_R - text: "r" - alternativeKeys: "ŕrř" - } - Key { - key: Qt.Key_T - text: "t" - alternativeKeys: "ţtŧť" - } - Key { - key: Qt.Key_Y - text: "y" - alternativeKeys: "ÿyýŷ" - } - Key { - key: Qt.Key_U - text: "u" - alternativeKeys: "űūũûüuùú" - } - Key { - key: Qt.Key_I - text: "i" - alternativeKeys: "îïīĩiìí" - } - Key { - key: Qt.Key_O - text: "o" - alternativeKeys: "œøõôöòóo" - } - Key { - key: Qt.Key_P - text: "p" - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: Qt.Key_A - text: "a" - alternativeKeys: "aäåãâàá" - width: 28 - } - Key { - key: Qt.Key_S - text: "s" - alternativeKeys: "šsşś" - width: 28 - } - Key { - key: Qt.Key_D - text: "d" - alternativeKeys: "đdƌď" - width: 28 - } - Key { - key: Qt.Key_F - text: "f" - width: 28 - } - Key { - key: Qt.Key_G - text: "g" - alternativeKeys: "ġgģǧĝğ" - width: 28 - } - Key { - key: Qt.Key_H - text: "h" - width: 28 - } - Key { - key: Qt.Key_J - text: "j" - width: 28 - } - Key { - key: Qt.Key_K - text: "k" - width: 28 - } - Key { - key: Qt.Key_L - text: "l" - alternativeKeys: "ĺŀłļľl" - width: 28 - } - Key { - key: Qt.Key_Adiaeresis - text: "ä" - width: 28 - } - Key { - key: Qt.Key_Odiaeresis - text: "ö" - width: 28 - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - ShiftKey {} - Key { - key: Qt.Key_Z - text: "z" - alternativeKeys: "zžż" - } - Key { - key: Qt.Key_X - text: "x" - } - Key { - key: Qt.Key_C - text: "c" - alternativeKeys: "çcċčć" - } - Key { - key: Qt.Key_V - text: "v" - } - Key { - key: Qt.Key_B - text: "b" - } - Key { - key: Qt.Key_N - text: "n" - alternativeKeys: "ņńnň" - } - Key { - key: Qt.Key_M - text: "m" - } - BackspaceKey {} - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - SymbolModeKey {} - ChangeLanguageKey {} - SpaceKey {} - HideKeyboardKey {} - EnterKey {} - } -} diff --git a/src/imports/virtualkeyboard/layouts/numbers.qml b/src/imports/virtualkeyboard/layouts/numbers.qml deleted file mode 100644 index 7d47066..0000000 --- a/src/imports/virtualkeyboard/layouts/numbers.qml +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import ".." -import "../components" -import Boot2Qt.InputContext 1.0 - -Column { - Row { - Repeater { - model: 3 - NumberKey { key: Qt.Key_1 + index; text: 1 + index } - } - BackspaceKey { width: 78 } - } - Row { - Repeater { - model: 3 - NumberKey { key: Qt.Key_4 + index; text: 4 + index } - } - SpaceKey { - width: 78 - displayText: "_" - } - } - Row { - Repeater { - model: 3 - NumberKey { key: Qt.Key_7 + index; text: 7 + index } - } - HideKeyboardKey { width: 78 } - } - Row { - NumberKey { - key: Qt.Key_Asterisk - displayText: "*+" - text: "*+" - textPixelSize: 40 - visible: InputContext.inputMethodHints & Qt.ImhDialableCharactersOnly - } - NumberKey { - key: Qt.Key_0 - text: "0" - width: InputContext.inputMethodHints & Qt.ImhDigitsOnly ? 270 : (InputContext.inputMethodHints & Qt.ImhFormattedNumbersOnly ? 180 : 77) - textPixelSize: 38 - } - NumberKey { - id: signKey - text: "#" - key: Qt.Key_NumberSign - visible: !(InputContext.inputMethodHints & Qt.ImhDigitsOnly) - states: State { - when: InputContext.inputMethodHints & Qt.ImhFormattedNumbersOnly - PropertyChanges { - target: signKey - - text: "." - key: Qt.Key_Period - enabled: InputContext.surroundingText.indexOf(".") == -1 - } - } - } - EnterKey { width: 78 } - } -} diff --git a/src/imports/virtualkeyboard/layouts/symbols.qml b/src/imports/virtualkeyboard/layouts/symbols.qml deleted file mode 100644 index f4c8293..0000000 --- a/src/imports/virtualkeyboard/layouts/symbols.qml +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../components" - -Column { - property bool secondPage - onVisibleChanged: if (!visible) secondPage = false - - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: secondPage ? Qt.Key_unknown : Qt.Key_1 - text: secondPage ? ":)" : "1" - textPixelSize: secondPage ? 20 : 24 - } - Key { - key: secondPage ? Qt.Key_unknown : Qt.Key_2 - text: secondPage ? ":D" : "2" - textPixelSize: secondPage ? 20 : 24 - } - Key { - key: secondPage ? Qt.Key_Dollar : Qt.Key_3 - text: secondPage ? ":(" : "3" - textPixelSize: secondPage ? 20 : 24 - } - Key { - key: secondPage ? Qt.Key_yen : Qt.Key_4 - text: secondPage ? "<3": "4" - textPixelSize: secondPage ? 18 : 24 - } - Key { - key: Qt.Key_5 - text: secondPage ? "½" : "5" - } - Key { - key: secondPage ? Qt.Key_Percent : Qt.Key_6 - text: secondPage ? "%": "6" - } - Key { - key: secondPage ? Qt.Key_Less : Qt.Key_7 - text: secondPage ? "<": "7" - } - Key { - key: secondPage ? Qt.Key_Greater : Qt.Key_8 - text: secondPage ? ">" : "8" - } - Key { - key: secondPage ? Qt.Key_BracketLeft : Qt.Key_9 - text: secondPage ? "[" : "9" - } - Key { - key: secondPage ? Qt.Key_BracketRight : Qt.Key_0 - text: secondPage ? "]" : "0" - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - key: secondPage ? Qt.Key_AsciiTilde : Qt.Key_At - text: secondPage ? "~" : "@" - } - Key { - key: secondPage ? Qt.Key_Agrave : Qt.Key_Asterisk - text: secondPage ? "`" : "*" - } - Key { - key: secondPage ? Qt.Key_AsciiCircum : Qt.Key_NumberSign - text: secondPage ? "^" : "#" - } - Key { - key: secondPage ? Qt.Key_Bar : Qt.Key_Plus - text: secondPage ? "|" : "+" - } - Key { - key: secondPage ? Qt.Key_Underscore : Qt.Key_Minus - text: secondPage ? "_" : "-" - } - Key { - key: secondPage ? Qt.Key_section : Qt.Key_Equal - text: secondPage ? "§" : "=" - } - Key { - key: secondPage ? Qt.Key_BraceLeft : Qt.Key_ParenLeft - text: secondPage ? "{" : "(" - } - Key { - key: secondPage ? Qt.Key_BraceRight : Qt.Key_ParenRight - text: secondPage ? "}" : ")" - } - Key { - key: secondPage ? Qt.Key_questiondown : Qt.Key_Question - text: secondPage ? "¿" : "?" - } - Key { - key: secondPage ? Qt.Key_exclamdown : Qt.Key_Apostrophe - text: secondPage ? "¡" : "!" - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - Key { - width: 47 - displayText: secondPage ? " 2/2" : " 1/2" - textPixelSize: 20 - functionKey: true - onClicked: secondPage = !secondPage - } - Key { - key: secondPage ? Qt.Key_guillemotleft : Qt.Key_Period - text: secondPage ? '«' : "." - } - Key { - key: secondPage ? Qt.Key_guillemotright : Qt.Key_Comma - text: secondPage ? '»' : "," - } - Key { - key: secondPage ? Qt.Key_QuoteDbl : Qt.Key_Slash - text: secondPage ? '"' : "/" - } - Key { - key: secondPage ? Qt.Key_unknown : Qt.Key_Backslash - text: secondPage ? '“' : "\\" - } - Key { - key: secondPage ? Qt.Key_unknown : Qt.Key_Exclam - text: secondPage ? '”' : "'" - } - Key { - key: secondPage ? Qt.Key_unknown : Qt.Key_Colon - text: secondPage ? '„' : ":" - } - Key { - key: secondPage ? Qt.Key_Ampersand : Qt.Key_Semicolon - text: secondPage ? "&" : ";" - } - BackspaceKey { - - } - } - Row { - anchors.horizontalCenter: parent.horizontalCenter - SymbolModeKey { displayText: "ABC" } - SpaceKey {} - HideKeyboardKey {} - EnterKey {} - } -} diff --git a/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.cpp b/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.cpp deleted file mode 100644 index bf55f9b..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "platforminputcontext.h" -#include "declarativeinputcontext.h" - -#include -#include -#include -#include -#include -#include - -DeclarativeInputContext::DeclarativeInputContext(PlatformInputContext *parent) : - QObject(parent), m_inputContext(parent), m_inputMethodVisible(false), m_focus(false), - m_shift(false), m_capsLock(false), m_cursorPosition(0), m_inputMethodHints(0) -{ - if (m_inputContext) - m_inputContext->setDeclarativeContext(this); -} - -DeclarativeInputContext::~DeclarativeInputContext() -{ - if (m_inputContext) - m_inputContext->setDeclarativeContext(0); - m_characterKeys.clear(); -} - -bool DeclarativeInputContext::inputMethodVisible() const -{ - return m_inputMethodVisible; -} - -void DeclarativeInputContext::setInputMethodVisibleProperty(bool visible) -{ - if (m_inputMethodVisible != visible) { - m_inputMethodVisible = visible; - emit inputMethodVisibleChanged(); - } -} - -bool DeclarativeInputContext::focus() const -{ - return m_focus; -} - -void DeclarativeInputContext::setFocus(bool enable) -{ - if (m_focus != enable) { - m_focus = enable; - emit focusChanged(); - } - emit focusEditorChanged(); -} - -bool DeclarativeInputContext::shift() const -{ - return m_shift; -} - -void DeclarativeInputContext::setShift(bool enable) -{ - if (m_shift != enable) { - m_shift = enable; - emit shiftChanged(); - } -} - -bool DeclarativeInputContext::capsLock() const -{ - return m_capsLock; -} - -void DeclarativeInputContext::setCapsLock(bool enable) -{ - if (m_capsLock != enable) { - m_capsLock = enable; - emit capsLockChanged(); - } -} - -int DeclarativeInputContext::cursorPosition() const -{ - return m_cursorPosition; -} - -Qt::InputMethodHints DeclarativeInputContext::inputMethodHints() const -{ - return m_inputMethodHints; -} - -QString DeclarativeInputContext::preeditText() const -{ - return m_preeditText; -} - -void DeclarativeInputContext::setPreeditText(const QString &text) -{ - if (text != m_preeditText) - sendPreedit(text); -} - -QString DeclarativeInputContext::surroundingText() const -{ - return m_surroundingText; -} - -QString DeclarativeInputContext::selectedText() const -{ - return m_selectedText; -} - -QRectF DeclarativeInputContext::cursorRectangle() const -{ - return m_cursorRectangle; -} - -void DeclarativeInputContext::sendKeyClick(int key, const QString &text, int modifiers) -{ - if (m_focus && m_inputContext) { - QKeyEvent pressEvent(QEvent::KeyPress, key, Qt::KeyboardModifiers(modifiers), text); - QKeyEvent releaseEvent(QEvent::KeyRelease, key, Qt::KeyboardModifiers(modifiers), text); - - m_inputContext->sendKeyEvent(&pressEvent); - m_inputContext->sendKeyEvent(&releaseEvent); - } -} - -void DeclarativeInputContext::sendPreedit(const QString &text, int cursor) -{ - const QString preedit = m_preeditText; - m_preeditText = text; - - if (m_inputContext) { - QList attributes; - - if (cursor >= 0 && cursor <= text.length()) { - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant())); - } else { - cursor = text.length(); - } - - QTextCharFormat textFormat; - textFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, text.length(), textFormat)); - - QInputMethodEvent event(text, attributes); - m_inputContext->sendEvent(&event); - } - - if (m_preeditText != preedit) - emit preeditTextChanged(); -} - -void DeclarativeInputContext::commit() -{ - commit(m_preeditText); -} - -void DeclarativeInputContext::commit(const QString &text, int replacementStart, int replacementLength) -{ - bool preeditChanged = !m_preeditText.isEmpty(); - m_preeditText.clear(); - - if (m_inputContext) { - QInputMethodEvent inputEvent; - inputEvent.setCommitString(text, replacementStart, replacementLength); - m_inputContext->sendEvent(&inputEvent); - } - - if (preeditChanged) - emit preeditTextChanged(); -} - -void DeclarativeInputContext::clear() -{ - bool preeditChanged = !m_preeditText.isEmpty(); - m_preeditText.clear(); - - QInputMethodEvent event; - m_inputContext->sendEvent(&event); - - if (preeditChanged) - emit preeditTextChanged(); -} - -void DeclarativeInputContext::setAnimating(bool animating) -{ - if (m_inputContext && m_inputContext->m_animating != animating) { - m_inputContext->m_animating = animating; - m_inputContext->emitAnimatingChanged(); - } -} - -void DeclarativeInputContext::setKeyboardRectangle(QRectF rectangle) -{ - if (m_inputContext && m_inputContext->m_keyboardRect != rectangle) { - m_inputContext->m_keyboardRect = rectangle; - m_inputContext->emitKeyboardRectChanged(); - } -} - -QRectF DeclarativeInputContext::keyboardRectangle() const -{ - return m_inputContext->m_keyboardRect; -} - -void DeclarativeInputContext::setLocale(QString name) -{ - if (m_inputContext && m_inputContext->m_locale.name() != name) { - m_inputContext->m_locale = QLocale(name); - m_inputContext->emitLocaleChanged(); - if (m_inputContext->m_inputDirection != m_inputContext->m_locale.textDirection()) { - m_inputContext->m_inputDirection = m_inputContext->m_locale.textDirection(); - m_inputContext->emitInputDirectionChanged(m_inputContext->m_inputDirection); - } - } -} - -void DeclarativeInputContext::update(Qt::InputMethodQueries queries) -{ - Q_UNUSED(queries); - - // fetch - Qt::InputMethodHints inputMethodHints = Qt::InputMethodHints(m_inputContext->inputMethodQuery(Qt::ImHints).toInt()); - int cursorPosition = m_inputContext->inputMethodQuery(Qt::ImCursorPosition).toInt(); - QRectF cursorRectangle = qApp->inputMethod()->cursorRectangle(); - QString surroundingText = m_inputContext->inputMethodQuery(Qt::ImSurroundingText).toString(); - QString selectedText = m_inputContext->inputMethodQuery(Qt::ImCurrentSelection).toString(); - - // check against changes - bool newInputMethodHints = inputMethodHints != m_inputMethodHints; - bool newSurroundingText = surroundingText != m_surroundingText; - bool newSelectedTextChange = selectedText != m_selectedText; - bool newCursorPosition = cursorPosition != m_cursorPosition; - bool newCursorRectangle = cursorRectangle != m_cursorRectangle; - - // update - m_inputMethodHints = inputMethodHints; - m_surroundingText = surroundingText; - m_selectedText = selectedText; - m_cursorPosition = cursorPosition; - m_cursorRectangle = cursorRectangle; - - // notify - if (newInputMethodHints) - emit inputMethodHintsChanged(); - if (newSurroundingText) - emit surroundingTextChanged(); - if (newSelectedTextChange) - emit selectedTextChanged(); - if (newCursorPosition) - emit cursorPositionChanged(); - if (newCursorRectangle) - emit cursorRectangleChanged(); -} - -void DeclarativeInputContext::registerCharacterKey(QQuickItem *key) -{ - m_characterKeys.append(key); -} - -void DeclarativeInputContext::unregisterCharacterKey(QQuickItem *key) -{ - m_characterKeys.removeOne(key); -} - -void DeclarativeInputContext::handleUppercasing(bool uppercased) -{ - foreach(QQuickItem* key, m_characterKeys) - key->setProperty("uppercased", uppercased); -} diff --git a/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.h b/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.h deleted file mode 100644 index cb695ab..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/declarativeinputcontext.h +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DECLARATIVEINPUTCONTEXT_H -#define DECLARATIVEINPUTCONTEXT_H - -#include -#include -#include -#include - -class PlatformInputContext; -class QQuickItem; - -class DeclarativeInputContext : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool inputMethodVisible READ inputMethodVisible NOTIFY inputMethodVisibleChanged) - Q_PROPERTY(bool focus READ focus NOTIFY focusChanged) - Q_PROPERTY(bool shift READ shift WRITE setShift NOTIFY shiftChanged) - Q_PROPERTY(bool capsLock READ capsLock WRITE setCapsLock NOTIFY capsLockChanged) - Q_PROPERTY(int cursorPosition READ cursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints NOTIFY inputMethodHintsChanged) - Q_PROPERTY(QString preeditText READ preeditText WRITE setPreeditText NOTIFY preeditTextChanged) - Q_PROPERTY(QString surroundingText READ surroundingText NOTIFY surroundingTextChanged) - Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) - Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) - Q_PROPERTY(QRectF keyboardRectangle READ keyboardRectangle WRITE setKeyboardRectangle NOTIFY keyboardRectangleChanged) - -public: - explicit DeclarativeInputContext(PlatformInputContext *parent = 0); - ~DeclarativeInputContext(); - - bool inputMethodVisible() const; - void setInputMethodVisibleProperty(bool visible); - - bool focus() const; - void setFocus(bool enable); - - bool shift() const; - void setShift(bool enable); - - bool capsLock() const; - void setCapsLock(bool enable); - - int cursorPosition() const; - - Qt::InputMethodHints inputMethodHints() const; - - QString preeditText() const; - void setPreeditText(const QString &text); - - QString surroundingText() const; - - QString selectedText() const; - - QRectF cursorRectangle() const; - - QRectF keyboardRectangle() const; - Q_INVOKABLE void setKeyboardRectangle(QRectF rectangle); - - Q_INVOKABLE void sendKeyClick(int key, const QString &text, int modifiers = 0); - Q_INVOKABLE void sendPreedit(const QString &text, int cursor = -1); - - Q_INVOKABLE void commit(); - Q_INVOKABLE void commit(const QString &text, int replacementStart = 0, int replacementEnd = 0); - - Q_INVOKABLE void clear(); - - Q_INVOKABLE void setAnimating(bool animating); - Q_INVOKABLE void setLocale(QString name); - - void update(Qt::InputMethodQueries queries); - - Q_INVOKABLE void registerCharacterKey(QQuickItem * key); - Q_INVOKABLE void unregisterCharacterKey(QQuickItem * key); - Q_INVOKABLE void handleUppercasing(bool uppercased); - -signals: - void inputMethodVisibleChanged(); - void focusChanged(); - void preeditTextChanged(); - void surroundingTextChanged(); - void selectedTextChanged(); - void cursorPositionChanged(); - void inputMethodHintsChanged(); - void focusEditorChanged(); - void shiftChanged(); - void capsLockChanged(); - void cursorRectangleChanged(); - void keyboardRectangleChanged(); - -private: - void updateInputMethodValues(); - - PlatformInputContext *m_inputContext; - bool m_inputMethodVisible; - bool m_focus; - bool m_shift; - bool m_capsLock; - int m_cursorPosition; - Qt::InputMethodHints m_inputMethodHints; - QString m_preeditText; - QString m_surroundingText; - QString m_selectedText; - QRectF m_cursorRectangle; - QList m_characterKeys; -}; - -QML_DECLARE_TYPE(DeclarativeInputContext) - -#endif diff --git a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.cpp b/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.cpp deleted file mode 100644 index a73a15a..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "platforminputcontext.h" -#include "declarativeinputcontext.h" - -#include -#include -#include -#include - -PlatformInputContext::PlatformInputContext() : - m_declarativeContext(0), m_animating(false), m_visible(false), - m_focusObject(0), m_locale("en_GB"), m_inputDirection(Qt::LeftToRight) -{ -} - -PlatformInputContext::~PlatformInputContext() -{ -} - -bool PlatformInputContext::isValid() const -{ - return true; -} - -bool PlatformInputContext::isAnimating() const -{ - return m_animating; -} - -bool PlatformInputContext::isInputPanelVisible() const -{ - return m_visible; -} - -QRectF PlatformInputContext::keyboardRect() const -{ - return m_keyboardRect; -} - -QLocale PlatformInputContext::locale() const -{ - return m_locale; -} - -Qt::LayoutDirection PlatformInputContext::inputDirection() const -{ - return m_inputDirection; -} - -void PlatformInputContext::reset() -{ - if (m_declarativeContext) - m_declarativeContext->commit(); -} - -void PlatformInputContext::update(Qt::InputMethodQueries queries) -{ - if (m_declarativeContext) - m_declarativeContext->update(queries); -} - -void PlatformInputContext::showInputPanel() { - if (!m_visible) { - m_visible = true; - if (m_declarativeContext) { - m_declarativeContext->setInputMethodVisibleProperty(true); - } - emitInputPanelVisibleChanged(); - } -} - -void PlatformInputContext::hideInputPanel() { - if (m_visible) { - m_visible = false; - if (m_declarativeContext) { - m_declarativeContext->setInputMethodVisibleProperty(false); - } - emitInputPanelVisibleChanged(); - } -} - -void PlatformInputContext::setFocusObject(QObject *object) -{ - m_focusObject = object; - bool enabled = false; - if (m_focusObject) { - QInputMethodQueryEvent event(Qt::ImEnabled); - sendEvent(&event); - enabled = event.value(Qt::ImEnabled).toBool(); - } - if (m_declarativeContext) { - bool focus = (object != 0 && enabled); - m_declarativeContext->setFocus(focus); - if (focus) - m_declarativeContext->update(Qt::ImQueryAll); - else - hideInputPanel(); - } -} - -void PlatformInputContext::sendEvent(QEvent *event) -{ - if (m_focusObject) - QGuiApplication::sendEvent(m_focusObject, event); -} - -void PlatformInputContext::sendKeyEvent(QKeyEvent *event) -{ - if (qApp && qApp->focusWindow()) - QGuiApplication::sendEvent(qApp->focusWindow(), event); -} - -QVariant PlatformInputContext::inputMethodQuery(Qt::InputMethodQuery query) -{ - QInputMethodQueryEvent event(query); - sendEvent(&event); - return event.value(query); -} - -void PlatformInputContext::setDeclarativeContext(DeclarativeInputContext *context) -{ - m_declarativeContext = context; -} diff --git a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.h b/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.h deleted file mode 100644 index bcfae44..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLATFORMINPUTCONTEXT_H -#define PLATFORMINPUTCONTEXT_H - -#include -#include -#include -#include - -class DeclarativeInputContext; -class PlatformInputContext : public QPlatformInputContext -{ - Q_OBJECT -public: - explicit PlatformInputContext(); - ~PlatformInputContext(); - - // from QPlatformInputContext - virtual bool isValid() const; - virtual bool isAnimating() const; - virtual bool isInputPanelVisible() const; - virtual QRectF keyboardRect() const; - virtual QLocale locale() const; - virtual Qt::LayoutDirection inputDirection() const; - - void reset(); - void update(Qt::InputMethodQueries queries); - virtual void showInputPanel(); - virtual void hideInputPanel(); - virtual void setFocusObject(QObject *object); - -protected: - void sendEvent(QEvent *event); - void sendKeyEvent(QKeyEvent *event); - QVariant inputMethodQuery(Qt::InputMethodQuery query); - void setDeclarativeContext(DeclarativeInputContext *context); - -protected: - friend class DeclarativeInputContext; - - DeclarativeInputContext *m_declarativeContext; - bool m_animating; - bool m_visible; - QRectF m_keyboardRect; - QPointer m_focusObject; - QLocale m_locale; - Qt::LayoutDirection m_inputDirection; -}; - -#endif diff --git a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.json b/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.json deleted file mode 100644 index 266da3c..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "b2qtinputcontext" ] -} diff --git a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.pro b/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.pro deleted file mode 100644 index e2288fe..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/platforminputcontext.pro +++ /dev/null @@ -1,21 +0,0 @@ -TEMPLATE = lib -TARGET = b2qtinputcontextplugin -TARGETPATH = $$[QT_INSTALL_PLUGINS]/platforminputcontexts - -target.path = $$TARGETPATH - -QT += quick gui gui-private - -CONFIG += plugin - -SOURCES += platforminputcontext.cpp \ - declarativeinputcontext.cpp \ - plugin.cpp - -HEADERS += platforminputcontext.h \ - declarativeinputcontext.h - -OTHER_FILES = $$$PWD/platforminputcontext.json - -INSTALLS += target -OTHER += platforminputcontext.json diff --git a/src/imports/virtualkeyboard/platforminputcontext/plugin.cpp b/src/imports/virtualkeyboard/platforminputcontext/plugin.cpp deleted file mode 100644 index 3b67024..0000000 --- a/src/imports/virtualkeyboard/platforminputcontext/plugin.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include "platforminputcontext.h" -#include "declarativeinputcontext.h" - -static PlatformInputContext *platformInputContext = 0; - -static QObject *createInputContextModule(QQmlEngine *engine, QJSEngine *scriptEngine) -{ - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new DeclarativeInputContext(platformInputContext); -} - -class PlatformInputContextPlugin : public QPlatformInputContextPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "platforminputcontext.json") - -public: - QStringList keys() const; - QPlatformInputContext *create(const QString&, const QStringList&); -}; - -QStringList PlatformInputContextPlugin::keys() const -{ - return QStringList(QStringLiteral("b2qtinputcontext")); -} - -QPlatformInputContext *PlatformInputContextPlugin::create(const QString& system, const QStringList& paramList) -{ - Q_UNUSED(paramList); - - qDebug("created..."); - - qmlRegisterSingletonType("Boot2Qt.InputContext", 1, 0, "InputContext", createInputContextModule); - - if (system.compare(system, QStringLiteral("b2qtinputcontext"), Qt::CaseInsensitive) == 0) - platformInputContext = new PlatformInputContext; - return platformInputContext; -} - -#include "plugin.moc" diff --git a/src/imports/virtualkeyboard/qmldir b/src/imports/virtualkeyboard/qmldir deleted file mode 100644 index 10e8915..0000000 --- a/src/imports/virtualkeyboard/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module Qt.labs.virtualkeyboard -Keyboard 1.0 Keyboard.qml diff --git a/src/imports/virtualkeyboard/qmlmodule.pro b/src/imports/virtualkeyboard/qmlmodule.pro deleted file mode 100644 index 008a9be..0000000 --- a/src/imports/virtualkeyboard/qmlmodule.pro +++ /dev/null @@ -1,34 +0,0 @@ -TARGETPATH = "Qt/labs/virtualkeyboard" - -QML_FILES = \ - images/shift.png \ - images/space.png \ - images/backspace.png \ - images/arrow.png \ - images/enter.png \ - images/keypad.png \ - images/hidekeyboard.png \ - components/AutoScroller.qml \ - components/InputEngine.qml \ - components/HideKeyboardKey.qml \ - components/NumberKey.qml \ - components/CharacterPreviewBubble.qml \ - components/SymbolModeKey.qml \ - components/ChangeLanguageKey.qml \ - components/SpaceKey.qml \ - components/Icon.qml \ - components/BaseKey.qml \ - components/Key.qml \ - components/ShiftKey.qml \ - components/EnterKey.qml \ - components/AlternativeKeys.qml \ - components/PressedKey.qml \ - components/BackspaceKey.qml \ - Keyboard.qml \ - layouts/symbols.qml \ - layouts/numbers.qml \ - layouts/ar_AR.qml \ - layouts/en_GB.qml \ - layouts/fi_FI.qml \ - -load(qml_module) diff --git a/src/imports/virtualkeyboard/virtualkeyboard.pro b/src/imports/virtualkeyboard/virtualkeyboard.pro deleted file mode 100644 index bedd662..0000000 --- a/src/imports/virtualkeyboard/virtualkeyboard.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += platforminputcontext qmlmodule.pro -- cgit v1.2.3 From 5980f4bff613e109375d3d841b2891847011074d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 7 Jan 2014 13:44:16 +0100 Subject: List the strongest access point when ssid equal List only the strongest access point when sensing several access points within the same network. Change-Id: I58bf3083058f6e1c8a0c353b20d731672e64aefc Reviewed-by: Eirik Aavitsland --- src/imports/wifi/qwifinetworklist.cpp | 46 +++++++++++++++++++---------------- src/imports/wifi/qwifinetworklist.h | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/imports/wifi/qwifinetworklist.cpp b/src/imports/wifi/qwifinetworklist.cpp index e7fa92d..8ded5fd 100644 --- a/src/imports/wifi/qwifinetworklist.cpp +++ b/src/imports/wifi/qwifinetworklist.cpp @@ -14,7 +14,6 @@ QWifiNetworkList::QWifiNetworkList(QWifiManager *manager) { } - QHash QWifiNetworkList::roleNames() const { QHash names; @@ -27,8 +26,6 @@ QHash QWifiNetworkList::roleNames() const return names; } - - QVariant QWifiNetworkList::data(const QModelIndex &index, int role) const { QWifiNetwork *n = m_networks.at(index.row()); @@ -42,15 +39,15 @@ QVariant QWifiNetworkList::data(const QModelIndex &index, int role) const case ID_NETWORK: return QVariant::fromValue((QObject *) n); } - qDebug("QWifiNetworkList::data(), undefined role: %d\n", role); + qWarning("QWifiNetworkList::data(), undefined role: %d\n", role); return QVariant(); } -QWifiNetwork *QWifiNetworkList::networkForBSSID(const QByteArray &bssid, int *pos) +QWifiNetwork *QWifiNetworkList::networkForSSID(const QByteArray &ssid, int *pos) { for (int i=0; ibssid() == bssid) { + if (m_networks.at(i)->ssid() == ssid) { if (pos) *pos = i; return m_networks.at(i); @@ -59,37 +56,48 @@ QWifiNetwork *QWifiNetworkList::networkForBSSID(const QByteArray &bssid, int *po return 0; } - void QWifiNetworkList::parseScanResults(const QByteArray &results) { QList lines = results.split('\n'); - QSet bssids; + QSet sensibleNetworks; for (int i=1; i info = lines.at(i).split('\t'); if (info.size() < 5 || info.at(4).isEmpty() || info.at(0).isEmpty()) continue; - bssids.insert(info.at(0)); int pos = 0; - QWifiNetwork *existing = networkForBSSID(info.at(0), &pos); - if (!existing) { + if (!sensibleNetworks.contains(info.at(4))) + sensibleNetworks.insert(info.at(4)); + QWifiNetwork *existingNetwork = networkForSSID(info.at(4), &pos); + if (!existingNetwork) { QWifiNetwork *network = new QWifiNetwork(); network->setBssid(info.at(0)); network->setFlags(info.at(3)); + // signal strength is in dBm network->setSignalStrength(info.at(2).toInt()); network->setSsid(info.at(4)); beginInsertRows(QModelIndex(), m_networks.size(), m_networks.size()); m_networks << network; endInsertRows(); - } else { - existing->setSignalStrength(info.at(2).toInt()); - dataChanged(createIndex(pos, 0), createIndex(pos, 0)); + // ssids are the same, compare bssids.. + if (existingNetwork->bssid() == info.at(0)) { + // same access point, simply update the signal strength + existingNetwork->setSignalStrength(info.at(2).toInt()); + dataChanged(createIndex(pos, 0), createIndex(pos, 0)); + } else if (existingNetwork->signalStrength() < info.at(2).toInt()) { + // replace with a stronger access point within the same network + m_networks.at(pos)->setBssid(info.at(0)); + m_networks.at(pos)->setFlags(info.at(3)); + m_networks.at(pos)->setSignalStrength(info.at(2).toInt()); + m_networks.at(pos)->setSsid(info.at(4)); + dataChanged(createIndex(pos, 0), createIndex(pos, 0)); + } } } - - for (int i=0; ibssid())) { + // remove networks that have gone out of range + for (int i = 0; i < m_networks.size(); ++i) { + if (!sensibleNetworks.contains(m_networks.at(i)->ssid())) { beginRemoveRows(QModelIndex(), i, i); delete m_networks.takeAt(i); endRemoveRows(); @@ -97,10 +105,6 @@ void QWifiNetworkList::parseScanResults(const QByteArray &results) ++i; } } - -// for (int i=0; ibssid() << m_networks.at(i)->ssid() << m_networks.at(i)->flags() << m_networks.at(i)->signalStrength(); -// } } diff --git a/src/imports/wifi/qwifinetworklist.h b/src/imports/wifi/qwifinetworklist.h index f6e134c..d223bc9 100644 --- a/src/imports/wifi/qwifinetworklist.h +++ b/src/imports/wifi/qwifinetworklist.h @@ -18,7 +18,7 @@ public: void parseScanResults(const QByteArray &data); - QWifiNetwork *networkForBSSID(const QByteArray &bssid, int *pos); + QWifiNetwork *networkForSSID(const QByteArray &ssid, int *pos); int rowCount(const QModelIndex &) const { return m_networks.size(); } QVariant data(const QModelIndex &index, int role) const; -- cgit v1.2.3 From 95a00d27cda8b8bea27192f7ee9eb2b5ae6eb405 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 20 Jan 2014 15:34:28 +0100 Subject: Introducing QConnectivityDaemon This change enables ethernet support on embedded android and provides DHCP info for other processes. Now we can simply plugin an ethernet cable and start browsing a network, for this we use netd events - netd is a network manager daemon, it opens android's "reserved" unix domain socket on /dev/socket/netd and listens for connections and commands. QConnectivityDaemon listens for DHCP requests on android's "reserved" socket /dev/socket/qconnectivity which can be used by other processes to do dhcp requests on different network interfaces (wifi, bluetooth, etc.). QConnectivityDaemon uses line-oriented protocol and expects requests to be "\n" terminated. Change-Id: I6d52619d27685650a155141bf09191e5a56914df Reviewed-by: Eirik Aavitsland --- src/qconnectivity/main.cpp | 381 ++++++++++++++++++++++++++++++++++++ src/qconnectivity/qconnectivity.pro | 13 ++ src/src.pro | 2 +- 3 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 src/qconnectivity/main.cpp create mode 100644 src/qconnectivity/qconnectivity.pro (limited to 'src') diff --git a/src/qconnectivity/main.cpp b/src/qconnectivity/main.cpp new file mode 100644 index 0000000..a02658a --- /dev/null +++ b/src/qconnectivity/main.cpp @@ -0,0 +1,381 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of Qt Enterprise Embedded. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** the contact form at http://qt.digia.com/ +** +****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include + +// Code values come from android/system/netd/ResponseCode.h +static const int InterfaceChange = 600; + +static const char UNIQUE_HOSTNAME[] = "net.hostname"; + +static bool QT_CONNECTIVITY_DEBUG = !qgetenv("QT_CONNECTIVITY_DEBUG").isEmpty(); +static bool QT_USE_EXPIRED_LEASE = !qgetenv("QT_USE_EXPIRED_LEASE").isEmpty(); + +// sanity check a renewal time, lower value than +// this might indicate a badly configured DHCP server +static int MIN_RENEWAL_TIME_SECS = 300; // 5 min + +#define ETH_INTERFACE "eth0" + +// this function is defined in android/system/core/libnetutils/dhcp_utils.c +extern "C" { +int dhcp_do_request_renew(const char *ifname, + const char *ipaddr, + const char *gateway, + uint32_t *prefixLength, + const char *dns1, + const char *dns2, + const char *server, + uint32_t *lease, + const char *vendorInfo); +} + +class LeaseTimer; +class QConnectivityDaemon : public QObject +{ + Q_OBJECT +public: + QConnectivityDaemon(); + +protected: + void setHostnamePropery(const char *interface) const; + void sendCommand(const char *command) const; + void handleInterfaceChange(const QList &message); + bool startDhcp(bool renew, const char *interface); + void stopDhcp(const char *interface); + bool ethernetSupported() const; + +protected slots: + void handleNetdEvent(); + void handleRequest(); + void handleNewConnection(); + void sendReply(QLocalSocket *requester, const QByteArray &reply) const; + void updateLease(); + void handleError(QLocalSocket::LocalSocketError /*socketError*/) const; + +private: + friend class LeaseTimer; + QLocalSocket *m_netdSocket; + // currently used to listen for requests from Qt Wifi library, + // in future can be used also for Bluetooth and etc. + QLocalServer *m_serverSocket; + bool m_linkUp; + LeaseTimer *m_leaseTimer; +}; + +class LeaseTimer : public QTimer +{ + Q_OBJECT +public: + LeaseTimer(QConnectivityDaemon *daemon) : m_daemon(daemon) {} + + void setInterface(const QByteArray &interface) + { + if (m_ifc.isEmpty()) { + m_ifc = interface; + } else { + // for example when user switches from eth0 to wlan0, we + // stop DHCP on the previous interface + if (m_ifc != interface) { + m_daemon->stopDhcp(m_ifc.constData()); + m_ifc = interface; + } + } + } + + QByteArray interface() const { return m_ifc; } + +private: + QConnectivityDaemon *m_daemon; + QByteArray m_ifc; +}; + +QConnectivityDaemon::QConnectivityDaemon() + : m_netdSocket(0), m_serverSocket(0), m_linkUp(false), m_leaseTimer(0) +{ + if (QT_CONNECTIVITY_DEBUG) qDebug() << "starting QConnectivityDaemon..."; + + m_leaseTimer = new LeaseTimer(this); + m_leaseTimer->setSingleShot(true); + connect(m_leaseTimer, SIGNAL(timeout()), this, SLOT(updateLease())); + + if (ethernetSupported()) { + int netdFd = socket_local_client("netd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + if (netdFd != -1) { + m_netdSocket = new QLocalSocket(this); + m_netdSocket->setSocketDescriptor(netdFd); + connect(m_netdSocket, SIGNAL(readyRead()), this, SLOT(handleNetdEvent())); + connect(m_netdSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), + this, SLOT(handleError(QLocalSocket::LocalSocketError))); + // down-up sequence generates "linkstate" events, which we can use to setup + // our daemon on initial startup or on daemon restarts + stopDhcp(ETH_INTERFACE); + sendCommand("0 interface setcfg " ETH_INTERFACE " down"); + sendCommand("0 interface setcfg " ETH_INTERFACE " up"); + } else { + qWarning() << "QConnectivityDaemon: failed to connect to netd socket"; + } + } + + int serverFd = socket_local_server("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + if (serverFd != -1) { + m_serverSocket = new QLocalServer(this); + if (m_serverSocket->listen(serverFd)) + connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); + else + qWarning() << "QConnectivityDaemon: not able to listen on the server socket..."; + } else { + qWarning() << "QConnectivityDaemon: failed to open qconnectivity server socket"; + } +} + +void QConnectivityDaemon::setHostnamePropery(const char *interface) const +{ + // Setup our unique device name (used as a host name argument for dhcpcd call in + // dhcp_do_request). On Android device name is set in ConnectivityService.java and + // the id is generated with the help of SecureRandom.java class. We will use Mac + // address as a unique hostname. + char prop_value[PROPERTY_VALUE_MAX]; + property_get(UNIQUE_HOSTNAME, prop_value, NULL); + if ((prop_value[0] == '\0')) { + char hwaddr[6]; + memset(hwaddr, 0, sizeof(hwaddr)); + ifc_init(); + if (ifc_get_hwaddr(interface, (void *)hwaddr) == 0) { + QByteArray macAddress(hwaddr, sizeof(hwaddr)); + property_set(UNIQUE_HOSTNAME, macAddress.toHex().prepend("b2qt-").constData()); + } else { + qWarning() << "QConnectivityDaemon: failed to get MAC address"; + } + ifc_close(); + } +} + +void QConnectivityDaemon::sendCommand(const char *command) const +{ + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: sending command - " << command; + // netd expects "\0" terminated commands... + m_netdSocket->write(command, qstrlen(command) + 1); + m_netdSocket->flush(); +} + +void QConnectivityDaemon::handleInterfaceChange(const QList &message) +{ + // Format: "Code Iface linkstate " + if (message.size() < 5) { + qWarning() << "QConnectivityDaemon: broken command"; + return; + } + if (message.at(2) == "linkstate" && message.at(3) == ETH_INTERFACE) { + if (message.at(4) == "up") { + // ethernet cable has been plugged in + if (!m_linkUp) { + m_linkUp = true; + startDhcp(false, ETH_INTERFACE); + } + } else { + // .. plugged out + if (m_linkUp) { + m_linkUp = false; + stopDhcp(ETH_INTERFACE); + } + } + } +} + +bool QConnectivityDaemon::startDhcp(bool renew, const char *interface) +{ + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: startDhcp [ renew" + << renew << "] " << "interface: " << interface; + setHostnamePropery(interface); + + int result = 0; + char ipaddr[PROPERTY_VALUE_MAX]; + quint32 prefixLength = 0; + char gateway[PROPERTY_VALUE_MAX]; + char dns1[PROPERTY_VALUE_MAX]; + char dns2[PROPERTY_VALUE_MAX]; + char server[PROPERTY_VALUE_MAX]; + quint32 lease = 0; + char vendorInfo[PROPERTY_VALUE_MAX]; + + if (renew) { + result = dhcp_do_request_renew(interface, ipaddr, gateway, &prefixLength, + dns1, dns2, server, &lease, vendorInfo); + } else { + // stop any existing DHCP daemon before starting new + dhcp_stop(interface); + // this uses "ctl.start.*" mechanism to start "dhcpcd" daemon as defined by + // the device init.rc. Android starts dhcpcd with argument -B which means that + // we are responsible for renewing a lease before it expires + ifc_clear_addresses(interface); + result = dhcp_do_request(interface, ipaddr, gateway, &prefixLength, + dns1, dns2, server, &lease, vendorInfo); + } + + bool success = (result == 0) ? true : false; + if (success) { + if (QT_CONNECTIVITY_DEBUG) qDebug() << "\nipaddr: " << ipaddr << "\nprefixLength: " << prefixLength + << "\ngateway: " << gateway << "\ndns1: " << dns1 << "\ndns2: " << dns2; + + if (!renew) { + in_addr _ipaddr, _gateway, _dns1, _dns2; + inet_aton(ipaddr, &_ipaddr); + inet_aton(gateway, &_gateway); + inet_aton(dns1, &_dns1); + inet_aton(dns2, &_dns2); + + ifc_configure(interface, _ipaddr.s_addr, prefixLength, + _gateway.s_addr, _dns1.s_addr, _dns2.s_addr); + + property_set("net.dns1", dns1); + property_set("net.dns2", dns2); + } + + if (lease >= 0) { + if (lease < MIN_RENEWAL_TIME_SECS) { + qWarning() << "QConnectivityDaemon: DHCP server proposes lease time " << lease + << "seconds. We will use" << MIN_RENEWAL_TIME_SECS << " seconds instead."; + lease = MIN_RENEWAL_TIME_SECS; + } + // update lease when 48% of lease time has elapsed + if (m_leaseTimer->isActive()) + m_leaseTimer->stop(); + m_leaseTimer->setInterface(interface); + m_leaseTimer->start(lease * 480); + } + } else { + qWarning("QConnectivityDaemon: DHCP request failed - %s", dhcp_get_errmsg()); + if (renew) { + // If it fails to renew a lease (faulty server, proxy?) we re-connect. + // Some users might prefer to use expired lease over having interrupt + // in network connection + if (QT_USE_EXPIRED_LEASE) + return true; + qDebug() << "QConnectivityDaemon: attempting to re-connect..."; + stopDhcp(interface); + startDhcp(false, interface); + } + } + return success; +} + +void QConnectivityDaemon::stopDhcp(const char *interface) +{ + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: stopDhcp: " << interface; + ifc_clear_addresses(interface); + dhcp_stop(interface); + if (m_leaseTimer->isActive()) + m_leaseTimer->stop(); +} + +bool QConnectivityDaemon::ethernetSupported() const +{ + // standard linux kernel path + return QDir().exists("/sys/class/net/" ETH_INTERFACE); +} + +void QConnectivityDaemon::handleNetdEvent() +{ + QByteArray data = m_netdSocket->readAll(); + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: netd event: " << data; + if (data.endsWith('\0')) + data.chop(1); + + QList message = data.split(' '); + int code = message.at(0).toInt(); + switch (code) { + case InterfaceChange: + handleInterfaceChange(message); + break; + default: + break; + } +} + +void QConnectivityDaemon::handleRequest() +{ + // Format: "interface " + QLocalSocket *requester = qobject_cast(QObject::sender()); + if (requester->canReadLine()) { + QByteArray request = requester->readLine(requester->bytesAvailable()); + + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: received a request: " << request; + QList cmd = request.split(' '); + if (cmd.size() < 2) + return; + + QByteArray interface = cmd.at(0); + if (cmd.at(1) == "connect") { + QByteArray reply; + if (startDhcp(false, interface.constData())) + reply = "success"; + else + reply = "failed"; + sendReply(requester, reply); + } else { + stopDhcp(interface.constData()); + } + } +} + +void QConnectivityDaemon::handleNewConnection() +{ + QLocalSocket *requester = m_serverSocket->nextPendingConnection(); + connect(requester, SIGNAL(readyRead()), this, SLOT(handleRequest())); + connect(requester, SIGNAL(disconnected()), requester, SLOT(deleteLater())); +} + +void QConnectivityDaemon::sendReply(QLocalSocket *requester, const QByteArray &reply) const +{ + QByteArray r = reply.left(reply.size()); + r.append("\n"); + requester->write(r.constData(), r.length()); + requester->flush(); + requester->disconnectFromServer(); +} + +void QConnectivityDaemon::updateLease() +{ + if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: updating lease"; + startDhcp(true, m_leaseTimer->interface().constData()); +} + +void QConnectivityDaemon::handleError(QLocalSocket::LocalSocketError /*socketError*/) const +{ + qWarning() << "QConnectivityDaemon: QLocalSocket::LocalSocketError"; +} + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + QConnectivityDaemon connectivityDaemon; + + return a.exec(); +} + +#include "main.moc" diff --git a/src/qconnectivity/qconnectivity.pro b/src/qconnectivity/qconnectivity.pro new file mode 100644 index 0000000..df3b366 --- /dev/null +++ b/src/qconnectivity/qconnectivity.pro @@ -0,0 +1,13 @@ +QT += core network +QT -= gui + +TARGET = qconnectivity +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +LIBS += -lcutils -lnetutils +SOURCES += main.cpp + +load(qt_tool) diff --git a/src/src.pro b/src/src.pro index 3670d42..fe2f463 100644 --- a/src/src.pro +++ b/src/src.pro @@ -7,4 +7,4 @@ SUBDIRS += \ plugins \ -android: SUBDIRS += doppelganger qt_hw_init +android: SUBDIRS += doppelganger qt_hw_init qconnectivity -- cgit v1.2.3 From 696510db8f43427a9bb6ff249f688851f531cd12 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 2 Jan 2014 15:57:14 +0100 Subject: Fix dhcp issues and improve public API - Use qconnectivity daemon for dhcp requests. Since dhcp requests are executed in other process we don't block gui thread for this lengthy operation. - Why not to use "do_dhcp_request" - it is a legacy implementation of a dhcp client and is not used anywhere in the Android source code itself. It appears that do_dhcp_request was not removed from the libhardware_legacy to keep compatibility for others, whose code might still depend on it. - Differnet changes to the internal implementation and the public API. - Add 'Interface' singleton type, installing a singleton type allows developers to provide arbitrary functionality to a client without requiring individual instances of the type to be instantiated by the client. We use this to determine if Android has wifi interface. Change-Id: I836f3a2a587b1ebf9f670ed08b10fe3483504b9e Reviewed-by: Eirik Aavitsland --- src/imports/imports.pro | 1 + src/imports/wifi/pluginmain.cpp | 35 +++- src/imports/wifi/qwifimanager.cpp | 328 ++++++++++++++++++++------------------ src/imports/wifi/qwifimanager.h | 65 ++++---- src/imports/wifi/qwifimodule.pro | 21 --- src/imports/wifi/wifi.pro | 21 +++ 6 files changed, 266 insertions(+), 205 deletions(-) delete mode 100644 src/imports/wifi/qwifimodule.pro create mode 100644 src/imports/wifi/wifi.pro (limited to 'src') diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 92eddcd..0a5ccf5 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs SUBDIRS = utils +android:SUBDIRS += wifi diff --git a/src/imports/wifi/pluginmain.cpp b/src/imports/wifi/pluginmain.cpp index 58aa590..0eeff78 100644 --- a/src/imports/wifi/pluginmain.cpp +++ b/src/imports/wifi/pluginmain.cpp @@ -21,6 +21,36 @@ #include #include +#include +#include + +class QWifiGlobal : public QObject +{ + Q_OBJECT +public: + explicit QWifiGlobal(QObject *parent = 0) + : QObject(parent) {} + ~QWifiGlobal() {} + + Q_INVOKABLE bool wifiSupported() const + { + char interface[PROPERTY_VALUE_MAX]; + property_get("wifi.interface", interface, NULL); + // standard linux kernel path + QByteArray path; + path.append("/sys/class/net/").append(interface); + bool interfaceFound = QDir().exists(path.constData()); + if (!interfaceFound) + qWarning() << "QWifiGlobal: could not find wifi interface in " << path; + return interfaceFound; + } +}; + +static QObject *global_object_wifi(QQmlEngine *, QJSEngine *) +{ + return new QWifiGlobal; +} + class QWifiPlugin : public QQmlExtensionPlugin { Q_OBJECT @@ -31,11 +61,10 @@ public: { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.wifi")); - qmlRegisterType(uri, 0, 1, "QWifiManager"); + qmlRegisterType(uri, 0, 1, "WifiManager"); qmlRegisterType(); + qmlRegisterSingletonType(uri, 0, 1, "Interface", global_object_wifi); } }; #include "pluginmain.moc" - - diff --git a/src/imports/wifi/qwifimanager.cpp b/src/imports/wifi/qwifimanager.cpp index b2b9363..e5ed67e 100644 --- a/src/imports/wifi/qwifimanager.cpp +++ b/src/imports/wifi/qwifimanager.cpp @@ -21,54 +21,48 @@ #include #include -#include +#include #include -#define WLAN_INTERFACE "wlan0" +static const char SUPPLICANT_SVC[] = "init.svc.wpa_supplicant"; +static const char WIFI_INTERFACE[] = "wifi.interface"; +static const char QT_WIFI_BACKEND[] = "qt.wifi"; static bool QT_WIFI_DEBUG = !qgetenv("QT_WIFI_DEBUG").isEmpty(); const QEvent::Type WIFI_SCAN_RESULTS = (QEvent::Type) (QEvent::User + 2001); const QEvent::Type WIFI_CONNECTED = (QEvent::Type) (QEvent::User + 2002); -static int q_wifi_start_supplicant() +/* + * This function is borrowed from /system/core/libnetutils/dhcp_utils.c + * + * Wait for a system property to be assigned a specified value. + * If desired_value is NULL, then just wait for the property to + * be created with any value. maxwait is the maximum amount of + * time in seconds to wait before giving up. + */ +static const int NAP_TIME = 200; // wait for 200ms at a time when polling for property values +static int wait_for_property(const char *name, const char *desired_value, int maxwait) { -#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) - return wifi_start_supplicant(0); -#else - return wifi_start_supplicant(); -#endif -} - -static int q_wifi_connect_to_supplicant() -{ -#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) - return wifi_connect_to_supplicant(WLAN_INTERFACE); -#else - return wifi_connect_to_supplicant(); -#endif -} - -static int q_wifi_command(const char *command, char *reply, size_t *reply_len) -{ -#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) - return wifi_command(WLAN_INTERFACE, command, reply, reply_len); -#else - return wifi_command(command, reply, reply_len); -#endif + char value[PROPERTY_VALUE_MAX] = {'\0'}; + int maxnaps = (maxwait * 1000) / NAP_TIME; -} + if (maxnaps < 1) { + maxnaps = 1; + } -static int q_wifi_wait_for_event(char *buf, size_t len) -{ -#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 1) - return wifi_wait_for_event(WLAN_INTERFACE, buf, len); -#else - return wifi_wait_for_event(buf, len); -#endif + while (maxnaps-- > 0) { + usleep(NAP_TIME * 1000); + if (property_get(name, value, NULL)) { + if (desired_value == NULL || + strcmp(value, desired_value) == 0) { + return 0; + } + } + } + return -1; /* failure */ } - class QWifiManagerEvent : public QEvent { public: @@ -84,13 +78,12 @@ private: QByteArray m_data; }; - - class QWifiManagerEventThread : public QThread { public: - QWifiManagerEventThread(QWifiManager *manager) + QWifiManagerEventThread(QWifiManager *manager, const QByteArray &interface) : m_manager(manager) + , m_if(interface) { } @@ -99,7 +92,9 @@ public: if (QT_WIFI_DEBUG) qDebug("EventReceiver thread is running"); char buffer[2048]; while (1) { - int size = q_wifi_wait_for_event(buffer, sizeof(buffer) - 1); + if (m_manager->exiting()) + return; + int size = wifi_wait_for_event(m_if.constData(), buffer, sizeof(buffer) - 1); if (size > 0) { buffer[size] = 0; @@ -112,34 +107,149 @@ public: } else if (strstr(event, "CONNECTED")) { QWifiManagerEvent *e = new QWifiManagerEvent(WIFI_CONNECTED); QCoreApplication::postEvent(m_manager, e); + } else if (strstr(event, "TERMINATING")) { + // stop monitoring for events when supplicant is terminating + return; } } } } QWifiManager *m_manager; + QByteArray m_if; }; - - QWifiManager::QWifiManager() : m_networks(this) , m_eventThread(0) , m_scanTimer(0) - , m_internalState(IS_Uninitialized) , m_scanning(false) + , m_daemonClientSocket(0) + , m_exiting(false) +{ + char interface[PROPERTY_VALUE_MAX]; + property_get(WIFI_INTERFACE, interface, NULL); + m_interface = interface; + if (QT_WIFI_DEBUG) qDebug("QWifiManager: using wifi interface: %s", m_interface.constData()); + m_eventThread = new QWifiManagerEventThread(this, m_interface); + + m_daemonClientSocket = new QLocalSocket; + int qconnFd = socket_local_client("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + if (qconnFd != -1) { + m_daemonClientSocket->setSocketDescriptor(qconnFd); + QObject::connect(m_daemonClientSocket, SIGNAL(readyRead()), this, SLOT(handleDhcpReply())); + QObject::connect(m_daemonClientSocket, SIGNAL(connected()), this, SLOT(connectedToDaemon())); + } else { + qWarning() << "QWifiManager: failed to connect to qconnectivity socket"; + } + + // check if backend has already been initialized + char backend_status[PROPERTY_VALUE_MAX]; + if (property_get(QT_WIFI_BACKEND, backend_status, NULL) + && strcmp(backend_status, "running") == 0) { + // let it re-connect, in most cases this will see that everything is working properly + // and will do nothing. Special case is when process has crashed or was killed by a system + // signal in previous execution, which results in broken connection to a supplicant, + // connectToBackend will fix it.. + connectToBackend(); + } else { + // same here, cleans up the state + disconnectFromBackend(); + } +} + +QWifiManager::~QWifiManager() +{ + m_exiting = true; + m_eventThread->wait(); +} + +void QWifiManager::handleDhcpReply() { + if (m_daemonClientSocket->canReadLine()) { + QByteArray receivedMessage; + receivedMessage = m_daemonClientSocket->readLine(m_daemonClientSocket->bytesAvailable()); + if (QT_WIFI_DEBUG) qDebug() << "QWifiManager: reply from qconnectivity: " << receivedMessage; + if (receivedMessage == "success") { + m_state = Connected; + emit networkStateChanged(); + emit connectedSSIDChanged(m_connectedSSID); + // Store settings of a working wifi connection + call("SAVE_CONFIG"); + } else if (receivedMessage == "failed") { + m_state = DhcpRequestFailed; + emit networkStateChanged(); + } else { + qWarning() << "QWifiManager: unknown message: " << receivedMessage; + } + } } +void QWifiManager::sendDhcpRequest(const QByteArray &request) +{ + if (QT_WIFI_DEBUG) qDebug() << "QWifiManager: sending request - " << request; + m_request = request; + m_request.append("\n"); + m_daemonClientSocket->abort(); + // path where android stores "reserved" sockets + m_daemonClientSocket->connectToServer(ANDROID_SOCKET_DIR "/qconnectivity"); +} +void QWifiManager::connectedToDaemon() +{ + m_daemonClientSocket->write(m_request.constData(), m_request.length()); + m_daemonClientSocket->flush(); +} void QWifiManager::start() { - if (QT_WIFI_DEBUG) qDebug("QWifiManager: start"); + if (QT_WIFI_DEBUG) qDebug("QWifiManager: connecting to the backend"); connectToBackend(); } +void QWifiManager::stop() +{ + if (QT_WIFI_DEBUG) qDebug("QWifiManager: shutting down"); + disconnectFromBackend(); +} + +void QWifiManager::connectToBackend() +{ + if (!(is_wifi_driver_loaded() || wifi_load_driver() == 0)) { + qWarning("QWifiManager: failed to load a driver"); + return; + } + if (wifi_start_supplicant(0) != 0) { + qWarning("QWifiManager: failed to start a supplicant"); + return; + } + if (wait_for_property(SUPPLICANT_SVC, "running", 5) < 0) { + qWarning("QWifiManager: Timed out waiting for supplicant to start"); + return; + } + if (wifi_connect_to_supplicant(m_interface.constData()) == 0) { + m_backendReady = true; + emit backendReadyChanged(); + property_set(QT_WIFI_BACKEND, "running"); + } else { + qWarning("QWifiManager: failed to connect to a supplicant"); + return; + } + if (QT_WIFI_DEBUG) qDebug("QWifiManager: started successfully"); + m_eventThread->start(); + handleConnected(); +} +void QWifiManager::disconnectFromBackend() +{ + m_eventThread->quit(); + if (wifi_stop_supplicant(0) < 0) + qWarning("QWifiManager: failed to stop supplicant"); + wifi_close_supplicant_connection(m_interface.constData()); + property_set(QT_WIFI_BACKEND, "stopped"); + m_backendReady = false; + emit backendReadyChanged(); +} void QWifiManager::setScanning(bool scanning) { @@ -147,70 +257,23 @@ void QWifiManager::setScanning(bool scanning) return; m_scanning = scanning; - emit scanningChanged(scanning); + emit scanningChanged(m_scanning); if (m_scanning) { if (QT_WIFI_DEBUG) qDebug("QWifiManager: scanning"); call("SCAN"); - m_scanTimer = startTimer(5000); + m_scanTimer = startTimer(5000); // ### todo - this could be a qml property } else { if (QT_WIFI_DEBUG) qDebug("QWifiManager: stop scanning"); killTimer(m_scanTimer); } } - - -QByteArray int_to_ip(int i) { - QByteArray ip; - - ip.append(QByteArray::number(i & 0x000000ff)); - ip.append('.'); - ip.append(QByteArray::number((i & 0x0000ff00) >> 8)); - ip.append('.'); - ip.append(QByteArray::number((i & 0x00ff0000) >> 16)); - ip.append('.'); - ip.append(QByteArray::number(i >> 24)); - - return ip; -} - - -void QWifiManager::connectToBackend() -{ - if (m_internalState == IS_Uninitialized) - m_internalState = IS_LoadDriver; - - if (m_internalState == IS_LoadDriver && (is_wifi_driver_loaded() || wifi_load_driver() >= 0)) - m_internalState = IS_StartBackend; - - if (m_internalState == IS_StartBackend && q_wifi_start_supplicant() >= 0) { - m_internalState = IS_ConnectToBackend; - sleep(3); //### - } - - if (m_internalState == IS_ConnectToBackend && q_wifi_connect_to_supplicant() >= 0) - m_internalState = IS_UpAndRunning; - - if (m_internalState == IS_UpAndRunning) { - qDebug("QWifiManager: started successfully"); - - emit readyChanged(true); - m_eventThread = new QWifiManagerEventThread(this); - m_eventThread->start(); - - handleConnected(); - } else { - qWarning("QWifiManager: stuck at internal state level: %d", m_internalState); - } -} - - -QByteArray QWifiManager::call(const char *command) +QByteArray QWifiManager::call(const char *command) const { char data[2048]; size_t len = sizeof(data) - 1; // -1: room to add a 0-terminator - if (q_wifi_command(command, data, &len) < 0) { + if (wifi_command(m_interface.constData(), command, data, &len) < 0) { qWarning("QWifiManager: call failed: %s", command); return QByteArray(); } @@ -221,13 +284,11 @@ QByteArray QWifiManager::call(const char *command) return result; } - -bool QWifiManager::checkedCall(const char *command) +bool QWifiManager::checkedCall(const char *command) const { return call(command).trimmed().toUpper() == "OK"; } - bool QWifiManager::event(QEvent *e) { switch ((int) e->type()) { @@ -261,9 +322,10 @@ void QWifiManager::connect(QWifiNetwork *network, const QString &passphrase) if (!m_connectedSSID.isEmpty()) { m_connectedSSID.clear(); emit connectedSSIDChanged(m_connectedSSID); - //also possibly change online state } + m_state = ObtainingIPAddress; + emit networkStateChanged(); bool networkKnown = false; QByteArray id; QByteArray listResult = call("LIST_NETWORKS"); @@ -295,7 +357,7 @@ void QWifiManager::connect(QWifiNetwork *network, const QString &passphrase) QByteArray key_mgmt; if (network->supportsWPA() || network->supportsWPA2()) { ok = ok && checkedCall(setNetworkCommand + QByteArray(" psk ") + '"' + passphrase.toLatin1() + '"'); - key_mgmt = "WPA_PSK"; + key_mgmt = "WPA-PSK"; } else if (network->supportsWEP()) { ok = ok && checkedCall(setNetworkCommand + QByteArray(" wep_key0 ") + '"' + passphrase.toLatin1() + '"'); ok = ok && checkedCall(setNetworkCommand + QByteArray(" auth_alg OPEN SHARED")); @@ -317,19 +379,16 @@ void QWifiManager::connect(QWifiNetwork *network, const QString &passphrase) call("RECONNECT"); } - -class ProcessRunner : public QThread { -public: - void run() { - QStringList args; - args << QStringLiteral("-A") - << QStringLiteral("-h") << QStringLiteral("KAON") //### hardcoded hostname, for testing - << QStringLiteral("wlan0"); - QProcess::execute(QStringLiteral("dhcpcd"), args); - deleteLater(); - } -}; - +void QWifiManager::disconnect() +{ + call("DISCONNECT"); + QByteArray req = m_interface; + sendDhcpRequest(req.append(" disconnect")); + m_state = Disconnected; + m_connectedSSID.clear(); + emit networkStateChanged(); + emit connectedSSIDChanged(m_connectedSSID); +} void QWifiManager::handleConnected() { @@ -344,49 +403,16 @@ void QWifiManager::handleConnected() if (connectedNetwork.isEmpty()) { if (QT_WIFI_DEBUG) qDebug("QWifiManager::handleConnected: not connected to a network..."); - m_online = false; - onlineChanged(m_online); + m_state = Disconnected; + emit networkStateChanged(); return; - } else { - if (QT_WIFI_DEBUG) qDebug("QWifiManager::handleConnected: current is %s", connectedNetwork.constData()); } + if (QT_WIFI_DEBUG) qDebug("QWifiManager::handleConnected: current is %s", connectedNetwork.constData()); + QList info = connectedNetwork.split('\t'); m_connectedSSID = info.at(1); - emit connectedSSIDChanged(m_connectedSSID); - - if (QT_WIFI_DEBUG) qDebug("QWifiManager::handleConnected: starting dhcpcd..."); - QThread *t = new ProcessRunner(); - t->start(); - - int ipaddr, gateway, mask, dns1, dns2, server, lease; - if (do_dhcp_request(&ipaddr, &gateway, &mask, &dns1, &dns2, &server, &lease) == 0) { - if (QT_WIFI_DEBUG) { - printf("ip ........: %s\n" - "gateway ...: %s\n" - "mask ......: %s\n" - "dns1 ......: %s\n" - "dns2 ......: %s\n" - "lease .....: %d\n", - int_to_ip(ipaddr).constData(), - int_to_ip(gateway).constData(), - int_to_ip(mask).constData(), - int_to_ip(dns1).constData(), - int_to_ip(dns2).constData(), - lease); - } - - // Updating dns values.. - property_set("net.dns1", int_to_ip(dns1).constData()); - property_set("net.dns2", int_to_ip(dns2).constData()); - - // Store (possibly updated) settings - call("SAVE_CONFIG"); - - m_online = true; - onlineChanged(m_online); - } else { - if (QT_WIFI_DEBUG) qDebug("QWifiManager::handleConnected: dhcp request failed..."); - } + QByteArray req = m_interface; + sendDhcpRequest(req.append(" connect")); } diff --git a/src/imports/wifi/qwifimanager.h b/src/imports/wifi/qwifimanager.h index 59f2b44..85384cc 100644 --- a/src/imports/wifi/qwifimanager.h +++ b/src/imports/wifi/qwifimanager.h @@ -21,6 +21,9 @@ #include #include +#include + +#include #include "qwifinetworklist.h" @@ -29,71 +32,73 @@ class QWifiManagerEventThread; class QWifiManager : public QObject { Q_OBJECT - - Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) - Q_PROPERTY(bool online READ isOnline NOTIFY onlineChanged) + Q_ENUMS(NetworkState) + Q_PROPERTY(NetworkState networkState READ networkState NOTIFY networkStateChanged) + Q_PROPERTY(bool backendReady READ isbackendReady NOTIFY backendReadyChanged) Q_PROPERTY(bool scanning READ scanning WRITE setScanning NOTIFY scanningChanged) - Q_PROPERTY(QString connectedSSID READ connectedSSID NOTIFY connectedSSIDChanged) Q_PROPERTY(QWifiNetworkList *networks READ networks CONSTANT) public: - enum InternalState { - IS_Uninitialized, - IS_LoadDriver, - IS_StartBackend, - IS_ConnectToBackend, - IS_UpAndRunning + enum NetworkState { + Disconnected, + ObtainingIPAddress, + DhcpRequestFailed, + Connected }; QWifiManager(); + ~QWifiManager(); QWifiNetworkList *networks() { return &m_networks; } - QString connectedSSID() const { return m_connectedSSID; } - bool scanning() const { return m_scanning; } void setScanning(bool scanning); - - bool isReady() const { return m_internalState == IS_UpAndRunning; } - bool isOnline() const { return m_online; } - + NetworkState networkState() const { return m_state; } + bool isbackendReady() const { return m_backendReady; } + bool exiting() const { return m_exiting; } public slots: void start(); - + void stop(); void connect(QWifiNetwork *network, const QString &passphrase); + void disconnect(); signals: void scanningChanged(bool arg); - void readyChanged(bool ready); - void onlineChanged(bool online); + void networkStateChanged(); + void backendReadyChanged(); void connectedSSIDChanged(const QString &); protected: bool event(QEvent *); + void sendDhcpRequest(const QByteArray &request); + void handleConnected(); + void connectToBackend(); + void disconnectFromBackend(); + QByteArray call(const char *command) const; + bool checkedCall(const char *command) const; + +protected slots: + void connectedToDaemon(); + void handleDhcpReply(); private: friend class QWifiManagerEventThread; - void handleConnected(); - void parseScanResults(); - void connectToBackend(); - QByteArray call(const char *command); - bool checkedCall(const char *command); - QString m_connectedSSID; QWifiNetworkList m_networks; - QWifiManagerEventThread *m_eventThread; int m_scanTimer; - - InternalState m_internalState; - bool m_scanning; - bool m_online; + bool m_backendReady; + QByteArray m_interface; + NetworkState m_state; + QLocalSocket *m_daemonClientSocket; + QByteArray m_request; + bool m_exiting; }; #endif // QWIFIMANAGER_H diff --git a/src/imports/wifi/qwifimodule.pro b/src/imports/wifi/qwifimodule.pro deleted file mode 100644 index 449617f..0000000 --- a/src/imports/wifi/qwifimodule.pro +++ /dev/null @@ -1,21 +0,0 @@ -CXX_MODULE = qml -QT += qml quick -TARGET = qwifimodule -TARGETPATH = Qt/labs/wifi -IMPORT_VERSION = 0.1 - -SOURCES += \ - pluginmain.cpp \ - qwifimanager.cpp \ - qwifinetwork.cpp \ - qwifinetworklist.cpp - -HEADERS += \ - qwifimanager.h \ - qwifinetwork.h \ - qwifinetworklist.h - -LIBS += -lhardware_legacy -lcutils - -load(qml_plugin) - diff --git a/src/imports/wifi/wifi.pro b/src/imports/wifi/wifi.pro new file mode 100644 index 0000000..0231479 --- /dev/null +++ b/src/imports/wifi/wifi.pro @@ -0,0 +1,21 @@ +CXX_MODULE = qml +QT += qml quick network +TARGET = qwifimodule +TARGETPATH = Qt/labs/wifi +IMPORT_VERSION = 0.1 + +SOURCES += \ + pluginmain.cpp \ + qwifimanager.cpp \ + qwifinetwork.cpp \ + qwifinetworklist.cpp + +HEADERS += \ + qwifimanager.h \ + qwifinetwork.h \ + qwifinetworklist.h + +LIBS += -lhardware_legacy -lcutils + +load(qml_plugin) + -- cgit v1.2.3 From 5055a8b531cee74ccf3bd4b82d7024f93e5f7d28 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 28 Jan 2014 11:45:54 +0100 Subject: Disable building of wifi library Change-Id: I3f8c2183f9bb0a620bad8128bdceda1bcb00ebd4 Reviewed-by: Eirik Aavitsland --- src/imports/imports.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 0a5ccf5..6284883 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = utils -android:SUBDIRS += wifi +#android:SUBDIRS += wifi -- cgit v1.2.3 From 6873ff8924ff9adcb065bddfd772eb71054b5b73 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 21 Jan 2014 10:37:56 +0100 Subject: Doc: Bump B2Qt version in the docs to 2.0.0 Set the b2qt version in the docs to 2.0.0. Also add dependencies to other doc modules, which may be useful in the future. Change-Id: I2034c893a3cce7d19c4a7198a34ebfc532aecddb Reviewed-by: Eirik Aavitsland --- src/doc/config/b2qt.qdocconf | 7 +++++-- src/doc/src/b2qt.qdoc | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/doc/config/b2qt.qdocconf b/src/doc/config/b2qt.qdocconf index 830d44b..7c97275 100644 --- a/src/doc/config/b2qt.qdocconf +++ b/src/doc/config/b2qt.qdocconf @@ -6,17 +6,20 @@ sourceencoding = UTF-8 project = QtEnterpriseEmbedded description = Qt Enterprise Embedded Documentation -version = 1.0.0 +version = 2.0.0 sourcedirs = ../src imagedirs += ../images sources.fileextensions = "*.qdoc" +indexes = $QT_INSTALL_DOCS/qtquick/qtquick.index \ + $QT_INSTALL_DOCS/emulator/emulator.index + qhp.projects = B2Qt qhp.B2Qt.file = b2qt.qhp -qhp.B2Qt.namespace = com.digia.b2qt.100 +qhp.B2Qt.namespace = com.digia.b2qt.200 qhp.B2Qt.virtualFolder = b2qt qhp.B2Qt.indexTitle = Qt Enterprise Embedded Documentation qhp.B2Qt.indexRoot = diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index e7ef357..34ae33d 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -335,9 +335,9 @@ \code cd - sudo ./Tools/b2qt/fastboot flash boot Boot2Qt-1.0/nexus7-eAndroid/images/boot.img - sudo ./Tools/b2qt/fastboot flash system Boot2Qt-1.0/nexus7-eAndroid/images/system.img - sudo ./Tools/b2qt/fastboot flash userdata Boot2Qt-1.0/nexus7-eAndroid/images/data.img + sudo ./Tools/b2qt/fastboot flash boot Boot2Qt-2.x/nexus7-eAndroid/images/boot.img + sudo ./Tools/b2qt/fastboot flash system Boot2Qt-2.x/nexus7-eAndroid/images/system.img + sudo ./Tools/b2qt/fastboot flash userdata Boot2Qt-2.x/nexus7-eAndroid/images/data.img \endcode \li Once the flashing is completed successfully, reboot the device: @@ -359,7 +359,7 @@ {https://developers.google.com/android/nexus/drivers#grouperjdq39} \code cd - ./Boot2Qt-1.0/nexus7-eAndroid/images/download.sh + ./Boot2Qt-2.x/nexus7-eAndroid/images/download.sh \endcode \note Only the version "Android 4.2.2 (JDQ39 to JDQ39E)" works with the @@ -372,7 +372,7 @@ Also check that the device is \e{not} in fastboot mode. \li Run the driver extractors: \code - cd Boot2Qt-1.0/nexus7-eAndroid/images/drivers + cd Boot2Qt-2.x/nexus7-eAndroid/images/drivers ./extract-nvidia-grouper.sh ./extract-asus-grouper.sh ./extract-invensense-grouper.sh @@ -386,7 +386,7 @@ \endcode \li Deploy the drivers to your device: \code - ./Boot2Qt-1.0/nexus7-eAndroid/images/deploy.sh + ./Boot2Qt-2.x/nexus7-eAndroid/images/deploy.sh \endcode \endlist @@ -440,12 +440,12 @@ \li \b{\B2QA} \code cd - sudo dd if=Boot2Qt-1.0/beagleboard-eAndroid/images/sdcard.img of=/dev/ bs=1M + sudo dd if=Boot2Qt-2.x/beagleboard-eAndroid/images/sdcard.img of=/dev/ bs=1M \endcode \li \b{\B2QL} \code cd - sudo Boot2Qt-1.0/beagleboard-eLinux/images/deploy.sh /dev/ + sudo Boot2Qt-2.x/beagleboard-eLinux/images/deploy.sh /dev/ \endcode \endlist @@ -528,12 +528,12 @@ \li \b{\B2QA} \code cd - Boot2Qt-1.0/iMX6-eAndroid/images/deploy.sh /dev/ + Boot2Qt-2.x/iMX6-eAndroid/images/deploy.sh /dev/ \endcode \li \b{\B2QL} \code cd - Boot2Qt-1.0/iMX6-eLinux/images/deploy.sh /dev/ + Boot2Qt-2.x/iMX6-eLinux/images/deploy.sh /dev/ \endcode \endlist @@ -585,7 +585,7 @@ \code cd - sudo Boot2Qt-1.0/raspberrypi-eLinux/images/deploy.sh /dev/ + sudo Boot2Qt-2.x/raspberrypi-eLinux/images/deploy.sh /dev/ \endcode After the image has been deployed, power on the device and check that -- cgit v1.2.3 From 30bf9ea54024a75c4bfdf6e6da11315658318363 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 27 Jan 2014 14:10:01 +0100 Subject: Re-connect if netd is not ready There is a delay from the time when netd service is started and when it is actually ready to listen for commands. Change-Id: I92a21639921682457f8d5ccf1124a0d310a7a41c Reviewed-by: Eirik Aavitsland --- src/qconnectivity/main.cpp | 51 +++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/qconnectivity/main.cpp b/src/qconnectivity/main.cpp index a02658a..4095c45 100644 --- a/src/qconnectivity/main.cpp +++ b/src/qconnectivity/main.cpp @@ -69,6 +69,7 @@ protected: bool ethernetSupported() const; protected slots: + void initNetdConnection(); void handleNetdEvent(); void handleRequest(); void handleNewConnection(); @@ -116,15 +117,32 @@ private: QConnectivityDaemon::QConnectivityDaemon() : m_netdSocket(0), m_serverSocket(0), m_linkUp(false), m_leaseTimer(0) { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "starting QConnectivityDaemon..."; + qDebug() << "starting QConnectivityDaemon..."; + initNetdConnection(); m_leaseTimer = new LeaseTimer(this); m_leaseTimer->setSingleShot(true); connect(m_leaseTimer, SIGNAL(timeout()), this, SLOT(updateLease())); + int serverFd = socket_local_server("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + if (serverFd != -1) { + m_serverSocket = new QLocalServer(this); + if (m_serverSocket->listen(serverFd)) + connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); + else + qWarning() << "QConnectivityDaemon: not able to listen on the server socket..."; + } else { + qWarning() << "QConnectivityDaemon: failed to open qconnectivity server socket"; + } +} + +void QConnectivityDaemon::initNetdConnection() +{ + static int attemptCount = 12; if (ethernetSupported()) { int netdFd = socket_local_client("netd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); if (netdFd != -1) { + qDebug() << "QConnectivityDaemon: connected to netd socket"; m_netdSocket = new QLocalSocket(this); m_netdSocket->setSocketDescriptor(netdFd); connect(m_netdSocket, SIGNAL(readyRead()), this, SLOT(handleNetdEvent())); @@ -137,19 +155,10 @@ QConnectivityDaemon::QConnectivityDaemon() sendCommand("0 interface setcfg " ETH_INTERFACE " up"); } else { qWarning() << "QConnectivityDaemon: failed to connect to netd socket"; + if (--attemptCount != 0) + QTimer::singleShot(2000, this, SLOT(initNetdConnection())); } } - - int serverFd = socket_local_server("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); - if (serverFd != -1) { - m_serverSocket = new QLocalServer(this); - if (m_serverSocket->listen(serverFd)) - connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); - else - qWarning() << "QConnectivityDaemon: not able to listen on the server socket..."; - } else { - qWarning() << "QConnectivityDaemon: failed to open qconnectivity server socket"; - } } void QConnectivityDaemon::setHostnamePropery(const char *interface) const @@ -176,7 +185,7 @@ void QConnectivityDaemon::setHostnamePropery(const char *interface) const void QConnectivityDaemon::sendCommand(const char *command) const { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: sending command - " << command; + qDebug() << "QConnectivityDaemon: sending command - " << command; // netd expects "\0" terminated commands... m_netdSocket->write(command, qstrlen(command) + 1); m_netdSocket->flush(); @@ -208,8 +217,8 @@ void QConnectivityDaemon::handleInterfaceChange(const QList &message bool QConnectivityDaemon::startDhcp(bool renew, const char *interface) { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: startDhcp [ renew" - << renew << "] " << "interface: " << interface; + qDebug() << "QConnectivityDaemon: startDhcp [ renew" << renew << "] " + << "interface: " << interface; setHostnamePropery(interface); int result = 0; @@ -238,8 +247,8 @@ bool QConnectivityDaemon::startDhcp(bool renew, const char *interface) bool success = (result == 0) ? true : false; if (success) { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "\nipaddr: " << ipaddr << "\nprefixLength: " << prefixLength - << "\ngateway: " << gateway << "\ndns1: " << dns1 << "\ndns2: " << dns2; + qDebug() << "\nipaddr: " << ipaddr << "\nprefixLength: " << prefixLength + << "\ngateway: " << gateway << "\ndns1: " << dns1 << "\ndns2: " << dns2; if (!renew) { in_addr _ipaddr, _gateway, _dns1, _dns2; @@ -285,7 +294,7 @@ bool QConnectivityDaemon::startDhcp(bool renew, const char *interface) void QConnectivityDaemon::stopDhcp(const char *interface) { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: stopDhcp: " << interface; + qDebug() << "QConnectivityDaemon: stopDhcp: " << interface; ifc_clear_addresses(interface); dhcp_stop(interface); if (m_leaseTimer->isActive()) @@ -323,7 +332,7 @@ void QConnectivityDaemon::handleRequest() if (requester->canReadLine()) { QByteArray request = requester->readLine(requester->bytesAvailable()); - if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: received a request: " << request; + qDebug() << "QConnectivityDaemon: received a request: " << request; QList cmd = request.split(' '); if (cmd.size() < 2) return; @@ -351,7 +360,7 @@ void QConnectivityDaemon::handleNewConnection() void QConnectivityDaemon::sendReply(QLocalSocket *requester, const QByteArray &reply) const { - QByteArray r = reply.left(reply.size()); + QByteArray r = reply; r.append("\n"); requester->write(r.constData(), r.length()); requester->flush(); @@ -360,7 +369,7 @@ void QConnectivityDaemon::sendReply(QLocalSocket *requester, const QByteArray &r void QConnectivityDaemon::updateLease() { - if (QT_CONNECTIVITY_DEBUG) qDebug() << "QConnectivityDaemon: updating lease"; + qDebug() << "QConnectivityDaemon: updating lease"; startDhcp(true, m_leaseTimer->interface().constData()); } -- cgit v1.2.3 From eb7f5c21121d7a5fe86b52ec04337d77bc9f3cf4 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 29 Jan 2014 19:07:20 +0100 Subject: Make sure that wifi event thread doesn't block on exit After setting m_exitEventThread to True we need to generate wifi event, otherwise there might be cases that we block in wifi_wait_for_event and wifi event thread never exits. Change-Id: I699ca0c25e23abc7045c1850bf773443bac897e8 Reviewed-by: Eirik Aavitsland --- src/imports/wifi/qwifimanager.cpp | 22 ++++++++++++++++------ src/imports/wifi/qwifimanager.h | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/imports/wifi/qwifimanager.cpp b/src/imports/wifi/qwifimanager.cpp index e5ed67e..9139242 100644 --- a/src/imports/wifi/qwifimanager.cpp +++ b/src/imports/wifi/qwifimanager.cpp @@ -92,8 +92,6 @@ public: if (QT_WIFI_DEBUG) qDebug("EventReceiver thread is running"); char buffer[2048]; while (1) { - if (m_manager->exiting()) - return; int size = wifi_wait_for_event(m_if.constData(), buffer, sizeof(buffer) - 1); if (size > 0) { buffer[size] = 0; @@ -102,6 +100,8 @@ public: char *event = &buffer[11]; if (strstr(event, "SCAN-RESULTS")) { + if (m_manager->exitingEventThread()) + return; QWifiManagerEvent *e = new QWifiManagerEvent(WIFI_SCAN_RESULTS); QCoreApplication::postEvent(m_manager, e); } else if (strstr(event, "CONNECTED")) { @@ -125,7 +125,7 @@ QWifiManager::QWifiManager() , m_scanTimer(0) , m_scanning(false) , m_daemonClientSocket(0) - , m_exiting(false) + , m_exitingEventThread(false) { char interface[PROPERTY_VALUE_MAX]; property_get(WIFI_INTERFACE, interface, NULL); @@ -160,8 +160,14 @@ QWifiManager::QWifiManager() QWifiManager::~QWifiManager() { - m_exiting = true; - m_eventThread->wait(); + // exit event thread if it is running + if (m_eventThread->isRunning()) { + m_exitingEventThread = true; + call("SCAN"); + m_eventThread->wait(); + } + delete m_eventThread; + delete m_daemonClientSocket; } void QWifiManager::handleDhcpReply() @@ -236,13 +242,17 @@ void QWifiManager::connectToBackend() return; } if (QT_WIFI_DEBUG) qDebug("QWifiManager: started successfully"); + m_exitingEventThread = false; m_eventThread->start(); handleConnected(); } void QWifiManager::disconnectFromBackend() { - m_eventThread->quit(); + m_exitingEventThread = true; + call("SCAN"); + m_eventThread->wait(); + if (wifi_stop_supplicant(0) < 0) qWarning("QWifiManager: failed to stop supplicant"); wifi_close_supplicant_connection(m_interface.constData()); diff --git a/src/imports/wifi/qwifimanager.h b/src/imports/wifi/qwifimanager.h index 85384cc..c9ba2ef 100644 --- a/src/imports/wifi/qwifimanager.h +++ b/src/imports/wifi/qwifimanager.h @@ -56,7 +56,7 @@ public: void setScanning(bool scanning); NetworkState networkState() const { return m_state; } bool isbackendReady() const { return m_backendReady; } - bool exiting() const { return m_exiting; } + bool exitingEventThread() const { return m_exitingEventThread; } public slots: void start(); @@ -98,7 +98,7 @@ private: NetworkState m_state; QLocalSocket *m_daemonClientSocket; QByteArray m_request; - bool m_exiting; + bool m_exitingEventThread; }; #endif // QWIFIMANAGER_H -- cgit v1.2.3 From 2ad3a8b8121cc1a4f2d1fa291b7f63a8fc7d34d3 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 29 Jan 2014 17:22:59 +0100 Subject: Re-enable the wifi plguin now that toolchains have been updated Change-Id: I87efe6b020b3c8b13491a1611b7992e8f697cb46 Reviewed-by: Gatis Paeglis --- src/imports/imports.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 6284883..0a5ccf5 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = utils -#android:SUBDIRS += wifi +android:SUBDIRS += wifi -- cgit v1.2.3 From 0e71a8a6df15433715fb9c6b54ad5962527f3126 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 30 Jan 2014 12:16:05 +0100 Subject: Doc: Remove embedded Android support for Beagleboard B2Qt 2.0 will support only embedded Linux on Beagleboard. Task-number: QTEE-303 Change-Id: Id9b0058a929ab7f441bcb17795ff5c562facb89f Reviewed-by: Eirik Aavitsland --- src/doc/src/b2qt.qdoc | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index 34ae33d..5c8ea7e 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -45,7 +45,7 @@ \list \li \l{Preparing Nexus 7}{Nexus 7 (2012) (embedded Android)} \li \l{Preparing Sabre Lite i.MX 6}{Sabre Lite i.MX 6 (embedded Android and Linux)} - \li \l{Preparing BeagleBoard-xM}{BeagleBoard-xM (embedded Android and Linux)} + \li \l{Preparing BeagleBoard-xM}{BeagleBoard-xM (embedded Linux)} \li \l{Preparing Raspberry Pi}{Raspberry Pi Model B (embedded Linux)} \endlist \li \l{Building and Running an Example} @@ -278,7 +278,7 @@ \list \li \l{Nexus 7 (2012) (embedded Android)} \li \l{Sabre Lite i.MX 6 (embedded Android and Linux)} - \li \l{BeagleBoard-xM (embedded Android and Linux)} + \li \l{BeagleBoard-xM (embedded Linux)} \li \l{Raspberry Pi Model B (embedded Linux)} \endlist @@ -406,7 +406,7 @@ */ /*! - \target BeagleBoard-xM (embedded Android and Linux) + \target BeagleBoard-xM (embedded Linux) \page qtee-preparing-hardware-beagleboard.html \title Preparing BeagleBoard-xM \previouspage qtee-installation-guide.html @@ -419,35 +419,23 @@ \note It is important that you repeat the steps in this section after you update \SDK. - The images containing \B2Q stack for BeagleBoard-xM are included in \SDK, + The image containing \B2Q stack for BeagleBoard-xM are included in \SDK, ready to be copied to an SD card. \section1 Preparing an SD Card - For \B2QA, an SD card of at least 2 GB capacity is needed. For \B2QL, - a card of at least 512 MB capacity is sufficient. + An SD card of at least 512 MB capacity is needed. \include detect-sd-card-device-name.qdocinc instructions \section1 Installing the \B2Q Image - The commands used in this step vary depending on whether you are developing - for embedded Android or embedded Linux. - To write the image to the SD card: - \list - \li \b{\B2QA} - \code - cd - sudo dd if=Boot2Qt-2.x/beagleboard-eAndroid/images/sdcard.img of=/dev/ bs=1M - \endcode - \li \b{\B2QL} - \code - cd - sudo Boot2Qt-2.x/beagleboard-eLinux/images/deploy.sh /dev/ - \endcode - \endlist + \code + cd + sudo Boot2Qt-2.x/beagleboard-eLinux/images/deploy.sh /dev/ + \endcode After the image has been deployed, power on the device and check that the \B2Q welcome screen and/or demo appear. -- cgit v1.2.3 From ca32a427ba15ddcf410e84069416757d366612f4 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 31 Jan 2014 11:24:35 +0100 Subject: Doc: Remove comment about Yocto compliance Task-number: QTEE-311 Change-Id: Ibf4052919e6235c569345d96c4244743a843b758 Reviewed-by: Samuli Piippo --- src/doc/src/b2qt.qdoc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/doc/src/b2qt.qdoc b/src/doc/src/b2qt.qdoc index 5c8ea7e..e2322de 100644 --- a/src/doc/src/b2qt.qdoc +++ b/src/doc/src/b2qt.qdoc @@ -101,11 +101,10 @@ \li \b{\B2QL} where the software stack is using the traditional embedded Linux kernel built with the Yocto Poky reference system (Yocto 1.4 - \e Dylan release). Because of its Yocto compliance, the Embedded - Linux variant is designed for great customization possibilities. - It contains only components required in the embedded device, - resulting in smaller image sizes while keeping valuable development - tools available. + \e Dylan release). The Embedded Linux variant is designed for great + customization possibilities. It contains only components required in + the embedded device, resulting in smaller image sizes while keeping + valuable development tools available. \endlist Both versions have been tested and verified on a number of different -- cgit v1.2.3 From 711bfedc706f609cce586406647cfb4ef4547f15 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 31 Jan 2014 11:06:52 +0100 Subject: Improve QDroidUtils IP address retrieval Instead of returning the first IP address from eth0, return a comma-separated list. This ensures that the IPv4 address is shown in Launcher Settings demo, important as it's required for setting up the connection to Raspberry Pi in Qt Creator (sometimes, IPv6 address is shown as first entry). Also, cleans up the garbage (trailing %eth0) returned for IPv6 addresses. Change-Id: Ibced367ba443ac76c2ad2a4f2589c9edcbc74b7f Reviewed-by: Eirik Aavitsland --- src/utils/qdroidutils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index 67d8d29..0952345 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -229,22 +229,22 @@ bool QDroidUtils::setDisplayBrightness(quint8 value) /*! - * Gets the current IP address of the device + * Gets the current IP address(es) of the device */ QString QDroidUtils::getIPAddress() { - QString address; + QStringList addresses; #ifdef Q_OS_ANDROID_NO_SDK qDebug("QDroidUtils::getIPAddress()"); #else QNetworkInterface interface = QNetworkInterface::interfaceFromName("eth0"); QList entries; entries = interface.addressEntries(); - if ( !entries.empty() ) { - address = entries.first().ip().toString(); + foreach (const QNetworkAddressEntry &entry, entries) { + addresses.append(entry.ip().toString().split('%').first()); } #endif - return address; + return addresses.join(QStringLiteral(", ")); } /*! -- cgit v1.2.3