SettingsView.qml 6.44 KB
Newer Older
1
2
3
4
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.12
5
import QtQuick.Dialogs 1.3 as SystemDialog
6
import QtQuick.Window 2.12
Leander Schulten's avatar
Leander Schulten committed
7
import "components"
8
9
10
11
12

Pane{
    GridLayout{
        anchors.left: parent.left
        anchors.right: parent.right
13
        rowSpacing: 16
14
15
16
17
        columns: 2
        Label{
            text: "Settings file path:"
        }
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
        RowLayout{
            id: root
            Item{
                Layout.fillWidth: true
                Layout.preferredWidth: inputSettingsPath.implicitWidth
                Layout.preferredHeight: inputSettingsPath.implicitHeight
                Layout.topMargin: 4
                clip: true
                id: wrapper
                TextInputField{
                    id: inputSettingsPath
                    readOnly: true
                    anchors.fill: parent
                    anchors.bottomMargin: 2
                    text: Settings.jsonSettingsFilePath
                }
            }
            Button{
                Layout.minimumWidth: implicitWidth
                Layout.leftMargin: 5
                Layout.preferredHeight: implicitHeight - 15
                text: "Save as"
                onClicked: {
                    fileDialog.openAt(Settings.jsonSettingsFilePath, false, false);
                    fileDialog.callback = function(file){
                        Settings.setJsonSettingsFilePath(file, false);
                    };
                }
            }
            Button{
                Layout.minimumWidth: implicitWidth
                Layout.leftMargin: 5
                Layout.preferredHeight: implicitHeight - 15
                text: "Load from"
                onClicked: {
                    fileDialog.openAt(Settings.jsonSettingsFilePath, false);
                    fileDialog.callback = function(file){
                        if(Settings.setJsonSettingsFilePath(file, true)){
                            popupChangedSettingsFile.visible = true;
                        }else{
                            ErrorNotifier.errorMessage += "You can not load the current opened settings file.";
                        }
                    };
                }
            }
63
        }
Leander Schulten's avatar
Leander Schulten committed
64

65
66
67
68
        Label{
            Layout.fillWidth: true
            text: "Driver file path:"
        }
Leander Schulten's avatar
Leander Schulten committed
69
        TextFieldFileChooser{
70
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
71
72
73
74
            folder: false
            path: Settings.driverFilePath
            onPathChanged: {Settings.driverFilePath = path;path = Settings.driverFilePath;}
            fileChooser: fileDialog
75
        }
Leander Schulten's avatar
Leander Schulten committed
76

Leander Schulten's avatar
Leander Schulten committed
77
78
79
80
81
82
83
84
85
86
87
        Label{
            text: "Update pause for dmx in ms:"
        }
        TextInputField{
            validator: IntValidator{
                bottom: 10
                top: 10000
            }
            text: Settings.updatePauseInMs;
            onAccepted: Settings.updatePauseInMs = text;
        }
Leander Schulten's avatar
Leander Schulten committed
88

89
90
91
92
        Label{
            Layout.fillWidth: true
            text: "Module Directory:"
        }
Leander Schulten's avatar
Leander Schulten committed
93
        TextFieldFileChooser{
94
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
95
96
97
98
            folder: true
            path: Settings.moduleDirPath
            onPathChanged: {Settings.moduleDirPath = path;path = Settings.moduleDirPath;}
            fileChooser: fileDialog
99
        }
Leander Schulten's avatar
Leander Schulten committed
100

Leander Schulten's avatar
Leander Schulten committed
101
102
103
104
        Label{
            Layout.fillWidth: true
            text: "Compiler File Path:"
        }
Leander Schulten's avatar
Leander Schulten committed
105
        TextFieldFileChooser{
Leander Schulten's avatar
Leander Schulten committed
106
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
107
108
109
110
            folder: true
            path: Settings.compilerPath
            onPathChanged: {Settings.compilerPath = path;path = Settings.compilerPath;}
            fileChooser: fileDialog
Leander Schulten's avatar
Leander Schulten committed
111
        }
112
113
114
115
116

        Label{
            Layout.fillWidth: true
            text: "Include Path:"
        }
Leander Schulten's avatar
Leander Schulten committed
117
        TextFieldFileChooser{
118
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
119
120
121
122
            folder: true
            path: Settings.includePath
            onPathChanged: {Settings.includePath = path;path = Settings.includePath;}
            fileChooser: fileDialog
123
        }
Leander Schulten's avatar
Leander Schulten committed
124

125
126
127
128
129
130
131
132
133
        Label{
            Layout.fillWidth: true
            text: "Compiler Flags:"
        }
        TextInputField{
            Layout.fillWidth: true
            text: Settings.compilerFlags
            onAccepted: Settings.compilerFlags = text;
        }
Leander Schulten's avatar
Leander Schulten committed
134

135
136
137
138
139
140
141
142
143
        Label{
            Layout.fillWidth: true
            text: "Compiler Library Flags:"
        }
        TextInputField{
            Layout.fillWidth: true
            text: Settings.compilerLibraryFlags
            onAccepted: Settings.compilerLibraryFlags = text;
        }
144

145
146
147
148
149
150
151
152
153
154
155
        Label{
            Layout.fillWidth: true
            text: "Audio Capture Device:"
        }
        ComboBox{
            model: AudioManager.captureDeviceNames
            Layout.fillWidth: true
            onActivated: AudioManager.currentCaptureDevice = index
            currentIndex: AudioManager.currentCaptureDevice
            onDownChanged: if(down)AudioManager.updateCaptureDeviceList()
        }
156
157
158
159
160
161
162
163
        Label{
            Layout.fillWidth: true
            text: "Theme:"
        }
        Button{
            text: "Modify Theme and appearance"
            onClicked: modifyThemeWindow.show()
        }
164
    }
165
    SystemDialog.FileDialog{
166
        property var callback;
167
168
169
        selectExisting: false
        defaultSuffix: ".json"
        function openAt(path, isFolder, selectExisting_ = true){
170
171
            selectFolder = isFolder;
            folder = pathToUrl(path);
172
            selectExisting = selectExisting_;
173
174
            open();
        }
175
        id: fileDialog
176
177
        title: "Please choose a file"
        onAccepted: {
178
179
180
181
182
183
            if(callback){
                callback(urlToPath(fileDialog.fileUrl));
            }else{
                console.error("Error in File Dialog in SettingsView: No callback provided!")
            }
        }
184
    }
185
186
187
188
189
190
191
192
193
194
195
196
197
    Window{
        id: modifyThemeWindow
        flags: Qt.WindowStaysOnTopHint | Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
        title: "Modify Theme"
        color: pane.Material.background
        width: 350
        height: 350
        Material.theme: Settings.theme
        ModifyThemePane{
            id: pane
            anchors.fill: parent
        }
    }
198
199
200
201
202
203
204
205
206
207
208
209
    Dialog{
        id: popupChangedSettingsFile
        modal: true
        margins: 50
        x: (parent.width - width) / 2
        y: 0
        closePolicy: Popup.NoAutoClose
        title: "Do you want to restart the light control now to load the settings file?"
        standardButtons: Dialog.No | Dialog.Yes
        onAccepted: Qt.quit();
    }

210
}