Commit 8464bec5 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

kcm: Add a configuration setting for offline updates

Lets users who prefer unstable systems to rebootting keep their old
ways.
Lets users from distros that don't enable it by default,
enable it and enjoy a more stable upgrade experience.

CCBUG: 435574
parent 676f354e
......@@ -3,6 +3,13 @@
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_updates\")
kcmutils_generate_module_data(
kcm_updates_PART_SRCS
MODULE_DATA_HEADER discoverdata.h
MODULE_DATA_CLASS_NAME DiscoverData
SETTINGS_HEADERS discoversettings.h
SETTINGS_CLASSES DiscoverSettings
)
kcmutils_generate_module_data(
kcm_updates_PART_SRCS
MODULE_DATA_HEADER updatesdata.h
......@@ -12,6 +19,7 @@ kcmutils_generate_module_data(
)
kconfig_add_kcfg_files(kcm_updates_PART_SRCS updatessettings.kcfgc GENERATE_MOC)
kconfig_add_kcfg_files(kcm_updates_PART_SRCS discoversettings.kcfgc GENERATE_MOC)
add_library(kcm_updates MODULE updates.cpp ${kcm_updates_PART_SRCS})
target_link_libraries(kcm_updates
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: (C) 2021 Aleix Pol Gonzalzez <aleixpol@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
-->
<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="Software">
<entry name="UseOfflineUpdates" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>
; SPDX-FileCopyrightText: (C) 2021 Aleix Pol Gonzalzez <aleixpol@kde.org>
;
; SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
File=discoversettings.kcfg
ClassName=DiscoverSettings
Notifiers=true
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
......@@ -23,6 +23,8 @@ SimpleKCM {
ColumnLayout {
Kirigami.FormLayout {
id: unattendedUpdatesLayout
Layout.fillWidth: true
QQC2.RadioButton {
Kirigami.FormData.label: i18n("Update software:")
text: i18n("Manually")
......@@ -55,5 +57,41 @@ SimpleKCM {
font: theme.smallestFont
text: xi18nc("@info", "Software updates will be downloaded automatically when they become available. Updates for applications will be installed immediately, while system updates will be installed the next time the computer is restarted.")
}
Kirigami.Separator {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.gridUnit
Layout.bottomMargin: Kirigami.Units.gridUnit
}
Kirigami.FormLayout {
Layout.fillWidth: true
twinFormLayouts: unattendedUpdatesLayout
QQC2.CheckBox {
id: offlineUpdatesBox
Kirigami.FormData.label: i18n("Use offline updates:")
enabled: !kcm.discoverSettings.isUseOfflineUpdatesImmutable
checked: kcm.discoverSettings.useOfflineUpdates
onToggled: {
kcm.discoverSettings.useOfflineUpdates = checked
}
}
SettingStateBinding {
configObject: kcm.discoverSettings
settingName: "useOfflineUpdates"
target: offlineUpdatesBox
}
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Math.min(Kirigami.Units.gridUnit * 25, Math.round(root.width * 0.6))
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
font: Kirigami.Theme.smallFont
text: i18n("Offline updates maximize system stability by applying changes while restarting the system. Using this update mode is strongly recommended.")
}
}
}
......@@ -11,6 +11,8 @@
#include <KLocalizedString>
#include <KPluginFactory>
#include <discoverdata.h>
#include <discoversettings.h>
#include <updatesdata.h>
#include <updatessettings.h>
......@@ -19,10 +21,12 @@ K_PLUGIN_FACTORY_WITH_JSON(UpdatesFactory, "kcm_updates.json", registerPlugin<Up
Updates::Updates(QObject *parent, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent)
, m_data(new UpdatesData(this))
, m_discoverData(new DiscoverData(this))
{
Q_UNUSED(args)
qmlRegisterAnonymousType<UpdatesSettings>("org.kde.discover.updates", 1);
qmlRegisterAnonymousType<DiscoverSettings>("org.kde.discover.updates", 1);
setAboutData(new KAboutData(QStringLiteral("kcm_updates"),
i18n("Software Updates"),
......@@ -32,9 +36,15 @@ Updates::Updates(QObject *parent, const QVariantList &args)
}
Updates::~Updates() = default;
UpdatesSettings *Updates::updatesSettings() const
{
return m_data->settings();
}
DiscoverSettings *Updates::discoverSettings() const
{
return m_discoverData->settings();
}
#include "updates.moc"
......@@ -12,18 +12,23 @@
class UpdatesData;
class UpdatesSettings;
class DiscoverData;
class DiscoverSettings;
class Updates : public KQuickAddons::ManagedConfigModule
{
Q_OBJECT
Q_PROPERTY(UpdatesSettings *updatesSettings READ updatesSettings CONSTANT)
Q_PROPERTY(DiscoverSettings *discoverSettings READ discoverSettings CONSTANT)
public:
explicit Updates(QObject *parent = nullptr, const QVariantList &list = QVariantList());
~Updates() override;
UpdatesSettings *updatesSettings() const;
DiscoverSettings *discoverSettings() const;
private:
UpdatesData *m_data;
DiscoverData *m_discoverData;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment