ElisaConfigurationDialog.qml 4.35 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
import QtQuick.Layouts 1.3
21
import QtQuick.Dialogs 1.2 as Dialogs
22
23
import QtQml.Models 2.3

24
25
26
Dialogs.Dialog {
    id: dialog
    title: 'Configure'
27

28
29
30
    visible: true
    modality: Qt.ApplicationModal
    standardButtons: Dialogs.StandardButton.Ok | Dialogs.StandardButton.Apply | Dialogs.StandardButton.Cancel
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

    SystemPalette {
        id: myPalette
        colorGroup: SystemPalette.Active
    }

    Component {
        id: highlightBar

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

    Component {
        id: pathDelegate

        Item {
            id: delegateItem

52
            height: 3 * 30
53

Alexander Stippich's avatar
Alexander Stippich committed
54
            width: scrollBar.visible ? pathList.width - scrollBar.width : pathList.width
55
56
57

            Rectangle {
                anchors.fill: parent
58
                anchors.margins: 0.1 * 30
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

                color: myPalette.base

                MouseArea {
                    anchors.fill: parent

                    hoverEnabled: true

                    onEntered: pathList.currentIndex = delegateItem.DelegateModel.itemsIndex

                    Label {
                        text: modelData

                        anchors.centerIn: parent
                    }

                    ToolButton {
Alexander Stippich's avatar
Alexander Stippich committed
76
                        icon.name: 'list-remove'
77

78
79
                        Accessible.onPressAction: onClicked

80
81
82
83
84
                        anchors.top: parent.top
                        anchors.right: parent.right

                        onClicked:
                        {
85
                            var oldPaths = config.rootPath
86
                            oldPaths.splice(delegateItem.DelegateModel.itemsIndex, 1)
87
                            config.rootPath = oldPaths
88
89
90
91
92
93
94
95
96
97
                        }
                    }
                }
            }
        }
    }

    RowLayout {
        spacing: 0

98
99
100
        LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
        LayoutMirroring.childrenInherit: true

101
102
103
        anchors.fill: parent
        anchors.margins: 0

104
        implicitWidth: 600
105
        implicitHeight: 400
106

Alexander Stippich's avatar
Alexander Stippich committed
107
108
        ListView {
            id:pathList
109
110
111

            Layout.fillWidth: true
            Layout.fillHeight: true
Alexander Stippich's avatar
Alexander Stippich committed
112
            boundsBehavior: Flickable.StopAtBounds
113

Alexander Stippich's avatar
Alexander Stippich committed
114
            model: DelegateModel {
115
                model: config.rootPath
116

Alexander Stippich's avatar
Alexander Stippich committed
117
118
                delegate: pathDelegate
            }
119

Alexander Stippich's avatar
Alexander Stippich committed
120
121
            ScrollBar.vertical: ScrollBar {
                id: scrollBar
122
            }
Alexander Stippich's avatar
Alexander Stippich committed
123
124

            highlight: highlightBar
125
126
127
128
        }

        ColumnLayout {
            Layout.fillHeight: true
Safa AlFulaij's avatar
Safa AlFulaij committed
129
130
            Layout.leftMargin: !LayoutMirroring.enabled ? (0.3 * 30) : 0
            Layout.rightMargin: LayoutMirroring.enabled ? (0.3 * 30) : 0
131
132

            Button {
133
                text: i18n("Add new path")
134
135
                onClicked: fileDialog.open()

136
137
                Accessible.onPressAction: onClicked

138
139
                Layout.alignment: Qt.AlignTop | Qt.AlignLeft

140
                Dialogs.FileDialog {
141
                    id: fileDialog
142
                    title: i18n("Choose a Folder")
143
144
145
146
147
148
                    folder: shortcuts.home
                    selectFolder: true

                    visible: false

                    onAccepted: {
149
                        var oldPaths = config.rootPath
150
                        oldPaths.push(fileDialog.fileUrls)
151
                        config.rootPath = oldPaths
152
153
154
155
156
157
158
159
160
                    }
                }
            }

            Item {
                Layout.fillHeight: true
            }
        }
    }
161
162
163
164
165
166
167

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

    onApply: config.save()
168
}