Changeset View
Changeset View
Standalone View
Standalone View
applets/fifteenPuzzle/package/contents/ui/configAppearance.qml
Show All 15 Lines | |||||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. | ||
19 | * | 19 | * | ||
20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | import QtQuick 2.0 | 24 | import QtQuick 2.5 | ||
25 | import QtQuick.Controls 1.2 as QtControls | 25 | import QtQuick.Controls 2.5 as QtControls | ||
26 | import QtQuick.Layouts 1.0 as QtLayouts | 26 | import QtQuick.Layouts 1.1 | ||
27 | import QtQuick.Dialogs 1.2 as QtDialogs | 27 | import QtQuick.Dialogs 1.2 as QtDialogs | ||
28 | import org.kde.kquickcontrols 2.0 as KQC | 28 | import org.kde.kquickcontrols 2.0 as KQC | ||
29 | import org.kde.kirigami 2.8 as Kirigami | ||||
29 | 30 | | |||
30 | QtLayouts.ColumnLayout { | 31 | Kirigami.FormLayout { | ||
31 | id: appearancePage | 32 | id: appearancePage | ||
32 | 33 | | |||
33 | property alias cfg_boardSize: sizeSpinBox.value | 34 | property alias cfg_boardSize: sizeSpinBox.value | ||
34 | property alias cfg_boardColor: pieceColorPicker.color | 35 | property alias cfg_boardColor: pieceColorPicker.color | ||
35 | property alias cfg_numberColor: numberColorPicker.color | 36 | property alias cfg_numberColor: numberColorPicker.color | ||
36 | property alias cfg_showNumerals: showNumeralsCheckBox.checked | 37 | property alias cfg_showNumerals: showNumeralsCheckBox.checked | ||
37 | 38 | | |||
38 | property alias cfg_useImage: useImageCheckBox.checked | 39 | property alias cfg_useImage: imageBackgroundRadioButton.checked | ||
39 | property alias cfg_imagePath: imagePathTextField.text | 40 | property alias cfg_imagePath: imagePathTextField.text | ||
40 | 41 | | |||
41 | QtLayouts.GridLayout { | 42 | QtControls.ButtonGroup { | ||
42 | columns: 2 | 43 | id: radioGroup | ||
44 | } | ||||
43 | 45 | | |||
44 | QtControls.Label { | 46 | // Need to manually set checked state for the color button based on the | ||
45 | text: i18nc("@label:spinbox", "Size:") | 47 | // other onebecause it's not aliased to a saved property | ||
46 | QtLayouts.Layout.alignment: Qt.AlignRight | 48 | Component.onCompleted: { | ||
49 | colorBackgroundRadioButton.checked = !imageBackgroundRadioButton.checked; | ||||
47 | } | 50 | } | ||
48 | 51 | | |||
49 | QtControls.SpinBox { | 52 | QtControls.SpinBox { | ||
50 | id: sizeSpinBox | 53 | id: sizeSpinBox | ||
54 | Kirigami.FormData.label: i18nc("@label:spinbox", "Grid size:") | ||||
51 | } | 55 | } | ||
52 | 56 | | |||
53 | QtControls.Label { | 57 | Item { | ||
54 | text: i18nc("@label:chooser", "Piece color:") | 58 | Kirigami.FormData.isSection: true | ||
55 | QtLayouts.Layout.alignment: Qt.AlignRight | | |||
56 | } | 59 | } | ||
57 | 60 | | |||
58 | KQC.ColorButton { | 61 | // Color background | ||
59 | id: pieceColorPicker | 62 | RowLayout { | ||
60 | } | 63 | Kirigami.FormData.label: i18n("Background:") | ||
64 | | ||||
65 | QtControls.RadioButton { | ||||
66 | id: colorBackgroundRadioButton | ||||
67 | QtControls.ButtonGroup.group: radioGroup | ||||
61 | 68 | | |||
62 | QtControls.Label { | 69 | text: i18n("Color:") | ||
63 | text: i18nc("@label:chooser", "Number color:") | | |||
64 | QtLayouts.Layout.alignment: Qt.AlignRight | | |||
65 | } | 70 | } | ||
66 | 71 | | |||
67 | KQC.ColorButton { | 72 | KQC.ColorButton { | ||
68 | id: numberColorPicker | 73 | id: pieceColorPicker | ||
74 | enabled: colorBackgroundRadioButton.checked | ||||
filipf: You could have `enabled: !useImageCheckBox.checked` here | |||||
75 | } | ||||
69 | } | 76 | } | ||
70 | 77 | | |||
71 | QtControls.CheckBox { | 78 | // Image background | ||
72 | id: useImageCheckBox | 79 | RowLayout { | ||
73 | text: i18nc("@option:check", "Use custom image") | 80 | QtControls.RadioButton { | ||
74 | QtLayouts.Layout.alignment: Qt.AlignRight | 81 | id: imageBackgroundRadioButton | ||
82 | QtControls.ButtonGroup.group: radioGroup | ||||
83 | | ||||
84 | text: i18n("Image:") | ||||
filipf: And then `enabled: showNumeralsCheckBox.checked` here | |||||
75 | } | 85 | } | ||
76 | 86 | | |||
77 | QtLayouts.RowLayout { | 87 | Kirigami.ActionTextField { | ||
78 | QtControls.TextField { | | |||
79 | id: imagePathTextField | 88 | id: imagePathTextField | ||
80 | QtLayouts.Layout.fillWidth: true | 89 | enabled: imageBackgroundRadioButton.checked | ||
81 | placeholderText: i18nc("@info:placeholder", "Path to custom image") | 90 | | ||
82 | onTextChanged: useImageCheckBox.checked = true | 91 | Layout.fillWidth: true | ||
92 | placeholderText: i18nc("@info:placeholder", "Path to custom image...") | ||||
93 | | ||||
94 | rightActions: [ | ||||
95 | Kirigami.Action { | ||||
96 | iconName: "edit-clear" | ||||
97 | visible: imagePathTextField.text.length !== 0 | ||||
98 | onTriggered: imagePathTextField.text = ""; | ||||
99 | } | ||||
100 | ] | ||||
83 | } | 101 | } | ||
84 | 102 | | |||
85 | QtControls.Button { | 103 | QtControls.Button { | ||
86 | iconName: "document-open" | 104 | enabled: imageBackgroundRadioButton.checked | ||
87 | tooltip: i18nc("@info:tooltip", "Browse...") | 105 | | ||
106 | icon.name: "document-open" | ||||
107 | | ||||
108 | QtControls.ToolTip.visible: hovered | ||||
109 | QtControls.ToolTip.delay: 100 | ||||
110 | QtControls.ToolTip.text: i18nc("@info:tooltip", "Choose image...") | ||||
88 | 111 | | |||
89 | onClicked: imagePicker.open() | 112 | onClicked: imagePicker.open() | ||
90 | 113 | | |||
91 | QtDialogs.FileDialog { | 114 | QtDialogs.FileDialog { | ||
92 | id: imagePicker | 115 | id: imagePicker | ||
93 | 116 | | |||
94 | title: i18nc("@title:window", "Choose an Image") | 117 | title: i18nc("@title:window", "Choose an Image") | ||
95 | 118 | | |||
96 | folder: shortcuts.pictures | 119 | folder: shortcuts.pictures | ||
97 | 120 | | |||
98 | // TODO ask QImageReader for supported formats | 121 | // TODO ask QImageReader for supported formats | ||
99 | nameFilters: [ i18n("Image Files (*.png *.jpg *.jpeg *.bmp *.svg *.svgz)") ] | 122 | nameFilters: [ i18n("Image Files (*.png *.jpg *.jpeg *.bmp *.svg *.svgz)") ] | ||
100 | 123 | | |||
101 | onFileUrlChanged: { | 124 | onFileUrlChanged: { | ||
102 | imagePathTextField.text = fileUrl.toString().replace("file://", "") | 125 | imagePathTextField.text = fileUrl.toString().replace("file://", "") | ||
103 | } | 126 | } | ||
104 | } | 127 | } | ||
105 | } | 128 | } | ||
106 | } | 129 | } | ||
107 | 130 | | |||
131 | Item { | ||||
132 | Kirigami.FormData.isSection: true | ||||
133 | } | ||||
134 | | ||||
135 | RowLayout { | ||||
136 | Kirigami.FormData.label: i18n("Tiles:") | ||||
GB_2: You could make it like this:
`Tiles: [ ] Colored numbers: [ Button ]` | |||||
137 | | ||||
108 | QtControls.CheckBox { | 138 | QtControls.CheckBox { | ||
109 | id: showNumeralsCheckBox | 139 | id: showNumeralsCheckBox | ||
110 | QtLayouts.Layout.columnSpan: 2 | 140 | text: i18n("Colored numbers:") | ||
111 | text: i18nc("@option:check", "Show numerals") | | |||
112 | } | | |||
113 | } | 141 | } | ||
114 | 142 | | |||
115 | Item { // tighten layout | 143 | KQC.ColorButton { | ||
116 | QtLayouts.Layout.fillHeight: true | 144 | id: numberColorPicker | ||
145 | enabled: showNumeralsCheckBox.checked | ||||
146 | } | ||||
117 | } | 147 | } | ||
118 | } | 148 | } |
You could have enabled: !useImageCheckBox.checked here