OutputPanel.qml 4.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/********************************************************************
Copyright © 2019 Roman Gilg <subdiff@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.9
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.3 as Controls
import org.kde.kirigami 2.4 as Kirigami

Nate Graham's avatar
Nate Graham committed
22
23
import org.kde.kcm 1.2 as KCM

24
25
26
27
28
ColumnLayout {
    id: outputPanel
    property var element: model

    Kirigami.FormLayout {
Nate Graham's avatar
Nate Graham committed
29
        twinFormLayouts: globalSettingsLayout
30
31
32
33
34

        Controls.CheckBox {
           text: i18n("Enabled")
           checked: element.enabled
           onClicked: element.enabled = checked
Nate Graham's avatar
Nate Graham committed
35
           visible: kcm.outputModel.rowCount() > 1
36
37
38
39
40
41
        }

        Controls.CheckBox {
           text: i18n("Primary")
           checked: element.primary
           onClicked: element.primary = checked
Nate Graham's avatar
Nate Graham committed
42
           visible: kcm.primaryOutputSupported && kcm.outputModel.rowCount() > 1
43
44
45
46
47
48
49
50
51
52
        }

        Controls.ComboBox {
            Kirigami.FormData.label: i18n("Resolution:")
            model: element.resolutions
            currentIndex: element.resolutionIndex !== undefined ?
                              element.resolutionIndex : -1
            onActivated: element.resolutionIndex = currentIndex
        }

Nate Graham's avatar
Nate Graham committed
53
        RowLayout {
54
55
56
57
            Layout.fillWidth: true

            visible: kcm.perOutputScaling
            Kirigami.FormData.label: i18n("Scale:")
Nate Graham's avatar
Nate Graham committed
58

59
60
61
62
63
64
            Controls.Slider {
                id: scaleSlider

                Layout.fillWidth: true
                from: 0.5
                to: 3
65
                stepSize: 0.25
66
67
68
69
                live: true
                value: element.scale
                onMoved: element.scale = value
            }
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
            Controls.SpinBox {
                id: spinbox
                // Because QQC2 SpinBox doesn't natively support decimal step
                // sizes: https://bugreports.qt.io/browse/QTBUG-67349
                property real factor: 20.0
                property real realValue: value / factor

                from : 0.5 * factor
                to : 3.0 * factor
                stepSize: 0.05 * factor
                value: element.scale * factor
                validator: DoubleValidator {
                    bottom: Math.min(spinbox.from, spinbox.to) * spinbox.factor
                    top:  Math.max(spinbox.from, spinbox.to) * spinbox.factor
                }
                textFromValue: function(value, locale) {
86
                    return i18nc("Global scale factor expressed in percentage form", "%1%", parseFloat(value * 1.0 / factor * 100.0));
87
88
                }
                valueFromText: function(text, locale) {
89
                    return Number.fromLocaleString(locale, text) * factor / 100.0
90
91
                }
                onValueModified: element.scale = realValue
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
            }
        }

        Controls.ButtonGroup {
            buttons: orientation.children
        }

        RowLayout {
           id: orientation
           Kirigami.FormData.label: i18n("Orientation:")

           RotationButton {
               value: 0
           }
           RotationButton {
               value: 90
           }
           RotationButton {
               value: 180
           }
           RotationButton {
               value: 270
           }
        }

        Controls.ComboBox {
            Kirigami.FormData.label: i18n("Refresh rate:")
            model: element.refreshRates
            currentIndex: element.refreshRateIndex ?
                              element.refreshRateIndex : 0
            onActivated: element.refreshRateIndex = currentIndex
        }
124
125
126
127

        Controls.ComboBox {
            Kirigami.FormData.label: i18n("Replica of:")
            model: element.replicationSourceModel
Nate Graham's avatar
Nate Graham committed
128
            visible: kcm.outputReplicationSupported && kcm.outputModel && kcm.outputModel.rowCount() > 1
129
130
131
132
133
134
135

            onModelChanged: enabled = (count > 1);
            onCountChanged: enabled = (count > 1);

            currentIndex: element.replicationSourceIndex
            onActivated: element.replicationSourceIndex = currentIndex
        }
136
137
    }
}