generic: port to the new spelling classes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-09 20:30:46 +03:00
parent 2dff528754
commit 15319dc6bc
18 changed files with 82 additions and 157 deletions

View file

@ -59,7 +59,6 @@
#include <kio/job.h> #include <kio/job.h>
#include <kio/jobclasses.h> #include <kio/jobclasses.h>
#include <kio/netaccess.h> #include <kio/netaccess.h>
#include <kapplication.h> #include <kapplication.h>
#include <kcharsets.h> #include <kcharsets.h>
#include <kcolorbutton.h> #include <kcolorbutton.h>
@ -88,6 +87,7 @@
#include <kactioncollection.h> #include <kactioncollection.h>
#include <kplugininfo.h> #include <kplugininfo.h>
#include <ktabwidget.h> #include <ktabwidget.h>
#include <kspeller.h>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QMap> #include <QtCore/QMap>
@ -342,9 +342,9 @@ KateSpellCheckConfigTab::KateSpellCheckConfigTab(QWidget *parent)
// //
// after initial reload, connect the stuff for the changed () signal // after initial reload, connect the stuff for the changed () signal
m_sonnetConfigWidget = new Sonnet::ConfigWidget(KGlobal::config().data(), this); m_spellConfigWidget = new KSpellConfigWidget(KGlobal::config().data(), this);
connect(m_sonnetConfigWidget, SIGNAL(configChanged()), this, SLOT(slotChanged())); connect(m_spellConfigWidget, SIGNAL(configChanged()), this, SLOT(slotChanged()));
layout->addWidget(m_sonnetConfigWidget); layout->addWidget(m_spellConfigWidget);
layout->addWidget(newWidget); layout->addWidget(newWidget);
setLayout(layout); setLayout(layout);
@ -369,7 +369,7 @@ void KateSpellCheckConfigTab::apply()
m_changed = false; m_changed = false;
KateDocumentConfig::global()->configStart(); KateDocumentConfig::global()->configStart();
m_sonnetConfigWidget->save(); m_spellConfigWidget->save();
KateDocumentConfig::global()->configEnd(); KateDocumentConfig::global()->configEnd();
foreach (KateDocument *doc, KateGlobal::self()->kateDocuments()) { foreach (KateDocument *doc, KateGlobal::self()->kateDocuments()) {
doc->refreshOnTheFlyCheck(); doc->refreshOnTheFlyCheck();
@ -1062,7 +1062,7 @@ KateDictionaryBar::KateDictionaryBar(KateView* view, QWidget *parent)
QHBoxLayout *topLayout = new QHBoxLayout(centralWidget()); QHBoxLayout *topLayout = new QHBoxLayout(centralWidget());
topLayout->setMargin(0); topLayout->setMargin(0);
//topLayout->setSpacing(spacingHint()); //topLayout->setSpacing(spacingHint());
m_dictionaryComboBox = new Sonnet::DictionaryComboBox(centralWidget()); m_dictionaryComboBox = new KSpellDictionaryComboBox(centralWidget());
connect(m_dictionaryComboBox, SIGNAL(dictionaryChanged(QString)), connect(m_dictionaryComboBox, SIGNAL(dictionaryChanged(QString)),
this, SLOT(dictionaryChanged(QString))); this, SLOT(dictionaryChanged(QString)));
connect(view->doc(), SIGNAL(defaultDictionaryChanged(KateDocument*)), connect(view->doc(), SIGNAL(defaultDictionaryChanged(KateDocument*)),
@ -1085,7 +1085,7 @@ void KateDictionaryBar::updateData()
KateDocument *document = m_view->doc(); KateDocument *document = m_view->doc();
QString dictionary = document->defaultDictionary(); QString dictionary = document->defaultDictionary();
if(dictionary.isEmpty()) { if(dictionary.isEmpty()) {
dictionary = Sonnet::Speller().defaultLanguage(); dictionary = KSpeller::defaultLanguage();
} }
m_dictionaryComboBox->setCurrentByDictionary(dictionary); m_dictionaryComboBox->setCurrentByDictionary(dictionary);
} }

View file

@ -38,9 +38,8 @@
#include <kdialog.h> #include <kdialog.h>
#include <kfiledialog.h> #include <kfiledialog.h>
#include <kmimetype.h> #include <kmimetype.h>
#include <kspellconfigwidget.h>
#include <sonnet/configwidget.h> #include <kspelldictionarycombobox.h>
#include <sonnet/dictionarycombobox.h>
#include <QtCore/QProcess> #include <QtCore/QProcess>
#include <QtCore/QStringList> #include <QtCore/QStringList>
@ -148,7 +147,7 @@ class KateDictionaryBar : public KateViewBarWidget
private: private:
KateView* m_view; KateView* m_view;
Sonnet::DictionaryComboBox *m_dictionaryComboBox; KSpellDictionaryComboBox *m_dictionaryComboBox;
}; };
class KateIndentConfigTab : public KateConfigPage class KateIndentConfigTab : public KateConfigPage
@ -240,7 +239,7 @@ class KateSpellCheckConfigTab : public KateConfigPage
protected: protected:
Ui::SpellCheckConfigWidget *ui; Ui::SpellCheckConfigWidget *ui;
Sonnet::ConfigWidget *m_sonnetConfigWidget; KSpellConfigWidget *m_spellConfigWidget;
public Q_SLOTS: public Q_SLOTS:
void apply (); void apply ();

