[network/alligator] /: Use KirigamiAppDefaults for setting style and other setup in main()

Arjen Hiemstra <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 1650f2befe75888ace1d6d0cf985b1972d6bf4d9 by Arjen Hiemstra.
Committed on 24/07/2026 at 14:26.
Pushed by tfella into branch 'master'.

Use KirigamiAppDefaults for setting style and other setup in main()

We have a function now that can take care of all of this, use it to
reduce code duplication and handle some things like style selection
better.

M  +1    -1    CMakeLists.txt
M  +1    -1    src/CMakeLists.txt
M  +3    -22   src/main.cpp

https://invent.kde.org/network/alligator/-/commit/1650f2befe75888ace1d6d0cf985b1972d6bf4d9

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ac76d5..7d15abf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ ecm_setup_version(${PROJECT_VERSION}
 find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Sql)
 find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Syndication Config I18n ColorScheme Kirigami)
 
-find_package(KF6KirigamiAddons 0.6 REQUIRED)
+find_package(KF6KirigamiAddons 1.12 REQUIRED)
 if (NOT BUILD_SHARED_LIBS)
     find_package(QQC2BreezeStyle REQUIRED)
 endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fe0cc2d..1737360 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,7 +55,7 @@ ecm_qt_declare_logging_category(alligator
 )
 
 target_include_directories(alligator PRIVATE ${CMAKE_BINARY_DIR})
-target_link_libraries(alligator PRIVATE Qt::Core Qt::Qml Qt::Quick Qt::QuickControls2 Qt::Sql KF6::Syndication KF6::CoreAddons KF6::ConfigGui KF6::I18n KF6::ColorScheme KF6::I18nQml)
+target_link_libraries(alligator PRIVATE Qt::Core Qt::Qml Qt::Quick Qt::QuickControls2 Qt::Sql KF6::Syndication KF6::CoreAddons KF6::ConfigGui KF6::I18n KF6::ColorScheme KF6::I18nQml KirigamiApp)
 if (NOT QT6_IS_SHARED_LIBS_BUILD)
     qt6_import_qml_plugins(alligator)
 endif()
diff --git a/src/main.cpp b/src/main.cpp
index 1c22547..e9f038f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,6 +26,7 @@
 #include <KColorSchemeManager>
 #include <KLocalizedQmlContext>
 #include <KLocalizedString>
+#include <KirigamiAddons/App/KirigamiAppDefaults>
 
 #include "alligator-version.h"
 #include "alligatorsettings.h"
@@ -44,30 +45,10 @@ int main(int argc, char *argv[])
 {
 #ifdef Q_OS_ANDROID
     QGuiApplication app(argc, argv);
-    QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
 #else
     QApplication app(argc, argv);
-    if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
-        QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
-    }
 #endif
-    KColorSchemeManager::instance();
-
-#ifdef Q_OS_WINDOWS
-    if (AttachConsole(ATTACH_PARENT_PROCESS)) {
-        FILE *outFile = freopen("CONOUT$", "w", stdout);
-        if (!outFile)
-            qCWarning(ALLIGATOR) << "Failed to reopen stdout";
-        FILE *errFile = freopen("CONOUT$", "w", stderr);
-        if (!errFile)
-            qCWarning(ALLIGATOR) << "Failed to reopen stderr";
-    }
 
-    QApplication::setStyle(QStringLiteral("breeze"));
-    auto font = app.font();
-    font.setPointSize(10);
-    app.setFont(font);
-#endif
     KLocalizedString::setApplicationDomain("alligator");
 
     QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
@@ -85,10 +66,10 @@ int main(int argc, char *argv[])
 
 #ifndef Q_OS_ANDROID
     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("alligator")));
-
-    KCrash::initialize();
 #endif
 
+    KirigamiAppDefaults::apply(&app);
+
     QQmlApplicationEngine engine;
     KLocalization::setupLocalizedContext(&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.