Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Keep the new app toolbars when upgrading xmlgui
David Faurebfab45efd62d
diff --git a/libs/widgetutils/xmlgui/kxmlguiversionhandler.cpp b/libs/widgetutils/xmlgui/kxmlguiversionhandler.cppindex 0597831650..e1f62dbf62 100644--- a/libs/widgetutils/xmlgui/kxmlguiversionhandler.cpp+++ b/libs/widgetutils/xmlgui/kxmlguiversionhandler.cpp@@ -33,12 +33,26 @@ static QList<QDomElement> extractToolBars(const QDomDocument &doc)return toolbars;}-static void removeAllToolBars(QDomDocument &doc)+static QStringList toolBarNames(const QList<QDomElement> &toolBars)+{+ QStringList names;+ names.reserve(toolBars.count());+ for (const QDomElement &e : toolBars) {+ names.append(e.attribute(QStringLiteral("name")));+ }+ return names;+}++static void removeToolBars(QDomDocument &doc, const QStringList &toolBarNames)+{QDomElement parent = doc.documentElement();const QList<QDomElement> toolBars = extractToolBars(doc);Q_FOREACH (const QDomElement &e, toolBars) {- parent.removeChild(e);+ if (toolBarNames.contains(e.attribute(QStringLiteral("name")))) {+ parent.removeChild(e);+ }+}}@@ -303,8 +317,10 @@ KXmlGuiVersionHandler::KXmlGuiVersionHandler(const QStringList &files)// and store the properties in therestoreActionProperties(document, properties);if (!toolbars.isEmpty()) {- // remove application toolbars- removeAllToolBars(document);+ // remove application toolbars present in the user file+ // (not others, that the app might have added since)+ removeToolBars(document, toolBarNames(toolbars));+// add user toolbarsinsertToolBars(document, toolbars);}