From 5c19b08e5e229a025a3e56db2bde05180fdfd13b Mon Sep 17 00:00:00 2001 From: Nethius Date: Thu, 18 Apr 2024 19:01:26 +0700 Subject: [PATCH] fixed checkbox selection on installedAppsDrawer (#759) * fixed checkbox selection on installedAppsDrawer * added sorting by name for split tunneling by application --- client/ui/models/installedAppsModel.cpp | 4 ++++ client/ui/models/installedAppsModel.h | 11 ++++++----- client/ui/qml/Components/InstalledAppsDrawer.qml | 2 +- .../ui/qml/Pages2/PageSettingsAppSplitTunneling.qml | 3 +++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/ui/models/installedAppsModel.cpp b/client/ui/models/installedAppsModel.cpp index 6030c19e..19c60dbd 100644 --- a/client/ui/models/installedAppsModel.cpp +++ b/client/ui/models/installedAppsModel.cpp @@ -37,6 +37,9 @@ QVariant InstalledAppsModel::data(const QModelIndex &index, int role) const case PackageNameRole: { return m_installedApps.at(index.row()).toObject().value("package"); } + case IsAppSelectedRole: { + return m_selectedAppIndexes.contains(index.row()); + } } return QVariant(); @@ -93,5 +96,6 @@ QHash InstalledAppsModel::roleNames() const roles[AppNameRole] = "appName"; roles[AppIconRole] = "appIcon"; roles[PackageNameRole] = "packageName"; + roles[IsAppSelectedRole] = "isAppSelected"; return roles; } diff --git a/client/ui/models/installedAppsModel.h b/client/ui/models/installedAppsModel.h index 32f67630..6d4b8d3f 100644 --- a/client/ui/models/installedAppsModel.h +++ b/client/ui/models/installedAppsModel.h @@ -1,18 +1,19 @@ #ifndef INSTALLEDAPPSMODEL_H #define INSTALLEDAPPSMODEL_H -#include #include +#include -class InstalledAppsModel: public QAbstractListModel +class InstalledAppsModel : public QAbstractListModel { Q_OBJECT public: enum Roles { - AppNameRole= Qt::UserRole + 1, + AppNameRole = Qt::UserRole + 1, PackageNameRole, - AppIconRole + AppIconRole, + IsAppSelectedRole }; explicit InstalledAppsModel(QObject *parent = nullptr); @@ -22,7 +23,7 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; public slots: - void selectedStateChanged(const int index, const bool selected); + void selectedStateChanged(const int index, const bool selected); QVector> getSelectedAppsInfo(); void updateModel(); diff --git a/client/ui/qml/Components/InstalledAppsDrawer.qml b/client/ui/qml/Components/InstalledAppsDrawer.qml index 915b2f54..6d6f1feb 100644 --- a/client/ui/qml/Components/InstalledAppsDrawer.qml +++ b/client/ui/qml/Components/InstalledAppsDrawer.qml @@ -101,7 +101,7 @@ DrawerType2 { Layout.fillWidth: true text: appName - + checked: isAppSelected onCheckedChanged: { installedAppsModel.selectedStateChanged(proxyInstalledAppsModel.mapToSource(index), checked) } diff --git a/client/ui/qml/Pages2/PageSettingsAppSplitTunneling.qml b/client/ui/qml/Pages2/PageSettingsAppSplitTunneling.qml index cb72d5a2..b67bc6bb 100644 --- a/client/ui/qml/Pages2/PageSettingsAppSplitTunneling.qml +++ b/client/ui/qml/Pages2/PageSettingsAppSplitTunneling.qml @@ -175,6 +175,9 @@ PageType { pattern: ".*" + searchField.textField.text + ".*" caseSensitivity: Qt.CaseInsensitive } + sorters: [ + RoleSorter { roleName: "appPath"; sortOrder: Qt.AscendingOrder } + ] } clip: true