[graphics/koko/release/26.08] src: NavigationActions: use the new api ActionCollection::removeAction()
Oliver Beard <[email protected]> Tue, 4 Aug 2026 13:30:43 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit d4a2bb8e46c8978b0ef72f66bd17deb20ad137f5 by Oliver Beard, on behalf of Marco Martin.
Committed on 04/08/2026 at 13:25.
Pushed by olib into branch 'release/26.08'.
NavigationActions: use the new api ActionCollection::removeAction()
when updating the saved folders remove all the actions of folders
not there anymore and add actions for each new folder that wasn;t there
yet
M +22 -6 src/navigationactions.cpp
https://invent.kde.org/graphics/koko/-/commit/d4a2bb8e46c8978b0ef72f66bd17deb20ad137f5
diff --git a/src/navigationactions.cpp b/src/navigationactions.cpp
index b7e6593f..2b87dc3f 100644
--- a/src/navigationactions.cpp
+++ b/src/navigationactions.cpp
@@ -125,18 +125,35 @@ void NavigationActions::updateSavedFolders()
auto config = Config::self();
const auto savedFolders = config->savedFolders();
- m_savedFolderNames.clear();
-
KirigamiActions::ActionCollection *coll = KirigamiActions::ActionCollections::self()->collection(u"org.kde.koko.navigation"_s);
- for (const auto &folder : savedFolders) {
+ QSet<QString> oldSavedFoldersSet(m_savedFolderNames.constBegin(), m_savedFolderNames.constEnd());
+
+ QSet<QString> newSavedFoldersSet;
+
+ std::ranges::copy(savedFolders | std::views::transform([](const QString &folder) {
+ return QUrl::fromLocalFile(QUrl(folder).toLocalFile()).toString();
+ }),
+ std::inserter(newSavedFoldersSet, newSavedFoldersSet.end()));
+
+ for (const auto &folder : m_savedFolderNames) {
+ if (!newSavedFoldersSet.contains(folder)) {
+ coll->removeAction(folder);
+ }
+ }
+ m_savedFolderNames.clear();
+
+ for (const auto &normalizedFolder : newSavedFoldersSet) {
+ m_savedFolderNames << normalizedFolder;
+ if (oldSavedFoldersSet.contains(normalizedFolder)) {
+ continue;
+ }
// Not added to the managed actions
- QString text = folder;
+ QString text = normalizedFolder;
if (text.endsWith(u'/')) {
text.chop(1);
}
text = text.split(u'/').constLast();
- QString normalizedFolder = QUrl::fromLocalFile(QUrl(folder).toLocalFile()).toString();
auto placeAction = coll->createAction(normalizedFolder, KIO::iconNameForUrl(normalizedFolder), text);
placeAction->setCheckable(true);
@@ -148,7 +165,6 @@ void NavigationActions::updateSavedFolders()
connect(placeAction, &QAction::triggered, this, [this, normalizedFolder] {
Q_EMIT navigate(FolderModel, normalizedFolder);
});
- m_savedFolderNames << normalizedFolder;
}
Q_EMIT savedFoldersChanged();