ElisaConfigurationDialog.qml 4.08 KB
Newer Older
1 2 3
/*
 * Copyright 2017 Matthieu Gallien <matthieu_gallien@yahoo.fr>
 *
4 5
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
6 7 8
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
9
 * This program is distributed in the hope that it will be useful,
10 11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14 15
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16 17
 */

18 19
import QtQuick 2.11
import QtQuick.Controls 2.4
20 21
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
22
import QtQml.Models 2.3
23
import org.kde.kirigami 2.5 as Kirigami
24

25
Window {
26
    id: dialog
27 28

    title: i18n("Configure")
29

30 31
    visible: true
    modality: Qt.ApplicationModal
32 33 34

    minimumWidth: 600
    minimumHeight: 400
35

36 37 38 39 40 41
    Shortcut {
        sequence: StandardKey.Cancel

        onActivated: close()
    }

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    SystemPalette {
        id: myPalette
        colorGroup: SystemPalette.Active
    }

    Component {
        id: highlightBar

        Rectangle {
            width: 200; height: 50
            color: myPalette.highlight
        }
    }

    RowLayout {
        spacing: 0

59 60 61
        anchors.fill: parent
        anchors.margins: 0

Alexander Stippich's avatar
Alexander Stippich committed
62
        ListView {
63
            id: pagesList
64 65

            Layout.fillHeight: true
66 67
            Layout.preferredWidth: 150

Alexander Stippich's avatar
Alexander Stippich committed
68
            boundsBehavior: Flickable.StopAtBounds
69

70 71 72 73 74
            delegate: ItemDelegate {
                text: model.pageName
                icon.name: model.iconName

                width: pagesList.width
75

76 77 78 79 80
                onClicked: pagesList.currentIndex = index
            }

            model: ListModel {
                id: settingsPagesModel
Alexander Stippich's avatar
Alexander Stippich committed
81
            }
82

Alexander Stippich's avatar
Alexander Stippich committed
83 84
            ScrollBar.vertical: ScrollBar {
                id: scrollBar
85
            }
Alexander Stippich's avatar
Alexander Stippich committed
86 87

            highlight: highlightBar
88 89
        }

90
        Kirigami.Separator {
91
            Layout.fillHeight: true
92
        }
93

94 95 96
        Rectangle {
            Layout.fillHeight: true
            Layout.fillWidth: true
97

98
            color: myPalette.window
99

100 101
            ColumnLayout {
                spacing: 0
102

103
                anchors.fill: parent
104

105 106 107
                StackLayout {
                    Layout.fillWidth: true
                    Layout.fillHeight: true
108

109 110 111 112 113 114 115
                    Layout.leftMargin: 10
                    Layout.rightMargin: 10
                    Layout.topMargin: 10
                    Layout.bottomMargin: 10

                    currentIndex: pagesList.currentIndex

116
                    GeneralConfiguration {
117 118 119
                    }

                    FileScanningConfiguration {
120 121 122
                    }
                }

123 124 125
                DialogButtonBox {
                    Layout.fillWidth: true

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                    Button {
                        text: i18n("OK")
                        DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
                    }

                    Button {
                        text: i18n("Apply")
                        DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole

                        enabled: config.isDirty
                    }

                    Button {
                        text: i18n("Cancel")
                        DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
                    }
142 143 144 145 146 147 148 149 150 151

                    onAccepted: {
                        config.save()
                        close()
                    }

                    onApplied: config.save()

                    onRejected: close()
                }
152 153 154
            }
        }
    }
155

156 157 158
    Component.onCompleted: {
        settingsPagesModel.insert(0, { "pageName": i18nc("Settings page about main preference", "General"), "iconName": 'settings-configure' })
        settingsPagesModel.insert(1, { "pageName": i18nc("Settings page about music search folders configuration", "Music Search Folders"), "iconName": 'folder-music' })
159
    }
160
}