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

0001 /*
0002     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "konqueror.h"
0008 
0009 #include <kconfig.h>
0010 #include <QDBusConnection>
0011 #include <QDBusMessage>
0012 #include <QCheckBox>
0013 #include <KLocalizedString>
0014 #include <KConfigGroup>
0015 
0016 namespace KCMPerformance
0017 {
0018 
0019 Konqueror::Konqueror(QWidget *parent_P)
0020     : Konqueror_ui(parent_P)
0021 {
0022     // TODO move these strings to konqueror.kcfg and use that from here
0023     cb_preload_on_startup->setToolTip(
0024         i18n("<p>If enabled, an instance of Konqueror will be preloaded after the ordinary Plasma "
0025              "startup sequence.</p>"
0026              "<p>This will make the first Konqueror window open faster, but "
0027              "at the expense of longer Plasma startup times (but you will be able to work "
0028              "while it is loading, so you may not even notice that it is taking longer).</p>"));
0029     cb_always_have_preloaded->setToolTip(
0030         i18n("<p>If enabled, Konqueror will always try to have one preloaded instance ready; "
0031              "preloading a new instance in the background whenever there is not one available, "
0032              "so that windows will always open quickly.</p>"
0033              "<p><b>Warning:</b> In some cases, it is actually possible that this will "
0034              "reduce perceived performance.</p>"));
0035     connect(cb_preload_on_startup, &QAbstractButton::toggled, this, &Konqueror::changed);
0036     connect(cb_always_have_preloaded, &QAbstractButton::toggled, this, &Konqueror::changed);
0037     defaults();
0038 }
0039 
0040 void Konqueror::load()
0041 {
0042     KConfig _cfg(QStringLiteral("konquerorrc"));
0043     KConfigGroup cfg(&_cfg, "Reusing");
0044     cb_preload_on_startup->setChecked(cfg.readEntry("PreloadOnStartup", false));
0045     cb_always_have_preloaded->setChecked(cfg.readEntry("AlwaysHavePreloaded", true));
0046 }
0047 
0048 void Konqueror::save()
0049 {
0050     KConfig _cfg(QStringLiteral("konquerorrc"));
0051     KConfigGroup cfg(&_cfg, "Reusing");
0052     cfg.writeEntry("PreloadOnStartup", cb_preload_on_startup->isChecked());
0053     cfg.writeEntry("AlwaysHavePreloaded", cb_always_have_preloaded->isChecked());
0054     cfg.sync();
0055     QDBusMessage message =
0056         QDBusMessage::createSignal(QStringLiteral("/KonqMain"), QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("reparseConfiguration"));
0057     QDBusConnection::sessionBus().send(message);
0058 }
0059 
0060 void Konqueror::defaults()
0061 {
0062     cb_preload_on_startup->setChecked(false);
0063     cb_always_have_preloaded->setChecked(true);
0064 }
0065 
0066 } // namespace