• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • app
kateconfigdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kateconfigdialog.h"
21#include "kateconfigdialog.moc"
22
23#include "katemainwindow.h"
24
25#include "kateconsole.h"
26#include "katedocmanager.h"
27#include "katepluginmanager.h"
28#include "kateconfigplugindialogpage.h"
29#include "kateviewmanager.h"
30#include "kateapp.h"
31#include "katefileselector.h"
32#include "katefilelist.h"
33#include "kateexternaltools.h"
34
35#include <tqbuttongroup.h>
36#include <tqcheckbox.h>
37#include <tqhbox.h>
38#include <tqlabel.h>
39#include <tqlayout.h>
40#include <tqpushbutton.h>
41#include <tqradiobutton.h>
42#include <tqspinbox.h>
43#include <tqvbox.h>
44#include <tqwhatsthis.h>
45#include <tqcombobox.h>
46
47#include <kinstance.h>
48#include <kdebug.h>
49#include <kdialogbase.h>
50#include <tdeglobalaccel.h>
51#include <tdeglobal.h>
52#include <tdeglobalsettings.h>
53#include <kiconloader.h>
54#include <kkeydialog.h>
55#include <tdelistbox.h>
56#include <tdelocale.h>
57#include <ksimpleconfig.h>
58#include <kstdaction.h>
59#include <tdestandarddirs.h>
60#include <twin.h>
61#include <kseparator.h>
62
63KateConfigDialog::KateConfigDialog ( KateMainWindow *parent, Kate::View *view )
64 : KDialogBase ( KDialogBase::TreeList,
65 i18n("Configure"),
66 KDialogBase::Ok | KDialogBase::Apply|KDialogBase::Cancel | KDialogBase::Help,
67 KDialogBase::Ok,
68 parent,
69 "configdialog" )
70{
71 TDEConfig *config = KateApp::self()->config();
72
73 KWin::setIcons( winId(), KateApp::self()->icon(), KateApp::self()->miniIcon() );
74
75 actionButton( KDialogBase::Apply)->setEnabled( false );
76
77 mainWindow = parent;
78
79 setMinimumSize(600,400);
80
81 v = view;
82
83 pluginPages.setAutoDelete (false);
84 editorPages.setAutoDelete (false);
85
86 TQStringList path;
87
88 setShowIconsInTreeList(true);
89
90 path.clear();
91 path << i18n("Application");
92 setFolderIcon (path, SmallIcon("kate", TDEIcon::SizeSmall));
93
94 path.clear();
95
96 //BEGIN General page
97 path << i18n("Application") << i18n("General");
98 TQFrame* frGeneral = addPage(path, i18n("General Options"), BarIcon("go-home", TDEIcon::SizeSmall));
99
100 TQVBoxLayout *lo = new TQVBoxLayout( frGeneral );
101 lo->setSpacing(KDialog::spacingHint());
102 config->setGroup("General");
103
104 // GROUP with the one below: "Appearance"
105 TQButtonGroup *bgStartup = new TQButtonGroup( 1, TQt::Horizontal, i18n("&Appearance"), frGeneral );
106 lo->addWidget( bgStartup );
107
108 // show full path in title
109 config->setGroup("General");
110 cb_fullPath = new TQCheckBox(i18n("&Show full path in title"), bgStartup);
111 cb_fullPath->setChecked(mainWindow->viewManager()->getShowFullPath());
112 TQWhatsThis::add(cb_fullPath, i18n("If this option is checked, the full document path will be shown in the window caption."));
113 connect(cb_fullPath, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
114
115 // show session name in title
116 cb_showSessionName = new TQCheckBox(i18n("Show s&ession name in title"), bgStartup);
117 cb_showSessionName->setChecked(parent->showSessionName);
118 TQWhatsThis::add(cb_showSessionName, i18n("If this option is checked, the session name will be shown in the window caption."));
119 connect(cb_showSessionName, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
120
121 // sort filelist if desired
122 cb_sortFiles = new TQCheckBox(bgStartup);
123 cb_sortFiles->setText(i18n("Sort &files alphabetically in the file list"));
124 cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
125 TQWhatsThis::add( cb_sortFiles, i18n(
126 "If this is checked, the files in the file list will be sorted alphabetically.") );
127 connect( cb_sortFiles, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotChanged() ) );
128
129 // GROUP with the one below: "Behavior"
130 bgStartup = new TQButtonGroup( 1, TQt::Horizontal, i18n("&Behavior"), frGeneral );
131 lo->addWidget( bgStartup );
132
133 // number of recent files
134 TQHBox *hbNrf = new TQHBox( bgStartup );
135 TQLabel *lNrf = new TQLabel( i18n("&Number of recent files:"), hbNrf );
136 sb_numRecentFiles = new TQSpinBox( 0, 1000, 1, hbNrf );
137 sb_numRecentFiles->setValue( mainWindow->fileOpenRecent->maxItems() );
138 lNrf->setBuddy( sb_numRecentFiles );
139 TQString numRecentFileHelpString ( i18n(
140 "<qt>Sets the number of recent files remembered by Kate.<p><strong>NOTE: </strong>"
141 "If you set this lower than the current value, the list will be truncated and "
142 "some items forgotten.</qt>") );
143 TQWhatsThis::add( lNrf, numRecentFileHelpString );
144 TQWhatsThis::add( sb_numRecentFiles, numRecentFileHelpString );
145 connect( sb_numRecentFiles, TQ_SIGNAL( valueChanged ( int ) ), this, TQ_SLOT( slotChanged() ) );
146
147 // Use only one instance of kate (MDI) ?
148 cb_useInstance = new TQCheckBox(bgStartup);
149 cb_useInstance->setText(i18n("Always use the current instance of kate to open new files"));
150 cb_useInstance->setChecked(parent->useInstance);
151 TQWhatsThis::add( cb_useInstance, i18n(
152 "When checked, all files opened from outside of Kate will only use the "
153 "currently opened instance of Kate.") );
154 connect( cb_useInstance, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotChanged() ) );
155
156 // sync the konsole ?
157 cb_syncKonsole = new TQCheckBox(bgStartup);
158 cb_syncKonsole->setText(i18n("Sync &terminal emulator with active document"));
159 cb_syncKonsole->setChecked(parent->syncKonsole);
160 TQWhatsThis::add( cb_syncKonsole, i18n(
161 "If this is checked, the built in Konsole will <code>cd</code> to the directory "
162 "of the active document when started and whenever the active document changes, "
163 "if the document is a local file.") );
164 connect( cb_syncKonsole, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotChanged() ) );
165
166 // modified files notification
167 cb_modNotifications = new TQCheckBox(
168 i18n("Wa&rn about files modified by foreign processes"), bgStartup );
169 cb_modNotifications->setChecked( parent->modNotification );
170 TQWhatsThis::add( cb_modNotifications, i18n(
171 "If enabled, when Kate receives focus you will be asked what to do with "
172 "files that have been modified on the hard disk. If not enabled, you will "
173 "be asked what to do with a file that has been modified on the hard disk only "
174 "when that file gains focus inside Kate.") );
175 connect( cb_modNotifications, TQ_SIGNAL( toggled( bool ) ),
176 this, TQ_SLOT( slotChanged() ) );
177
178 // GROUP with the one below: "Meta-informations"
179 bgStartup = new TQButtonGroup( 2, TQt::Horizontal, i18n("Meta-Information"), frGeneral );
180 lo->addWidget( bgStartup );
181
182 // save meta infos
183 cb_saveMetaInfos = new TQCheckBox( bgStartup );
184 cb_saveMetaInfos->setText(i18n("Keep &meta-information past sessions"));
185 cb_saveMetaInfos->setChecked(KateDocManager::self()->getSaveMetaInfos());
186 TQWhatsThis::add(cb_saveMetaInfos, i18n(
187 "Check this if you want document configuration like for example "
188 "bookmarks to be saved past editor sessions. The configuration will be "
189 "restored if the document has not changed when reopened."));
190 connect( cb_saveMetaInfos, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotChanged() ) );
191
192 // meta infos days
193 TQHBox *hbDmf = new TQHBox( bgStartup );
194 hbDmf->setEnabled(KateDocManager::self()->getSaveMetaInfos());
195 TQLabel *lDmf = new TQLabel( i18n("&Delete unused meta-information after:"), hbDmf );
196 sb_daysMetaInfos = new TQSpinBox( 0, 180, 1, hbDmf );
197 sb_daysMetaInfos->setSpecialValueText(i18n("(never)"));
198 sb_daysMetaInfos->setSuffix(i18n(" day(s)"));
199 sb_daysMetaInfos->setValue( KateDocManager::self()->getDaysMetaInfos() );
200 lDmf->setBuddy( sb_daysMetaInfos );
201 connect( cb_saveMetaInfos, TQ_SIGNAL( toggled( bool ) ), hbDmf, TQ_SLOT( setEnabled( bool ) ) );
202 connect( sb_daysMetaInfos, TQ_SIGNAL( valueChanged ( int ) ), this, TQ_SLOT( slotChanged() ) );
203
204 lo->addStretch(1); // :-] works correct without autoadd
205 //END General page
206
207 path.clear();
208
209 //BEGIN Session page
210 path << i18n("Application") << i18n("Sessions");
211 TQFrame* frSessions = addPage(path, i18n("Session Management"), BarIcon("history", TDEIcon::SizeSmall));
212
213 lo = new TQVBoxLayout( frSessions );
214 lo->setSpacing(KDialog::spacingHint());
215
216 // GROUP with the one below: "Startup"
217 bgStartup = new TQButtonGroup( 1, TQt::Horizontal, i18n("Elements of Sessions"), frSessions );
218 lo->addWidget( bgStartup );
219
220 // restore view config
221 cb_restoreVC = new TQCheckBox( bgStartup );
222 cb_restoreVC->setText(i18n("Include &window configuration"));
223 config->setGroup("General");
224 cb_restoreVC->setChecked( config->readBoolEntry("Restore Window Configuration", true) );
225 TQWhatsThis::add(cb_restoreVC, i18n(
226 "Check this if you want all your views and frames restored each time you open Kate"));
227 connect( cb_restoreVC, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotChanged() ) );
228
229 TQRadioButton *rb1, *rb2, *rb3;
230
231 sessions_start = new TQButtonGroup( 1, TQt::Horizontal, i18n("Behavior on Application Startup"), frSessions );
232 lo->add (sessions_start);
233
234 sessions_start->setRadioButtonExclusive( true );
235 sessions_start->insert( rb1=new TQRadioButton( i18n("&Start new session"), sessions_start ), 0 );
236 sessions_start->insert( rb2=new TQRadioButton( i18n("&Load last-used session"), sessions_start ), 1 );
237 sessions_start->insert( rb3=new TQRadioButton( i18n("&Manually choose a session"), sessions_start ), 2 );
238
239 config->setGroup("General");
240 TQString sesStart (config->readEntry ("Startup Session", "manual"));
241 if (sesStart == "new")
242 sessions_start->setButton (0);
243 else if (sesStart == "last")
244 sessions_start->setButton (1);
245 else
246 sessions_start->setButton (2);
247
248 connect(rb1, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
249 connect(rb2, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
250 connect(rb3, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
251
252 sessions_exit = new TQButtonGroup( 1, TQt::Horizontal, i18n("Behavior on Application Exit or Session Switch"), frSessions );
253 lo->add (sessions_exit);
254
255 sessions_exit->setRadioButtonExclusive( true );
256 sessions_exit->insert( rb1=new TQRadioButton( i18n("&Do not save session"), sessions_exit ), 0 );
257 sessions_exit->insert( rb2=new TQRadioButton( i18n("&Save session"), sessions_exit ), 1 );
258 sessions_exit->insert( rb3=new TQRadioButton( i18n("&Ask user"), sessions_exit ), 2 );
259
260 config->setGroup("General");
261 TQString sesExit (config->readEntry ("Session Exit", "save"));
262 if (sesExit == "discard")
263 sessions_exit->setButton (0);
264 else if (sesExit == "save")
265 sessions_exit->setButton (1);
266 else
267 sessions_exit->setButton (2);
268
269 connect(rb1, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
270 connect(rb2, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
271 connect(rb3, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
272
273 lo->addStretch(1); // :-] works correct without autoadd
274 //END Session page
275
276 path.clear();
277
278 // file selector page
279 path << i18n("Application") << i18n("File Selector");
280
281 TQVBox *page = addVBoxPage( path, i18n("File Selector Settings"),
282 BarIcon("document-open", TDEIcon::SizeSmall) );
283 fileSelConfigPage = new KFSConfigPage( page, "file selector config page",
284 mainWindow->fileselector );
285 connect( fileSelConfigPage, TQ_SIGNAL( changed() ), this, TQ_SLOT( slotChanged() ) );
286 path.clear();
287
288 path << i18n("Application") << i18n("Document List");
289 page = addVBoxPage( path, i18n("Document List Settings"),
290 BarIcon("view_text", TDEIcon::SizeSmall) );
291 filelistConfigPage = new KFLConfigPage( page, "file list config page",
292 mainWindow->filelist );
293 connect( filelistConfigPage, TQ_SIGNAL( changed() ), this, TQ_SLOT( slotChanged() ) );
294 path.clear();
295
296 path << i18n("Application") << i18n("Plugins");
297 /*TQVBox **/page=addVBoxPage(path,i18n("Plugin Manager"),
298 BarIcon("connect_established",TDEIcon::SizeSmall));
299 KateConfigPluginPage *configPluginPage = new KateConfigPluginPage(page, this);
300 connect( configPluginPage, TQ_SIGNAL( changed() ), this, TQ_SLOT( slotChanged() ) );
301
302 // Tools->External Tools menu
303 path.clear();
304 path << i18n("Application") << i18n("External Tools");
305 page = addVBoxPage( path, i18n("External Tools"),
306 BarIcon("configure", TDEIcon::SizeSmall) );
307 configExternalToolsPage = new KateExternalToolsConfigWidget(page, "external tools config page");
308 connect( configExternalToolsPage, TQ_SIGNAL(changed()), this, TQ_SLOT(slotChanged()) );
309
310 // editor widgets from kwrite/kwdialog
311 path.clear();
312 path << i18n("Editor");
313 setFolderIcon (path, SmallIcon("edit", TDEIcon::SizeSmall));
314
315 for (uint i = 0; i < KTextEditor::configInterfaceExtension (v->document())->configPages (); i++)
316 {
317 path.clear();
318 path << i18n("Editor") << KTextEditor::configInterfaceExtension (v->document())->configPageName (i);
319 /*TQVBox **/page = addVBoxPage(path, KTextEditor::configInterfaceExtension (v->document())->configPageFullName (i),
320 KTextEditor::configInterfaceExtension (v->document())->configPagePixmap(i, TDEIcon::SizeSmall) );
321
322 KTextEditor::ConfigPage *cPage = KTextEditor::configInterfaceExtension (v->document())->configPage(i, page);
323 connect( cPage, TQ_SIGNAL( changed() ), this, TQ_SLOT( slotChanged() ) );
324 editorPages.append (cPage);
325 }
326
327 KatePluginList &pluginList (KatePluginManager::self()->pluginList());
328 for (unsigned int i=0; i < pluginList.size(); ++i)
329 {
330 if ( pluginList[i].load
331 && Kate::pluginConfigInterfaceExtension(pluginList[i].plugin) )
332 addPluginPage (pluginList[i].plugin);
333 }
334
335 enableButtonSeparator(true);
336 dataChanged = false;
337 unfoldTreeList ();
338}
339
340KateConfigDialog::~KateConfigDialog()
341{
342}
343
344void KateConfigDialog::addPluginPage (Kate::Plugin *plugin)
345{
346 if (!Kate::pluginConfigInterfaceExtension(plugin))
347 return;
348
349 for (uint i=0; i<Kate::pluginConfigInterfaceExtension(plugin)->configPages(); i++)
350 {
351 TQStringList path;
352 path.clear();
353 path << i18n("Application")<<i18n("Plugins") << Kate::pluginConfigInterfaceExtension(plugin)->configPageName(i);
354 TQVBox *page=addVBoxPage(path, Kate::pluginConfigInterfaceExtension(plugin)->configPageFullName(i), Kate::pluginConfigInterfaceExtension(plugin)->configPagePixmap(i, TDEIcon::SizeSmall));
355
356 PluginPageListItem *info=new PluginPageListItem;
357 info->plugin = plugin;
358 info->page = Kate::pluginConfigInterfaceExtension(plugin)->configPage (i, page);
359 connect( info->page, TQ_SIGNAL( changed() ), this, TQ_SLOT( slotChanged() ) );
360 pluginPages.append(info);
361 }
362}
363
364void KateConfigDialog::removePluginPage (Kate::Plugin *plugin)
365{
366 if (!Kate::pluginConfigInterfaceExtension(plugin))
367 return;
368
369 for (uint i=0; i<pluginPages.count(); i++)
370 {
371 if ( pluginPages.at(i)->plugin == plugin )
372 {
373 TQWidget *w = pluginPages.at(i)->page->parentWidget();
374 delete pluginPages.at(i)->page;
375 delete w;
376 pluginPages.remove(pluginPages.at(i));
377 i--;
378 }
379 }
380}
381
382void KateConfigDialog::slotOk()
383{
384 slotApply();
385 accept();
386}
387
388void KateConfigDialog::slotApply()
389{
390 TDEConfig *config = KateApp::self()->config();
391
392 // if data changed apply the kate app stuff
393 if( dataChanged )
394 {
395 config->setGroup("General");
396
397 config->writeEntry("Restore Window Configuration", cb_restoreVC->isChecked());
398
399 int bu = sessions_start->id (sessions_start->selected());
400
401 if (bu == 0)
402 config->writeEntry ("Startup Session", "new");
403 else if (bu == 1)
404 config->writeEntry ("Startup Session", "last");
405 else
406 config->writeEntry ("Startup Session", "manual");
407
408 bu = sessions_exit->id (sessions_exit->selected());
409
410 if (bu == 0)
411 config->writeEntry ("Session Exit", "discard");
412 else if (bu == 1)
413 config->writeEntry ("Session Exit", "save");
414 else
415 config->writeEntry ("Session Exit", "ask");
416
417 config->writeEntry("Save Meta Infos", cb_saveMetaInfos->isChecked());
418 KateDocManager::self()->setSaveMetaInfos(cb_saveMetaInfos->isChecked());
419
420 config->writeEntry("Days Meta Infos", sb_daysMetaInfos->value() );
421 KateDocManager::self()->setDaysMetaInfos(sb_daysMetaInfos->value());
422
423 config->writeEntry("Modified Notification", cb_modNotifications->isChecked());
424 mainWindow->modNotification = cb_modNotifications->isChecked();
425
426 mainWindow->showSessionName = cb_showSessionName->isChecked();
427 mainWindow->syncKonsole = cb_syncKonsole->isChecked();
428 mainWindow->useInstance = cb_useInstance->isChecked();
429 mainWindow->filelist->setSortType(cb_sortFiles->isChecked() ? KateFileList::sortByName : KateFileList::sortByID);
430
431 config->writeEntry( "Number of recent files", sb_numRecentFiles->value() );
432 mainWindow->fileOpenRecent->setMaxItems( sb_numRecentFiles->value() );
433
434 fileSelConfigPage->apply();
435
436 filelistConfigPage->apply();
437
438 configExternalToolsPage->apply();
439 KateExternalToolsCommand::self()->reload();
440 for (uint i=0; i < KateApp::self()->mainWindows(); i++)
441 {
442 KateMainWindow *win = KateApp::self()->mainWindow (i);
443 win->externalTools->reload();
444 }
445 //mainWindow->externalTools->reload();
446
447 mainWindow->viewManager()->setShowFullPath(cb_fullPath->isChecked());
448
449 mainWindow->saveOptions ();
450
451 // save plugin config !!
452 KateApp::self()->pluginManager()->writeConfig ();
453 }
454
455 //
456 // editor config ! (the apply() methode will check the changed state internally)
457 //
458 for (uint i=0; i<editorPages.count(); i++)
459 {
460 editorPages.at(i)->apply();
461 }
462
463 v->getDoc()->writeConfig(config);
464
465 //
466 // plugins config ! (the apply() methode SHOULD check the changed state internally)
467 //
468 for (uint i=0; i<pluginPages.count(); i++)
469 {
470 pluginPages.at(i)->page->apply();
471 }
472
473 config->sync();
474
475 dataChanged = false;
476 actionButton( KDialogBase::Apply)->setEnabled( false );
477}
478
479void KateConfigDialog::slotChanged()
480{
481 dataChanged = true;
482 actionButton( KDialogBase::Apply)->setEnabled( true );
483}
KateApp::mainWindow
KateMainWindow * mainWindow(uint n)
give back the window you want
Definition: kateapp.cpp:475
KateApp::self
static KateApp * self()
static accessor to avoid casting ;)
Definition: kateapp.cpp:114
KateApp::pluginManager
KatePluginManager * pluginManager()
other accessors for global unique instances
Definition: kateapp.cpp:367
KateApp::mainWindows
uint mainWindows() const
give back number of existing main windows
Definition: kateapp.cpp:470
KateExternalToolsConfigWidget
The config widget.
Definition: kateexternaltools.h:144

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.