Debian Codegraph @

src/qml/SettingsDialog.qml

raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 import QtQuick 2.15
5 import QtQuick.Controls 2.15
6 import QtQuick.Layouts 1.15
7 import "Style.js" as Style
8
9 Dialog {
10 id: settingsDlg
11
12 title: qsTr("Settings")
13
14 focus: true
15 modal: true
16 standardButtons: Dialog.Ok | Dialog.Cancel
17 closePolicy: Popup.CloseOnEscape
18
19 // center in parent
20 x: (parent.width - width) / 2
21 y: (parent.height - height) / 2
22
23 spacing: 10
24
25 ColumnLayout {
26 anchors.fill: parent
27
28 TabBar {
29 id: tabBar
30 Layout.fillWidth: true
31 hoverEnabled: Style.g_hover
32
33 Repeater {
34 model: [qsTr("General"), qsTr("Workarounds")]
35
36 CTabButton {
37 text: modelData
38 }
39 }
40 }
41
42 StackLayout {
43 currentIndex: tabBar.currentIndex
44
45 SettingsGeneral {
46 id: general
47 onSettingsChanged: footer.standardButton(Dialog.Ok).enabled = true
48 }
49
50 SettingsWorkarounds {
51 id: workarounds
52 onSettingsChanged: footer.standardButton(Dialog.Ok).enabled = true
53 }
54 }
55 }
56
57 onOpened: {
58 general.opened()
59 workarounds.opened()
60
61 footer.standardButton(Dialog.Ok).enabled = false
62 }
63
64 onAccepted: {
65 general.accepted()
66 workarounds.accepted()
67
68 close()
69 }
70
71 onRejected: close()
72
73 Component.onCompleted: {
74 footer.standardButton(Dialog.Ok).enabled = false
75 footer.standardButton(Dialog.Ok).hoverEnabled = Style.g_hover
76 footer.standardButton(Dialog.Cancel).hoverEnabled = Style.g_hover
77 }
78 }