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

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • 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 
35 using namespace Sonnet;
36 
37 class ConfigWidget::Private
38 {
39 public:
40  Loader *loader;
41  Ui_SonnetConfigUI ui;
42  QWidget *wdg;
43  KConfig *config;
44 };
45 
46 ConfigWidget::ConfigWidget(KConfig *config, QWidget *parent)
47  : QWidget(parent),
48  d(new Private)
49 {
50  init(config);
51 }
52 
53 ConfigWidget::~ConfigWidget()
54 {
55  delete d;
56 }
57 
58 void 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 
92 void ConfigWidget::save()
93 {
94  setFromGui();
95  d->loader->settings()->save(d->config);
96 }
97 
98 void 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 
113 void ConfigWidget::slotChanged()
114 {
115  d->loader->settings()->setCurrentIgnoreList(
116  d->ui.m_ignoreListBox->items() );
117 }
118 
119 void ConfigWidget::setCorrectLanguage( const QStringList& )
120 {
121  // can be removed in KDE5.
122 }
123 
124 void ConfigWidget::setBackgroundCheckingButtonShown( bool b )
125 {
126  d->ui.m_bgSpellCB->setVisible( b );
127 }
128 
129 bool ConfigWidget::backgroundCheckingButtonShown() const
130 {
131  return !d->ui.m_bgSpellCB->isHidden();
132 }
133 
134 void 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 
143 void ConfigWidget::setLanguage( const QString &language )
144 {
145  d->ui.m_langCombo->setCurrentByDictionary( language );
146 }
147 
148 QString 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"
QWidget::layout
QLayout * layout() const
keditlistbox.h
Sonnet::ConfigWidget::ConfigWidget
ConfigWidget(KConfig *config, QWidget *parent)
Definition: configwidget.cpp:46
kcombobox.h
QWidget
Sonnet::ConfigWidget::save
void save()
Definition: configwidget.cpp:92
kconfig.h
Sonnet::ConfigWidget::setBackgroundCheckingButtonShown
void setBackgroundCheckingButtonShown(bool)
Definition: configwidget.cpp:124
settings_p.h
Sonnet::ConfigWidget::~ConfigWidget
~ConfigWidget()
Definition: configwidget.cpp:53
klocale.h
configwidget.h
Sonnet::ConfigWidget::language
QString language() const
Get the currently selected language for spell checking.
Definition: configwidget.cpp:148
config
KSharedConfigPtr config()
Sonnet::ConfigWidget::Private
friend class Private
Definition: configwidget.h:78
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QObject::setObjectName
void setObjectName(const QString &name)
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
QVBoxLayout
QString
QLayout::setMargin
void setMargin(int margin)
Sonnet::ConfigWidget::configChanged
void configChanged()
Signal sends when config was changed.
QStringList
loader_p.h
Sonnet::ConfigWidget::slotChanged
void slotChanged()
Definition: configwidget.cpp:113
KConfig
Sonnet::Loader::openLoader
static Loader * openLoader()
QWidget::QWidget
QWidget(QWidget *parent, QFlags< Qt::WindowType > f)
Sonnet::Loader
QStringList::sort
void sort()
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Sonnet::ConfigWidget::backgroundCheckingButtonShown
bool backgroundCheckingButtonShown() const
Definition: configwidget.cpp:129
Sonnet::ConfigWidget::slotDefault
void slotDefault()
Definition: configwidget.cpp:134
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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