Warning, file /utilities/rsibreak/src/setupgeneral.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2005-2007 Tom Albers <toma@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 // Local includes.
0008 
0009 #include "setupgeneral.h"
0010 
0011 #include <QCheckBox>
0012 #include <QGroupBox>
0013 #include <QRadioButton>
0014 #include <QVBoxLayout>
0015 
0016 #include <KConfig>
0017 #include <KConfigGroup>
0018 #include <KLocalizedString>
0019 #include <KSharedConfig>
0020 
0021 class SetupGeneralPriv
0022 {
0023 public:
0024     QCheckBox *autoStart;
0025     QGroupBox *breakTimerSettings;
0026     QRadioButton *useNoIdleTimer;
0027     QRadioButton *useIdleTimer;
0028     QCheckBox *suppressable;
0029 };
0030 
0031 SetupGeneral::SetupGeneral(QWidget *parent)
0032     : QWidget(parent)
0033 {
0034     d = new SetupGeneralPriv;
0035 
0036     QVBoxLayout *l = new QVBoxLayout(this);
0037 
0038     d->autoStart = new QCheckBox(i18n("&Automatically start RSIBreak at startup"), this);
0039     d->autoStart->setWhatsThis(
0040         i18n("With this option you can indicate that "
0041              "you want RSIBreak to start on Desktop Environment start."));
0042 
0043     d->breakTimerSettings = new QGroupBox(i18n("Timer Settings"), this);
0044     d->useNoIdleTimer = new QRadioButton(i18n("Break at &fixed times"), this);
0045     d->useNoIdleTimer->setWhatsThis(
0046         i18n("With this option you indicate that "
0047              "you want to break at fixed intervals"));
0048     d->useIdleTimer = new QRadioButton(i18n("Take activity into account"), this);
0049     d->useIdleTimer->setWhatsThis(
0050         i18n("With this option you indicate that "
0051              "you want to use idle detection. This means that only the time you are "
0052              "active (when you use the keyboard or the mouse) will be counted "
0053              "to calculate when to break next."));
0054     QVBoxLayout *vbox = new QVBoxLayout(d->breakTimerSettings);
0055     vbox->addWidget(d->useNoIdleTimer);
0056     vbox->addWidget(d->useIdleTimer);
0057     d->breakTimerSettings->setLayout(vbox);
0058     connect(d->useIdleTimer, &QRadioButton::toggled, this, &SetupGeneral::useIdleTimerChanged);
0059 
0060     d->suppressable = new QCheckBox(i18n("&Suppress if fullscreen windows present"), this);
0061     d->suppressable->setWhatsThis(
0062         i18n("With this option you can indicate that "
0063              "you do not want RSIBreak to interfere with presentations, games, "
0064              "video playback, and any other fullscreen application on the "
0065              "current virtual desktop."));
0066 
0067     l->addWidget(d->autoStart);
0068     l->addWidget(d->breakTimerSettings);
0069     l->addWidget(d->suppressable);
0070     l->addStretch(1);
0071 
0072     setLayout(l);
0073     readSettings();
0074 }
0075 
0076 SetupGeneral::~SetupGeneral()
0077 {
0078     delete d;
0079 }
0080 
0081 void SetupGeneral::applySettings()
0082 {
0083     KConfigGroup config = KSharedConfig::openConfig()->group("General");
0084     config.writeEntry("AutoStart", d->autoStart->isChecked());
0085 
0086     config = KSharedConfig::openConfig()->group("General Settings");
0087     config.writeEntry("UseNoIdleTimer", d->useNoIdleTimer->isChecked());
0088     config.writeEntry("SuppressIfPresenting", d->suppressable->isChecked());
0089 
0090     config.sync();
0091 }
0092 
0093 bool SetupGeneral::useIdleTimer() const
0094 {
0095     return d->useIdleTimer->isChecked();
0096 }
0097 
0098 void SetupGeneral::readSettings()
0099 {
0100     KConfigGroup config = KSharedConfig::openConfig()->group("General");
0101     d->autoStart->setChecked(config.readEntry("AutoStart", false));
0102 
0103     config = KSharedConfig::openConfig()->group("General Settings");
0104     d->useNoIdleTimer->setChecked(config.readEntry("UseNoIdleTimer", false));
0105     d->useIdleTimer->setChecked(!d->useNoIdleTimer->isChecked());
0106     d->suppressable->setChecked(config.readEntry("SuppressIfPresenting", true));
0107 }