Changeset View
Changeset View
Standalone View
Standalone View
kcms/cursortheme/package/contents/ui/main.qml
Show All 26 Lines | |||||
27 | 27 | | |||
28 | import org.kde.private.kcm_cursortheme 1.0 | 28 | import org.kde.private.kcm_cursortheme 1.0 | ||
29 | 29 | | |||
30 | KCM.GridViewKCM { | 30 | KCM.GridViewKCM { | ||
31 | KCM.ConfigModule.quickHelp: i18n("This module lets you choose the mouse cursor theme.") | 31 | KCM.ConfigModule.quickHelp: i18n("This module lets you choose the mouse cursor theme.") | ||
32 | 32 | | |||
33 | view.model: kcm.cursorsModel | 33 | view.model: kcm.cursorsModel | ||
34 | view.delegate: Delegate {} | 34 | view.delegate: Delegate {} | ||
35 | view.currentIndex: kcm.cursorThemeIndex(kcm.cursorThemeSettings.cursorTheme); | ||||
36 | | ||||
35 | view.onCurrentIndexChanged: { | 37 | view.onCurrentIndexChanged: { | ||
36 | kcm.selectedThemeRow = view.currentIndex; | 38 | kcm.cursorThemeSettings.cursorTheme = kcm.cursorThemeFromIndex(view.currentIndex) | ||
37 | view.positionViewAtIndex(view.currentIndex, view.GridView.Beginning); | 39 | view.positionViewAtIndex(view.currentIndex, view.GridView.Beginning); | ||
38 | } | 40 | } | ||
39 | 41 | | |||
42 | Component.onCompleted: { | ||||
43 | view.positionViewAtIndex(view.currentIndex, GridView.Beginning); | ||||
44 | } | ||||
45 | | ||||
40 | enabled: !kcm.downloadingFile | 46 | enabled: !kcm.downloadingFile | ||
41 | 47 | | |||
42 | DropArea { | 48 | DropArea { | ||
43 | anchors.fill: parent | 49 | anchors.fill: parent | ||
44 | onEntered: { | 50 | onEntered: { | ||
45 | if (!drag.hasUrls) { | 51 | if (!drag.hasUrls) { | ||
46 | drag.accepted = false; | 52 | drag.accepted = false; | ||
47 | } | 53 | } | ||
48 | } | 54 | } | ||
49 | onDropped: kcm.installThemeFromFile(drop.urls[0]) | 55 | onDropped: kcm.installThemeFromFile(drop.urls[0]) | ||
50 | } | 56 | } | ||
51 | 57 | | |||
52 | Connections { | | |||
53 | target: kcm | | |||
54 | onSelectedThemeRowChanged: view.currentIndex = kcm.selectedThemeRow; | | |||
55 | } | | |||
56 | | ||||
57 | footer: ColumnLayout { | 58 | footer: ColumnLayout { | ||
58 | id: footerLayout | 59 | id: footerLayout | ||
59 | 60 | | |||
60 | Kirigami.InlineMessage { | 61 | Kirigami.InlineMessage { | ||
61 | id: infoLabel | 62 | id: infoLabel | ||
62 | Layout.fillWidth: true | 63 | Layout.fillWidth: true | ||
63 | 64 | | |||
64 | showCloseButton: true | 65 | showCloseButton: true | ||
Show All 31 Lines | 95 | RowLayout { | |||
96 | enabled: kcm.canResize | 97 | enabled: kcm.canResize | ||
97 | QtControls.Label { | 98 | QtControls.Label { | ||
98 | text: i18n("Size:") | 99 | text: i18n("Size:") | ||
99 | } | 100 | } | ||
100 | QtControls.ComboBox { | 101 | QtControls.ComboBox { | ||
101 | id: sizeCombo | 102 | id: sizeCombo | ||
102 | model: kcm.sizesModel | 103 | model: kcm.sizesModel | ||
103 | textRole: "display" | 104 | textRole: "display" | ||
105 | currentIndex: kcm.cursorSizeIndex(kcm.cursorThemeSettings.cursorSize); | ||||
davidedmundson: I think this will be broken if you change this combo box, then change theme.
When a user… | |||||
After testing seems to be not broken. bport: After testing seems to be not broken.
the binding is set to a method that transorm current size… | |||||
David has a point, the binding of currentIndex will be broken as soon as the user changes the entry in the combo box. That being said, IIRC this shouldn't matter much in that context though, because we seem to be just after pre-selecting the right entry in the combo box when the module is displayed and not always enforcing a currentIndex value (which we can't in the context of combo box as David pointed out). What matters is that the settings get properly updated when the user select a new entry in the combo box which is handled with onActivated just fine. ervin: David has a point, the binding of currentIndex will be broken as soon as the user changes the… | |||||
104 | onActivated: { | 106 | onActivated: { | ||
105 | kcm.selectedSizeRow = sizeCombo.currentIndex | 107 | kcm.cursorThemeSettings.cursorSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex); | ||
106 | } | 108 | kcm.preferredSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex); | ||
107 | | ||||
108 | Connections { | | |||
109 | target: kcm | | |||
110 | onSelectedSizeRowChanged: { | | |||
111 | sizeCombo.currentIndex = kcm.selectedSizeRow | | |||
112 | } | | |||
113 | } | 109 | } | ||
114 | 110 | | |||
115 | delegate: QtControls.ItemDelegate { | 111 | delegate: QtControls.ItemDelegate { | ||
116 | id: sizeComboDelegate | 112 | id: sizeComboDelegate | ||
117 | 113 | | |||
118 | readonly property int size: parseInt(model.display) | 114 | readonly property int size: parseInt(model.display) | ||
119 | 115 | | |||
120 | width: parent.width | 116 | width: parent.width | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |
I think this will be broken if you change this combo box, then change theme.
When a user explicitly changes this combo box this binding gets broken with currentIndex now reflecting an explicit number.
On theme change cursorThemeSettings.cursorSize changes correctly but our binding is gone.
This might have to be a connection again