From bbdada22fd1cffcd1b3565be1d47ba4ca7484ecb Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 15 Mar 2024 00:46:08 +0200 Subject: [PATCH] kcontrol: fix spellchecking KCM reset and defaults actions and because I rewrote everything underneath the KCM (which happened last year) copyright goes to me Signed-off-by: Ivailo Monev --- kcontrol/spellchecking/spellchecking.cpp | 78 ++++++++++++++---------- kcontrol/spellchecking/spellchecking.h | 54 ++++++++-------- 2 files changed, 73 insertions(+), 59 deletions(-) diff --git a/kcontrol/spellchecking/spellchecking.cpp b/kcontrol/spellchecking/spellchecking.cpp index f3409041..530f347b 100644 --- a/kcontrol/spellchecking/spellchecking.cpp +++ b/kcontrol/spellchecking/spellchecking.cpp @@ -1,59 +1,71 @@ -/* +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev -Copyright 2008 Albert Astals Cid + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of -the License or (at your option) version 3 or any later version -accepted by the membership of KDE e.V. (or its successor approved -by the membership of KDE e.V.), which shall act as a proxy -defined in Section 14 of version 3 of the license. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ #include "spellchecking.h" #include -#include -#include +K_PLUGIN_FACTORY(SpellFactory, registerPlugin();) +K_EXPORT_PLUGIN(SpellFactory("kcmspellchecking")) -K_PLUGIN_FACTORY(SpellFactory, registerPlugin();) -K_EXPORT_PLUGIN(SpellFactory( "kcmspellchecking" )) - -SonnetSpellCheckingModule::SonnetSpellCheckingModule(QWidget* parent, const QVariantList&): - KCModule(SpellFactory::componentData(), parent) +SpellCheckingModule::SpellCheckingModule(QWidget *parent, const QVariantList &args) + : KCModule(SpellFactory::componentData(), parent, args), + m_layout(nullptr), + m_configWidget(nullptr), + m_config(nullptr) { - QBoxLayout *layout = new QVBoxLayout( this ); - layout->setMargin(0); + Q_UNUSED(args); + + m_layout = new QVBoxLayout(this); + m_layout->setMargin(0); m_config = new KConfig("kdeglobals"); - m_configWidget = new KSpellConfigWidget( m_config, this ); - layout->addWidget(m_configWidget); - connect(m_configWidget, SIGNAL(configChanged()), this, SLOT(changed())); } -SonnetSpellCheckingModule::~SonnetSpellCheckingModule() +SpellCheckingModule::~SpellCheckingModule() { delete m_config; } -void SonnetSpellCheckingModule::save() +void SpellCheckingModule::load() { - m_configWidget->save(); + if (m_configWidget) { + delete m_configWidget; + } + m_configWidget = new KSpellConfigWidget(m_config, this); + m_layout->addWidget(m_configWidget); + connect(m_configWidget, SIGNAL(configChanged()), this, SLOT(slotConfigChanged())); + emit changed(false); } -void SonnetSpellCheckingModule::defaults() +void SpellCheckingModule::save() +{ + m_configWidget->save(); + emit changed(false); +} + +void SpellCheckingModule::defaults() { m_configWidget->slotDefault(); } +void SpellCheckingModule::slotConfigChanged() +{ + emit changed(true); +} + #include "moc_spellchecking.cpp" diff --git a/kcontrol/spellchecking/spellchecking.h b/kcontrol/spellchecking/spellchecking.h index 76fe1889..e23c707c 100644 --- a/kcontrol/spellchecking/spellchecking.h +++ b/kcontrol/spellchecking/spellchecking.h @@ -1,49 +1,51 @@ -/* +/* This file is part of the KDE project + Copyright (C) 2023 Ivailo Monev -Copyright 2008 Albert Astals Cid + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of -the License or (at your option) version 3 or any later version -accepted by the membership of KDE e.V. (or its successor approved -by the membership of KDE e.V.), which shall act as a proxy -defined in Section 14 of version 3 of the license. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ -#ifndef SONNETSPELLCHECKINGMODULE_H -#define SONNETSPELLCHECKINGMODULE_H +#ifndef SPELLCHECKING_H +#define SPELLCHECKING_H -#include "kcmodule.h" +#include +#include +#include -class KConfig; -class KSpellConfigWidget; +#include -class SonnetSpellCheckingModule : public KCModule +class SpellCheckingModule : public KCModule { Q_OBJECT public: - SonnetSpellCheckingModule(QWidget* parent, const QVariantList&); - ~SonnetSpellCheckingModule(); + SpellCheckingModule(QWidget *parent, const QVariantList &args); + ~SpellCheckingModule(); // KCModule reimplementations public Q_SLOTS: + void load() final; void save() final; void defaults() final; +private Q_SLOTS: + void slotConfigChanged(); + private: + QVBoxLayout* m_layout; KSpellConfigWidget *m_configWidget; KConfig *m_config; }; -#endif +#endif // SPELLCHECKING_H