From a011628b2ac58feb63acf3f3da64f1474ae15065 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 25 Aug 2023 19:40:09 +0300 Subject: [PATCH] knotify: implement save and load for the KCM now to implemented KNotificationConfigWidget.. Signed-off-by: Ivailo Monev --- knotify/kcm/knotificationconfig.cpp | 25 +++++++++++++++++-------- knotify/kcm/knotificationconfig.h | 7 +++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/knotify/kcm/knotificationconfig.cpp b/knotify/kcm/knotificationconfig.cpp index 93634854..0a32b8f2 100644 --- a/knotify/kcm/knotificationconfig.cpp +++ b/knotify/kcm/knotificationconfig.cpp @@ -31,6 +31,8 @@ K_PLUGIN_FACTORY(KCMNotificationFactory, registerPlugin();) K_EXPORT_PLUGIN(KCMNotificationFactory("kcmknotificationconfig", "kcm_knotificationconfig")) +static const QString s_kdenotification = QString::fromLatin1("kde"); + KCMNotification::KCMNotification(QWidget *parent, const QVariantList &args) : KCModule(KCMNotificationFactory::componentData(), parent), m_layout(nullptr), @@ -40,11 +42,11 @@ KCMNotification::KCMNotification(QWidget *parent, const QVariantList &args) { Q_UNUSED(args); - setButtons(KCModule::Default | KCModule::Apply); + setButtons(KCModule::Apply); setQuickHelp(i18n("

Notifications Configuration

This module allows you to change KDE notification options.")); KAboutData *about = new KAboutData( - I18N_NOOP("kcmkgreeter"), 0, + I18N_NOOP("kcmknotificationconfig"), 0, ki18n("KDE Notifications Configuration Module"), 0, KLocalizedString(), KAboutData::License_GPL, ki18n("Copyright 2023, Ivailo Monev xakepa10@gmail.com") @@ -75,9 +77,11 @@ KCMNotification::KCMNotification(QWidget *parent, const QVariantList &args) } } m_notificationsbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + connect(m_notificationsbox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSourceIndexChanged(int))); m_layout->addWidget(m_notificationsbox, 0, 1); - m_notificationswidget = new KNotificationConfigWidget(QString(), this); + m_notificationswidget = new KNotificationConfigWidget(s_kdenotification, this); + connect(m_notificationswidget, SIGNAL(changed(bool)), this, SLOT(slotNotificationChanged(bool))); m_layout->addWidget(m_notificationswidget, 1, 0, 1, 2); } @@ -87,20 +91,25 @@ KCMNotification::~KCMNotification() void KCMNotification::load() { - // TODO: + m_notificationswidget->setNotification(s_kdenotification); emit changed(false); } void KCMNotification::save() { - // TODO: + m_notificationswidget->save(); emit changed(false); } -void KCMNotification::defaults() +void KCMNotification::slotSourceIndexChanged(int index) { - // TODO: - emit changed(true); + const QString notification = m_notificationsbox->itemData(index).toString(); + m_notificationswidget->setNotification(notification); +} + +void KCMNotification::slotNotificationChanged(bool state) +{ + emit changed(state); } #include "moc_knotificationconfig.cpp" diff --git a/knotify/kcm/knotificationconfig.h b/knotify/kcm/knotificationconfig.h index 93732bc0..59399573 100644 --- a/knotify/kcm/knotificationconfig.h +++ b/knotify/kcm/knotificationconfig.h @@ -26,7 +26,7 @@ #include /** - * Control KDE free space notifier + * Control KDE notifications * * @author Ivailo Monev (xakepa10@gmail.com) */ @@ -41,7 +41,10 @@ public: public Q_SLOTS: void load() final; void save() final; - void defaults() final; + +private Q_SLOTS: + void slotSourceIndexChanged(int index); + void slotNotificationChanged(bool state); private: QGridLayout* m_layout;