Commit 4b9bdde4 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Save last used sort order

Separately for installed page and the rest

BUG: 401856
parent f8d991fa
......@@ -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
......
......@@ -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>();
......
<?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>
File=discoversettings.kcfg
ClassName=DiscoverSettings
GenerateProperties=true
Mutators=true
IncludeFiles=resources/ResourcesProxyModel.h
......@@ -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
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment