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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-15 00:46:08 +02:00
parent 94fc697139
commit bbdada22fd
2 changed files with 73 additions and 59 deletions

View file

@ -1,59 +1,71 @@
/* /* This file is part of the KDE project
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
Copyright 2008 Albert Astals Cid <aacid@kde.org> 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 This library is distributed in the hope that it will be useful,
modify it under the terms of the GNU General Public License as but WITHOUT ANY WARRANTY; without even the implied warranty of
published by the Free Software Foundation; either version 2 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
the License or (at your option) version 3 or any later version Library General Public License for more details.
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 <http://www.gnu.org/licenses/>.
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 "spellchecking.h"
#include <kpluginfactory.h> #include <kpluginfactory.h>
#include <kspellconfigwidget.h>
#include <QBoxLayout> K_PLUGIN_FACTORY(SpellFactory, registerPlugin<SpellCheckingModule>();)
K_EXPORT_PLUGIN(SpellFactory("kcmspellchecking"))
K_PLUGIN_FACTORY(SpellFactory, registerPlugin<SonnetSpellCheckingModule>();) SpellCheckingModule::SpellCheckingModule(QWidget *parent, const QVariantList &args)
K_EXPORT_PLUGIN(SpellFactory( "kcmspellchecking" )) : KCModule(SpellFactory::componentData(), parent, args),
m_layout(nullptr),
SonnetSpellCheckingModule::SonnetSpellCheckingModule(QWidget* parent, const QVariantList&): m_configWidget(nullptr),
KCModule(SpellFactory::componentData(), parent) m_config(nullptr)
{ {
QBoxLayout *layout = new QVBoxLayout( this ); Q_UNUSED(args);
layout->setMargin(0);
m_layout = new QVBoxLayout(this);
m_layout->setMargin(0);
m_config = new KConfig("kdeglobals"); 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; 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(); m_configWidget->slotDefault();
} }
void SpellCheckingModule::slotConfigChanged()
{
emit changed(true);
}
#include "moc_spellchecking.cpp" #include "moc_spellchecking.cpp"

View file

@ -1,49 +1,51 @@
/* /* This file is part of the KDE project
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
Copyright 2008 Albert Astals Cid <aacid@kde.org> 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 This library is distributed in the hope that it will be useful,
modify it under the terms of the GNU General Public License as but WITHOUT ANY WARRANTY; without even the implied warranty of
published by the Free Software Foundation; either version 2 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
the License or (at your option) version 3 or any later version Library General Public License for more details.
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 <http://www.gnu.org/licenses/>.
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 #ifndef SPELLCHECKING_H
#define SONNETSPELLCHECKINGMODULE_H #define SPELLCHECKING_H
#include "kcmodule.h" #include <kcmodule.h>
#include <kspellconfigwidget.h>
#include <kconfig.h>
class KConfig; #include <QBoxLayout>
class KSpellConfigWidget;
class SonnetSpellCheckingModule : public KCModule class SpellCheckingModule : public KCModule
{ {
Q_OBJECT Q_OBJECT
public: public:
SonnetSpellCheckingModule(QWidget* parent, const QVariantList&); SpellCheckingModule(QWidget *parent, const QVariantList &args);
~SonnetSpellCheckingModule(); ~SpellCheckingModule();
// KCModule reimplementations // KCModule reimplementations
public Q_SLOTS: public Q_SLOTS:
void load() final;
void save() final; void save() final;
void defaults() final; void defaults() final;
private Q_SLOTS:
void slotConfigChanged();
private: private:
QVBoxLayout* m_layout;
KSpellConfigWidget *m_configWidget; KSpellConfigWidget *m_configWidget;
KConfig *m_config; KConfig *m_config;
}; };
#endif #endif // SPELLCHECKING_H