diff --git a/src/modules/keyboardq/data/Key.qml b/src/modules/keyboardq/data/Key.qml new file mode 100644 index 000000000..e85b44f08 --- /dev/null +++ b/src/modules/keyboardq/data/Key.qml @@ -0,0 +1,179 @@ +/* === This file is part of Calamares - === + * + * Copyright 2021, Anke Boersma + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +import QtQuick 2.15 + +Item { + id: key + + property string mainLabel: "A" + property var secondaryLabels: []; + + property var iconSource; + + property var keyImageLeft: "" + property var keyImageRight: "" + property var keyImageCenter: "" + + property color keyColor: "#404040" + property color keyPressedColor: "grey" + property int keyBounds: 2 + property var keyPressedColorOpacity: 1 + + property var mainFontFamily: "Roboto" + property color mainFontColor: "white" + property int mainFontSize: 18 + + property var secondaryFontFamily: "Roboto" + property color secondaryFontColor: "white" + property int secondaryFontSize: 10 + + property bool secondaryLabelVisible: true + + property bool isChekable; + property bool isChecked; + + property bool upperCase; + + signal clicked() + signal alternatesClicked(string symbol) + + Item { + anchors.fill: parent + anchors.margins: key.keyBounds + visible: key.keyImageLeft != "" || key.keyImageCenter != "" || key.keyImageRight != "" ? 1 : 0 + Image { + id: backgroundImage_left + anchors.left: parent.left + height: parent.height + fillMode: Image.PreserveAspectFit + source: key.keyImageLeft + } + Image { + id: backgroundImage_right + anchors.right: parent.right + height: parent.height + fillMode: Image.PreserveAspectFit + source: key.keyImageRight + } + Image { + id: backgroundImage_center + anchors.fill: parent + anchors.leftMargin: backgroundImage_left.width - 1 + anchors.rightMargin: backgroundImage_right.width - 1 + height: parent.height + fillMode: Image.Stretch + source: key.keyImageCenter + } + } + + Rectangle { + id: backgroundItem + anchors.fill: parent + anchors.margins: key.keyBounds + color: key.isChecked || mouseArea.pressed ? key.keyPressedColor : key.keyColor; + opacity: key.keyPressedColorOpacity + } + + Column + { + anchors.centerIn: backgroundItem + + Text { + id: secondaryLabelsItem + smooth: true + anchors.right: parent.right + visible: true //secondaryLabelVisible + text: secondaryLabels.length > 0 ? secondaryLabels : "" + color: secondaryFontColor + + font.pixelSize: secondaryFontSize + font.weight: Font.Light + font.family: secondaryFontFamily + font.capitalization: upperCase ? Font.AllUppercase : + Font.MixedCase + } + + Row { + anchors.horizontalCenter: parent.horizontalCenter + + Image { + id: icon + smooth: true + anchors.verticalCenter: parent.verticalCenter + source: iconSource + //sourceSize.width: key.width * 0.6 + sourceSize.height: key.height * 0.4 + } + + Text { + id: mainLabelItem + smooth: true + anchors.verticalCenter: parent.verticalCenter + text: mainLabel + color: mainFontColor + visible: iconSource ? false : true + + font.pixelSize: mainFontSize + font.weight: Font.Light + font.family: mainFontFamily + font.capitalization: upperCase ? Font.AllUppercase : + Font.MixedCase + } + } + } + + Row { + id: alternatesRow + property int selectedIndex: -1 + visible: false + anchors.bottom: backgroundItem.top + anchors.left: backgroundItem.left + + Repeater { + model: secondaryLabels.length + + Rectangle { + property bool isSelected: alternatesRow.selectedIndex == index + color: isSelected ? mainLabelItem.color : key.keyPressedColor + height: backgroundItem.height + width: backgroundItem.width + + Text { + anchors.centerIn: parent + text: secondaryLabels[ index ] + font: mainLabelItem.font + color: isSelected ? key.keyPressedColor : mainLabelItem.color + } + } + } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onPressAndHold: alternatesRow.visible = true + onClicked: { + if (key.isChekable) key.isChecked = !key.isChecked + key.clicked() + } + + onReleased: { + alternatesRow.visible = false + if (alternatesRow.selectedIndex > -1) + key.alternatesClicked(secondaryLabels[alternatesRow.selectedIndex]) + } + + onMouseXChanged: { + alternatesRow.selectedIndex = + (mouseY < 0 && mouseX > 0 && mouseY < alternatesRow.width) ? + Math.floor(mouseX / backgroundItem.width) : + -1; + } + } +} diff --git a/src/modules/keyboardq/data/Keyboard.qml b/src/modules/keyboardq/data/Keyboard.qml new file mode 100644 index 000000000..a804ca9f4 --- /dev/null +++ b/src/modules/keyboardq/data/Keyboard.qml @@ -0,0 +1,222 @@ +/* === This file is part of Calamares - === + * + * Copyright 2021, Anke Boersma + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +import QtQuick 2.15 +import QtQuick.XmlListModel 2.10 + +Item { + id: keyboard + + width: 1024 + height: 640 + + property int rows: 4; + property int columns: 10; + + property string source: "generic.xml" + property var target; + + property color backgroundColor: "black" + + property var keyImageLeft: "" + property var keyImageRight: "" + property var keyImageCenter: "" + + property color keyColor: "#404040" + property color keyPressedColor: "grey" + property int keyBounds: 2 + property var keyPressedColorOpacity: 1 + + property var mainFontFamily: "Roboto" + property color mainFontColor: "white" + property int mainFontSize: 59 + + property var secondaryFontFamily: "Roboto" + property color secondaryFontColor: "white" + property int secondaryFontSize: 30 + + property bool secondaryLabelsVisible: false + property bool doSwitchSource: true + + property bool allUpperCase: false + + signal keyClicked(string key) + signal switchSource(string source) + signal enterClicked() + + Rectangle { + id: root + anchors.fill: parent + color: backgroundColor + + property int keyWidth: keyboard.width / columns; + property int keyHeight: keyboard.height / rows; + + property int xmlIndex: 1 + + Text { + id: proxyMainTextItem + color: keyboard.mainFontColor + font.pixelSize: keyboard.mainFontSize + font.weight: Font.Light + font.family: keyboard.mainFontFamily + font.capitalization: keyboard.allUpperCase ? Font.AllUppercase : + Font.MixedCase + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Text { + id: proxySecondaryTextItem + color: keyboard.secondaryFontColor + font.pixelSize: keyboard.secondaryFontSize + font.weight: Font.Light + font.family: keyboard.secondaryFontFamily + font.capitalization: keyboard.allUpperCase ? Font.AllUppercase : + Font.MixedCase + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Column { + id: column + anchors.centerIn: parent + + Repeater { + id: rowRepeater + + model: XmlListModel { + id: keyboardModel + source: keyboard.source + query: "/Keyboard/Row" + + Behavior on source { + NumberAnimation { + easing.type: Easing.InOutSine + duration: 100 + } + } + } + + Row { + id: keyRow + property int rowIndex: index + anchors.horizontalCenter: if(parent) parent.horizontalCenter + + Repeater { + id: keyRepeater + + model: XmlListModel { + source: keyboard.source + query: "/Keyboard/Row[" + (rowIndex + 1) + "]/Key" + + XmlRole { name: "labels"; query: "@labels/string()" } + XmlRole { name: "ratio"; query: "@ratio/number()" } + XmlRole { name: "icon"; query: "@icon/string()" } + XmlRole { name: "checkable"; query: "@checkable/string()" } + } + + Key { + id: key + width: root.keyWidth * ratio + height: root.keyHeight + iconSource: icon + mainFontFamily: proxyMainTextItem.font + mainFontColor: proxyMainTextItem.color + secondaryFontFamily: proxySecondaryTextItem.font + secondaryFontColor: proxySecondaryTextItem.color + secondaryLabelVisible: keyboard.secondaryLabelsVisible + keyColor: keyboard.keyColor + keyImageLeft: keyboard.keyImageLeft + keyImageRight: keyboard.keyImageRight + keyImageCenter: keyboard.keyImageCenter + keyPressedColor: keyboard.keyPressedColor + keyPressedColorOpacity: keyboard.keyPressedColorOpacity + keyBounds: keyboard.keyBounds + isChekable: checkable + isChecked: isChekable && + command && + command === "shift" && + keyboard.allUpperCase + upperCase: keyboard.allUpperCase + + property var command + property var params: labels + + onParamsChanged: { + var labelSplit; + + if(params[0] === '|') + { + mainLabel = '|' + labelSplit = params + } + else + { + labelSplit = params.split(/[|]+/) + + if (labelSplit[0] === '!') + mainLabel = '!'; + else + mainLabel = params.split(/[!|]+/)[0].toString(); + } + + if (labelSplit[1]) secondaryLabels = labelSplit[1]; + + if (labelSplit[0] === '!') + command = params.split(/[!|]+/)[1]; + else + command = params.split(/[!]+/)[1]; + } + + onClicked: { + if (command) + { + var commandList = command.split(":"); + + switch(commandList[0]) + { + case "source": + keyboard.switchSource(commandList[1]) + if(doSwitchSource) keyboard.source = commandList[1] + return; + case "shift": + keyboard.allUpperCase = !keyboard.allUpperCase + return; + case "backspace": + keyboard.keyClicked('\b'); + target.text = target.text.substring(0,target.text.length-1) + return; + case "enter": + keyboard.enterClicked() + return; + case "tab": + keyboard.keyClicked('\t'); + target.text = target.text + " " + return; + default: return; + } + } + if (mainLabel.length === 1) + root.emitKeyClicked(mainLabel); + } + onAlternatesClicked: root.emitKeyClicked(symbol); + } + } + } + } + } + + function emitKeyClicked(text) { + var emitText = keyboard.allUpperCase ? text.toUpperCase() : text; + keyClicked( emitText ); + target.text = target.text + emitText + } + } +} + diff --git a/src/modules/keyboardq/data/afgani.xml b/src/modules/keyboardq/data/afgani.xml new file mode 100644 index 000000000..356e393f7 --- /dev/null +++ b/src/modules/keyboardq/data/afgani.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/ar.xml b/src/modules/keyboardq/data/ar.xml new file mode 100644 index 000000000..07bd9b087 --- /dev/null +++ b/src/modules/keyboardq/data/ar.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/backspace.svg b/src/modules/keyboardq/data/backspace.svg new file mode 100755 index 000000000..4d29e246c --- /dev/null +++ b/src/modules/keyboardq/data/backspace.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + diff --git a/src/modules/keyboardq/data/backspace.svg.license b/src/modules/keyboardq/data/backspace.svg.license new file mode 100644 index 000000000..36158c604 --- /dev/null +++ b/src/modules/keyboardq/data/backspace.svg.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 https://www.onlinewebfonts.com/fonts +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/button_bkg_center.png b/src/modules/keyboardq/data/button_bkg_center.png new file mode 100755 index 000000000..d17e1698e Binary files /dev/null and b/src/modules/keyboardq/data/button_bkg_center.png differ diff --git a/src/modules/keyboardq/data/button_bkg_center.png.license b/src/modules/keyboardq/data/button_bkg_center.png.license new file mode 100644 index 000000000..d36c167bb --- /dev/null +++ b/src/modules/keyboardq/data/button_bkg_center.png.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 MarcoPellin +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/button_bkg_left.png b/src/modules/keyboardq/data/button_bkg_left.png new file mode 100755 index 000000000..0a674af6c Binary files /dev/null and b/src/modules/keyboardq/data/button_bkg_left.png differ diff --git a/src/modules/keyboardq/data/button_bkg_left.png.license b/src/modules/keyboardq/data/button_bkg_left.png.license new file mode 100644 index 000000000..d36c167bb --- /dev/null +++ b/src/modules/keyboardq/data/button_bkg_left.png.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 MarcoPellin +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/button_bkg_right.png b/src/modules/keyboardq/data/button_bkg_right.png new file mode 100755 index 000000000..ce7c4ad71 Binary files /dev/null and b/src/modules/keyboardq/data/button_bkg_right.png differ diff --git a/src/modules/keyboardq/data/button_bkg_right.png.license b/src/modules/keyboardq/data/button_bkg_right.png.license new file mode 100644 index 000000000..d36c167bb --- /dev/null +++ b/src/modules/keyboardq/data/button_bkg_right.png.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 MarcoPellin +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/de.xml b/src/modules/keyboardq/data/de.xml new file mode 100644 index 000000000..55513157e --- /dev/null +++ b/src/modules/keyboardq/data/de.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/empty.xml b/src/modules/keyboardq/data/empty.xml new file mode 100644 index 000000000..74e913a07 --- /dev/null +++ b/src/modules/keyboardq/data/empty.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/en.xml b/src/modules/keyboardq/data/en.xml new file mode 100644 index 000000000..2ab9a344d --- /dev/null +++ b/src/modules/keyboardq/data/en.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/enter.svg b/src/modules/keyboardq/data/enter.svg new file mode 100755 index 000000000..c66a74921 --- /dev/null +++ b/src/modules/keyboardq/data/enter.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/enter.svg.license b/src/modules/keyboardq/data/enter.svg.license new file mode 100644 index 000000000..36158c604 --- /dev/null +++ b/src/modules/keyboardq/data/enter.svg.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 https://www.onlinewebfonts.com/fonts +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/es.xml b/src/modules/keyboardq/data/es.xml new file mode 100644 index 000000000..6f69c9cbe --- /dev/null +++ b/src/modules/keyboardq/data/es.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/fr.xml b/src/modules/keyboardq/data/fr.xml new file mode 100644 index 000000000..0f77c3f06 --- /dev/null +++ b/src/modules/keyboardq/data/fr.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/generic.xml b/src/modules/keyboardq/data/generic.xml new file mode 100644 index 000000000..7304626c4 --- /dev/null +++ b/src/modules/keyboardq/data/generic.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/generic_qz.xml b/src/modules/keyboardq/data/generic_qz.xml new file mode 100644 index 000000000..c896f59ff --- /dev/null +++ b/src/modules/keyboardq/data/generic_qz.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/pt.xml b/src/modules/keyboardq/data/pt.xml new file mode 100644 index 000000000..0142260ee --- /dev/null +++ b/src/modules/keyboardq/data/pt.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/ru.xml b/src/modules/keyboardq/data/ru.xml new file mode 100644 index 000000000..38f2b6836 --- /dev/null +++ b/src/modules/keyboardq/data/ru.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/scan.xml b/src/modules/keyboardq/data/scan.xml new file mode 100644 index 000000000..76981f3c1 --- /dev/null +++ b/src/modules/keyboardq/data/scan.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/keyboardq/data/shift.license b/src/modules/keyboardq/data/shift.license new file mode 100644 index 000000000..36158c604 --- /dev/null +++ b/src/modules/keyboardq/data/shift.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2019 https://www.onlinewebfonts.com/fonts +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/keyboardq/data/shift.svg b/src/modules/keyboardq/data/shift.svg new file mode 100755 index 000000000..825ba649b --- /dev/null +++ b/src/modules/keyboardq/data/shift.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + diff --git a/src/modules/keyboardq/keyboardq.qml b/src/modules/keyboardq/keyboardq.qml index 8f8bf05d1..1d59cf30e 100644 --- a/src/modules/keyboardq/keyboardq.qml +++ b/src/modules/keyboardq/keyboardq.qml @@ -1,200 +1,138 @@ -/* === This file is part of Calamares - === +/* === This file is part of Calamares - === * - * SPDX-FileCopyrightText: 2020 Anke Boersma + * SPDX-FileCopyrightText: 2020 - 2021 Anke Boersma * SPDX-License-Identifier: GPL-3.0-or-later * - * Calamares is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Calamares is Free Software: see the License-Identifier above. * - * Calamares is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Calamares. If not, see . */ import io.calamares.core 1.0 import io.calamares.ui 1.0 -import QtQuick 2.10 -import QtQuick.Controls 2.10 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtQuick.Window 2.14 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami +import "data" -Page { +Item { width: 800 //parent.width - height: 500 + height: 600 - StackView { - id: stack + readonly property color backgroundColor: "#E6E9EA" //Kirigami.Theme.backgroundColor + readonly property color listBackgroundColor: "white" + readonly property color textFieldColor: "#121212" + readonly property color textFieldBackgroundColor: "#F8F8F8" + readonly property color textColor: Kirigami.Theme.textColor + readonly property color highlightedTextColor: Kirigami.Theme.highlightedTextColor + readonly property color highlightColor: Kirigami.Theme.highlightColor + + property var langXml: ["de", "en", "es", "fr", "ru",] + property var arXml: ["Arabic"] + property var ruXml: ["Azerba", "Belaru", "Kazakh", "Kyrgyz", "Mongol", + "Russia", "Tajik", "Ukrain"] + property var frXml: ["Bambar", "Belgia","French", "Wolof"] + property var enXml: ["Bikol", "Chines", "Englis", "Irish", "Lithua", "Maori"] + property var esXml: ["Spanis"] + property var deXml: ["German"] + property var ptXml: ["Portug"] + property var scanXml: ["Danish", "Finnis", "Norweg", "Swedis"] + property var afganiXml: ["Afghan"] + property var genericXml: ["Armeni", "Bulgar", "Dutch", "Estoni", "Icelan", + "Indone", "Italia", "Latvia", "Maltes", "Moldav", "Romani", "Swahil", "Turkis"] + property var genericQzXml: ["Albani", "Bosnia", "Croati", "Czech", "Hungar", + "Luxemb", "Monten", "Polish", "Serbia", "Sloven", "Slovak"] + property var genericAzXml: [] + + property var keyIndex: [] + + Rectangle { + id: backgroundItem anchors.fill: parent - clip: true + color: backgroundColor - initialItem: Item { + Label { + id: header + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("To activate keyboard preview, select a layout.") + color: textColor + font.bold: true + } + + Label { + id: intro + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: header.bottom + color: textColor + horizontalAlignment: Text.AlignHCenter + width: parent.width / 1.2 + wrapMode: Text.WordWrap + text: ( config.prettyStatus) + } + + RowLayout { + id: models + anchors.top: intro.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width /1.5 + spacing: 10 Label { - - id: header - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Keyboard Model") - color: Kirigami.Theme.textColor + Layout.alignment: Qt.AlignCenter + text: qsTr("Keyboard Model:") + color: textColor font.bold: true - font.weight: Font.Bold - font.pointSize: 24 } - Label { - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: header.bottom - color: Kirigami.Theme.textColor - horizontalAlignment: Text.AlignHCenter - width: parent.width / 1.5 - wrapMode: Text.WordWrap - text: qsTr("Click your preferred keyboard model to select layout and variant, or use the default one based on the detected hardware.") - } - - ListView { - - id: list1 - - ScrollBar.vertical: ScrollBar { - - active: true - } - - width: parent.width / 2 - height: 250 - anchors.centerIn: parent - anchors.verticalCenterOffset: -30 - focus: true - clip: true - boundsBehavior: Flickable.StopAtBounds - spacing: 2 - - Rectangle { - - z: parent.z - 1 - anchors.fill: parent - color: "#BDC3C7" - radius: 5 - opacity: 0.7 - } - + ComboBox { + Layout.fillWidth: true + textRole: "label" model: config.keyboardModelsModel - //model: ["Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"] - currentIndex: model.currentIndex - delegate: ItemDelegate { - - hoverEnabled: true - width: parent.width - highlighted: ListView.isCurrentItem - - RowLayout { - anchors.fill: parent - - Label { - - text: model.label // modelData - Layout.fillHeight: true - Layout.fillWidth: true - width: parent.width - height: 32 - color: highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor - - background: Rectangle { - - color: highlighted || hovered ? Kirigami.Theme.highlightColor : "white" //Kirigami.Theme.backgroundColor - opacity: highlighted || hovered ? 0.5 : 0.3 - } - } - - Kirigami.Icon { - - source: "checkmark" - Layout.preferredWidth: 22 - Layout.preferredHeight: 22 - color: Kirigami.Theme.highlightedTextColor - visible: highlighted - } - } - - onClicked: { - - list1.model.currentIndex = index - stack.push(layoutsList) - list1.positionViewAtIndex(index, ListView.Center) - } - } + onCurrentIndexChanged: config.keyboardModels = currentIndex } } - Component { - id: layoutsList + StackView { + id: stack + anchors.top: models.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + clip: true - Item { - - Label { - - id: header - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Keyboard Layout") - color: Kirigami.Theme.textColor - font.bold: true - font.weight: Font.Bold - font.pointSize: 24 - } - - Label { - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: header.bottom - color: Kirigami.Theme.textColor - horizontalAlignment: Text.AlignHCenter - width: parent.width / 1.5 - wrapMode: Text.WordWrap - text: config.prettyStatus - //text: qsTr("Set keyboard model or use the default one based on the detected hardware.") - } + initialItem: Item { ListView { - - id: list2 + id: layouts ScrollBar.vertical: ScrollBar { - active: true } width: parent.width / 2 - height: 250 - anchors.centerIn: parent - anchors.verticalCenterOffset: -30 + height: 200 + anchors.horizontalCenter: parent.horizontalCenter focus: true clip: true boundsBehavior: Flickable.StopAtBounds spacing: 2 Rectangle { - z: parent.z - 1 anchors.fill: parent - color: "#BDC3C7" - radius: 5 + color: listBackgroundColor opacity: 0.7 } model: config.keyboardLayoutsModel - //model: ["Brussels", "London", "Madrid", "New York", "Melbourne", "London", "Madrid", "New York", "Brussels", "London", "Madrid", "New York", "Brussels", "London", "Madrid", "New York"] - currentIndex: model.currentIndex + Component.onCompleted: positionViewAtIndex(model.currentIndex, ListView.Center) delegate: ItemDelegate { hoverEnabled: true @@ -202,203 +140,169 @@ Page { highlighted: ListView.isCurrentItem RowLayout { - anchors.fill: parent + anchors.fill: parent Label { - - text: model.label // modelData + id: label1 + text: model.label Layout.fillHeight: true Layout.fillWidth: true + padding: 10 width: parent.width - height: 30 - color: highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor + height: 32 + color: highlighted ? highlightedTextColor : textColor background: Rectangle { - - color: highlighted || hovered ? Kirigami.Theme.highlightColor : "white" //Kirigami.Theme.backgroundColor + color: highlighted || hovered ? highlightColor : listBackgroundColor opacity: highlighted || hovered ? 0.5 : 0.3 } } - - Kirigami.Icon { - - source: "checkmark" - Layout.preferredWidth: 22 - Layout.preferredHeight: 22 - color: Kirigami.Theme.highlightedTextColor - visible: highlighted - } } onClicked: { - list2.model.currentIndex = index + layouts.model.currentIndex = index + keyIndex = label1.text.substring(0,6) stack.push(variantsList) - list2.positionViewAtIndex(index, ListView.Center) + layouts.positionViewAtIndex(index, ListView.Center) } } } - - ColumnLayout { - - spacing: 2 - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: -30 - anchors.left: parent.left - anchors.leftMargin: parent.width / 15 - - Button { - - icon.name: "go-previous" - text: qsTr("Models") - onClicked: stack.pop() - } - - Button { - - icon.name: "go-next" - text: qsTr("Variants") - onClicked: stack.push(variantsList) - } - } - } - } - - Component { - id: variantsList - - Item { - - Label { - - id: header - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Keyboard Variant") - color: Kirigami.Theme.textColor - font.bold: true - font.weight: Font.Bold - font.pointSize: 24 - } - - Label { - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: header.bottom - color: Kirigami.Theme.textColor - horizontalAlignment: Text.AlignHCenter - width: parent.width / 1.5 - wrapMode: Text.WordWrap - text: config.prettyStatus - //text: qsTr("Variant keyboard model or use the default one based on the detected hardware.") - } - - ListView { - - id: list3 - - ScrollBar.vertical: ScrollBar { - - active: true - } - - width: parent.width / 2 - height: 250 - anchors.centerIn: parent - anchors.verticalCenterOffset: -30 - focus: true - clip: true - boundsBehavior: Flickable.StopAtBounds - spacing: 2 - - Rectangle { - - z: parent.z - 1 - anchors.fill: parent - color: "#BDC3C7" - radius: 5 - opacity: 0.7 - } - - model: config.keyboardVariantsModel - //model: ["Brussels", "London", "Madrid", "New York", "Melbourne", "London", "Madrid", "New York", "Brussels", "London", "Madrid", "New York", "Brussels", "London", "Madrid", "New York"] - - currentIndex: model.currentIndex - delegate: ItemDelegate { - - hoverEnabled: true - width: parent.width - highlighted: ListView.isCurrentItem - - RowLayout { - anchors.fill: parent - - Label { - - text: model.label //modelData - Layout.fillHeight: true - Layout.fillWidth: true - width: parent.width - height: 30 - color: highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor - - background: Rectangle { - - color: highlighted || hovered ? Kirigami.Theme.highlightColor : "white" //Kirigami.Theme.backgroundColor - opacity: highlighted || hovered ? 0.5 : 0.3 - } - } - - Kirigami.Icon { - - source: "checkmark" - Layout.preferredWidth: 22 - Layout.preferredHeight: 22 - color: Kirigami.Theme.highlightedTextColor - visible: highlighted - } - } - - onClicked: { - - list3.model.currentIndex = index - list3.positionViewAtIndex(index, ListView.Center) - } - } - } - Button { Layout.fillWidth: true anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: -30 - anchors.left: parent.left + anchors.verticalCenterOffset: -parent.height / 3.5 + anchors.left: parent.left anchors.leftMargin: parent.width / 15 - icon.name: "go-previous" - text: qsTr("Layouts") - onClicked: stack.pop() + icon.name: "go-next" + text: qsTr("Variants") + onClicked: stack.push(variantsList) + } + } + + Component { + id: variantsList + + Item { + + ListView { + id: variants + + ScrollBar.vertical: ScrollBar { + active: true + } + + width: parent.width / 2 + height: 200 + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: 10 + focus: true + clip: true + boundsBehavior: Flickable.StopAtBounds + spacing: 2 + + Rectangle { + z: parent.z - 1 + anchors.fill: parent + color: listBackgroundColor + opacity: 0.7 + } + + model: config.keyboardVariantsModel + currentIndex: model.currentIndex + Component.onCompleted: positionViewAtIndex(model.currentIndex, ListView.Center) + + delegate: ItemDelegate { + hoverEnabled: true + width: parent.width + highlighted: ListView.isCurrentItem + + RowLayout { + anchors.fill: parent + + Label { + text: model.label + Layout.fillHeight: true + Layout.fillWidth: true + padding: 10 + width: parent.width + height: 30 + color: highlighted ? highlightedTextColor : textColor + + background: Rectangle { + color: highlighted || hovered ? highlightColor : listBackgroundColor + opacity: highlighted || hovered ? 0.5 : 0.3 + } + } + } + + onClicked: { + variants.model.currentIndex = index + variants.positionViewAtIndex(index, ListView.Center) + } + } + } + + Button { + Layout.fillWidth: true + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: -parent.height / 3.5 + anchors.left: parent.left + anchors.leftMargin: parent.width / 15 + icon.name: "go-previous" + text: qsTr("Layouts") + onClicked: stack.pop() + } } } } - } - TextField { + TextField { + id: textInput + placeholderText: qsTr("Type here to test your keyboard") + height: 36 + width: parent.width / 1.5 + horizontalAlignment: TextInput.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: keyboard.top + anchors.bottomMargin: parent.height / 25 + color: textFieldColor - placeholderText: qsTr("Test your keyboard") - height: 48 - width: parent.width / 1.5 - horizontalAlignment: TextInput.AlignHCenter - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: parent.height / 10 - color: "#1F1F1F" + background:Rectangle { + z: parent.z - 1 + anchors.fill: parent + color: textFieldBackgroundColor + radius: 2 + } + } - background:Rectangle { - - z: parent.z - 1 - anchors.fill: parent - color: "#BDC3C7" - radius: 2 - opacity: 0.3 + Keyboard { + id: keyboard + width: parent.width + height: parent.height / 3 + anchors.bottom: parent.bottom + source: langXml.includes(keyIndex) ? (keyIndex + ".xml") : + afganiXml.includes(keyIndex) ? "afgani.xml" : + scanXml.includes(keyIndex) ? "scan.xml" : + genericXml.includes(keyIndex) ? "generic.xml" : + genericQzXml.includes(keyIndex) ? "generic_qz.xml" : + arXml.includes(keyIndex) ? "ar.xml" : + deXml.includes(keyIndex) ? "de.xml" : + enXml.includes(keyIndex) ? "en.xml" : + esXml.includes(keyIndex) ? "es.xml" : + frXml.includes(keyIndex) ? "fr.xml" : + ptXml.includes(keyIndex) ? "pt.xml" : + ruXml.includes(keyIndex) ? "ru.xml" :"empty.xml" + rows: 4 + columns: 10 + keyColor: "transparent" + keyPressedColorOpacity: 0.2 + keyImageLeft: "button_bkg_left.png" + keyImageRight: "button_bkg_right.png" + keyImageCenter: "button_bkg_center.png" + target: textInput + onEnterClicked: console.log("Enter!") } } }