Don't lose list position after installing KNS cursor themes

When installing a new cursor theme (or ditto uninstalling) from
KNewStuff, the current theme would become deselected due to a
full refresh of the theme list.

TEST PLAN
Install a theme using Get Hot New Stuff, see that after the list
refreshes, the current theme is reselected. Also uninstall a KNS
originated theme and see the same is true.

BUG:406084
parent da0adfed
......@@ -462,7 +462,35 @@ void CursorThemeConfig::getNewClicked()
if (dialog.exec()) {
KNS3::Entry::List list = dialog.changedEntries();
if (!list.isEmpty()) {
m_model->refreshList();
for (const KNS3::Entry& entry : list) {
if (entry.status() == KNS3::Entry::Deleted) {
for (const QString& deleted : entry.uninstalledFiles()) {
QVector<QStringRef> list = deleted.splitRef(QLatin1Char('/'));
if (list.last() == QLatin1Char('*')) {
list.takeLast();
}
QModelIndex idx = m_model->findIndex(list.last().toString());
if (idx.isValid()) {
m_model->removeTheme(idx);
}
}
} else if (entry.status() == KNS3::Entry::Installed) {
for (const QString& created : entry.installedFiles()) {
QStringList list = created.split(QLatin1Char('/'));
if (list.last() == QLatin1Char('*')) {
list.takeLast();
}
// Because we sometimes get some extra slashes in the installed files list
list.removeAll({});
// Because we'll also get the containing folder, if it was not already there
// we need to ignore it.
if (list.last() == QLatin1String(".icons")) {
continue;
}
m_model->addTheme(list.join(QLatin1Char('/')));
}
}
}
}
}
}
......
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