• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • sonnet
configwidget.cpp
Go to the documentation of this file.
1
21#include "configwidget.h"
22#include "ui_configui.h"
23
24#include "loader_p.h"
25#include "settings_p.h"
26
27#include <keditlistbox.h>
28#include <kcombobox.h>
29#include <kconfig.h>
30#include <klocale.h>
31
32#include <QtGui/QCheckBox>
33#include <QtGui/QLayout>
34
35using namespace Sonnet;
36
37class ConfigWidget::Private
38{
39public:
40 Loader *loader;
41 Ui_SonnetConfigUI ui;
42 QWidget *wdg;
43 KConfig *config;
44};
45
46ConfigWidget::ConfigWidget(KConfig *config, QWidget *parent)
47 : QWidget(parent),
48 d(new Private)
49{
50 init(config);
51}
52
53ConfigWidget::~ConfigWidget()
54{
55 delete d;
56}
57
58void ConfigWidget::init(KConfig *config)
59{
60 d->loader = Loader::openLoader();
61 d->loader->settings()->restore(config);
62 d->config = config;
63
64 QVBoxLayout *layout = new QVBoxLayout( this );
65 layout->setMargin( 0 );
66 layout->setObjectName( "SonnetConfigUILayout" );
67 d->wdg = new QWidget( this );
68 d->ui.setupUi( d->wdg );
69
70 //QStringList clients = d->loader->clients();
71 d->ui.m_langCombo->setCurrentByDictionary( d->loader->settings()->defaultLanguage() );
72 //d->ui->m_clientCombo->insertStringList( clients );
73 d->ui.m_skipUpperCB->setChecked( !d->loader->settings()->checkUppercase() );
74 d->ui.m_skipRunTogetherCB->setChecked( d->loader->settings()->skipRunTogether() );
75 d->ui.m_checkerEnabledByDefaultCB->setChecked( d->loader->settings()->checkerEnabledByDefault() );
76 QStringList ignoreList = d->loader->settings()->currentIgnoreList();
77 ignoreList.sort();
78 d->ui.m_ignoreListBox->insertStringList( ignoreList );
79 d->ui.m_bgSpellCB->setChecked( d->loader->settings()->backgroundCheckerEnabled() );
80 d->ui.m_bgSpellCB->hide();//hidden by default
81 connect( d->ui.m_ignoreListBox, SIGNAL(changed()), SLOT(slotChanged()) );
82
83 layout->addWidget( d->wdg );
84 connect(d->ui.m_langCombo, SIGNAL(dictionaryChanged(QString)), this, SIGNAL(configChanged()));
85 connect(d->ui.m_bgSpellCB, SIGNAL(clicked(bool)),this,SIGNAL(configChanged()));
86 connect(d->ui.m_skipUpperCB, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
87 connect(d->ui.m_skipRunTogetherCB, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
88 connect(d->ui.m_checkerEnabledByDefaultCB, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
89 connect(d->ui.m_ignoreListBox, SIGNAL(changed()), this, SIGNAL(configChanged()));
90}
91
92void ConfigWidget::save()
93{
94 setFromGui();
95 d->loader->settings()->save(d->config);
96}
97
98void ConfigWidget::setFromGui()
99{
100 if (d->ui.m_langCombo->count() ) {
101 d->loader->settings()->setDefaultLanguage( d->ui.m_langCombo->currentDictionary() );
102 }
103 d->loader->settings()->setCheckUppercase(
104 !d->ui.m_skipUpperCB->isChecked() );
105 d->loader->settings()->setSkipRunTogether(
106 d->ui.m_skipRunTogetherCB->isChecked() );
107 d->loader->settings()->setBackgroundCheckerEnabled(
108 d->ui.m_bgSpellCB->isChecked() );
109 d->loader->settings()->setCheckerEnabledByDefault(
110 d->ui.m_checkerEnabledByDefaultCB->isChecked() );
111}
112
113void ConfigWidget::slotChanged()
114{
115 d->loader->settings()->setCurrentIgnoreList(
116 d->ui.m_ignoreListBox->items() );
117}
118
119void ConfigWidget::setCorrectLanguage( const QStringList& )
120{
121 // can be removed in KDE5.
122}
123
124void ConfigWidget::setBackgroundCheckingButtonShown( bool b )
125{
126 d->ui.m_bgSpellCB->setVisible( b );
127}
128
129bool ConfigWidget::backgroundCheckingButtonShown() const
130{
131 return !d->ui.m_bgSpellCB->isHidden();
132}
133
134void ConfigWidget::slotDefault()
135{
136 d->ui.m_skipUpperCB->setChecked( false );
137 d->ui.m_skipRunTogetherCB->setChecked( false );
138 d->ui.m_checkerEnabledByDefaultCB->setChecked( false );
139 d->ui.m_bgSpellCB->setChecked( true );
140 d->ui.m_ignoreListBox->clear();
141}
142
143void ConfigWidget::setLanguage( const QString &language )
144{
145 d->ui.m_langCombo->setCurrentByDictionary( language );
146}
147
148QString ConfigWidget::language() const
149{
150 if ( d->ui.m_langCombo->count() ) {
151 return d->ui.m_langCombo->currentDictionary();
152 } else {
153 return QString();
154 }
155}
156
157#include "configwidget.moc"
KConfig
QWidget
Sonnet::ConfigWidget::configChanged
void configChanged()
Signal sends when config was changed.
Sonnet::ConfigWidget::setLanguage
void setLanguage(const QString &language)
Sets the language/dictionary that will be selected by default in this config widget.
Definition: configwidget.cpp:143
Sonnet::ConfigWidget::slotDefault
void slotDefault()
Definition: configwidget.cpp:134
Sonnet::ConfigWidget::slotChanged
void slotChanged()
Definition: configwidget.cpp:113
Sonnet::ConfigWidget::language
QString language() const
Get the currently selected language for spell checking.
Definition: configwidget.cpp:148
Sonnet::ConfigWidget::save
void save()
Definition: configwidget.cpp:92
Sonnet::ConfigWidget::backgroundCheckingButtonShown
bool backgroundCheckingButtonShown() const
Definition: configwidget.cpp:129
Sonnet::ConfigWidget::ConfigWidget
ConfigWidget(KConfig *config, QWidget *parent)
Definition: configwidget.cpp:46
Sonnet::ConfigWidget::~ConfigWidget
~ConfigWidget()
Definition: configwidget.cpp:53
Sonnet::ConfigWidget::setBackgroundCheckingButtonShown
void setBackgroundCheckingButtonShown(bool)
Definition: configwidget.cpp:124
Sonnet::Loader
Sonnet::Loader::openLoader
static Loader * openLoader()
configwidget.h
kcombobox.h
kconfig.h
keditlistbox.h
klocale.h
loader_p.h
config
KSharedConfigPtr config()
Sonnet
dialog.cpp
settings_p.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal