Changeset View
Changeset View
Standalone View
Standalone View
desktoppackage/contents/configuration/ConfigCategoryDelegate.qml
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.0 | 19 | import QtQuick 2.0 | ||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Controls 1.0 as QtControls | 21 | import QtQuick.Controls 2.3 as QtControls | ||
22 | import QtQuick.Window 2.2 | 22 | import QtQuick.Window 2.2 | ||
23 | 23 | | |||
24 | import org.kde.kquickcontrolsaddons 2.0 | 24 | import org.kde.kquickcontrolsaddons 2.0 | ||
25 | import org.kde.kirigami 2.5 as Kirigami | ||||
25 | 26 | | |||
26 | MouseArea { | 27 | MouseArea { | ||
27 | id: delegate | 28 | id: delegate | ||
28 | 29 | | |||
29 | //BEGIN properties | 30 | //BEGIN properties | ||
30 | implicitWidth: delegateContents.implicitWidth + 4 * units.smallSpacing | 31 | implicitWidth: delegateContents.implicitWidth + 4 * units.smallSpacing | ||
31 | implicitHeight: delegateContents.height + units.smallSpacing * 4 | 32 | implicitHeight: delegateContents.height + units.smallSpacing * 4 | ||
32 | Layout.fillWidth: true | 33 | Layout.fillWidth: true | ||
33 | hoverEnabled: true | 34 | hoverEnabled: true | ||
34 | 35 | | |||
35 | property bool current: (model.kcm && main.currentItem.kcm && model.kcm == main.currentItem.kcm) || (model.source == main.sourceFile) | 36 | property bool current: (model.kcm && pageStack.currentItem.kcm && model.kcm == pageStack.currentItem.kcm) || (model.source == pageStack.sourceFile) | ||
36 | //END properties | 37 | //END properties | ||
37 | 38 | | |||
38 | //BEGIN functions | 39 | //BEGIN functions | ||
39 | function openCategory() { | 40 | function openCategory() { | ||
40 | if (current) { | 41 | if (current) { | ||
41 | return; | 42 | return; | ||
42 | } | 43 | } | ||
43 | if (typeof(categories.currentItem) !== "undefined") { | 44 | if (typeof(categories.currentItem) !== "undefined") { | ||
44 | main.invertAnimations = (categories.currentItem.y > delegate.y); | 45 | pageStack.invertAnimations = (categories.currentItem.y > delegate.y); | ||
45 | categories.currentItem = delegate; | 46 | categories.currentItem = delegate; | ||
46 | } | 47 | } | ||
47 | if (model.source) { | 48 | if (model.source) { | ||
48 | main.sourceFile = model.source; | 49 | pageStack.sourceFile = model.source; | ||
49 | } else if (model.kcm) { | 50 | } else if (model.kcm) { | ||
50 | main.sourceFile = ""; | 51 | pageStack.sourceFile = ""; | ||
51 | main.sourceFile = Qt.resolvedUrl("ConfigurationKcmPage.qml"); | 52 | pageStack.sourceFile = Qt.resolvedUrl("ConfigurationKcmPage.qml"); | ||
52 | main.currentItem.kcm = model.kcm; | 53 | pageStack.currentItem.kcm = model.kcm; | ||
53 | } else { | 54 | } else { | ||
54 | main.sourceFile = ""; | 55 | pageStack.sourceFile = ""; | ||
55 | } | 56 | } | ||
56 | main.title = model.name | 57 | pageStack.title = model.name | ||
57 | } | 58 | } | ||
58 | //END functions | 59 | //END functions | ||
59 | 60 | | |||
60 | //BEGIN connections | 61 | //BEGIN connections | ||
61 | onPressed: { | 62 | onPressed: { | ||
62 | categoriesScroll.forceActiveFocus() | 63 | categoriesScroll.forceActiveFocus() | ||
63 | 64 | | |||
64 | if (current) { | 65 | if (current) { | ||
65 | return; | 66 | return; | ||
66 | } | 67 | } | ||
67 | 68 | | |||
68 | //print("model source: " + model.source + " " + main.sourceFile); | 69 | //print("model source: " + model.source + " " + pageStack.sourceFile); | ||
69 | if (applyButton.enabled) { | 70 | if (applyButton.enabled) { | ||
70 | messageDialog.delegate = delegate; | 71 | messageDialog.delegate = delegate; | ||
71 | messageDialog.open(); | 72 | messageDialog.open(); | ||
72 | return; | 73 | return; | ||
73 | } | 74 | } | ||
74 | 75 | | |||
75 | openCategory(); | 76 | openCategory(); | ||
76 | } | 77 | } | ||
77 | onCurrentChanged: { | 78 | onCurrentChanged: { | ||
78 | if (current) { | 79 | if (current) { | ||
79 | categories.currentItem = delegate; | 80 | categories.currentItem = delegate; | ||
80 | } | 81 | } | ||
81 | } | 82 | } | ||
82 | //END connections | 83 | //END connections | ||
83 | 84 | | |||
84 | //BEGIN UI components | 85 | //BEGIN UI components | ||
85 | Rectangle { | 86 | Rectangle { | ||
86 | anchors.fill: parent | 87 | anchors.fill: parent | ||
87 | color: syspal.highlight | 88 | color: Kirigami.Theme.highlightColor | ||
88 | opacity: { // try to match Breeze style hover handling | 89 | opacity: { // try to match Breeze style hover handling | ||
89 | var active = categoriesScroll.activeFocus && Window.active | 90 | var active = categoriesScroll.activeFocus && Window.active | ||
90 | if (current) { | 91 | if (current) { | ||
91 | if (active) { | 92 | if (active) { | ||
92 | return 1 | 93 | return 1 | ||
93 | } else if (delegate.containsMouse) { | 94 | } else if (delegate.containsMouse) { | ||
94 | return 0.6 | 95 | return 0.6 | ||
95 | } else { | 96 | } else { | ||
Show All 32 Lines | 116 | ColumnLayout { | |||
128 | } | 129 | } | ||
129 | 130 | | |||
130 | QtControls.Label { | 131 | QtControls.Label { | ||
131 | id: nameLabel | 132 | id: nameLabel | ||
132 | Layout.fillWidth: true | 133 | Layout.fillWidth: true | ||
133 | text: model.name | 134 | text: model.name | ||
134 | wrapMode: Text.Wrap | 135 | wrapMode: Text.Wrap | ||
135 | horizontalAlignment: Text.AlignHCenter | 136 | horizontalAlignment: Text.AlignHCenter | ||
136 | color: current && categoriesScroll.activeFocus ? syspal.highlightedText : syspal.text | 137 | color: current && categoriesScroll.activeFocus ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor | ||
137 | Behavior on color { | 138 | Behavior on color { | ||
138 | ColorAnimation { | 139 | ColorAnimation { | ||
139 | duration: units.longDuration | 140 | duration: units.longDuration | ||
140 | easing.type: Easing.InOutQuad | 141 | easing.type: Easing.InOutQuad | ||
141 | } | 142 | } | ||
142 | } | 143 | } | ||
143 | } | 144 | } | ||
144 | } | 145 | } | ||
145 | //END UI components | 146 | //END UI components | ||
146 | } | 147 | } |