Commit b943d4ac authored by Nate Graham's avatar Nate Graham 🔩

Sort icon and cursor themes case-insensitively

Summary:
Stick a QSortFilterProxyModel between the model and the view, and tell it to sort case-insensitively. Thanks to https://stackoverflow.com/a/5732026/2934226 for providing the solution.

BUG: 368600
FIXED-IN: 5.14.0

Test Plan: Could not test as I was unable to locate a working GTK 2 or 3 theme that started with a lowercase letter. But theoretically this code should do the trick, and it does not appear to cause any regressions at least.

Reviewers: apol, #plasma, broulik

Reviewed By: apol

Subscribers: wbauer, cfeck, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15598
parent 090ecd13
......@@ -84,6 +84,4 @@ void CursorThemesModel::reload()
fillItem(dir, themeit);
appendRow(themeit);
}
sort(0);
}
......@@ -37,6 +37,7 @@
#include "abstractappearance.h"
#include "iconthemesmodel.h"
#include "fontshelpers.h"
#include <QSortFilterProxyModel>
#include <qstringlistmodel.h>
K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin<GTKConfigKCModule>();)
......@@ -73,11 +74,23 @@ GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args )
setButtons(KCModule::Default | KCModule::Apply);
ui->setupUi(this);
appareance = new AppearenceGTK;
m_cursorsModel = new CursorThemesModel(this);
ui->cb_cursor->setModel(m_cursorsModel);
QSortFilterProxyModel *cursorsProxyModel = new QSortFilterProxyModel(this);
cursorsProxyModel->setSourceModel(m_cursorsModel);
cursorsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
cursorsProxyModel->setSortRole(Qt::DisplayRole);
cursorsProxyModel->sort(0);
ui->cb_cursor->setModel(cursorsProxyModel);
m_iconsModel = new IconThemesModel(false, this);
ui->cb_icon->setModel(m_iconsModel);
ui->cb_icon_fallback->setModel(m_iconsModel);
QSortFilterProxyModel *iconsProxyModel = new QSortFilterProxyModel(this);
iconsProxyModel->setSourceModel(m_iconsModel);
iconsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
iconsProxyModel->setSortRole(Qt::DisplayRole);
iconsProxyModel->sort(0);
ui->cb_icon->setModel(iconsProxyModel);
ui->cb_icon_fallback->setModel(iconsProxyModel);
m_tempGtk2Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/gtkrc-2.0";
m_tempGtk3Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/.config/gtk-3.0/settings.ini";
......
......@@ -32,7 +32,6 @@ IconThemesModel::IconThemesModel(bool onlyHome, QObject* parent)
: QStandardItemModel(parent)
, m_onlyHome(onlyHome)
{
setSortRole(Qt::DisplayRole);
reload();
}
......@@ -129,5 +128,4 @@ void IconThemesModel::reload()
appendRow(item);
}
sort(0);
}
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