Warning, /plasma/kdeplasma-addons/applets/mediaframe/package/contents/ui/ConfigGeneral.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Lars Pontoppidan <dev.larpon@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010 import org.kde.kirigami 2.4 as Kirigami
0011 import org.kde.kcmutils as KCM
0012 
0013 KCM.SimpleKCM {
0014     id: root
0015 
0016     property alias cfg_randomize: randomizeCheckBox.checked
0017     property alias cfg_pauseOnMouseOver: pauseOnMouseOverCheckBox.checked
0018     property alias cfg_leftClickOpenImage: leftClickOpenImageCheckBox.checked
0019     //property alias cfg_showCountdown: showCountdownCheckBox.checked
0020     property alias cfg_fillMode: root.fillMode
0021 
0022     property int cfg_interval: 0
0023     property int hoursIntervalValue: Math.floor(cfg_interval / 3600)
0024     property int minutesIntervalValue: Math.floor(cfg_interval % 3600) / 60
0025     property int secondsIntervalValue: cfg_interval % 3600 % 60
0026 
0027     /*
0028     * Image.Stretch - the image is scaled to fit
0029     * Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping
0030     * Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary
0031     * Image.Tile - the image is duplicated horizontally and vertically
0032     * Image.TileVertically - the image is stretched horizontally and tiled vertically
0033     * Image.TileHorizontally - the image is stretched vertically and tiled horizontally
0034     * Image.Pad - the image is not transformed
0035     */
0036     property int fillMode: Image.PreserveAspectFit
0037 
0038     Kirigami.FormLayout {
0039         TextMetrics {
0040             id: textMetrics
0041             text: "00"
0042         }
0043 
0044         //FIXME: there should be only one spinbox: QtControls spinboxes are still too limited for it tough
0045         RowLayout {
0046             Layout.fillWidth: true
0047 
0048             Kirigami.FormData.label: i18n("Change picture every:")
0049 
0050             Connections {
0051                 target: root
0052                 function onHoursIntervalValueChanged() {hoursInterval.value = root.hoursIntervalValue}
0053                 function onMinutesIntervalValueChanged() {minutesInterval.value = root.minutesIntervalValue}
0054                 function onSecondsIntervalValueChanged() {secondsInterval.value = root.secondsIntervalValue}
0055             }
0056             SpinBox {
0057                 id: hoursInterval
0058                 value: root.hoursIntervalValue
0059                 from: 0
0060                 to: 24
0061                 editable: true
0062                 onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
0063             }
0064             Label {
0065                 text: i18n("Hours")
0066             }
0067             Item {
0068                 Layout.preferredWidth: Kirigami.Units.gridUnit
0069             }
0070             SpinBox {
0071                 id: minutesInterval
0072                 value: root.minutesIntervalValue
0073                 from: 0
0074                 to: 60
0075                 editable: true
0076                 onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
0077             }
0078             Label {
0079                 text: i18n("Minutes")
0080             }
0081             Item {
0082                 Layout.preferredWidth: Kirigami.Units.gridUnit
0083             }
0084             SpinBox {
0085                 id: secondsInterval
0086                 value: root.secondsIntervalValue
0087                 from: root.hoursIntervalValue === 0 && root.minutesIntervalValue === 0 ? 1 : 0
0088                 to: 60
0089                 editable: true
0090                 onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
0091             }
0092             Label {
0093                 text: i18n("Seconds")
0094             }
0095         }
0096 
0097         Item {
0098             Kirigami.FormData.isSection: false
0099         }
0100 
0101         ComboBox {
0102             id: comboBox
0103             Kirigami.FormData.label: i18nc("@label:listbox", "Image fill mode:")
0104 
0105     //         Layout.minimumWidth: Kirigami.Units.gridUnit * 10
0106             currentIndex: fillModeToIndex(fillMode)
0107             textRole: "text"
0108             model: [
0109                 {
0110                     text: i18nc("@item:inlistbox", "Stretch"),
0111                     description: i18nc("@info", "The image is scaled to fit the frame"),
0112                     value: Image.Stretch
0113                 },
0114                 {
0115                     text: i18nc("@item:inlistbox", "Preserve aspect fit"),
0116                     description: i18nc("@info", "The image is scaled uniformly to fit without cropping"),
0117                     value: Image.PreserveAspectFit
0118                 },
0119                 {
0120                     text: i18nc("@item:inlistbox", "Preserve aspect crop"),
0121                     description: i18nc("@info", "The image is scaled uniformly to fill, cropping if necessary"),
0122                     value: Image.PreserveAspectCrop
0123                 },
0124                 {
0125                     text: i18nc("@item:inlistbox", "Tile"),
0126                     description: i18nc("@info", "The image is duplicated horizontally and vertically"),
0127                     value: Image.Tile
0128                 },
0129                 {
0130                     text: i18nc("@item:inlistbox", "Tile vertically"),
0131                     description: i18nc("@info", "The image is stretched horizontally and tiled vertically"),
0132                     value: Image.TileVertically
0133                 },
0134                 {
0135                     text: i18nc("@item:inlistbox", "Tile horizontally"),
0136                     description: i18nc("@info", "The image is stretched vertically and tiled horizontally"),
0137                     value: Image.TileHorizontally
0138                 },
0139                 {
0140                     text: i18nc("@item:inlistbox", "Pad"),
0141                     description: i18nc("@info", "The image is not transformed"),
0142                     value: Image.Pad
0143                 }
0144             ]
0145 
0146             onActivated: root.fillMode = comboBox.model[index].value
0147 
0148             function fillModeToIndex(fillMode) {
0149                 if(fillMode == Image.Stretch) {
0150                     return 0
0151                 }
0152                 else if(fillMode == Image.PreserveAspectFit) {
0153                     return 1
0154                 }
0155                 else if(fillMode == Image.PreserveAspectCrop) {
0156                     return 2
0157                 }
0158                 else if(fillMode == Image.Tile) {
0159                     return 3
0160                 }
0161                 else if(fillMode == Image.TileVertically) {
0162                     return 4
0163                 }
0164                 else if(fillMode == Image.TileHorizontally) {
0165                     return 5
0166                 }
0167                 else if(fillMode == Image.Pad) {
0168                     return 6
0169                 }
0170             }
0171         }
0172 
0173         Label {
0174             id: fillModeDescription
0175             Layout.fillWidth: true
0176             wrapMode: Text.WordWrap
0177             text: comboBox.model[comboBox.currentIndex] ? comboBox.model[comboBox.currentIndex].description : ""
0178         }
0179 
0180         Item {
0181                 Kirigami.FormData.isSection: false
0182             }
0183 
0184         CheckBox {
0185             id: randomizeCheckBox
0186             Kirigami.FormData.label: i18nc("@label:checkbox", "General:")
0187             text: i18nc("@option:check", "Randomize order")
0188         }
0189 
0190         CheckBox {
0191             id: pauseOnMouseOverCheckBox
0192             text: i18nc("@option:check", "Pause slideshow when cursor is over image")
0193         }
0194 
0195         CheckBox {
0196             id: leftClickOpenImageCheckBox
0197             text: i18nc("@option:check", "Click on image to open in external application")
0198         }
0199     }
0200 }