[plasma/discover] libdiscover: Use KConfigXT for AllowPreRelease
Nicolas Fella <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit f3e47aad33749b043f25118429a6d6874429d005 by Nicolas Fella.
Committed on 28/07/2026 at 15:24.
Pushed by nicolasfella into branch 'master'.
Use KConfigXT for AllowPreRelease
M +3 -0 libdiscover/CMakeLists.txt
M +5 -5 libdiscover/appstream/AppStreamIntegration.cpp
A +12 -0 libdiscover/appstream/discover-appstream-settings.kcfg
https://invent.kde.org/plasma/discover/-/commit/f3e47aad33749b043f25118429a6d6874429d005
diff --git a/libdiscover/CMakeLists.txt b/libdiscover/CMakeLists.txt
index ae19146ce..bf34a27e8 100644
--- a/libdiscover/CMakeLists.txt
+++ b/libdiscover/CMakeLists.txt
@@ -12,8 +12,10 @@ if (TARGET AppStreamQt)
add_library(DiscoverAppStreamIntegration STATIC
appstream/AppStreamIntegration.cpp
)
+ kconfig_target_kcfg_file(DiscoverAppStreamIntegration FILE ${CMAKE_CURRENT_SOURCE_DIR}/appstream/discover-appstream-settings.kcfg CLASS_NAME AppstreamSettings INHERITS KCoreConfigSkeleton)
target_link_libraries(DiscoverAppStreamIntegration KF6::CoreAddons KF6::ConfigCore AppStreamQt)
set_property(TARGET DiscoverAppStreamIntegration PROPERTY POSITION_INDEPENDENT_CODE ON)
+ install(FILES appstream/discover-appstream-settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
endif()
set(discovercommon_SRCS
@@ -70,6 +72,7 @@ if(TARGET AppStreamQt)
appstream/AppStreamIntegration.cpp
appstream/AppStreamUtils.cpp
)
+ kconfig_target_kcfg_file(DiscoverCommon FILE ${CMAKE_CURRENT_SOURCE_DIR}/appstream/discover-appstream-settings.kcfg CLASS_NAME AppstreamSettings INHERITS KCoreConfigSkeleton)
target_link_libraries(DiscoverCommon PRIVATE
Qt::Concurrent
KF6::IconThemes
diff --git a/libdiscover/appstream/AppStreamIntegration.cpp b/libdiscover/appstream/AppStreamIntegration.cpp
index f37eff957..7747318e1 100644
--- a/libdiscover/appstream/AppStreamIntegration.cpp
+++ b/libdiscover/appstream/AppStreamIntegration.cpp
@@ -9,10 +9,10 @@
#include <AppStreamQt/systeminfo.h>
#include <AppStreamQt/utils.h>
#include <AppStreamQt/version.h>
-#include <KConfigGroup>
-#include <KSharedConfig>
#include <QDebug>
+#include "discover-appstream-settings.h"
+
using namespace Qt::StringLiterals;
AppStreamIntegration *AppStreamIntegration::global()
@@ -53,9 +53,9 @@ std::optional<AppStream::Release> AppStreamIntegration::getDistroUpgrade(AppStre
// In Appstream metadata terms:
// - Development releases are specified as KindSnapshot
// - Pre-releases are specified as KindDevelopment
- KConfigGroup settings(KSharedConfig::openConfig(QStringLiteral("discoverrc")), QStringLiteral("DistroUpgrade"));
- bool allowPreRelease = settings.readEntry<bool>("AllowPreRelease", false);
- bool allowDevelopmentRelease = settings.readEntry<bool>("AllowDevelopmentRelease", false);
+ AppstreamSettings settings;
+ bool allowPreRelease = settings.allowPreRelease();
+ bool allowDevelopmentRelease = settings.allowDevelopmentRelease();
QString currentVersion = osRelease()->versionId();
diff --git a/libdiscover/appstream/discover-appstream-settings.kcfg b/libdiscover/appstream/discover-appstream-settings.kcfg
new file mode 100644
index 000000000..b4c9bf74c
--- /dev/null
+++ b/libdiscover/appstream/discover-appstream-settings.kcfg
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
+ <kcfgfile name="discoverrc"/>
+ <group name="DistroUpgrade">
+ <entry name="AllowPreRelease" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="AllowDevelopmentRelease" type="Bool">
+ <default>false</default>
+ </entry>
+ </group>
+</kcfg>