View file

@ -61,7 +61,7 @@ KateOnTheFlyChecker::KateOnTheFlyChecker(KateDocument *document)
connect(&document->buffer(), SIGNAL(respellCheckBlock(int,int)), connect(&document->buffer(), SIGNAL(respellCheckBlock(int,int)),
this, SLOT(handleRespellCheckBlock(int,int))); this, SLOT(handleRespellCheckBlock(int,int)));
// load the settings for the speller // creates speller and loads the settings for it
updateConfig(); updateConfig();
foreach(KTextEditor::View* view, document->views()) { foreach(KTextEditor::View* view, document->views()) {
@ -394,24 +394,14 @@ void KateOnTheFlyChecker::performSpellCheck()
m_currentDecToEncOffsetList, m_currentDecToEncOffsetList,
encToDecOffsetList); encToDecOffsetList);
ON_THE_FLY_DEBUG << "next spell checking" << text; ON_THE_FLY_DEBUG << "next spell checking" << text;
if(text.isEmpty()) { // passing an empty string to Sonnet can lead to a bad allocation exception if(text.isEmpty()) { // passing an empty string to speller can lead to a bad allocation exception
spellCheckDone(); // (bug 225867) spellCheckDone(); // (bug 225867)
return; return;
} }
if(m_speller.language() != language) {
m_speller.setLanguage(language);
}
if(!m_backgroundChecker) { if(!m_backgroundChecker) {
m_backgroundChecker = new Sonnet::BackgroundChecker(m_speller, this); updateConfig();
connect(m_backgroundChecker,
SIGNAL(misspelling(QString,int)),
this,
SLOT(misspelling(QString,int)));
connect(m_backgroundChecker, SIGNAL(done()), this, SLOT(spellCheckDone()));
m_backgroundChecker->restore(KGlobal::config().data());
} }
m_backgroundChecker->setSpeller(m_speller); m_backgroundChecker->changeLanguage(language);
m_backgroundChecker->setText(text); // don't call 'start()' after this! m_backgroundChecker->setText(text); // don't call 'start()' after this!
} }
@ -628,10 +618,6 @@ void KateOnTheFlyChecker::misspelling(const QString &word, int start)
movingRange->setAttribute(KTextEditor::Attribute::Ptr(attribute)); movingRange->setAttribute(KTextEditor::Attribute::Ptr(attribute));
m_misspelledList.push_back(MisspelledItem(movingRange, m_currentlyCheckedItem.second)); m_misspelledList.push_back(MisspelledItem(movingRange, m_currentlyCheckedItem.second));
if(m_backgroundChecker) {
m_backgroundChecker->continueChecking();
}
} }
void KateOnTheFlyChecker::spellCheckDone() void KateOnTheFlyChecker::spellCheckDone()
@ -667,11 +653,17 @@ QList<KTextEditor::MovingRange*> KateOnTheFlyChecker::installedMovingRanges(cons
void KateOnTheFlyChecker::updateConfig() void KateOnTheFlyChecker::updateConfig()
{ {
ON_THE_FLY_DEBUG; ON_THE_FLY_DEBUG;
m_speller.restore(KGlobal::config().data());
if(m_backgroundChecker) { if(m_backgroundChecker) {
m_backgroundChecker->restore(KGlobal::config().data()); delete m_backgroundChecker;
m_backgroundChecker = nullptr;
} }
m_backgroundChecker = new KSpellBackgroundChecker(KGlobal::config().data(), this);
connect(m_backgroundChecker,
SIGNAL(misspelling(QString,int)),
this,
SLOT(misspelling(QString,int)));
connect(m_backgroundChecker, SIGNAL(done()), this, SLOT(spellCheckDone()));
} }
void KateOnTheFlyChecker::refreshSpellCheck(const KTextEditor::Range &range) void KateOnTheFlyChecker::refreshSpellCheck(const KTextEditor::Range &range)

View file

@ -30,14 +30,10 @@
#include <QSet> #include <QSet>
#include <QTimer> #include <QTimer>
#include <sonnet/speller.h> #include <kspellbackgroundchecker.h>
#include "katedocument.h" #include "katedocument.h"
namespace Sonnet {
class BackgroundChecker;
}
class KateOnTheFlyChecker : public QObject, private KTextEditor::MovingRangeFeedback { class KateOnTheFlyChecker : public QObject, private KTextEditor::MovingRangeFeedback {
Q_OBJECT Q_OBJECT
@ -73,9 +69,8 @@ class KateOnTheFlyChecker : public QObject, private KTextEditor::MovingRangeFeed
protected: protected:
KateDocument *const m_document; KateDocument *const m_document;
Sonnet::Speller m_speller;
QList<SpellCheckItem> m_spellCheckQueue; QList<SpellCheckItem> m_spellCheckQueue;
Sonnet::BackgroundChecker *m_backgroundChecker; KSpellBackgroundChecker *m_backgroundChecker;
SpellCheckItem m_currentlyCheckedItem; SpellCheckItem m_currentlyCheckedItem;
static const SpellCheckItem invalidSpellCheckQueueItem; static const SpellCheckItem invalidSpellCheckQueueItem;
MisspelledList m_misspelledList; MisspelledList m_misspelledList;

View file

@ -30,7 +30,7 @@
#include <kactioncollection.h> #include <kactioncollection.h>
#include <ktexteditor/view.h> #include <ktexteditor/view.h>
#include <sonnet/speller.h> #include <kspeller.h>
#include "katedocument.h" #include "katedocument.h"
#include "katehighlight.h" #include "katehighlight.h"
@ -46,22 +46,22 @@ KateSpellCheckManager::~KateSpellCheckManager()
QStringList KateSpellCheckManager::suggestions(const QString& word, const QString& dictionary) QStringList KateSpellCheckManager::suggestions(const QString& word, const QString& dictionary)
{ {
Sonnet::Speller speller; KSpeller speller(KGlobal::config().data());
speller.setLanguage(dictionary); speller.setDictionary(dictionary);
return speller.suggest(word); return speller.suggest(word);
} }
void KateSpellCheckManager::ignoreWord(const QString& word, const QString& dictionary) void KateSpellCheckManager::ignoreWord(const QString& word, const QString& dictionary)
{ {
Sonnet::Speller speller; KSpeller speller(KGlobal::config().data());
speller.setLanguage(dictionary); speller.setDictionary(dictionary);
speller.addToSession(word); speller.addToSession(word);
} }
void KateSpellCheckManager::addToDictionary(const QString& word, const QString& dictionary) void KateSpellCheckManager::addToDictionary(const QString& word, const QString& dictionary)
{ {
Sonnet::Speller speller; KSpeller speller(KGlobal::config().data());
speller.setLanguage(dictionary); speller.setDictionary(dictionary);
speller.addToPersonal(word); speller.addToPersonal(word);
} }

View file

@ -27,8 +27,6 @@
#include <QString> #include <QString>
#include <ktexteditor/document.h> #include <ktexteditor/document.h>
#include <sonnet/backgroundchecker.h>
#include <sonnet/speller.h>
class KateDocument; class KateDocument;
class KateView; class KateView;

View file

@ -36,16 +36,12 @@
#include <kactioncollection.h> #include <kactioncollection.h>
#include <kicon.h> #include <kicon.h>
#include <kstandardaction.h> #include <kstandardaction.h>
#include <sonnet/dialog.h> #include <kspelldialog.h>
#include <sonnet/backgroundchecker.h>
#include <sonnet/speller.h>
KateSpellCheckDialog::KateSpellCheckDialog( KateView* view ) KateSpellCheckDialog::KateSpellCheckDialog( KateView* view )
: QObject( view ) : QObject( view )
, m_view (view) , m_view (view)
, m_speller (NULL) , m_spellDialog(NULL)
, m_backgroundChecker(NULL)
, m_sonnetDialog(NULL)
, m_globalSpellCheckRange(NULL) , m_globalSpellCheckRange(NULL)
, m_spellCheckCancelledByUser(false) , m_spellCheckCancelledByUser(false)
{ {
@ -54,9 +50,7 @@ KateSpellCheckDialog::KateSpellCheckDialog( KateView* view )
KateSpellCheckDialog::~KateSpellCheckDialog() KateSpellCheckDialog::~KateSpellCheckDialog()
{ {
delete m_globalSpellCheckRange; delete m_globalSpellCheckRange;
delete m_sonnetDialog; delete m_spellDialog;
delete m_backgroundChecker;
delete m_speller;
} }
void KateSpellCheckDialog::createActions( KActionCollection* ac ) void KateSpellCheckDialog::createActions( KActionCollection* ac )
@ -106,41 +100,27 @@ void KateSpellCheckDialog::spellcheck( const KTextEditor::Cursor &from, const KT
end = m_view->doc()->documentEnd(); end = m_view->doc()->documentEnd();
} }
if ( !m_speller ) if ( !m_spellDialog )
{ {
m_speller = new Sonnet::Speller(); m_spellDialog = new KSpellDialog(KGlobal::config().data(), m_view);
} m_spellDialog->showSpellCheckCompletionMessage();
m_speller->restore(KGlobal::config().data()); m_spellDialog->setSpellCheckContinuedAfterReplacement(false);
if ( !m_backgroundChecker ) connect(m_spellDialog,SIGNAL(accepted()),this,SLOT(installNextSpellCheckRange()));
{
m_backgroundChecker = new Sonnet::BackgroundChecker(*m_speller);
}
m_backgroundChecker->restore(KGlobal::config().data()); connect(m_spellDialog,SIGNAL(replace(QString,int,QString)),
if ( !m_sonnetDialog )
{
m_sonnetDialog = new Sonnet::Dialog(m_backgroundChecker, m_view);
m_sonnetDialog->showProgressDialog(200);
m_sonnetDialog->showSpellCheckCompletionMessage();
m_sonnetDialog->setSpellCheckContinuedAfterReplacement(false);
connect(m_sonnetDialog,SIGNAL(done(QString)),this,SLOT(installNextSpellCheckRange()));
connect(m_sonnetDialog,SIGNAL(replace(QString,int,QString)),
this,SLOT(corrected(QString,int,QString))); this,SLOT(corrected(QString,int,QString)));
connect(m_sonnetDialog,SIGNAL(misspelling(QString,int)), connect(m_spellDialog,SIGNAL(misspelling(QString,int)),
this,SLOT(misspelling(QString,int))); this,SLOT(misspelling(QString,int)));
connect(m_sonnetDialog,SIGNAL(cancel()), connect(m_spellDialog,SIGNAL(rejected()),
this,SLOT(cancelClicked())); this,SLOT(cancelClicked()));
connect(m_sonnetDialog,SIGNAL(destroyed(QObject*)), connect(m_spellDialog,SIGNAL(destroyed(QObject*)),
this,SLOT(objectDestroyed(QObject*))); this,SLOT(objectDestroyed(QObject*)));
connect(m_sonnetDialog,SIGNAL(languageChanged(QString)), connect(m_spellDialog,SIGNAL(languageChanged(QString)),
this,SLOT(languageChanged(QString))); this,SLOT(languageChanged(QString)));
} }
@ -206,7 +186,7 @@ void KateSpellCheckDialog::corrected( const QString& word, int pos, const QStrin
m_currentSpellCheckRange.setRange( KTextEditor::Range( replacementStartCursor, m_currentSpellCheckRange.end() ) ); m_currentSpellCheckRange.setRange( KTextEditor::Range( replacementStartCursor, m_currentSpellCheckRange.end() ) );
// we have to be careful here: due to static word wrapping the text might change in addition to simply // we have to be careful here: due to static word wrapping the text might change in addition to simply
// the misspelled word being replaced, i.e. new line breaks might be inserted as well. As such, the text // the misspelled word being replaced, i.e. new line breaks might be inserted as well. As such, the text
// in the 'Sonnet::Dialog' might be eventually out of sync with the visible text. Therefore, we 'restart' // in the 'KSpellDialog' might be eventually out of sync with the visible text. Therefore, we 'restart'
// spell checking from the current position. // spell checking from the current position.
performSpellCheck( KTextEditor::Range( replacementStartCursor, m_globalSpellCheckRange->end().toCursor() ) ); performSpellCheck( KTextEditor::Range( replacementStartCursor, m_globalSpellCheckRange->end().toCursor() ) );
} }
@ -222,7 +202,7 @@ void KateSpellCheckDialog::performSpellCheck(const KTextEditor::Range& range)
installNextSpellCheckRange(); installNextSpellCheckRange();
// first check if there is really something to spell check // first check if there is really something to spell check
if(m_currentSpellCheckRange.isValid()) { if(m_currentSpellCheckRange.isValid()) {
m_sonnetDialog->show(); m_spellDialog->show();
} }
} }
@ -283,19 +263,15 @@ void KateSpellCheckDialog::installNextSpellCheckRange()
QString text = m_view->doc()->decodeCharacters(m_currentSpellCheckRange, QString text = m_view->doc()->decodeCharacters(m_currentSpellCheckRange,
m_currentDecToEncOffsetList, m_currentDecToEncOffsetList,
encToDecOffsetList); encToDecOffsetList);
// ensure that no empty string is passed on to Sonnet as this can lead to a crash // ensure that no empty string is passed on to speller as this can lead to a crash
// (bug 228789) // (bug 228789)
if(text.isEmpty()) { if(text.isEmpty()) {
nextRangeBegin = m_currentSpellCheckRange.end(); nextRangeBegin = m_currentSpellCheckRange.end();
continue; continue;
} }
if(m_speller->language() != dictionary) { m_spellDialog->changeLanguage(dictionary);
m_speller->setLanguage(dictionary); m_spellDialog->setBuffer(text);
m_backgroundChecker->setSpeller(*m_speller);
}
m_sonnetDialog->setBuffer(text);
break; break;
} }
} }
@ -321,7 +297,7 @@ void KateSpellCheckDialog::spellCheckDone()
void KateSpellCheckDialog::objectDestroyed(QObject *object) void KateSpellCheckDialog::objectDestroyed(QObject *object)
{ {
Q_UNUSED(object); Q_UNUSED(object);
m_sonnetDialog = NULL; m_spellDialog = NULL;
} }
void KateSpellCheckDialog::languageChanged(const QString &language) void KateSpellCheckDialog::languageChanged(const QString &language)

