blob: 27c84bdc12d6abf47bc599ec1e22ddc97c31902f [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2019-2020 by Savoir-faire Linux
3 * Author: Yang Wang <yang.wang@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.15
20import QtQuick.Window 2.14
21import QtQuick.Controls 2.14
22import QtQuick.Controls.Universal 2.12
23import QtQuick.Layouts 1.3
24import QtGraphicalEffects 1.14
25import QtQuick.Controls.Styles 1.4
26
27RowLayout {
28 property string labelText: value
29 property int widthOfSwitch: 50
30 property int heightOfSwitch: 10
31 property int heightOfLayout: 30
32 property int fontPointSize: 13
33
34 property alias toggleSwitch: switchOfLayout
35 property alias checked: switchOfLayout.checked
36
37 signal switchToggled
38
39 spacing: 18
40 Layout.fillWidth: true
41 Layout.maximumHeight: 30
42
43 Switch {
44 id: switchOfLayout
45 Layout.alignment: Qt.AlignVCenter
46
47 Layout.maximumWidth: widthOfSwitch
48 Layout.preferredWidth: widthOfSwitch
49 Layout.minimumWidth: widthOfSwitch
50
51 Layout.minimumHeight: heightOfSwitch
52 Layout.preferredHeight: heightOfSwitch
53 Layout.maximumHeight: heightOfSwitch
54
55 onToggled: {
56 switchToggled()
57 }
58 }
59
60 Label {
61 Layout.fillWidth: true
62
63 Layout.minimumHeight: heightOfLayout
64 Layout.preferredHeight: heightOfLayout
65 Layout.maximumHeight: heightOfLayout
66
67 text: qsTr(labelText)
68 font.pointSize: fontPointSize
69 font.kerning: true
70
71 horizontalAlignment: Text.AlignLeft
72 verticalAlignment: Text.AlignVCenter
73 }
74}