File indexing completed on 2024-04-28 05:46:12
0001 /*************************************************************************** 0002 * Copyright © 2009 Jonathan Thomas <echidnaman@kubuntu.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License as * 0006 * published by the Free Software Foundation; either version 2 of * 0007 * the License or (at your option) version 3 or any later version * 0008 * accepted by the membership of KDE e.V. (or its successor approved * 0009 * by the membership of KDE e.V.), which shall act as a proxy * 0010 * defined in Section 14 of version 3 of the license. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0019 ***************************************************************************/ 0020 0021 #include "notificationhelperconfigmodule.h" 0022 0023 // Qt includes 0024 #include <QButtonGroup> 0025 #include <QCheckBox> 0026 #include <QGroupBox> 0027 #include <QLabel> 0028 #include <QRadioButton> 0029 #include <QVBoxLayout> 0030 0031 // KDE includes 0032 #include <KAboutData> 0033 #include <KConfig> 0034 #include <KConfigGroup> 0035 #include <KLocalizedString> 0036 #include <KPluginFactory> 0037 0038 #warning oh god the class name 0039 0040 K_PLUGIN_FACTORY(NotificationHelperConfigFactory, 0041 registerPlugin<NotificationHelperConfigModule>();) 0042 0043 NotificationHelperConfigModule::NotificationHelperConfigModule(QWidget* parent, const QVariantList&) 0044 : KCModule(parent) 0045 , m_apportCheckBox(nullptr) 0046 , m_driverCheckBox(nullptr) 0047 , m_hookCheckBox(nullptr) 0048 , m_installCheckBox(nullptr) 0049 , m_l10nCheckBox(nullptr) 0050 , m_rebootCheckBox(nullptr) 0051 { 0052 KAboutData *aboutData = new KAboutData("kcmnotificationhelper", 0053 i18n("Kubuntu Notification Helper Configuration"), 0054 VERSION_STRING, 0055 QStringLiteral(""), 0056 KAboutLicense::LicenseKey::GPL, 0057 i18n("(C) 2009-2010 Jonathan Thomas, (C) 2009-2014 Harald Sitter")); 0058 0059 aboutData->addAuthor(i18n("Jonathan Thomas"), QString(), "echidnaman@kubuntu.org"); 0060 aboutData->addAuthor(i18n("Harald Sitter"), QString(), "apachelogger@ubuntu.com"); 0061 0062 setAboutData(aboutData); 0063 0064 setButtons(Apply); 0065 setQuickHelp(i18n("Configure the behavior of Kubuntu Notification Helper")); 0066 0067 KConfig kdedrc("notificationhelper", KConfig::NoGlobals); 0068 0069 QVBoxLayout *lay = new QVBoxLayout(this); 0070 0071 QLabel *label = new QLabel(this); 0072 label->setText(i18n("Show notifications for:")); 0073 0074 m_apportCheckBox = new QCheckBox(i18n("Application crashes"), this); 0075 m_driverCheckBox = new QCheckBox(i18n("Proprietary Driver availability"), this); 0076 m_hookCheckBox = new QCheckBox(i18n("Upgrade information"), this); 0077 m_installCheckBox = new QCheckBox(i18n("Restricted codec availability"), this); 0078 m_l10nCheckBox = new QCheckBox(i18n("Incomplete language support"), this); 0079 m_rebootCheckBox = new QCheckBox(i18n("Required reboots"), this); 0080 0081 connect(m_apportCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0082 connect(m_driverCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0083 connect(m_hookCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0084 connect(m_installCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0085 connect(m_l10nCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0086 connect(m_rebootCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); 0087 0088 QWidget *spacer = new QWidget(this); 0089 0090 QLabel *label2 = new QLabel(this); 0091 label2->setText(i18n("Notification type:")); 0092 0093 QButtonGroup *notifyTypeGroup = new QButtonGroup(this); 0094 m_comboRadio = new QRadioButton(this); 0095 m_comboRadio->setText(i18n("Use both popups and tray icons")); 0096 m_disableKNotifyRadio = new QRadioButton(this); 0097 m_disableKNotifyRadio->setText(i18n("Tray icons only")); 0098 m_disableTrayIconRadio = new QRadioButton(this); 0099 m_disableTrayIconRadio->setText(i18n("Popup notifications only")); 0100 0101 notifyTypeGroup->addButton(m_comboRadio); 0102 notifyTypeGroup->addButton(m_disableKNotifyRadio); 0103 notifyTypeGroup->addButton(m_disableTrayIconRadio); 0104 0105 connect(m_comboRadio, SIGNAL(clicked()), this, SLOT(configChanged())); 0106 connect(m_disableKNotifyRadio, SIGNAL(clicked()), this, SLOT(configChanged())); 0107 connect(m_disableTrayIconRadio, SIGNAL(clicked()), this, SLOT(configChanged())); 0108 0109 lay->addWidget(label); 0110 lay->addWidget(m_apportCheckBox); 0111 lay->addWidget(m_driverCheckBox); 0112 lay->addWidget(m_hookCheckBox); 0113 lay->addWidget(m_installCheckBox); 0114 lay->addWidget(m_l10nCheckBox); 0115 lay->addWidget(m_rebootCheckBox); 0116 lay->addWidget(spacer); 0117 lay->addWidget(label2); 0118 lay->addWidget(m_comboRadio); 0119 lay->addWidget(m_disableKNotifyRadio); 0120 lay->addWidget(m_disableTrayIconRadio); 0121 lay->addStretch(); 0122 } 0123 0124 NotificationHelperConfigModule::~NotificationHelperConfigModule() 0125 { 0126 } 0127 0128 void NotificationHelperConfigModule::load() 0129 { 0130 KConfig cfg("notificationhelper", KConfig::NoGlobals); 0131 KConfigGroup notifyGroup(&cfg, "Event"); 0132 0133 m_apportCheckBox->setChecked(!notifyGroup.readEntry("hideApportNotifier", false)); 0134 m_driverCheckBox->setChecked(!notifyGroup.readEntry("hideDriverNotifier", false)); 0135 m_hookCheckBox->setChecked(!notifyGroup.readEntry("hideHookNotifier", false)); 0136 m_installCheckBox->setChecked(!notifyGroup.readEntry("hideInstallNotifier", false)); 0137 m_l10nCheckBox->setChecked(!notifyGroup.readEntry("hideL10nNotifier", false)); 0138 m_rebootCheckBox->setChecked(!notifyGroup.readEntry("hideRestartNotifier", false)); 0139 0140 KConfigGroup notifyTypeGroup(&cfg, "NotificationType"); 0141 QString notifyType = notifyTypeGroup.readEntry("NotifyType", "Combo"); 0142 0143 if (notifyType == "Combo") { 0144 m_comboRadio->setChecked(true); 0145 } else if (notifyType == "TrayOnly") { 0146 m_disableKNotifyRadio->setChecked(true); 0147 } else { 0148 m_disableTrayIconRadio->setChecked(true); 0149 } 0150 } 0151 0152 void NotificationHelperConfigModule::save() 0153 { 0154 KConfig cfg("notificationhelper", KConfig::NoGlobals); 0155 KConfigGroup notifyGroup(&cfg, "Event"); 0156 0157 notifyGroup.writeEntry("hideApportNotifier", !m_apportCheckBox->isChecked(), KConfig::Notify); 0158 notifyGroup.writeEntry("hideDriverNotifier", !m_driverCheckBox->isChecked(), KConfig::Notify); 0159 notifyGroup.writeEntry("hideHookNotifier", !m_hookCheckBox->isChecked(), KConfig::Notify); 0160 notifyGroup.writeEntry("hideInstallNotifier", !m_installCheckBox->isChecked(), KConfig::Notify); 0161 notifyGroup.writeEntry("hideL10nNotifier", !m_l10nCheckBox->isChecked(), KConfig::Notify); 0162 notifyGroup.writeEntry("hideRestartNotifier", !m_rebootCheckBox->isChecked(), KConfig::Notify); 0163 0164 KConfigGroup notifyTypeGroup(&cfg, "NotificationType"); 0165 notifyTypeGroup.writeEntry("NotifyType", m_comboRadio->isChecked() ? "Combo" : 0166 m_disableKNotifyRadio->isChecked() ? "TrayOnly" : 0167 m_disableTrayIconRadio->isChecked() ? "KNotifyOnly" : 0168 "Combo", KConfig::Notify); 0169 0170 cfg.sync(); 0171 notifyGroup.sync(); 0172 } 0173 0174 void NotificationHelperConfigModule::defaults() 0175 { 0176 m_apportCheckBox->setChecked(true); 0177 m_driverCheckBox->setChecked(true); 0178 m_hookCheckBox->setChecked(true); 0179 m_installCheckBox->setChecked(true); 0180 m_l10nCheckBox->setChecked(true); 0181 m_rebootCheckBox->setChecked(true); 0182 } 0183 0184 void NotificationHelperConfigModule::configChanged() 0185 { 0186 emit changed(true); 0187 } 0188 0189 #include "notificationhelperconfigmodule.moc"