25 #include <tdeglobal.h>
26 #include <tdelocale.h>
27 #include <tdeconfig.h>
31 #include <tqstringlist.h>
35 class Settings::Private
39 TDESharedConfig::Ptr config;
42 TQString defaultLanguage;
43 TQString defaultClient;
47 bool backgroundCheckerEnabled;
49 TQMap<TQString, bool> ignore;
52 Settings::Settings( Broker *broker, TDESharedConfig *config )
69 TDESharedConfig *Settings::sharedConfig()
const
74 void Settings::setDefaultLanguage(
const TQString& lang )
76 TQStringList cs = d->broker->languages();
77 if ( cs.find( lang ) != cs.end() &&
78 d->defaultLanguage != lang ) {
79 d->defaultLanguage = lang;
86 TQString Settings::defaultLanguage()
const
88 return d->defaultLanguage;
91 void Settings::setDefaultClient(
const TQString& client )
96 if ( d->broker->clients().contains( client ) ) {
97 d->defaultClient = client;
103 TQString Settings::defaultClient()
const
105 return d->defaultClient;
108 void Settings::setCheckUppercase(
bool check )
110 if ( d->checkUppercase != check ) {
112 d->checkUppercase = check;
116 bool Settings::checkUppercase()
const
118 return d->checkUppercase;
121 void Settings::setSkipRunTogether(
bool skip )
123 if ( d->skipRunTogether != skip ) {
125 d->skipRunTogether = skip;
129 bool Settings::skipRunTogether()
const
131 return d->skipRunTogether;
134 void Settings::setBackgroundCheckerEnabled(
bool enable )
136 if ( d->backgroundCheckerEnabled != enable ) {
138 d->backgroundCheckerEnabled = enable;
142 bool Settings::backgroundCheckerEnabled()
const
144 return d->backgroundCheckerEnabled;
147 void Settings::setCurrentIgnoreList(
const TQStringList& ignores )
149 setQuietIgnoreList( ignores );
153 void Settings::setQuietIgnoreList(
const TQStringList& ignores )
155 d->ignore = TQMap<TQString, bool>();
156 for ( TQStringList::const_iterator itr = ignores.begin();
157 itr != ignores.end(); ++itr ) {
158 d->ignore.insert( *itr,
true );
162 TQStringList Settings::currentIgnoreList()
const
164 return d->ignore.keys();
167 void Settings::addWordToIgnore(
const TQString& word )
169 if ( !d->ignore.contains( word ) ) {
171 d->ignore.insert( word,
true );
175 bool Settings::ignore(
const TQString& word )
177 return d->ignore.contains( word );
180 void Settings::readIgnoreList()
182 TDEConfigGroup conf( d->config,
"Spelling" );
183 TQString ignoreEntry = TQString(
"ignore_%1" ).arg( d->defaultLanguage );
184 TQStringList ignores = conf.readListEntry( ignoreEntry );
185 setQuietIgnoreList( ignores );
188 void Settings::save()
191 TDEConfigGroup conf( d->config,
"Spelling" );
192 conf.writeEntry(
"defaultClient", d->defaultClient );
193 conf.writeEntry(
"defaultLanguage", d->defaultLanguage );
194 conf.writeEntry(
"checkUppercase", d->checkUppercase );
195 conf.writeEntry(
"skipRunTogether", d->skipRunTogether );
196 conf.writeEntry(
"backgroundCheckerEnabled", d->backgroundCheckerEnabled );
197 conf.writeEntry( TQString(
"ignore_%1" ).arg( d->defaultLanguage ),
203 void Settings::loadConfig()
205 TDEConfigGroup conf( d->config,
"Spelling" );
206 d->defaultClient = conf.readEntry(
"defaultClient",
208 d->defaultLanguage = conf.readEntry(
209 "defaultLanguage", TDEGlobal::locale()->language() );
212 d->checkUppercase = conf.readBoolEntry(
213 "checkUppercase",
true );
215 d->skipRunTogether = conf.readBoolEntry(
216 "skipRunTogether",
true );
218 d->backgroundCheckerEnabled = conf.readBoolEntry(
219 "backgroundCheckerEnabled",
true );