[multimedia/kasts] /: Use KirigamiAppDefaults to initialize several common things in main()

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

Use KirigamiAppDefaults to initialize several common things in main()

We now have a standardised function for this, let's use it to reduce
code duplication and to handle some cases better such as style
selection.

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

https://invent.kde.org/multimedia/kasts/-/commit/51428cde9ff1b4e4c6ef8c5cdb17a726856c2ff7

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40ec4844..12fb01bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,7 +59,7 @@ find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS I18n CoreAddons Kirigami
 
 find_package(KF6 ${KF_MIN_VERSION} QUIET COMPONENTS BreezeIcons)
 
-find_package(KF6KirigamiAddons 1.6.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 3f779857..66f1f06e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -291,6 +291,7 @@ target_link_libraries(kasts
         KF6::ColorScheme
         KF6::IconThemes
         KMediaSession
+        KirigamiApp
 )
 
 if(TARGET KF6::BreezeIcons)
diff --git a/src/main.cpp b/src/main.cpp
index 7ec80212..0b72f4d7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,6 +40,7 @@
 #ifdef HAVE_WINDOWSYSTEM
 #include <KWindowSystem>
 #endif
+#include <KirigamiAddons/App/KirigamiAppDefaults>
 
 #ifdef WITH_BREEZEICONS_LIB
 #include <BreezeIcons>
@@ -64,8 +65,6 @@ Q_DECL_EXPORT
 
 int main(int argc, char *argv[])
 {
-    KIconTheme::initTheme();
-
     // Check if we need to force the interface to mobile or desktop, or stick
     // with the built-in Kirigami setting
     if (SettingsManager::self() && SettingsManager::self()->interfaceMode() != 2) {
@@ -86,30 +85,16 @@ int main(int argc, char *argv[])
     QGuiApplication app(argc, argv);
     qInstallMessageHandler(myMessageHandler);
     QLoggingCategory::setFilterRules(QStringLiteral("org.kde.*=true"));
-    QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
 #else
     QApplication app(argc, argv);
-    if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
-        QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
-    }
-#endif
-
-#ifdef Q_OS_WINDOWS
-    if (AttachConsole(ATTACH_PARENT_PROCESS)) {
-        freopen("CONOUT$", "w", stdout);
-        freopen("CONOUT$", "w", stderr);
-    }
-
-    QApplication::setStyle(QStringLiteral("breeze"));
-    auto font = app.font();
-    font.setPointSize(10);
-    app.setFont(font);
 #endif
 
 #ifdef WITH_BREEZEICONS_LIB
     BreezeIcons::initIcons();
 #endif
 
+    KirigamiAppDefaults::apply(&app);
+
     KLocalizedString::setApplicationDomain("kasts");
 
     QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
@@ -175,8 +160,6 @@ int main(int argc, char *argv[])
 
 #ifndef Q_OS_ANDROID
     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kasts")));
-
-    KCrash::initialize();
 #endif
 
 #ifdef HAVE_KDBUSADDONS
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.