ConfigGeneral.qml 6.94 KB
Newer Older
1
/*
2
 *  SPDX-FileCopyrightText: 2015 Lars Pontoppidan <dev.larpon@gmail.com>
3
 *
4
 *  SPDX-License-Identifier: GPL-2.0-or-later
5 6
 */

7
import QtQuick 2.7
8 9 10
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12
import org.kde.kirigami 2.4 as Kirigami
11

12
Kirigami.FormLayout {
13
    id: root
14 15
    anchors.left: parent.left
    anchors.right: parent.right
16 17 18 19 20

    property alias cfg_randomize: randomizeCheckBox.checked
    property alias cfg_pauseOnMouseOver: pauseOnMouseOverCheckBox.checked
    property alias cfg_useBackground: useBackgroundCheckBox.checked
    property alias cfg_leftClickOpenImage: leftClickOpenImageCheckBox.checked
21
    //property alias cfg_showCountdown: showCountdownCheckBox.checked
22 23
    property alias cfg_fillMode: root.fillMode

24 25 26 27 28
    property int cfg_interval: 0
    property int hoursIntervalValue: Math.floor(cfg_interval / 3600)
    property int minutesIntervalValue: Math.floor(cfg_interval % 3600) / 60
    property int secondsIntervalValue: cfg_interval % 3600 % 60

29 30 31 32 33 34 35 36 37 38 39
    /*
     * Image.Stretch - the image is scaled to fit
     * Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping
     * Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary
     * Image.Tile - the image is duplicated horizontally and vertically
     * Image.TileVertically - the image is stretched horizontally and tiled vertically
     * Image.TileHorizontally - the image is stretched vertically and tiled horizontally
     * Image.Pad - the image is not transformed
     */
    property int fillMode: Image.PreserveAspectFit

40 41 42 43 44 45 46 47 48 49
    TextMetrics {
        id: textMetrics
        text: "00"
    }

    //FIXME: there should be only one spinbox: QtControls spinboxes are still too limited for it tough
    RowLayout {
        Layout.fillWidth: true

        Kirigami.FormData.label: i18n("Change picture every:")
50

51 52 53 54 55 56 57 58 59 60 61 62 63 64
        Connections {
            target: root
            onHoursIntervalValueChanged: hoursInterval.value = root.hoursIntervalValue
            onMinutesIntervalValueChanged: minutesInterval.value = root.minutesIntervalValue
            onSecondsIntervalValueChanged: secondsInterval.value = root.secondsIntervalValue
        }
        SpinBox {
            id: hoursInterval
            value: root.hoursIntervalValue
            from: 0
            to: 24
            editable: true
            onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
        }
65
        Label {
66 67 68 69
            text: i18n("Hours")
        }
        Item {
            Layout.preferredWidth: Kirigami.Units.gridUnit
70 71
        }
        SpinBox {
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
            id: minutesInterval
            value: root.minutesIntervalValue
            from: 0
            to: 60
            editable: true
            onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
        }
        Label {
            text: i18n("Minutes")
        }
        Item {
            Layout.preferredWidth: Kirigami.Units.gridUnit
        }
        SpinBox {
            id: secondsInterval
            value: root.secondsIntervalValue
            from: root.hoursIntervalValue === 0 && root.minutesIntervalValue === 0 ? 1 : 0
            to: 60
            editable: true
            onValueChanged: cfg_interval = hoursInterval.value * 3600 + minutesInterval.value * 60 + secondsInterval.value
        }
        Label {
            text: i18n("Seconds")
        }
    }
97

98 99 100
    Item {
        Kirigami.FormData.isSection: false
    }
101

102 103 104 105
    ComboBox {
        id: comboBox
        Kirigami.FormData.label: i18nc("@label:listbox", "Image fill mode:")

106
//         Layout.minimumWidth: Kirigami.Units.gridUnit * 10
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
        currentIndex: fillModeToIndex(fillMode)
        textRole: "text"
        model: [
            {
                text: i18nc("@item:inlistbox", "Stretch"),
                description: i18nc("@info", "The image is scaled to fit the frame"),
                value: Image.Stretch
            },
            {
                text: i18nc("@item:inlistbox", "Preserve aspect fit"),
                description: i18nc("@info", "The image is scaled uniformly to fit without cropping"),
                value: Image.PreserveAspectFit
            },
            {
                text: i18nc("@item:inlistbox", "Preserve aspect crop"),
                description: i18nc("@info", "The image is scaled uniformly to fill, cropping if necessary"),
                value: Image.PreserveAspectCrop
            },
            {
                text: i18nc("@item:inlistbox", "Tile"),
                description: i18nc("@info", "The image is duplicated horizontally and vertically"),
                value: Image.Tile
            },
            {
                text: i18nc("@item:inlistbox", "Tile vertically"),
                description: i18nc("@info", "The image is stretched horizontally and tiled vertically"),
                value: Image.TileVertically
            },
            {
                text: i18nc("@item:inlistbox", "Tile horizontally"),
                description: i18nc("@info", "The image is stretched vertically and tiled horizontally"),
                value: Image.TileHorizontally
            },
            {
                text: i18nc("@item:inlistbox", "Pad"),
                description: i18nc("@info", "The image is not transformed"),
                value: Image.Pad
            }
        ]

        onActivated: root.fillMode = comboBox.model[index].value

        function fillModeToIndex(fillMode) {
            if(fillMode == Image.Stretch) {
                return 0
            }
            else if(fillMode == Image.PreserveAspectFit) {
                return 1
            }
            else if(fillMode == Image.PreserveAspectCrop) {
                return 2
            }
            else if(fillMode == Image.Tile) {
                return 3
            }
            else if(fillMode == Image.TileVertically) {
                return 4
            }
            else if(fillMode == Image.TileHorizontally) {
                return 5
            }
            else if(fillMode == Image.Pad) {
                return 6
            }
171
        }
172
    }
173

174 175 176 177 178 179
    Label {
        id: fillModeDescription
        Layout.fillWidth: true
        wrapMode: Text.WordWrap
        text: comboBox.model[comboBox.currentIndex] ? comboBox.model[comboBox.currentIndex].description : ""
    }
180

181 182
    Item {
            Kirigami.FormData.isSection: false
183
        }
184 185 186

    CheckBox {
        id: randomizeCheckBox
187 188
        Kirigami.FormData.label: i18nc("@label:checkbox", "General:")
        text: i18nc("@option:check", "Randomize order")
189 190 191 192
    }

    CheckBox {
        id: pauseOnMouseOverCheckBox
193
        text: i18nc("@option:check", "Pause slideshow when cursor is over image")
194 195 196 197
    }

    CheckBox {
        id: useBackgroundCheckBox
198
        text: i18nc("@option:check", "Show background frame")
199 200 201 202
    }

    CheckBox {
        id: leftClickOpenImageCheckBox
203
        text: i18nc("@option:check", "Click on image to open in external application")
204
    }
205
}