[multimedia/elisa] /: Use KirigamiAppDefaults for several setup tasks in main()

Arjen Hiemstra <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit a10c73fd9ed31d55a242d93fbf3afa92f3662925 by Arjen Hiemstra.
Committed on 24/07/2026 at 12:55.
Pushed by ngraham into branch 'master'.

Use KirigamiAppDefaults for several setup tasks in main()

We now have a shared function that can do several of the setup things
that are done in main(). Use that function to reduce the amount of
duplicated code and to handle some cases like style selection better.

M  +5    -0    CMakeLists.txt
M  +1    -0    src/CMakeLists.txt
M  +3    -32   src/main.cpp

https://invent.kde.org/multimedia/elisa/-/commit/a10c73fd9ed31d55a242d93fbf3afa92f3662925

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0bba5238..93e2d083a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,6 +108,11 @@ set_package_properties(KF6Crash PROPERTIES
     DESCRIPTION "Graceful handling of application crashes."
     TYPE OPTIONAL)
 
+find_package(KF6KirigamiAddons CONFIG QUIET)
+set_package_properties(KF6KirigamiAddons PROPERTIES
+    DESCRIPTION "Addons for Kirigami applications"
+    TYPE REQUIRED)
+
 if (NOT WIN32 AND NOT ANDROID)
     find_package(KF6DBusAddons ${REQUIRED_KF_VERSION} CONFIG QUIET)
     set_package_properties(KF6DBusAddons PROPERTIES
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 276767464..190814a26 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -424,6 +424,7 @@ if (Qt6Quick_FOUND AND Qt6Widgets_FOUND)
         Qt::Widgets Qt::QuickControls2
         KF6::I18n KF6::I18nQml KF6::CoreAddons KF6::ConfigCore KF6::ConfigGui
         KF6::IconThemes
+        KirigamiApp
         )
 
     if (ANDROID)
diff --git a/src/main.cpp b/src/main.cpp
index 4af125701..60e942bfc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,6 +28,7 @@
 
 #include <KAboutData>
 #include <KIconTheme>
+#include <KirigamiAddons/App/KirigamiAppDefaults>
 
 #if KFCrash_FOUND
 #include <KCrash>
@@ -68,11 +69,6 @@ int __attribute__((visibility("default"))) main(int argc, char *argv[])
 int main(int argc, char *argv[])
 #endif
 {
-    KIconTheme::initTheme();
-    auto format = QSurfaceFormat::defaultFormat();
-    format.setOption(QSurfaceFormat::ResetNotification);
-    QSurfaceFormat::setDefaultFormat(format);
-
 #ifdef Q_OS_ANDROID
     if(argc > 1 && strcmp(argv[1], "-service") == 0){
         QAndroidService app(argc, argv);
@@ -90,21 +86,10 @@ int main(int argc, char *argv[])
     AndroidPlayerJni::registerNativeMethods();
 #endif
 
-#ifdef Q_OS_WIN
-    if (AttachConsole(ATTACH_PARENT_PROCESS)) {
-        freopen("CONOUT$", "w", stdout);
-        freopen("CONOUT$", "w", stderr);
-    }
-#endif
-
     qputenv("QT_GSTREAMER_USE_PLAYBIN_VOLUME", "true");
 
     QApplication app(argc, argv);
 
-#if defined Q_OS_WIN || defined Q_OS_MAC
-    QApplication::setStyle(QStringLiteral("breeze"));
-#endif
-
     KLocalizedString::setApplicationDomain(QByteArrayLiteral("elisa"));
 
     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("elisa")));
@@ -126,28 +111,14 @@ int main(int argc, char *argv[])
     aboutData.addCredit(QStringLiteral("Jérôme Guidon"), i18nc("@label", "Support for online radios"), QStringLiteral("[email protected]"));
 
     KAboutData::setApplicationData(aboutData);
-#if KFCrash_FOUND
-    KCrash::initialize();
-#endif
+
+    KirigamiAppDefaults::apply(&app);
 
     QCommandLineParser parser;
     aboutData.setupCommandLine(&parser);
     parser.process(app);
     aboutData.processCommandLine(&parser);
 
-
-    // If styling has not been set via QT_QUICK_CONTROLS_STYLE, default to some
-    // styles that make sense for desktop and mobile form factors.
-    if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
-#ifdef Q_OS_ANDROID
-        QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
-        QQuickStyle::setFallbackStyle(QStringLiteral("Material"));
-#else
-        QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
-        QQuickStyle::setFallbackStyle(QStringLiteral("Fusion"));
-#endif
-    }
-
     QQmlApplicationEngine engine;
     engine.addImportPath(QStringLiteral("qrc:/imports"));
     QQmlFileSelector selector(&engine);
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.