View file

@ -34,11 +34,7 @@ class KateView;
class KAction; class KAction;
class KActionCollection; class KActionCollection;
class KProgressDialog; class KProgressDialog;
namespace Sonnet { class KSpellDialog;
class Dialog;
class BackgroundChecker;
class Speller;
}
#include "ktexteditor/range.h" #include "ktexteditor/range.h"
@ -93,9 +89,7 @@ class KateSpellCheckDialog : public QObject
KateView *m_view; KateView *m_view;
KAction *m_spellcheckSelection; KAction *m_spellcheckSelection;
Sonnet::Speller *m_speller; KSpellDialog *m_spellDialog;
Sonnet::BackgroundChecker *m_backgroundChecker;
Sonnet::Dialog *m_sonnetDialog;
// define the part of the text that is to be checked // define the part of the text that is to be checked
KTextEditor::Range m_currentSpellCheckRange; KTextEditor::Range m_currentSpellCheckRange;

View file

@ -35,7 +35,7 @@
#include <kiconloader.h> #include <kiconloader.h>
#include <klocale.h> #include <klocale.h>
#include <kcolorcombo.h> #include <kcolorcombo.h>
#include <sonnet/dictionarycombobox.h> #include <kspelldictionarycombobox.h>
//BEGIN VariableEditor //BEGIN VariableEditor
VariableEditor::VariableEditor(VariableItem* item, QWidget* parent) VariableEditor::VariableEditor(VariableItem* item, QWidget* parent)
@ -316,7 +316,7 @@ VariableSpellCheckEditor::VariableSpellCheckEditor(VariableSpellCheckItem *item,
{ {
QGridLayout *l = (QGridLayout*) layout(); QGridLayout *l = (QGridLayout*) layout();
m_dictionaryCombo = new Sonnet::DictionaryComboBox(this); m_dictionaryCombo = new KSpellDictionaryComboBox(this);
m_dictionaryCombo->setCurrentByDictionary(item->value()); m_dictionaryCombo->setCurrentByDictionary(item->value());
l->addWidget(m_dictionaryCombo, 0, 2, Qt::AlignLeft); l->addWidget(m_dictionaryCombo, 0, 2, Qt::AlignLeft);

View file

@ -21,7 +21,12 @@
#ifndef VARIABLE_EDITOR_H #ifndef VARIABLE_EDITOR_H
#define VARIABLE_EDITOR_H #define VARIABLE_EDITOR_H
#include <QtGui/QWidget> #include <QWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
class KateHelpButton; class KateHelpButton;
@ -37,15 +42,7 @@ class VariableRemoveSpacesItem;
class KColorCombo; class KColorCombo;
class KFontComboBox; class KFontComboBox;
#include <QCheckBox> class KSpellDictionaryComboBox;
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
namespace Sonnet {
class DictionaryComboBox;
}
class VariableEditor : public QWidget class VariableEditor : public QWidget
{ {
@ -169,7 +166,7 @@ protected Q_SLOTS:
void setItemValue(const QString& newValue); void setItemValue(const QString& newValue);
private: private:
Sonnet::DictionaryComboBox *m_dictionaryCombo; KSpellDictionaryComboBox *m_dictionaryCombo;
}; };

View file

@ -42,7 +42,7 @@
#include <kdialog.h> #include <kdialog.h>
#include <klocale.h> #include <klocale.h>
#include <sonnet/speller.h> #include <kspeller.h>
VariableLineEdit::VariableLineEdit(QWidget* parent) VariableLineEdit::VariableLineEdit(QWidget* parent)
: QWidget(parent) : QWidget(parent)
@ -179,8 +179,7 @@ void VariableLineEdit::addKateItems(VariableListView* listview)
listview->addItem(item); listview->addItem(item);
// Add 'default-dictionary' to list // Add 'default-dictionary' to list
Sonnet::Speller speller; item = new VariableSpellCheckItem("default-dictionary", KSpeller::defaultLanguage());
item = new VariableSpellCheckItem("default-dictionary", speller.defaultLanguage());
item->setHelpText(i18nc("short translation please", "Set the default dictionary used for spell checking.")); item->setHelpText(i18nc("short translation please", "Set the default dictionary used for spell checking."));
listview->addItem(item); listview->addItem(item);

View file

@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "spellchecking.h" #include "spellchecking.h"
#include <kpluginfactory.h> #include <kpluginfactory.h>
#include <sonnet/configwidget.h> #include <kspellconfigwidget.h>
#include <QBoxLayout> #include <QBoxLayout>
@ -35,8 +35,8 @@ SonnetSpellCheckingModule::SonnetSpellCheckingModule(QWidget* parent, const QVar
{ {
QBoxLayout *layout = new QVBoxLayout( this ); QBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin(0); layout->setMargin(0);
m_config = new KConfig("sonnetrc"); m_config = new KConfig("kdeglobals");
m_configWidget = new Sonnet::ConfigWidget( m_config, this ); m_configWidget = new KSpellConfigWidget( m_config, this );
layout->addWidget(m_configWidget); layout->addWidget(m_configWidget);
connect(m_configWidget, SIGNAL(configChanged()), this, SLOT(changed())); connect(m_configWidget, SIGNAL(configChanged()), this, SLOT(changed()));
} }

View file

@ -26,11 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kcmodule.h" #include "kcmodule.h"
class KConfig; class KConfig;
class KSpellConfigWidget;
namespace Sonnet
{
class ConfigWidget;
}
class SonnetSpellCheckingModule : public KCModule class SonnetSpellCheckingModule : public KCModule
{ {
@ -44,7 +40,7 @@ class SonnetSpellCheckingModule : public KCModule
void defaults(); void defaults();
private: private:
Sonnet::ConfigWidget *m_configWidget; KSpellConfigWidget *m_configWidget;
KConfig *m_config; KConfig *m_config;
}; };

View file

@ -24,8 +24,7 @@
#include <KStandardAction> #include <KStandardAction>
#include <KActionCollection> #include <KActionCollection>
#include <KAction> #include <KAction>
#include <sonnet/dialog.h> #include <KSpellDialog>
#include <sonnet/backgroundchecker.h>
KLineSpellChecking::KLineSpellChecking(QWidget* parent) KLineSpellChecking::KLineSpellChecking(QWidget* parent)
: KLineEdit(parent) : KLineEdit(parent)
@ -43,12 +42,9 @@ void KLineSpellChecking::slotCheckSpelling()
if ( text().isEmpty() ) { if ( text().isEmpty() ) {
return; return;
} }
Sonnet::Dialog *spellDialog = new Sonnet::Dialog(new Sonnet::BackgroundChecker(this), 0); KSpellDialog *spellDialog = new KSpellDialog(KGlobal::config().data(), 0);
connect(spellDialog, SIGNAL(replace(QString,int,QString)), this, SLOT(spellCheckerCorrected(QString,int,QString))); connect(spellDialog, SIGNAL(replace(QString,int,QString)), this, SLOT(spellCheckerCorrected(QString,int,QString)));
connect(spellDialog, SIGNAL(misspelling(QString,int)), this, SLOT(spellCheckerMisspelling(QString,int))); connect(spellDialog, SIGNAL(misspelling(QString,int)), this, SLOT(spellCheckerMisspelling(QString,int)));
connect(spellDialog, SIGNAL(done(QString)), this, SLOT(slotSpellCheckDone(QString)));
connect(spellDialog, SIGNAL(cancel()), this, SLOT(spellCheckerFinished()));
connect(spellDialog, SIGNAL(stop()), this, SLOT(spellCheckerFinished()));
spellDialog->setBuffer(text()); spellDialog->setBuffer(text());
spellDialog->show(); spellDialog->show();
} }
@ -73,16 +69,6 @@ void KLineSpellChecking::spellCheckerCorrected( const QString &old, int pos, con
} }
} }
void KLineSpellChecking::spellCheckerFinished()
{
}
void KLineSpellChecking::slotSpellCheckDone( const QString &s )
{
if( s != text() )
setText( s );
}
void KLineSpellChecking::contextMenuEvent(QContextMenuEvent *e) void KLineSpellChecking::contextMenuEvent(QContextMenuEvent *e)
{ {
QMenu* popup = createStandardContextMenu(); QMenu* popup = createStandardContextMenu();

View file

@ -37,10 +37,8 @@ protected:
private slots: private slots:
void slotCheckSpelling(); void slotCheckSpelling();
void slotSpellCheckDone( const QString &s );
void spellCheckerMisspelling( const QString &text, int pos); void spellCheckerMisspelling( const QString &text, int pos);
void spellCheckerCorrected( const QString &, int, const QString &); void spellCheckerCorrected( const QString &, int, const QString &);
void spellCheckerFinished();
private: private:
KAction *m_spellAction; KAction *m_spellAction;

View file

@ -34,7 +34,6 @@
#include <KStandardAction> #include <KStandardAction>
#include <KStandardShortcut> #include <KStandardShortcut>
#include <KXMLGUIFactory> #include <KXMLGUIFactory>
#include <sonnet/configdialog.h>
#include "treeview.h" #include "treeview.h"
#include "basictab.h" #include "basictab.h"

View file

@ -24,7 +24,6 @@
#include <KLocale> #include <KLocale>
#include <KConfigGroup> #include <KConfigGroup>
#include <sonnet/configwidget.h>
PreferencesDialog::PreferencesDialog( QWidget *parent ) PreferencesDialog::PreferencesDialog( QWidget *parent )
: KPageDialog( parent ) : KPageDialog( parent )
@ -57,7 +56,7 @@ SpellCheckingPage::SpellCheckingPage( QWidget *parent )
: QWidget( parent ) : QWidget( parent )
{ {
QHBoxLayout *lay = new QHBoxLayout( this ); QHBoxLayout *lay = new QHBoxLayout( this );
m_confPage = new Sonnet::ConfigWidget(&( *KGlobal::config() ), this ); m_confPage = new KSpellConfigWidget(KGlobal::config().data(), this );
lay->addWidget( m_confPage ); lay->addWidget( m_confPage );
setLayout( lay ); setLayout( lay );
} }

View file

@ -20,15 +20,12 @@
#ifndef PREFERENCESDLG_H #ifndef PREFERENCESDLG_H
#define PREFERENCESDLG_H #define PREFERENCESDLG_H
#include <QCheckBox>
#include <KPageDialog> #include <KPageDialog>
#include <KSpellConfigWidget>
class SpellCheckingPage; class SpellCheckingPage;
class MiscPage; class MiscPage;
#include <QCheckBox>
namespace Sonnet {
class ConfigWidget;
}
class PreferencesDialog : public KPageDialog class PreferencesDialog : public KPageDialog
{ {
@ -51,7 +48,7 @@ public:
SpellCheckingPage( QWidget * ); SpellCheckingPage( QWidget * );
void saveOptions(); void saveOptions();
private: private:
Sonnet::ConfigWidget *m_confPage; KSpellConfigWidget *m_confPage;
}; };
class MiscPage : public QWidget class MiscPage : public QWidget