summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2016-12-19 13:43:03 +0100
committerAleix Pol <[email protected]>2016-12-19 13:43:03 +0100
commitbb9bd034854f4275858bfa1256bde35759f73f78 (patch)
treefaad2646237d7bebbd7f75b81e6a39a449533d84
parent70c3c97a7f0998f5d578e13025071965e919494d (diff)
Centralize action-based list items into a component
Removes duplicated code in the drawer
-rw-r--r--discover/qml/ActionListItem.qml35
-rw-r--r--discover/qml/DiscoverDrawer.qml34
-rw-r--r--discover/resources.qrc1
3 files changed, 42 insertions, 28 deletions
diff --git a/discover/qml/ActionListItem.qml b/discover/qml/ActionListItem.qml
new file mode 100644
index 0000000..d969ff0
--- /dev/null
+++ b/discover/qml/ActionListItem.qml
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright © 2015 Aleix Pol Gonzalez <[email protected]> *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License or (at your option) version 3 or any later version *
+ * accepted by the membership of KDE e.V. (or its successor approved *
+ * by the membership of KDE e.V.), which shall act as a proxy *
+ * defined in Section 14 of version 3 of the license. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+import QtQml 2.0
+import QtQuick.Controls 2.0
+import org.kde.kirigami 2.0 as Kirigami
+
+Kirigami.BasicListItem {
+ property QtObject action: null
+ checked: action.checked
+ icon: action.iconName
+ label: action.text
+ separatorVisible: false
+ onClicked: {
+ drawer.resetMenu()
+ action.trigger()
+ }
+}
diff --git a/discover/qml/DiscoverDrawer.qml b/discover/qml/DiscoverDrawer.qml
index 706aa12..07bc992 100644
--- a/discover/qml/DiscoverDrawer.qml
+++ b/discover/qml/DiscoverDrawer.qml
@@ -115,37 +115,15 @@ Kirigami.GlobalDrawer {
separatorVisible: false
}
- Kirigami.BasicListItem {
- checked: installedAction.checked
- icon: installedAction.iconName
- label: installedAction.text
- separatorVisible: false
- onClicked: {
- drawer.resetMenu()
- installedAction.trigger()
- }
+ ActionListItem {
+ action: installedAction
}
- Kirigami.BasicListItem {
- checked: settingsAction.checked
- icon: settingsAction.iconName
- label: settingsAction.text
- separatorVisible: false
- onClicked: {
- drawer.resetMenu()
- settingsAction.trigger()
- }
+ ActionListItem {
+ action: settingsAction
}
- Kirigami.BasicListItem {
+ ActionListItem {
objectName: "updateButton"
- enabled: updateAction.enabled
- checked: updateAction.checked
- icon: updateAction.iconName
- label: updateAction.text
- separatorVisible: false
- onClicked: {
- drawer.resetMenu()
- updateAction.trigger()
- }
+ action: updateAction
backgroundColor: enabled ? "orange" : Kirigami.Theme.viewBackgroundColor
}
diff --git a/discover/resources.qrc b/discover/resources.qrc
index b99d19b..5537dc4 100644
--- a/discover/resources.qrc
+++ b/discover/resources.qrc
@@ -34,6 +34,7 @@
<file>qml/DiscoverWindow.qml</file>
<file>qml/DiscoverDrawer.qml</file>
<file>qml/Helpers.qml</file>
+ <file>qml/ActionListItem.qml</file>
<file>qml/navigation.js</file>