1/* Webcamoid, webcam capture application. 2 * Copyright (C) 2016 Gonzalo Exequiel Pedone 3 * 4 * Webcamoid is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Webcamoid is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Webcamoid. If not, see <http://www.gnu.org/licenses/>. 16 * 17 * Web-Site: http://webcamoid.github.io/ 18 */ 19 20import QtQuick 2.7 21import QtQuick.Controls 2.0 22import QtQuick.Dialogs 1.2 23import QtQuick.Layouts 1.3 24import AkQmlControls 1.0 25 26GridLayout { 27 columns: 2 28 29 function optionIndex(cbx, option) 30 { 31 var index = -1 32 33 for (var i = 0; i < cbx.model.count; i++) 34 if (cbx.model.get(i).option === option) { 35 index = i 36 break 37 } 38 39 return index 40 } 41 42 function fromRgba(rgba) 43 { 44 var a = ((rgba >> 24) & 0xff) / 255.0 45 var r = ((rgba >> 16) & 0xff) / 255.0 46 var g = ((rgba >> 8) & 0xff) / 255.0 47 var b = (rgba & 0xff) / 255.0 48 49 return Qt.rgba(r, g, b, a) 50 } 51 52 function toRgba(color) 53 { 54 var a = Math.round(255 * color.a) << 24 55 var r = Math.round(255 * color.r) << 16 56 var g = Math.round(255 * color.g) << 8 57 var b = Math.round(255 * color.b) 58 59 return a | r | g | b 60 } 61 62 Label { 63 text: qsTr("N° of drops") 64 } 65 TextField { 66 text: Matrix.nDrops 67 validator: RegExpValidator { 68 regExp: /\d+/ 69 } 70 Layout.fillWidth: true 71 72 onTextChanged: Matrix.nDrops = text 73 } 74 75 Label { 76 text: qsTr("Symbols") 77 } 78 TextField { 79 text: Matrix.charTable 80 onTextChanged: Matrix.charTable = text 81 Layout.fillWidth: true 82 } 83 84 Label { 85 text: qsTr("Font") 86 } 87 RowLayout { 88 TextField { 89 id: txtTable 90 text: Matrix.font.family + " " + Matrix.font.pointSize 91 readOnly: true 92 font: Matrix.font 93 Layout.fillWidth: true 94 } 95 AkButton { 96 label: qsTr("Select") 97 iconRc: "image://icons/preferences-desktop-font" 98 99 onClicked: fontDialog.open() 100 } 101 } 102 103 Label { 104 text: qsTr("Hinting") 105 } 106 ComboBox { 107 id: cbxHinting 108 textRole: "text" 109 currentIndex: optionIndex(cbxHinting, Matrix.hintingPreference) 110 Layout.fillWidth: true 111 112 model: ListModel { 113 ListElement { 114 text: qsTr("Default") 115 option: "PreferDefaultHinting" 116 } 117 ListElement { 118 text: qsTr("No hinting") 119 option: "PreferNoHinting" 120 } 121 ListElement { 122 text: qsTr("Vertical hinting") 123 option: "PreferVerticalHinting" 124 } 125 ListElement { 126 text: qsTr("Full hinting") 127 option: "PreferFullHinting" 128 } 129 } 130 131 onCurrentIndexChanged: Matrix.hintingPreference = cbxHinting.model.get(currentIndex).option 132 } 133 134 Label { 135 text: qsTr("Style") 136 } 137 ComboBox { 138 id: cbxStyle 139 textRole: "text" 140 currentIndex: optionIndex(cbxStyle, Matrix.styleStrategy) 141 Layout.fillWidth: true 142 143 model: ListModel { 144 ListElement { 145 text: qsTr("Default") 146 option: "PreferDefault" 147 } 148 ListElement { 149 text: qsTr("Bitmap") 150 option: "PreferBitmap" 151 } 152 ListElement { 153 text: qsTr("Device") 154 option: "PreferDevice" 155 } 156 ListElement { 157 text: qsTr("Outline") 158 option: "PreferOutline" 159 } 160 ListElement { 161 text: qsTr("Force outline") 162 option: "ForceOutline" 163 } 164 ListElement { 165 text: qsTr("Match") 166 option: "PreferMatch" 167 } 168 ListElement { 169 text: qsTr("Quality") 170 option: "PreferQuality" 171 } 172 ListElement { 173 text: qsTr("Antialias") 174 option: "PreferAntialias" 175 } 176 ListElement { 177 text: qsTr("No antialias") 178 option: "NoAntialias" 179 } 180 ListElement { 181 text: qsTr("Compatible with OpenGL") 182 option: "OpenGLCompatible" 183 } 184 ListElement { 185 text: qsTr("Force integer metrics") 186 option: "ForceIntegerMetrics" 187 } 188 ListElement { 189 text: qsTr("No subpixel antialias") 190 option: "NoSubpixelAntialias" 191 } 192 ListElement { 193 text: qsTr("No font merging") 194 option: "NoFontMerging" 195 } 196 } 197 198 onCurrentIndexChanged: Matrix.styleStrategy = cbxStyle.model.get(currentIndex).option 199 } 200 201 Label { 202 text: qsTr("Cursor color") 203 } 204 AkColorButton { 205 currentColor: fromRgba(Matrix.cursorColor) 206 title: qsTr("Choose the cursor color") 207 208 onCurrentColorChanged: Matrix.cursorColor = toRgba(currentColor) 209 } 210 211 Label { 212 text: qsTr("Foreground color") 213 } 214 AkColorButton { 215 currentColor: fromRgba(Matrix.foregroundColor) 216 title: qsTr("Choose the foreground color") 217 218 onCurrentColorChanged: Matrix.foregroundColor = toRgba(currentColor) 219 } 220 221 Label { 222 text: qsTr("Background color") 223 } 224 AkColorButton { 225 currentColor: fromRgba(Matrix.backgroundColor) 226 title: qsTr("Choose the background color") 227 228 onCurrentColorChanged: Matrix.backgroundColor = toRgba(currentColor) 229 } 230 231 Label { 232 text: qsTr("Min. drop length") 233 } 234 TextField { 235 text: Matrix.minDropLength 236 validator: RegExpValidator { 237 regExp: /\d+/ 238 } 239 Layout.fillWidth: true 240 241 onTextChanged: Matrix.minDropLength = text 242 } 243 244 Label { 245 text: qsTr("Max. drop length") 246 } 247 TextField { 248 text: Matrix.maxDropLength 249 validator: RegExpValidator { 250 regExp: /\d+/ 251 } 252 Layout.fillWidth: true 253 254 onTextChanged: Matrix.maxDropLength = text 255 } 256 257 Label { 258 text: qsTr("Min. speed") 259 } 260 TextField { 261 text: Matrix.minSpeed 262 validator: RegExpValidator { 263 regExp: /\d+\.\d+|\d+\.|\.\d+|\d+/ 264 } 265 Layout.fillWidth: true 266 267 onTextChanged: Matrix.minSpeed = text 268 } 269 270 Label { 271 text: qsTr("Max. speed") 272 } 273 TextField { 274 text: Matrix.maxSpeed 275 validator: RegExpValidator { 276 regExp: /\d+\.\d+|\d+\.|\.\d+|\d+/ 277 } 278 Layout.fillWidth: true 279 280 onTextChanged: Matrix.maxSpeed = text 281 } 282 283 Label { 284 text: qsTr("Show cursor") 285 } 286 CheckBox { 287 checked: Matrix.showCursor 288 289 onCheckedChanged: Matrix.showCursor = checked 290 } 291 292 FontDialog { 293 id: fontDialog 294 title: qsTr("Please choose a font") 295 font: Matrix.font 296 297 onAccepted: Matrix.font = font 298 } 299} 300