20 #include "kateconfigdialog.h"
21 #include "kateconfigdialog.moc"
23 #include "katemainwindow.h"
25 #include "kateconsole.h"
26 #include "katedocmanager.h"
27 #include "katepluginmanager.h"
28 #include "kateconfigplugindialogpage.h"
29 #include "kateviewmanager.h"
31 #include "katefileselector.h"
32 #include "katefilelist.h"
33 #include "kateexternaltools.h"
35 #include <tqbuttongroup.h>
36 #include <tqcheckbox.h>
40 #include <tqpushbutton.h>
41 #include <tqradiobutton.h>
42 #include <tqspinbox.h>
44 #include <tqwhatsthis.h>
45 #include <tqcombobox.h>
47 #include <kinstance.h>
49 #include <kdialogbase.h>
50 #include <kglobalaccel.h>
52 #include <kglobalsettings.h>
53 #include <kiconloader.h>
54 #include <kkeydialog.h>
57 #include <ksimpleconfig.h>
58 #include <kstdaction.h>
59 #include <kstandarddirs.h>
61 #include <kseparator.h>
63 KateConfigDialog::KateConfigDialog ( KateMainWindow *parent, Kate::View *view )
64 : KDialogBase ( KDialogBase::TreeList,
66 KDialogBase::Ok | KDialogBase::Apply|KDialogBase::Cancel | KDialogBase::Help,
75 actionButton( KDialogBase::Apply)->setEnabled(
false );
79 setMinimumSize(600,400);
83 pluginPages.setAutoDelete (
false);
84 editorPages.setAutoDelete (
false);
88 setShowIconsInTreeList(
true);
91 path << i18n(
"Application");
92 setFolderIcon (path, SmallIcon(
"kate", KIcon::SizeSmall));
97 path << i18n(
"Application") << i18n(
"General");
98 TQFrame* frGeneral = addPage(path, i18n(
"General Options"), BarIcon(
"gohome", KIcon::SizeSmall));
100 TQVBoxLayout *lo =
new TQVBoxLayout( frGeneral );
101 lo->setSpacing(KDialog::spacingHint());
102 config->setGroup(
"General");
105 TQButtonGroup *bgStartup =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"&Appearance"), frGeneral );
106 lo->addWidget( bgStartup );
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, TQT_SIGNAL( toggled(
bool ) ),
this, TQT_SLOT( slotChanged() ) );
116 cb_sortFiles =
new TQCheckBox(bgStartup);
117 cb_sortFiles->setText(i18n(
"Sort &files alphabetically in the file list"));
118 cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
119 TQWhatsThis::add( cb_sortFiles, i18n(
120 "If this is checked, the files in the file list will be sorted alphabetically.") );
121 connect( cb_sortFiles, TQT_SIGNAL( toggled(
bool ) ),
this, TQT_SLOT( slotChanged() ) );
124 bgStartup =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"&Behavior"), frGeneral );
125 lo->addWidget( bgStartup );
128 TQHBox *hbNrf =
new TQHBox( bgStartup );
129 TQLabel *lNrf =
new TQLabel( i18n(
"&Number of recent files:"), hbNrf );
130 sb_numRecentFiles =
new TQSpinBox( 0, 1000, 1, hbNrf );
131 sb_numRecentFiles->setValue(
mainWindow->fileOpenRecent->maxItems() );
132 lNrf->setBuddy( sb_numRecentFiles );
133 TQString numRecentFileHelpString ( i18n(
134 "<qt>Sets the number of recent files remembered by Kate.<p><strong>NOTE: </strong>"
135 "If you set this lower than the current value, the list will be truncated and "
136 "some items forgotten.</qt>") );
137 TQWhatsThis::add( lNrf, numRecentFileHelpString );
138 TQWhatsThis::add( sb_numRecentFiles, numRecentFileHelpString );
139 connect( sb_numRecentFiles, TQT_SIGNAL( valueChanged (
int ) ),
this, TQT_SLOT( slotChanged() ) );
142 cb_syncKonsole =
new TQCheckBox(bgStartup);
143 cb_syncKonsole->setText(i18n(
"Sync &terminal emulator with active document"));
144 cb_syncKonsole->setChecked(parent->syncKonsole);
145 TQWhatsThis::add( cb_syncKonsole, i18n(
146 "If this is checked, the built in Konsole will <code>cd</code> to the directory "
147 "of the active document when started and whenever the active document changes, "
148 "if the document is a local file.") );
149 connect( cb_syncKonsole, TQT_SIGNAL( toggled(
bool ) ),
this, TQT_SLOT( slotChanged() ) );
152 cb_modNotifications =
new TQCheckBox(
153 i18n(
"Wa&rn about files modified by foreign processes"), bgStartup );
154 cb_modNotifications->setChecked( parent->modNotification );
155 TQWhatsThis::add( cb_modNotifications, i18n(
156 "If enabled, when Kate receives focus you will be asked what to do with "
157 "files that have been modified on the hard disk. If not enabled, you will "
158 "be asked what to do with a file that has been modified on the hard disk only "
159 "when that file gains focus inside Kate.") );
160 connect( cb_modNotifications, TQT_SIGNAL( toggled(
bool ) ),
161 this, TQT_SLOT( slotChanged() ) );
164 bgStartup =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Meta-Information"), frGeneral );
165 lo->addWidget( bgStartup );
168 cb_saveMetaInfos =
new TQCheckBox( bgStartup );
169 cb_saveMetaInfos->setText(i18n(
"Keep &meta-information past sessions"));
170 cb_saveMetaInfos->setChecked(KateDocManager::self()->getSaveMetaInfos());
171 TQWhatsThis::add(cb_saveMetaInfos, i18n(
172 "Check this if you want document configuration like for example "
173 "bookmarks to be saved past editor sessions. The configuration will be "
174 "restored if the document has not changed when reopened."));
175 connect( cb_saveMetaInfos, TQT_SIGNAL( toggled(
bool ) ),
this, TQT_SLOT( slotChanged() ) );
178 TQHBox *hbDmf =
new TQHBox( bgStartup );
179 hbDmf->setEnabled(KateDocManager::self()->getSaveMetaInfos());
180 TQLabel *lDmf =
new TQLabel( i18n(
"&Delete unused meta-information after:"), hbDmf );
181 sb_daysMetaInfos =
new TQSpinBox( 0, 180, 1, hbDmf );
182 sb_daysMetaInfos->setSpecialValueText(i18n(
"(never)"));
183 sb_daysMetaInfos->setSuffix(i18n(
" day(s)"));
184 sb_daysMetaInfos->setValue( KateDocManager::self()->getDaysMetaInfos() );
185 lDmf->setBuddy( sb_daysMetaInfos );
186 connect( cb_saveMetaInfos, TQT_SIGNAL( toggled(
bool ) ), hbDmf, TQT_SLOT( setEnabled(
bool ) ) );
187 connect( sb_daysMetaInfos, TQT_SIGNAL( valueChanged (
int ) ),
this, TQT_SLOT( slotChanged() ) );
195 path << i18n(
"Application") << i18n(
"Sessions");
196 TQFrame* frSessions = addPage(path, i18n(
"Session Management"), BarIcon(
"history", KIcon::SizeSmall));
198 lo =
new TQVBoxLayout( frSessions );
199 lo->setSpacing(KDialog::spacingHint());
202 bgStartup =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Elements of Sessions"), frSessions );
203 lo->addWidget( bgStartup );
206 cb_restoreVC =
new TQCheckBox( bgStartup );
207 cb_restoreVC->setText(i18n(
"Include &window configuration"));
208 config->setGroup(
"General");
209 cb_restoreVC->setChecked( config->readBoolEntry(
"Restore Window Configuration",
true) );
210 TQWhatsThis::add(cb_restoreVC, i18n(
211 "Check this if you want all your views and frames restored each time you open Kate"));
212 connect( cb_restoreVC, TQT_SIGNAL( toggled(
bool ) ),
this, TQT_SLOT( slotChanged() ) );
214 TQRadioButton *rb1, *rb2, *rb3;
216 sessions_start =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Behavior on Application Startup"), frSessions );
217 lo->add (sessions_start);
219 sessions_start->setRadioButtonExclusive(
true );
220 sessions_start->insert( rb1=
new TQRadioButton( i18n(
"&Start new session"), sessions_start ), 0 );
221 sessions_start->insert( rb2=
new TQRadioButton( i18n(
"&Load last-used session"), sessions_start ), 1 );
222 sessions_start->insert( rb3=
new TQRadioButton( i18n(
"&Manually choose a session"), sessions_start ), 2 );
224 config->setGroup(
"General");
225 TQString sesStart (config->readEntry (
"Startup Session",
"manual"));
226 if (sesStart ==
"new")
227 sessions_start->setButton (0);
228 else if (sesStart ==
"last")
229 sessions_start->setButton (1);
231 sessions_start->setButton (2);
233 connect(rb1, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
234 connect(rb2, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
235 connect(rb3, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
237 sessions_exit =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Behavior on Application Exit or Session Switch"), frSessions );
238 lo->add (sessions_exit);
240 sessions_exit->setRadioButtonExclusive(
true );
241 sessions_exit->insert( rb1=
new TQRadioButton( i18n(
"&Do not save session"), sessions_exit ), 0 );
242 sessions_exit->insert( rb2=
new TQRadioButton( i18n(
"&Save session"), sessions_exit ), 1 );
243 sessions_exit->insert( rb3=
new TQRadioButton( i18n(
"&Ask user"), sessions_exit ), 2 );
245 config->setGroup(
"General");
246 TQString sesExit (config->readEntry (
"Session Exit",
"save"));
247 if (sesExit ==
"discard")
248 sessions_exit->setButton (0);
249 else if (sesExit ==
"save")
250 sessions_exit->setButton (1);
252 sessions_exit->setButton (2);
254 connect(rb1, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
255 connect(rb2, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
256 connect(rb3, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
264 path << i18n(
"Application") << i18n(
"File Selector");
266 TQVBox *page = addVBoxPage( path, i18n(
"File Selector Settings"),
267 BarIcon(
"fileopen", KIcon::SizeSmall) );
268 fileSelConfigPage =
new KFSConfigPage( page,
"file selector config page",
270 connect( fileSelConfigPage, TQT_SIGNAL( changed() ),
this, TQT_SLOT( slotChanged() ) );
273 path << i18n(
"Application") << i18n(
"Document List");
274 page = addVBoxPage( path, i18n(
"Document List Settings"),
275 BarIcon(
"view_text", KIcon::SizeSmall) );
276 filelistConfigPage =
new KFLConfigPage( page,
"file list config page",
278 connect( filelistConfigPage, TQT_SIGNAL( changed() ),
this, TQT_SLOT( slotChanged() ) );
281 path << i18n(
"Application") << i18n(
"Plugins");
282 page=addVBoxPage(path,i18n(
"Plugin Manager"),
283 BarIcon(
"connect_established",KIcon::SizeSmall));
284 KateConfigPluginPage *configPluginPage =
new KateConfigPluginPage(page,
this);
285 connect( configPluginPage, TQT_SIGNAL( changed() ), TQT_TQOBJECT(
this), TQT_SLOT( slotChanged() ) );
289 path << i18n(
"Application") << i18n(
"External Tools");
290 page = addVBoxPage( path, i18n(
"External Tools"),
291 BarIcon(
"configure", KIcon::SizeSmall) );
293 connect( configExternalToolsPage, TQT_SIGNAL(changed()), TQT_TQOBJECT(
this), TQT_SLOT(slotChanged()) );
297 path << i18n(
"Editor");
298 setFolderIcon (path, SmallIcon(
"edit", KIcon::SizeSmall));
300 for (uint i = 0; i < KTextEditor::configInterfaceExtension (v->document())->configPages (); i++)
303 path << i18n(
"Editor") << KTextEditor::configInterfaceExtension (v->document())->configPageName (i);
304 page = addVBoxPage(path, KTextEditor::configInterfaceExtension (v->document())->configPageFullName (i),
305 KTextEditor::configInterfaceExtension (v->document())->configPagePixmap(i, KIcon::SizeSmall) );
307 KTextEditor::ConfigPage *cPage = KTextEditor::configInterfaceExtension (v->document())->configPage(i, page);
308 connect( cPage, TQT_SIGNAL( changed() ),
this, TQT_SLOT( slotChanged() ) );
309 editorPages.append (cPage);
312 KatePluginList &pluginList (KatePluginManager::self()->pluginList());
313 for (
unsigned int i=0; i < pluginList.size(); ++i)
315 if ( pluginList[i].load
316 && Kate::pluginConfigInterfaceExtension(pluginList[i].plugin) )
317 addPluginPage (pluginList[i].plugin);
320 enableButtonSeparator(
true);
325 KateConfigDialog::~KateConfigDialog()
329 void KateConfigDialog::addPluginPage (Kate::Plugin *plugin)
331 if (!Kate::pluginConfigInterfaceExtension(plugin))
334 for (uint i=0; i<Kate::pluginConfigInterfaceExtension(plugin)->configPages(); i++)
338 path << i18n(
"Application")<<i18n(
"Plugins") << Kate::pluginConfigInterfaceExtension(plugin)->configPageName(i);
339 TQVBox *page=addVBoxPage(path, Kate::pluginConfigInterfaceExtension(plugin)->configPageFullName(i), Kate::pluginConfigInterfaceExtension(plugin)->configPagePixmap(i, KIcon::SizeSmall));
341 PluginPageListItem *info=
new PluginPageListItem;
342 info->plugin = plugin;
343 info->page = Kate::pluginConfigInterfaceExtension(plugin)->configPage (i, page);
344 connect( info->page, TQT_SIGNAL( changed() ),
this, TQT_SLOT( slotChanged() ) );
345 pluginPages.append(info);
349 void KateConfigDialog::removePluginPage (Kate::Plugin *plugin)
351 if (!Kate::pluginConfigInterfaceExtension(plugin))
354 for (uint i=0; i<pluginPages.count(); i++)
356 if ( pluginPages.at(i)->plugin == plugin )
358 TQWidget *w = pluginPages.at(i)->page->parentWidget();
359 delete pluginPages.at(i)->page;
361 pluginPages.remove(pluginPages.at(i));
367 void KateConfigDialog::slotOk()
373 void KateConfigDialog::slotApply()
380 config->setGroup(
"General");
382 config->writeEntry(
"Restore Window Configuration", cb_restoreVC->isChecked());
384 int bu = sessions_start->id (sessions_start->selected());
387 config->writeEntry (
"Startup Session",
"new");
389 config->writeEntry (
"Startup Session",
"last");
391 config->writeEntry (
"Startup Session",
"manual");
393 bu = sessions_exit->id (sessions_exit->selected());
396 config->writeEntry (
"Session Exit",
"discard");
398 config->writeEntry (
"Session Exit",
"save");
400 config->writeEntry (
"Session Exit",
"ask");
402 config->writeEntry(
"Save Meta Infos", cb_saveMetaInfos->isChecked());
403 KateDocManager::self()->setSaveMetaInfos(cb_saveMetaInfos->isChecked());
405 config->writeEntry(
"Days Meta Infos", sb_daysMetaInfos->value() );
406 KateDocManager::self()->setDaysMetaInfos(sb_daysMetaInfos->value());
408 config->writeEntry(
"Modified Notification", cb_modNotifications->isChecked());
409 mainWindow->modNotification = cb_modNotifications->isChecked();
411 mainWindow->syncKonsole = cb_syncKonsole->isChecked();
412 mainWindow->filelist->setSortType(cb_sortFiles->isChecked() ? KateFileList::sortByName : KateFileList::sortByID);
414 config->writeEntry(
"Number of recent files", sb_numRecentFiles->value() );
415 mainWindow->fileOpenRecent->setMaxItems( sb_numRecentFiles->value() );
417 fileSelConfigPage->apply();
419 filelistConfigPage->apply();
421 configExternalToolsPage->apply();
422 KateExternalToolsCommand::self()->reload();
426 win->externalTools->reload();
430 mainWindow->viewManager()->setShowFullPath( cb_fullPath->isChecked() );
432 mainWindow->saveOptions ();
441 for (uint i=0; i<editorPages.count(); i++)
443 editorPages.at(i)->apply();
446 v->getDoc()->writeConfig(config);
451 for (uint i=0; i<pluginPages.count(); i++)
453 pluginPages.at(i)->page->apply();
459 actionButton( KDialogBase::Apply)->setEnabled(
false );
462 void KateConfigDialog::slotChanged()
465 actionButton( KDialogBase::Apply)->setEnabled(
true );