Warning, /plasma-bigscreen/calamares-bigscreen-branding/bigscreen/keyboarddata/Keyboard.qml is written in an unsupported language. File is not indexed.
0001 /* === This file is part of Calamares - <https://calamares.io> === 0002 * 0003 * SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us> 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 * 0006 * Calamares is Free Software: see the License-Identifier above. 0007 * 0008 */ 0009 0010 import QtQuick 2.15 0011 import QtQuick.XmlListModel 2.10 0012 0013 Item { 0014 id: keyboard 0015 0016 width: 1024 0017 height: 640 0018 0019 property int rows: 4; 0020 property int columns: 10; 0021 0022 property string source: "generic.xml" 0023 property var target; 0024 0025 property color backgroundColor: "black" 0026 0027 property var keyImageLeft: "" 0028 property var keyImageRight: "" 0029 property var keyImageCenter: "" 0030 0031 property color keyColor: "#404040" 0032 property color keyPressedColor: "grey" 0033 property int keyBounds: 2 0034 property var keyPressedColorOpacity: 1 0035 0036 property var mainFontFamily: "Roboto" 0037 property color mainFontColor: "white" 0038 property int mainFontSize: 59 0039 0040 property var secondaryFontFamily: "Roboto" 0041 property color secondaryFontColor: "white" 0042 property int secondaryFontSize: 30 0043 0044 property bool secondaryLabelsVisible: false 0045 property bool doSwitchSource: true 0046 0047 property bool allUpperCase: false 0048 0049 signal keyClicked(string key) 0050 signal switchSource(string source) 0051 signal enterClicked() 0052 0053 Rectangle { 0054 id: root 0055 anchors.fill: parent 0056 color: backgroundColor 0057 0058 property int keyWidth: keyboard.width / columns; 0059 property int keyHeight: keyboard.height / rows; 0060 0061 property int xmlIndex: 1 0062 0063 Text { 0064 id: proxyMainTextItem 0065 color: keyboard.mainFontColor 0066 font.pixelSize: keyboard.mainFontSize 0067 font.weight: Font.Light 0068 font.family: keyboard.mainFontFamily 0069 font.capitalization: keyboard.allUpperCase ? Font.AllUppercase : 0070 Font.MixedCase 0071 verticalAlignment: Text.AlignVCenter 0072 horizontalAlignment: Text.AlignHCenter 0073 } 0074 0075 Text { 0076 id: proxySecondaryTextItem 0077 color: keyboard.secondaryFontColor 0078 font.pixelSize: keyboard.secondaryFontSize 0079 font.weight: Font.Light 0080 font.family: keyboard.secondaryFontFamily 0081 font.capitalization: keyboard.allUpperCase ? Font.AllUppercase : 0082 Font.MixedCase 0083 verticalAlignment: Text.AlignVCenter 0084 horizontalAlignment: Text.AlignHCenter 0085 } 0086 0087 Column { 0088 id: column 0089 anchors.centerIn: parent 0090 0091 Repeater { 0092 id: rowRepeater 0093 0094 model: XmlListModel { 0095 id: keyboardModel 0096 source: keyboard.source 0097 query: "/Keyboard/Row" 0098 0099 Behavior on source { 0100 NumberAnimation { 0101 easing.type: Easing.InOutSine 0102 duration: 100 0103 } 0104 } 0105 } 0106 0107 Row { 0108 id: keyRow 0109 property int rowIndex: index 0110 anchors.horizontalCenter: if(parent) parent.horizontalCenter 0111 0112 Repeater { 0113 id: keyRepeater 0114 0115 model: XmlListModel { 0116 source: keyboard.source 0117 query: "/Keyboard/Row[" + (rowIndex + 1) + "]/Key" 0118 0119 XmlRole { name: "labels"; query: "@labels/string()" } 0120 XmlRole { name: "ratio"; query: "@ratio/number()" } 0121 XmlRole { name: "icon"; query: "@icon/string()" } 0122 XmlRole { name: "checkable"; query: "@checkable/string()" } 0123 } 0124 0125 Key { 0126 id: key 0127 width: root.keyWidth * ratio 0128 height: root.keyHeight 0129 iconSource: icon 0130 mainFontFamily: proxyMainTextItem.font 0131 mainFontColor: proxyMainTextItem.color 0132 secondaryFontFamily: proxySecondaryTextItem.font 0133 secondaryFontColor: proxySecondaryTextItem.color 0134 secondaryLabelVisible: keyboard.secondaryLabelsVisible 0135 keyColor: keyboard.keyColor 0136 keyImageLeft: keyboard.keyImageLeft 0137 keyImageRight: keyboard.keyImageRight 0138 keyImageCenter: keyboard.keyImageCenter 0139 keyPressedColor: keyboard.keyPressedColor 0140 keyPressedColorOpacity: keyboard.keyPressedColorOpacity 0141 keyBounds: keyboard.keyBounds 0142 isChekable: checkable 0143 isChecked: isChekable && 0144 command && 0145 command === "shift" && 0146 keyboard.allUpperCase 0147 upperCase: keyboard.allUpperCase 0148 0149 property var command 0150 property var params: labels 0151 0152 onParamsChanged: { 0153 var labelSplit; 0154 0155 if(params[0] === '|') 0156 { 0157 mainLabel = '|' 0158 labelSplit = params 0159 } 0160 else 0161 { 0162 labelSplit = params.split(/[|]+/) 0163 0164 if (labelSplit[0] === '!') 0165 mainLabel = '!'; 0166 else 0167 mainLabel = params.split(/[!|]+/)[0].toString(); 0168 } 0169 0170 if (labelSplit[1]) secondaryLabels = labelSplit[1]; 0171 0172 if (labelSplit[0] === '!') 0173 command = params.split(/[!|]+/)[1]; 0174 else 0175 command = params.split(/[!]+/)[1]; 0176 } 0177 0178 onClicked: { 0179 if (command) 0180 { 0181 var commandList = command.split(":"); 0182 0183 switch(commandList[0]) 0184 { 0185 case "source": 0186 keyboard.switchSource(commandList[1]) 0187 if(doSwitchSource) keyboard.source = commandList[1] 0188 return; 0189 case "shift": 0190 keyboard.allUpperCase = !keyboard.allUpperCase 0191 return; 0192 case "backspace": 0193 keyboard.keyClicked('\b'); 0194 target.text = target.text.substring(0,target.text.length-1) 0195 return; 0196 case "enter": 0197 keyboard.enterClicked() 0198 return; 0199 case "tab": 0200 keyboard.keyClicked('\t'); 0201 target.text = target.text + " " 0202 return; 0203 default: return; 0204 } 0205 } 0206 if (mainLabel.length === 1) 0207 root.emitKeyClicked(mainLabel); 0208 } 0209 onAlternatesClicked: root.emitKeyClicked(symbol); 0210 } 0211 } 0212 } 0213 } 0214 } 0215 0216 function emitKeyClicked(text) { 0217 var emitText = keyboard.allUpperCase ? text.toUpperCase() : text; 0218 keyClicked( emitText ); 0219 target.text = target.text + emitText 0220 } 0221 } 0222 } 0223