1/* 2 * Copyright (c) 2015-2021 Meltytech, LLC 3 * 4 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18import QtQuick 2.12 19import QtQuick.Controls 2.12 20import QtQuick.Layouts 1.12 21import Shotcut.Controls 1.0 as Shotcut 22 23Item { 24 property string colorParam: '0' 25 property string colorDefault: '#00ef00' 26 property string distanceParam: '1' 27 property double distanceDefault: 28.8 28 property var defaultParameters: [colorParam, distanceParam] 29 width: 350 30 height: 50 31 Component.onCompleted: { 32 presetItem.parameters = defaultParameters 33 filter.set('threads', 0) 34 if (filter.isNew) { 35 // Set default parameter values 36 filter.set(colorParam, colorDefault) 37 filter.set(distanceParam, distanceDefault / 100) 38 filter.savePreset(defaultParameters) 39 } 40 colorPicker.value = filter.get(colorParam) 41 distanceSlider.value = filter.getDouble(distanceParam) * 100 42 } 43 44 GridLayout { 45 columns: 3 46 anchors.fill: parent 47 anchors.margins: 8 48 49 Label { 50 text: qsTr('Preset') 51 Layout.alignment: Qt.AlignRight 52 } 53 Shotcut.Preset { 54 id: presetItem 55 Layout.columnSpan: 2 56 onPresetSelected: { 57 colorPicker.value = filter.get(colorParam) 58 distanceSlider.value = filter.getDouble(distanceParam) * 100 59 } 60 } 61 62 // Row 1 63 Label { 64 text: qsTr('Key color') 65 Layout.alignment: Qt.AlignRight 66 } 67 Shotcut.ColorPicker { 68 id: colorPicker 69 onValueChanged: { 70 filter.set(colorParam, value) 71 filter.set('disable', 0) 72 } 73 onPickStarted: filter.set('disable', 1) 74 onPickCancelled: filter.set('disable', 0) 75 } 76 Shotcut.UndoButton { 77 onClicked: colorPicker.value = colorDefault 78 } 79 80 // Row 2 81 Label { 82 text: qsTr('Distance') 83 Layout.alignment: Qt.AlignRight 84 } 85 Shotcut.SliderSpinner { 86 id: distanceSlider 87 minimumValue: 0 88 maximumValue: 100 89 decimals: 1 90 suffix: ' %' 91 value: filter.getDouble(distanceParam) * 100 92 onValueChanged: filter.set(distanceParam, value / 100) 93 } 94 Shotcut.UndoButton { 95 onClicked: distanceSlider.value = distanceDefault 96 } 97 98 Item { 99 Layout.fillHeight: true 100 } 101 } 102} 103