1
/* ****************************************************************************
2
This file is part of KBabel
4
Copyright (C) 1999-2000 by Matthias Kiefer
5
<matthias.kiefer@gmx.de>
6
2004-2005 by Stanislav Visnovsky
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
In addition, as a special exception, the copyright holders give
24
permission to link the code of this program with any edition of
25
the Qt library by Trolltech AS, Norway (or with modified versions
26
of Qt that use the same license as Qt), and distribute linked
27
combinations including the two. You must obey the GNU General
28
Public License in all respects for all of the code used other than
29
Qt. If you modify this file, you may extend this exception to
30
your version of the file, but you are not obligated to do so. If
31
you do not wish to do so, delete this exception statement from
34
**************************************************************************** */
35
#include "projectpref.h"
36
#include "projectprefwidgets.h"
37
#include "diffpreferences.h"
38
#include "kbprojectsettings.h"
41
#include <qwhatsthis.h>
46
#include <kiconloader.h>
47
#include <kapplication.h>
50
#define PAGE_IDENTITY 0
56
#define PAGE_DIRCOMMANDS 6
57
#define PAGE_FILECOMMANDS 7
61
using namespace KBabel;
63
ProjectDialog::ProjectDialog(Project::Ptr project)
64
: KConfigDialog(0, "project dialog", project->settings(),
65
IconList, Help|Default|Ok|Apply|Cancel)
69
_identityPage = new IdentityPreferences(0, project->name());
70
addPage(_identityPage, i18n("title of page in preferences dialog","Identity")
72
, i18n("Information About You and Translation Team")
75
_savePage = new SavePreferences(0);
76
addPage(_savePage, i18n("title of page in preferences dialog","Save")
78
, i18n("Options for File Saving"));
81
_spellPage = new SpellPreferences(0);
82
addPage(_spellPage, i18n("title of page in preferences dialog","Spelling")
84
, i18n("Options for Spell Checking"));
85
connect( _spellPage, SIGNAL( settingsChanged() )
86
, this, SLOT(updateButtons()) );
88
_sourcePage = new SourceContextPreferences(0);
89
addPage(_sourcePage, i18n("title of page in preferences dialog","Source")
91
,i18n("Options for Showing Source Context"));
92
connect(_sourcePage, SIGNAL (itemsChanged())
93
, this, SLOT (updateButtons()) );
95
_miscPage = new MiscPreferences(0);
96
addPage(_miscPage, i18n("title of page in preferences dialog","Miscellaneous")
98
,i18n("Miscellaneous Settings"));
100
_catmanPage = new CatmanPreferences(0);
101
addPage(_catmanPage, i18n("title of page in preferences dialog","Folders")
103
, i18n("Paths to Message Catalogs & Catalog Templates"));
105
_dirCommandsPage = new DirCommandsPreferences(0);
106
addPage(_dirCommandsPage, i18n("title of page in preferences dialog","Folder Commands")
108
, i18n("User-Defined Commands for Folder Items"));
109
connect( _dirCommandsPage, SIGNAL( settingsChanged() ),
110
this, SLOT(updateButtons()) );
112
_fileCommandsPage = new FileCommandsPreferences(0);
113
addPage(_fileCommandsPage, i18n("title of page in preferences dialog","File Commands")
115
, i18n("User-Defined Commands for File Items"));
116
connect( _fileCommandsPage, SIGNAL( settingsChanged() ),
117
this, SLOT(updateButtons()) );
119
_viewPage = new ViewPreferences(0);
120
addPage(_viewPage, i18n("title of page in preferences dialog","Catalog Manager")
122
, i18n("Catalog Manager View Settings"));
124
_diffPage = new DiffPreferences(0);
125
addPage(_diffPage, i18n("title of page in preferences dialog","Diff")
127
, i18n("Searching for Differences"));
129
setHelp( "preferences-project-settings", "kbabel" );
134
void ProjectDialog::slotDefault()
136
// redefine the KConfigDialog behavior to push default on the
139
_project->settings()->useDefaults(true);
141
switch(activePageIndex())
144
_identityPage->defaults(_project->identitySettings());
147
_savePage->defaults(_project->saveSettings());
150
_miscPage->defaults(_project->miscSettings());
153
_spellPage->defaults(_project->spellcheckSettings());
156
_sourcePage->defaults(_project->sourceContextSettings());
159
_catmanPage->defaults(_project->catManSettings());
161
case PAGE_DIRCOMMANDS:
162
_dirCommandsPage->defaults(_project->catManSettings());
164
case PAGE_FILECOMMANDS:
165
_fileCommandsPage->defaults(_project->catManSettings());
168
_viewPage->defaults(_project->catManSettings());
172
_project->settings()->useDefaults(false);
175
void ProjectDialog::updateSettings()
177
KBabel::CatManSettings _CatManSettings;
178
SourceContextSettings contextSettings;
180
_spellPage->mergeSettings(_spellcheckSettings);
181
_dirCommandsPage->mergeSettings(_CatManSettings);
182
_fileCommandsPage->mergeSettings(_CatManSettings);
183
_sourcePage->mergeSettings(contextSettings);
185
_project->settings()->setDirCommands( _CatManSettings.dirCommands );
186
_project->settings()->setDirCommandNames( _CatManSettings.dirCommandNames );
187
_project->settings()->setFileCommands( _CatManSettings.fileCommands );
188
_project->settings()->setFileCommandNames( _CatManSettings.fileCommandNames );
190
_project->setSettings(_spellcheckSettings);
192
_project->settings()->setPaths( contextSettings.sourcePaths );
195
void ProjectDialog::updateWidgets()
197
_spellPage->updateWidgets(_project->spellcheckSettings());
198
_dirCommandsPage->updateWidgets(_project->catManSettings());
199
_fileCommandsPage->updateWidgets(_project->catManSettings());
200
_sourcePage->updateWidgets(_project->sourceContextSettings());
203
void ProjectDialog::updateWidgetsDefault()
205
_project->settings()->useDefaults( true );
207
_project->settings()->useDefaults( false );
210
bool ProjectDialog::isDefault()
212
SourceContextSettings contextSettings, defaultContextSettings;
214
// get the current values
215
_spellPage->mergeSettings(_spellcheckSettings);
216
_dirCommandsPage->mergeSettings(_CatManSettings);
217
_fileCommandsPage->mergeSettings(_CatManSettings);
218
_sourcePage->mergeSettings(defaultContextSettings);
220
// get default values
221
_project->settings()->useDefaults(true);
222
SpellcheckSettings defaultSpell = _project->spellcheckSettings();
223
CatManSettings defaultCatMan = _project->catManSettings();
224
defaultContextSettings = _project->sourceContextSettings();
225
_project->settings()->useDefaults(false);
229
result &= _spellcheckSettings.noRootAffix == defaultSpell.noRootAffix;
230
result &= _spellcheckSettings.runTogether == defaultSpell.runTogether;
231
result &= _spellcheckSettings.spellClient == defaultSpell.spellClient;
232
result &= _spellcheckSettings.spellDict == defaultSpell.spellDict;
233
result &= _spellcheckSettings.spellEncoding == defaultSpell.spellEncoding;
235
result &= _CatManSettings.dirCommandNames == defaultCatMan.dirCommandNames;
236
result &= _CatManSettings.dirCommands == defaultCatMan.dirCommands;
237
result &= _CatManSettings.fileCommandNames == defaultCatMan.fileCommandNames;
238
result &= _CatManSettings.fileCommands == defaultCatMan.fileCommands;
240
result &= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
245
bool ProjectDialog::hasChanged()
247
SourceContextSettings contextSettings, defaultContextSettings;
249
// get the current values
250
_spellPage->mergeSettings(_spellcheckSettings);
251
_dirCommandsPage->mergeSettings(_CatManSettings);
252
_fileCommandsPage->mergeSettings(_CatManSettings);
253
_sourcePage->mergeSettings(contextSettings);
255
// get project values
256
SpellcheckSettings defaultSpell = _project->spellcheckSettings();
257
CatManSettings defaultCatMan = _project->catManSettings();
258
defaultContextSettings = _project->sourceContextSettings();
262
result |= _spellcheckSettings.noRootAffix != defaultSpell.noRootAffix;
263
result |= _spellcheckSettings.runTogether != defaultSpell.runTogether;
264
result |= _spellcheckSettings.spellClient != defaultSpell.spellClient;
265
result |= _spellcheckSettings.spellDict != defaultSpell.spellDict;
266
result |= _spellcheckSettings.spellEncoding != defaultSpell.spellEncoding;
268
result |= _CatManSettings.dirCommandNames != defaultCatMan.dirCommandNames;
269
result |= _CatManSettings.dirCommands != defaultCatMan.dirCommands;
270
result |= _CatManSettings.fileCommandNames != defaultCatMan.fileCommandNames;
271
result |= _CatManSettings.fileCommands != defaultCatMan.fileCommands;
273
result |= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
278
#include "projectpref.moc"