[graphics/optiimage] /: Use KirigamiAppDefaults for style selection and other initializtion in main()

Arjen Hiemstra <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 4cf4d8cd6e66051407c89c8678071be2b5a365ce by Arjen Hiemstra.
Committed on 30/07/2026 at 12:48.
Pushed by tfella into branch 'master'.

Use KirigamiAppDefaults for style selection and other initializtion in main()

This reduces code duplication and handles some cases better.

M  +1    -1    CMakeLists.txt
M  +1    -0    src/CMakeLists.txt
M  +2    -15   src/main.cpp

https://invent.kde.org/graphics/optiimage/-/commit/4cf4d8cd6e66051407c89c8678071be2b5a365ce

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ff33c9..a1c136e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ set_package_properties(KF6Crash PROPERTIES
         PURPOSE "For crash handling"
 )
 
-find_package(KF6KirigamiAddons 1.5.0)
+find_package(KF6KirigamiAddons 1.12.0)
 set_package_properties(KF6KirigamiAddons PROPERTIES
     TYPE REQUIRED
     PURPOSE "Required application components and runtime dependency"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2285a07..72fe9a4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,6 +41,7 @@ target_link_libraries(optiimage_static PUBLIC
     KF6::KIOCore
     KF6::KIOFileWidgets
     KF6::IconThemes
+    KirigamiApp
     QCoro::Core
     QCoro::Qml
 )
diff --git a/src/main.cpp b/src/main.cpp
index ec6930c..4ea8a76 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,7 @@
 #include <KIconTheme>
 #include <KLocalizedQmlContext>
 #include <KLocalizedString>
+#include <KirigamiAddons/App/KirigamiAppDefaults>
 #include <QApplication>
 #include <QCoroQml>
 #include <QIcon>
@@ -13,24 +14,14 @@
 
 #include "optiimage-version.h"
 
-#if __has_include("KCrash")
-#include <KCrash>
-#endif
-
 using namespace Qt::Literals::StringLiterals;
 
 int main(int argc, char *argv[])
 {
-    KIconTheme::initTheme();
-    QIcon::setFallbackThemeName(u"breeze"_s);
-
     QApplication app(argc, argv);
     KLocalizedString::setApplicationDomain("optiimage");
 
-    // Default to org.kde.desktop style unless the user forces another style
-    if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
-        QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
-    }
+    KirigamiAppDefaults::apply(&app);
 
     KAboutData about(QStringLiteral("optiimage"),
                      i18n("OptiImage"),
@@ -46,10 +37,6 @@ int main(int argc, char *argv[])
     KAboutData::setApplicationData(about);
     QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.optiimage")));
 
-#if __has_include("KCrash")
-    KCrash::initialize();
-#endif
-
     QQmlApplicationEngine engine;
     QCoro::Qml::registerTypes();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.