summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-12-11 01:41:05 +0100
committerAleix Pol <[email protected]>2018-12-11 01:41:05 +0100
commit4b9bdde405a70140d494266647bdf0f0001dade0 (patch)
tree4aeb9e10754e601b257558bbcf9fe0f94092beb4
parentf8d991fab364daeeaccafb2e46781bc32bede23c (diff)
Save last used sort order
Separately for installed page and the rest BUG: 401856
-rw-r--r--discover/CMakeLists.txt1
-rw-r--r--discover/DiscoverObject.cpp8
-rw-r--r--discover/discoversettings.kcfg8
-rw-r--r--discover/discoversettings.kcfgc5
-rw-r--r--discover/qml/ApplicationsListPage.qml17
-rw-r--r--discover/qml/InstalledPage.qml2
6 files changed, 34 insertions, 7 deletions
diff --git a/discover/CMakeLists.txt b/discover/CMakeLists.txt
index 929614d..90fb9b1 100644
--- a/discover/CMakeLists.txt
+++ b/discover/CMakeLists.txt
@@ -6,6 +6,7 @@ endif()
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/..)
ecm_qt_declare_logging_category(plasma_discover_SRCS HEADER discover_debug.h IDENTIFIER DISCOVER_LOG CATEGORY_NAME org.kde.plasma.discover)
+kconfig_add_kcfg_files(plasma_discover_SRCS discoversettings.kcfgc GENERATE_MOC)
add_executable(plasma-discover ${plasma_discover_SRCS}
main.cpp
diff --git a/discover/DiscoverObject.cpp b/discover/DiscoverObject.cpp
index cd7bfb8..3036dd1 100644
--- a/discover/DiscoverObject.cpp
+++ b/discover/DiscoverObject.cpp
@@ -69,6 +69,8 @@
#include <utils.h>
#include <QMimeDatabase>
+#include "discoversettings.h"
+
class OurSortFilterProxyModel : public QSortFilterProxyModel, public QQmlParserStatus
{
Q_OBJECT
@@ -100,6 +102,12 @@ DiscoverObject::DiscoverObject(CompactMode mode)
qmlRegisterType<FeaturedModel>("org.kde.discover.app", 1, 0, "FeaturedModel");
qmlRegisterType<OurSortFilterProxyModel>("org.kde.discover.app", 1, 0, "QSortFilterProxyModel");
+ qmlRegisterSingletonType<DiscoverSettings>("org.kde.discover.app", 1, 0, "DiscoverSettings", [](QQmlEngine*, QJSEngine*) -> QObject* {
+ auto r = new DiscoverSettings;
+ connect(r, &DiscoverSettings::installedPageSortingChanged, r, &DiscoverSettings::save);
+ connect(r, &DiscoverSettings::appsListPageSortingChanged, r, &DiscoverSettings::save);
+ return r;
+ });
qmlRegisterType<QQuickView>();
qmlRegisterType<QActionGroup>();
qmlRegisterType<QAction>();
diff --git a/discover/discoversettings.kcfg b/discover/discoversettings.kcfg
new file mode 100644
index 0000000..668a3cf
--- /dev/null
+++ b/discover/discoversettings.kcfg
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
+ <kcfgfile arg="true"/>
+ <group name="DiscoverUI">
+ <entry name="appsListPageSorting" type="Int"><default>ResourcesProxyModel::SortableRatingRole</default></entry>
+ <entry name="installedPageSorting" type="Int"><default>ResourcesProxyModel::NameRole</default></entry>
+ </group>
+</kcfg>
diff --git a/discover/discoversettings.kcfgc b/discover/discoversettings.kcfgc
new file mode 100644
index 0000000..9afaaf7
--- /dev/null
+++ b/discover/discoversettings.kcfgc
@@ -0,0 +1,5 @@
+File=discoversettings.kcfg
+ClassName=DiscoverSettings
+GenerateProperties=true
+Mutators=true
+IncludeFiles=resources/ResourcesProxyModel.h
diff --git a/discover/qml/ApplicationsListPage.qml b/discover/qml/ApplicationsListPage.qml
index 2feb6eb..0cde29c 100644
--- a/discover/qml/ApplicationsListPage.qml
+++ b/discover/qml/ApplicationsListPage.qml
@@ -43,6 +43,7 @@ DiscoverPage {
property alias count: apps.count
property alias listHeader: apps.header
property alias listHeaderPositioning: apps.headerPositioning
+ property alias sortProperty: saveChanges.property
property bool compact: page.width < 550 || !applicationWindow().wideScreen
property bool showRating: true
@@ -74,6 +75,13 @@ DiscoverPage {
exclusive: true
}
+ Binding {
+ id: saveChanges
+ target: DiscoverSettings
+ property: "appsListPageSorting"
+ value: appsModel.sortRole
+ }
+
contextualActions: [
Kirigami.Action {
visible: !appsModel.sortByRelevancy
@@ -83,7 +91,6 @@ DiscoverPage {
text: i18n("Name")
onTriggered: {
appsModel.sortRole = ResourcesProxyModel.NameRole
- appsModel.sortOrder = Qt.AscendingOrder
}
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.NameRole
@@ -93,7 +100,6 @@ DiscoverPage {
text: i18n("Rating")
onTriggered: {
appsModel.sortRole = ResourcesProxyModel.SortableRatingRole
- appsModel.sortOrder = Qt.DescendingOrder
}
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.SortableRatingRole
@@ -103,7 +109,6 @@ DiscoverPage {
text: i18n("Size")
onTriggered: {
appsModel.sortRole = ResourcesProxyModel.SizeRole
- appsModel.sortOrder = Qt.AscendingOrder
}
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.SizeRole
@@ -113,7 +118,6 @@ DiscoverPage {
text: i18n("Release Date")
onTriggered: {
appsModel.sortRole = ResourcesProxyModel.ReleaseDateRole
- appsModel.sortOrder = Qt.DescendingOrder
}
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.ReleaseDateRole
@@ -133,8 +137,9 @@ DiscoverPage {
model: ResourcesProxyModel {
id: appsModel
- sortRole: ResourcesProxyModel.SortableRatingRole
- sortOrder: Qt.DescendingOrder
+ sortRole: DiscoverSettings.appsListPageSorting
+ sortOrder: sortRole === ResourcesProxyModel.SortableRatingRole || sortRole === ResourcesProxyModel.ReleaseDateRole ? Qt.DescendingOrder : Qt.AscendingOrder
+
onBusyChanged: if (isBusy) {
apps.currentIndex = -1
}
diff --git a/discover/qml/InstalledPage.qml b/discover/qml/InstalledPage.qml
index ddb179f..4c8f8bb 100644
--- a/discover/qml/InstalledPage.qml
+++ b/discover/qml/InstalledPage.qml
@@ -8,9 +8,9 @@ import org.kde.kirigami 2.1 as Kirigami
ApplicationsListPage {
id: page
stateFilter: AbstractResource.Installed
- sortRole: ResourcesProxyModel.NameRole
sortOrder: Qt.AscendingOrder
allBackends: true
+ sortProperty: "installedPageSorting"
title: i18n("Installed")
compact: true