Changeset View
Changeset View
Standalone View
Standalone View
applets/mediaframe/package/contents/ui/ConfigGeneral.qml
Show All 11 Lines | |||||
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.7 | 19 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 1.5 | 20 | import QtQuick.Controls 2.5 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.12 | ||
22 | import org.kde.kirigami 2.4 as Kirigami | ||||
22 | 23 | | |||
23 | ColumnLayout { | 24 | Kirigami.FormLayout { | ||
24 | id: root | 25 | id: root | ||
26 | anchors.left: parent.left | ||||
27 | anchors.right: parent.right | ||||
25 | 28 | | |||
26 | property alias cfg_interval: intervalSpinBox.value | | |||
27 | property alias cfg_randomize: randomizeCheckBox.checked | 29 | property alias cfg_randomize: randomizeCheckBox.checked | ||
28 | property alias cfg_pauseOnMouseOver: pauseOnMouseOverCheckBox.checked | 30 | property alias cfg_pauseOnMouseOver: pauseOnMouseOverCheckBox.checked | ||
29 | property alias cfg_useBackground: useBackgroundCheckBox.checked | 31 | property alias cfg_useBackground: useBackgroundCheckBox.checked | ||
30 | property alias cfg_leftClickOpenImage: leftClickOpenImageCheckBox.checked | 32 | property alias cfg_leftClickOpenImage: leftClickOpenImageCheckBox.checked | ||
31 | //property alias cfg_showCountdown: showCountdownCheckBox.checked | 33 | //property alias cfg_showCountdown: showCountdownCheckBox.checked | ||
32 | property alias cfg_fillMode: root.fillMode | 34 | property alias cfg_fillMode: root.fillMode | ||
33 | 35 | | |||
36 | property int cfg_interval: 0 | ||||
37 | property int hoursIntervalValue: Math.floor(cfg_interval / 3600) | ||||
38 | property int minutesIntervalValue: Math.floor(cfg_interval % 3600) / 60 | ||||
39 | property int secondsIntervalValue: cfg_interval % 3600 % 60 | ||||
40 | | ||||
34 | /* | 41 | /* | ||
35 | * Image.Stretch - the image is scaled to fit | 42 | * Image.Stretch - the image is scaled to fit | ||
36 | * Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping | 43 | * Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping | ||
37 | * Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary | 44 | * Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary | ||
38 | * Image.Tile - the image is duplicated horizontally and vertically | 45 | * Image.Tile - the image is duplicated horizontally and vertically | ||
39 | * Image.TileVertically - the image is stretched horizontally and tiled vertically | 46 | * Image.TileVertically - the image is stretched horizontally and tiled vertically | ||
40 | * Image.TileHorizontally - the image is stretched vertically and tiled horizontally | 47 | * Image.TileHorizontally - the image is stretched vertically and tiled horizontally | ||
41 | * Image.Pad - the image is not transformed | 48 | * Image.Pad - the image is not transformed | ||
42 | */ | 49 | */ | ||
43 | property int fillMode: Image.PreserveAspectFit | 50 | property int fillMode: Image.PreserveAspectFit | ||
44 | 51 | | |||
45 | GridLayout { | 52 | TextMetrics { | ||
46 | columns: 2 | 53 | id: textMetrics | ||
54 | text: "00" | ||||
55 | } | ||||
56 | | ||||
57 | //FIXME: there should be only one spinbox: QtControls spinboxes are still too limited for it tough | ||||
58 | RowLayout { | ||||
59 | Layout.fillWidth: true | ||||
60 | spacing: Kirigami.Units.largeSpacing / 2 | ||||
filipf: Do we need this? It ends up looking the same for me without it. | |||||
47 | 61 | | |||
62 | Kirigami.FormData.label: i18n("Change picture every:") | ||||
63 | | ||||
64 | Connections { | ||||
65 | target: root | ||||
66 | onHoursIntervalValueChanged: hoursInterval.value = root.hoursIntervalValue | ||||
67 | onMinutesIntervalValueChanged: minutesInterval.value = root.minutesIntervalValue | ||||
68 | onSecondsIntervalValueChanged: secondsInterval.value = root.secondsIntervalValue | ||||
69 | } | ||||
70 | SpinBox { | ||||
71 | id: hoursInterval | ||||
72 | Layout.minimumWidth: textMetrics.width + Kirigami.Units.gridUnit | ||||
And do we need to set this? I removed Layout.minimumWidth and width for all the spinboxes, everything looks the same and the numbers fit in nicely. filipf: And do we need to set this? I removed `Layout.minimumWidth` and width for all the `spinboxes`… | |||||
73 | width: Kirigami.Units.gridUnit * 3 | ||||
filipf: Ditto. | |||||
74 | value: root.hoursIntervalValue | ||||
75 | from: 0 | ||||
76 | to: 24 | ||||
77 | editable: true | ||||
78 | onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value | ||||
79 | } | ||||
48 | Label { | 80 | Label { | ||
49 | Layout.row: 0 | 81 | text: i18n("Hours") | ||
50 | Layout.column: 0 | 82 | } | ||
51 | Layout.alignment: Qt.AlignRight | 83 | Item { | ||
52 | text: i18nc("@label:spinbox", "Change picture every") | 84 | Layout.preferredWidth: Kirigami.Units.gridUnit | ||
53 | } | 85 | } | ||
54 | | ||||
55 | SpinBox { | 86 | SpinBox { | ||
56 | id: intervalSpinBox | 87 | id: minutesInterval | ||
57 | Layout.row: 0 | 88 | Layout.minimumWidth: textMetrics.width + Kirigami.Units.gridUnit | ||
58 | Layout.column: 1 | 89 | width: Kirigami.Units.gridUnit * 3 | ||
59 | suffix: i18nc("@item:valuesuffix spacing to number + unit (seconds)", " s") | 90 | value: root.minutesIntervalValue | ||
60 | decimals: 1 | 91 | from: 0 | ||
61 | 92 | to: 60 | |||
62 | // Once a day should be high enough | 93 | editable: true | ||
63 | maximumValue: 24*(60*60) | 94 | onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value | ||
64 | } // end SpinBox | 95 | } | ||
65 | 96 | Label { | |||
97 | text: i18n("Minutes") | ||||
98 | } | ||||
99 | Item { | ||||
100 | Layout.preferredWidth: Kirigami.Units.gridUnit | ||||
101 | } | ||||
102 | SpinBox { | ||||
103 | id: secondsInterval | ||||
104 | Layout.minimumWidth: textMetrics.width + Kirigami.Units.gridUnit | ||||
105 | width: Kirigami.Units.gridUnit * 3 | ||||
106 | value: root.secondsIntervalValue | ||||
107 | from: root.hoursIntervalValue === 0 && root.minutesIntervalValue === 0 ? 1 : 0 | ||||
108 | to: 60 | ||||
109 | editable: true | ||||
110 | onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value | ||||
111 | } | ||||
66 | Label { | 112 | Label { | ||
67 | id: fillLabel | 113 | text: i18n("Seconds") | ||
68 | Layout.row: 1 | 114 | } | ||
69 | Layout.column: 0 | 115 | } | ||
70 | Layout.alignment: Qt.AlignRight | 116 | | ||
71 | text: i18nc("@label:listbox", "Fill mode:") | 117 | Item { | ||
118 | Kirigami.FormData.isSection: false | ||||
72 | } | 119 | } | ||
73 | 120 | | |||
74 | ComboBox { | 121 | ComboBox { | ||
QQC2 Combobox seems to be behaving well here. What I did in my task manager port was add (or keep?) Layout.fillWidth; true to all of the comboboxes. But because the first RowLayout is quite wide it would look odd here so perhaps it's better to leave it as it is, right? filipf: QQC2 Combobox seems to be behaving well here. What I did in my task manager port was add (or… | |||||
75 | id: comboBox | 122 | id: comboBox | ||
76 | Layout.row: 1 | 123 | Kirigami.FormData.label: i18nc("@label:listbox", "Image fill mode:") | ||
77 | Layout.column: 1 | 124 | | ||
78 | width: units.gridUnit * 10 | 125 | // Layout.minimumWidth: units.gridUnit * 10 | ||
79 | currentIndex: fillModeToIndex(fillMode) | 126 | currentIndex: fillModeToIndex(fillMode) | ||
127 | textRole: "text" | ||||
80 | model: [ | 128 | model: [ | ||
81 | { | 129 | { | ||
82 | text: i18nc("@item:inlistbox", "Stretch"), | 130 | text: i18nc("@item:inlistbox", "Stretch"), | ||
83 | description: i18nc("@info", "The image is scaled to fit the frame"), | 131 | description: i18nc("@info", "The image is scaled to fit the frame"), | ||
84 | value: Image.Stretch | 132 | value: Image.Stretch | ||
85 | }, | 133 | }, | ||
86 | { | 134 | { | ||
87 | text: i18nc("@item:inlistbox", "Preserve aspect fit"), | 135 | text: i18nc("@item:inlistbox", "Preserve aspect fit"), | ||
Show All 20 Lines | 154 | { | |||
108 | description: i18nc("@info", "The image is stretched vertically and tiled horizontally"), | 156 | description: i18nc("@info", "The image is stretched vertically and tiled horizontally"), | ||
109 | value: Image.TileHorizontally | 157 | value: Image.TileHorizontally | ||
110 | }, | 158 | }, | ||
111 | { | 159 | { | ||
112 | text: i18nc("@item:inlistbox", "Pad"), | 160 | text: i18nc("@item:inlistbox", "Pad"), | ||
113 | description: i18nc("@info", "The image is not transformed"), | 161 | description: i18nc("@info", "The image is not transformed"), | ||
114 | value: Image.Pad | 162 | value: Image.Pad | ||
115 | } | 163 | } | ||
116 | ] // end of ComboBox model | 164 | ] | ||
117 | 165 | | |||
118 | onActivated: root.fillMode = comboBox.model[index].value | 166 | onActivated: root.fillMode = comboBox.model[index].value | ||
119 | 167 | | |||
120 | function fillModeToIndex(fillMode) { | 168 | function fillModeToIndex(fillMode) { | ||
121 | if(fillMode == Image.Stretch) { | 169 | if(fillMode == Image.Stretch) { | ||
122 | return 0 | 170 | return 0 | ||
123 | } | 171 | } | ||
124 | else if(fillMode == Image.PreserveAspectFit) { | 172 | else if(fillMode == Image.PreserveAspectFit) { | ||
Show All 9 Lines | 181 | else if(fillMode == Image.TileVertically) { | |||
134 | return 4 | 182 | return 4 | ||
135 | } | 183 | } | ||
136 | else if(fillMode == Image.TileHorizontally) { | 184 | else if(fillMode == Image.TileHorizontally) { | ||
137 | return 5 | 185 | return 5 | ||
138 | } | 186 | } | ||
139 | else if(fillMode == Image.Pad) { | 187 | else if(fillMode == Image.Pad) { | ||
140 | return 6 | 188 | return 6 | ||
141 | } | 189 | } | ||
142 | } // end of fillModeToIndex function | 190 | } | ||
143 | } // end of ComboBox and related functions | 191 | } | ||
144 | 192 | | |||
145 | Label { | 193 | Label { | ||
146 | id: fillModeDescription | 194 | id: fillModeDescription | ||
147 | Layout.row: 2 | | |||
148 | Layout.column: 1 | | |||
149 | Layout.fillWidth: true | 195 | Layout.fillWidth: true | ||
150 | wrapMode: Text.WordWrap | 196 | wrapMode: Text.WordWrap | ||
151 | text: comboBox.model[comboBox.currentIndex] ? comboBox.model[comboBox.currentIndex].description : "" | 197 | text: comboBox.model[comboBox.currentIndex] ? comboBox.model[comboBox.currentIndex].description : "" | ||
152 | } | 198 | } | ||
153 | } // end of top section GridLayout | | |||
154 | 199 | | |||
155 | // these CheckBoxes should take over as their own ColumnLayout entries | 200 | Item { | ||
201 | Kirigami.FormData.isSection: false | ||||
202 | } | ||||
203 | | ||||
156 | CheckBox { | 204 | CheckBox { | ||
157 | id: randomizeCheckBox | 205 | id: randomizeCheckBox | ||
158 | text: i18nc("@option:check", "Randomize items") | 206 | Kirigami.FormData.label: i18nc("@label:checkbox", "General:") | ||
207 | text: i18nc("@option:check", "Randomize order") | ||||
159 | } | 208 | } | ||
160 | 209 | | |||
161 | CheckBox { | 210 | CheckBox { | ||
162 | id: pauseOnMouseOverCheckBox | 211 | id: pauseOnMouseOverCheckBox | ||
163 | text: i18nc("@option:check", "Pause on mouse-over") | 212 | text: i18nc("@option:check", "Pause slideshow when cursor is over image") | ||
164 | } | 213 | } | ||
165 | 214 | | |||
166 | CheckBox { | 215 | CheckBox { | ||
167 | id: useBackgroundCheckBox | 216 | id: useBackgroundCheckBox | ||
168 | text: i18nc("@option:check", "Background frame") | 217 | text: i18nc("@option:check", "Show background frame") | ||
169 | } | 218 | } | ||
170 | 219 | | |||
171 | CheckBox { | 220 | CheckBox { | ||
172 | id: leftClickOpenImageCheckBox | 221 | id: leftClickOpenImageCheckBox | ||
173 | text: i18nc("@option:check", "Left click image opens in external viewer") | 222 | text: i18nc("@option:check", "Click on image to open in external application") | ||
174 | } | 223 | } | ||
175 | | ||||
176 | Item { // tighten layout | | |||
177 | Layout.fillHeight: true | | |||
178 | } | 224 | } | ||
179 | } // end ColumnLayout | |
Do we need this? It ends up looking the same for me without it.