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: 3 28 29 function fromRgba(rgba) 30 { 31 var a = ((rgba >> 24) & 0xff) / 255.0 32 var r = ((rgba >> 16) & 0xff) / 255.0 33 var g = ((rgba >> 8) & 0xff) / 255.0 34 var b = (rgba & 0xff) / 255.0 35 36 return Qt.rgba(r, g, b, a) 37 } 38 39 function toRgba(color) 40 { 41 var a = Math.round(255 * color.a) << 24 42 var r = Math.round(255 * color.r) << 16 43 var g = Math.round(255 * color.g) << 8 44 var b = Math.round(255 * color.b) 45 46 return a | r | g | b 47 } 48 49 Connections { 50 target: Wave 51 52 onAmplitudeChanged: { 53 sldAmplitude.value = amplitude 54 spbAmplitude.rvalue = amplitude 55 } 56 57 onFrequencyChanged: { 58 sldFrequency.value = frequency 59 spbFrequency.rvalue = frequency 60 } 61 62 onPhaseChanged: { 63 sldPhase.value = phase 64 spbPhase.rvalue = phase 65 } 66 } 67 68 Label { 69 id: lblAmplitude 70 text: qsTr("Amplitude") 71 } 72 Slider { 73 id: sldAmplitude 74 value: Wave.amplitude 75 stepSize: 0.01 76 to: 1 77 Layout.fillWidth: true 78 79 onValueChanged: Wave.amplitude = value 80 } 81 AkSpinBox { 82 id: spbAmplitude 83 decimals: 2 84 rvalue: Wave.amplitude 85 maximumValue: sldAmplitude.to 86 step: sldAmplitude.stepSize 87 88 onRvalueChanged: Wave.amplitude = rvalue 89 } 90 91 Label { 92 id: lblFrequency 93 text: qsTr("Frequency") 94 } 95 Slider { 96 id: sldFrequency 97 value: Wave.frequency 98 stepSize: 0.01 99 to: 100 100 Layout.fillWidth: true 101 102 onValueChanged: Wave.frequency = value 103 } 104 AkSpinBox { 105 id: spbFrequency 106 decimals: 2 107 rvalue: Wave.frequency 108 maximumValue: sldFrequency.to 109 step: sldFrequency.stepSize 110 111 onRvalueChanged: Wave.frequency = rvalue 112 } 113 114 Label { 115 id: lblPhase 116 text: qsTr("Phase") 117 } 118 Slider { 119 id: sldPhase 120 value: Wave.phase 121 stepSize: 0.01 122 to: 1 123 Layout.fillWidth: true 124 125 onValueChanged: Wave.phase = value 126 } 127 AkSpinBox { 128 id: spbPhase 129 decimals: 2 130 rvalue: Wave.phase 131 maximumValue: sldPhase.to 132 step: sldPhase.stepSize 133 134 onRvalueChanged: Wave.phase = rvalue 135 } 136 137 Label { 138 text: qsTr("Background color") 139 } 140 AkColorButton { 141 currentColor: fromRgba(Wave.background) 142 title: qsTr("Choose the background color") 143 144 onCurrentColorChanged: Wave.background = toRgba(currentColor) 145 } 146 Label { 147 } 148} 149