File indexing completed on 2024-05-05 05:00:09

0001 /*
0002     SPDX-FileCopyrightText: 2004 Lubos Lunak <l.lunak@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "system.h"
0008 
0009 #include <kconfig.h>
0010 
0011 #include <QCheckBox>
0012 #include <KLocalizedString>
0013 #include <KConfigGroup>
0014 
0015 namespace KCMPerformance
0016 {
0017 
0018 SystemWidget::SystemWidget(QWidget *parent_P)
0019     : System_ui(parent_P)
0020 {
0021     QString tmp =
0022         i18n("<p>During startup KDE needs to perform a check of its system configuration"
0023              " (mimetypes, installed applications, etc.), and in case the configuration"
0024              " has changed since the last time, the system configuration cache (KSyCoCa)"
0025              " needs to be updated.</p>"
0026              "<p>This option delays the check, which avoid scanning all directories containing"
0027              " files describing the system during KDE startup, thus"
0028              " making KDE startup faster. However, in the rare case the system configuration"
0029              " has changed since the last time, and the change is needed before this"
0030              " delayed check takes place, this option may lead to various problems"
0031              " (missing applications in the K Menu, reports from applications about missing"
0032              " required mimetypes, etc.).</p>"
0033              "<p>Changes of system configuration mostly happen by (un)installing applications."
0034              " It is therefore recommended to turn this option temporarily off while"
0035              " (un)installing applications.</p>");
0036     cb_disable_kbuildsycoca->setToolTip(tmp);
0037     label_kbuildsycoca->setToolTip(tmp);
0038     connect(cb_disable_kbuildsycoca, &QAbstractButton::clicked, this, &SystemWidget::changed);
0039     defaults();
0040 }
0041 
0042 void SystemWidget::load()
0043 {
0044     KConfig _cfg(QStringLiteral("kdedrc"));
0045     KConfigGroup cfg(&_cfg, "General");
0046     cb_disable_kbuildsycoca->setChecked(cfg.readEntry("DelayedCheck", false));
0047 }
0048 
0049 void SystemWidget::save()
0050 {
0051     KConfig _cfg(QStringLiteral("kdedrc"));
0052     KConfigGroup cfg(&_cfg, "General");
0053     cfg.writeEntry("DelayedCheck", cb_disable_kbuildsycoca->isChecked());
0054 }
0055 
0056 void SystemWidget::defaults()
0057 {
0058     cb_disable_kbuildsycoca->setChecked(false);
0059 }
0060 
0061 } // namespace
0062