SettingsView.qml 7.31 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
7
import custom.licht 1.0
Leander Schulten's avatar
Leander Schulten committed
8
import "components"
9
10
11
12
13

Pane{
    GridLayout{
        anchors.left: parent.left
        anchors.right: parent.right
14
        rowSpacing: 16
15
16
17
18
        columns: 2
        Label{
            text: "Settings file path:"
        }
19
20
        RowLayout{
            id: root
21
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_SETTINGS_FILE_PATH)
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
63
64
            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.";
                        }
                    };
                }
            }
65
        }
Leander Schulten's avatar
Leander Schulten committed
66

67
68
69
70
        Label{
            Layout.fillWidth: true
            text: "Driver file path:"
        }
Leander Schulten's avatar
Leander Schulten committed
71
        TextFieldFileChooser{
72
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_DMX_DRIVER_LIB)
73
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
74
75
76
77
            folder: false
            path: Settings.driverFilePath
            onPathChanged: {Settings.driverFilePath = path;path = Settings.driverFilePath;}
            fileChooser: fileDialog
78
        }
Leander Schulten's avatar
Leander Schulten committed
79

Leander Schulten's avatar
Leander Schulten committed
80
81
82
83
        Label{
            text: "Update pause for dmx in ms:"
        }
        TextInputField{
84
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_DMX_UPDATE_RATE)
Leander Schulten's avatar
Leander Schulten committed
85
86
87
88
89
90
91
            validator: IntValidator{
                bottom: 10
                top: 10000
            }
            text: Settings.updatePauseInMs;
            onAccepted: Settings.updatePauseInMs = text;
        }
Leander Schulten's avatar
Leander Schulten committed
92

93
94
95
96
        Label{
            Layout.fillWidth: true
            text: "Module Directory:"
        }
Leander Schulten's avatar
Leander Schulten committed
97
        TextFieldFileChooser{
98
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_MODULE_SETTINGS)
99
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
100
101
102
103
            folder: true
            path: Settings.moduleDirPath
            onPathChanged: {Settings.moduleDirPath = path;path = Settings.moduleDirPath;}
            fileChooser: fileDialog
104
        }
Leander Schulten's avatar
Leander Schulten committed
105

Leander Schulten's avatar
Leander Schulten committed
106
107
108
109
        Label{
            Layout.fillWidth: true
            text: "Compiler File Path:"
        }
Leander Schulten's avatar
Leander Schulten committed
110
        TextFieldFileChooser{
111
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_MODULE_SETTINGS)
Leander Schulten's avatar
Leander Schulten committed
112
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
113
114
115
116
            folder: true
            path: Settings.compilerPath
            onPathChanged: {Settings.compilerPath = path;path = Settings.compilerPath;}
            fileChooser: fileDialog
Leander Schulten's avatar
Leander Schulten committed
117
        }
118
119
120
121
122

        Label{
            Layout.fillWidth: true
            text: "Include Path:"
        }
Leander Schulten's avatar
Leander Schulten committed
123
        TextFieldFileChooser{
124
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_MODULE_SETTINGS)
125
            Layout.fillWidth: true
Leander Schulten's avatar
Leander Schulten committed
126
127
128
129
            folder: true
            path: Settings.includePath
            onPathChanged: {Settings.includePath = path;path = Settings.includePath;}
            fileChooser: fileDialog
130
        }
Leander Schulten's avatar
Leander Schulten committed
131

132
133
134
135
136
        Label{
            Layout.fillWidth: true
            text: "Compiler Flags:"
        }
        TextInputField{
137
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_MODULE_SETTINGS)
138
139
140
141
            Layout.fillWidth: true
            text: Settings.compilerFlags
            onAccepted: Settings.compilerFlags = text;
        }
Leander Schulten's avatar
Leander Schulten committed
142

143
144
145
146
147
        Label{
            Layout.fillWidth: true
            text: "Compiler Library Flags:"
        }
        TextInputField{
148
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_MODULE_SETTINGS)
149
150
151
152
            Layout.fillWidth: true
            text: Settings.compilerLibraryFlags
            onAccepted: Settings.compilerLibraryFlags = text;
        }
153

154
155
156
157
158
159
160
161
162
163
164
        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()
        }
165
166
167
168
169
        Label{
            Layout.fillWidth: true
            text: "Theme:"
        }
        Button{
170
            enabled: UserManagment.currentUser.havePermission(Permission.MODIFY_THEME)
171
172
173
            text: "Modify Theme and appearance"
            onClicked: modifyThemeWindow.show()
        }
174
    }
175
    SystemDialog.FileDialog{
176
        property var callback;
177
178
179
        selectExisting: false
        defaultSuffix: ".json"
        function openAt(path, isFolder, selectExisting_ = true){
180
181
            selectFolder = isFolder;
            folder = pathToUrl(path);
182
            selectExisting = selectExisting_;
183
184
            open();
        }
185
        id: fileDialog
186
187
        title: "Please choose a file"
        onAccepted: {
188
189
190
191
192
193
            if(callback){
                callback(urlToPath(fileDialog.fileUrl));
            }else{
                console.error("Error in File Dialog in SettingsView: No callback provided!")
            }
        }
194
    }
195
196
197
198
199
200
201
202
203
204
205
206
207
    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
        }
    }
208
209
210
211
212
213
214
215
216
217
218
219
    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();
    }

220
}