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>
44#include <tqwhatsthis.h>
45#include <tqcombobox.h>
47#include <tdeinstance.h>
49#include <kdialogbase.h>
50#include <tdeglobalaccel.h>
52#include <tdeglobalsettings.h>
53#include <kiconloader.h>
54#include <kkeydialog.h>
55#include <tdelistbox.h>
57#include <tdesimpleconfig.h>
58#include <kstdaction.h>
59#include <tdestandarddirs.h>
61#include <kseparator.h>
63KateConfigDialog::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", TDEIcon::SizeSmall));
97 path << i18n(
"Application") << i18n(
"General");
98 TQFrame* frGeneral = addPage(path, i18n(
"General Options"), BarIcon(
"go-home", TDEIcon::SizeSmall));
100 TQVBoxLayout *lo =
new TQVBoxLayout( frGeneral );
101 lo->setSpacing(KDialog::spacingHint());
102 config->setGroup(
"General");
105 TQButtonGroup *bgStartup =
new TQButtonGroup( 1, TQt::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, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
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()));
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() ) );
130 bgStartup =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"&Behavior"), frGeneral );
131 lo->addWidget( bgStartup );
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() ) );
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() ) );
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() ) );
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() ) );
179 bgStartup =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Meta-Information"), frGeneral );
180 lo->addWidget( bgStartup );
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() ) );
193 TQWidget *wDmf =
new TQWidget( bgStartup );
194 wDmf->setEnabled(KateDocManager::self()->getSaveMetaInfos());
195 TQLayout *layDmf =
new TQHBoxLayout(wDmf);
196 TQLayout *layLabelDmf =
new TQHBoxLayout(layDmf);
197 layLabelDmf->addItem(
new TQSpacerItem(20,1, TQSizePolicy::Fixed));
198 TQLabel *lDmf =
new TQLabel( i18n(
"&Delete unused meta-information after:"), wDmf);
199 layLabelDmf->add(lDmf);
200 sb_daysMetaInfos =
new TQSpinBox( 0, 180, 1, wDmf );
201 sb_daysMetaInfos->setSpecialValueText(i18n(
"(never)"));
202 sb_daysMetaInfos->setSuffix(i18n(
" day(s)"));
203 sb_daysMetaInfos->setValue( KateDocManager::self()->getDaysMetaInfos() );
204 layDmf->add(sb_daysMetaInfos);
205 lDmf->setBuddy( sb_daysMetaInfos );
206 connect( cb_saveMetaInfos, TQ_SIGNAL( toggled(
bool ) ), wDmf, TQ_SLOT( setEnabled(
bool ) ) );
207 connect( sb_daysMetaInfos, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( slotChanged() ) );
215 path << i18n(
"Application") << i18n(
"Sessions");
216 TQFrame* frSessions = addPage(path, i18n(
"Session Management"), BarIcon(
"history", TDEIcon::SizeSmall));
218 lo =
new TQVBoxLayout( frSessions );
219 lo->setSpacing(KDialog::spacingHint());
222 bgStartup =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Elements of Sessions"), frSessions );
223 lo->addWidget( bgStartup );
226 cb_restoreVC =
new TQCheckBox( bgStartup );
227 cb_restoreVC->setText(i18n(
"Include &window configuration"));
228 config->setGroup(
"General");
229 cb_restoreVC->setChecked( config->readBoolEntry(
"Restore Window Configuration",
true) );
230 TQWhatsThis::add(cb_restoreVC, i18n(
231 "Check this if you want all your views and frames restored each time you open Kate"));
232 connect( cb_restoreVC, TQ_SIGNAL( toggled(
bool ) ),
this, TQ_SLOT( slotChanged() ) );
234 TQRadioButton *rb1, *rb2, *rb3;
236 sessions_start =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Behavior on Application Startup"), frSessions );
237 lo->add (sessions_start);
239 sessions_start->setRadioButtonExclusive(
true );
240 sessions_start->insert( rb1=
new TQRadioButton( i18n(
"&Start new session"), sessions_start ), 0 );
241 sessions_start->insert( rb2=
new TQRadioButton( i18n(
"&Load last-used session"), sessions_start ), 1 );
242 sessions_start->insert( rb3=
new TQRadioButton( i18n(
"&Manually choose a session"), sessions_start ), 2 );
244 config->setGroup(
"General");
245 TQString sesStart (config->readEntry (
"Startup Session",
"manual"));
246 if (sesStart ==
"new")
247 sessions_start->setButton (0);
248 else if (sesStart ==
"last")
249 sessions_start->setButton (1);
251 sessions_start->setButton (2);
253 connect(rb1, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
254 connect(rb2, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
255 connect(rb3, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
257 sessions_exit =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Behavior on Application Exit or Session Switch"), frSessions );
258 lo->add (sessions_exit);
260 sessions_exit->setRadioButtonExclusive(
true );
261 sessions_exit->insert( rb1=
new TQRadioButton( i18n(
"&Do not save session"), sessions_exit ), 0 );
262 sessions_exit->insert( rb2=
new TQRadioButton( i18n(
"&Save session"), sessions_exit ), 1 );
263 sessions_exit->insert( rb3=
new TQRadioButton( i18n(
"&Ask user"), sessions_exit ), 2 );
265 config->setGroup(
"General");
266 TQString sesExit (config->readEntry (
"Session Exit",
"save"));
267 if (sesExit ==
"discard")
268 sessions_exit->setButton (0);
269 else if (sesExit ==
"save")
270 sessions_exit->setButton (1);
272 sessions_exit->setButton (2);
274 connect(rb1, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
275 connect(rb2, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
276 connect(rb3, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
284 path << i18n(
"Application") << i18n(
"File Selector");
286 TQVBox *page = addVBoxPage( path, i18n(
"File Selector Settings"),
287 BarIcon(
"document-open", TDEIcon::SizeSmall) );
288 fileSelConfigPage =
new KFSConfigPage( page,
"file selector config page",
289 mainWindow->fileselector );
290 connect( fileSelConfigPage, TQ_SIGNAL( changed() ),
this, TQ_SLOT( slotChanged() ) );
293 path << i18n(
"Application") << i18n(
"Document List");
294 page = addVBoxPage( path, i18n(
"Document List Settings"),
295 BarIcon(
"view_text", TDEIcon::SizeSmall) );
296 filelistConfigPage =
new KFLConfigPage( page,
"file list config page",
297 mainWindow->filelist );
298 connect( filelistConfigPage, TQ_SIGNAL( changed() ),
this, TQ_SLOT( slotChanged() ) );
301 path << i18n(
"Application") << i18n(
"Plugins");
302 page=addVBoxPage(path,i18n(
"Plugin Manager"),
303 BarIcon(
"connect_established",TDEIcon::SizeSmall));
304 KateConfigPluginPage *configPluginPage =
new KateConfigPluginPage(page,
this);
305 connect( configPluginPage, TQ_SIGNAL( changed() ),
this, TQ_SLOT( slotChanged() ) );
309 path << i18n(
"Application") << i18n(
"External Tools");
310 page = addVBoxPage( path, i18n(
"External Tools"),
311 BarIcon(
"configure", TDEIcon::SizeSmall) );
313 connect( configExternalToolsPage, TQ_SIGNAL(changed()),
this, TQ_SLOT(slotChanged()) );
317 path << i18n(
"Editor");
318 setFolderIcon (path, SmallIcon(
"edit", TDEIcon::SizeSmall));
320 for (uint i = 0; i < KTextEditor::configInterfaceExtension (v->document())->configPages (); i++)
323 path << i18n(
"Editor") << KTextEditor::configInterfaceExtension (v->document())->configPageName (i);
324 page = addVBoxPage(path, KTextEditor::configInterfaceExtension (v->document())->configPageFullName (i),
325 KTextEditor::configInterfaceExtension (v->document())->configPagePixmap(i, TDEIcon::SizeSmall) );
327 KTextEditor::ConfigPage *cPage = KTextEditor::configInterfaceExtension (v->document())->configPage(i, page);
328 connect( cPage, TQ_SIGNAL( changed() ),
this, TQ_SLOT( slotChanged() ) );
329 editorPages.append (cPage);
332 KatePluginList &pluginList (KatePluginManager::self()->pluginList());
333 for (
unsigned int i=0; i < pluginList.size(); ++i)
335 if ( pluginList[i].load
336 && Kate::pluginConfigInterfaceExtension(pluginList[i].plugin) )
337 addPluginPage (pluginList[i].plugin);
340 enableButtonSeparator(
true);
345KateConfigDialog::~KateConfigDialog()
349void KateConfigDialog::addPluginPage (Kate::Plugin *plugin)
351 if (!Kate::pluginConfigInterfaceExtension(plugin))
354 for (uint i=0; i<Kate::pluginConfigInterfaceExtension(plugin)->configPages(); i++)
358 path << i18n(
"Application")<<i18n(
"Plugins") << Kate::pluginConfigInterfaceExtension(plugin)->configPageName(i);
359 TQVBox *page=addVBoxPage(path, Kate::pluginConfigInterfaceExtension(plugin)->configPageFullName(i), Kate::pluginConfigInterfaceExtension(plugin)->configPagePixmap(i, TDEIcon::SizeSmall));
361 PluginPageListItem *info=
new PluginPageListItem;
362 info->plugin = plugin;
363 info->page = Kate::pluginConfigInterfaceExtension(plugin)->configPage (i, page);
364 connect( info->page, TQ_SIGNAL( changed() ),
this, TQ_SLOT( slotChanged() ) );
365 pluginPages.append(info);
369void KateConfigDialog::removePluginPage (Kate::Plugin *plugin)
371 if (!Kate::pluginConfigInterfaceExtension(plugin))
374 for (uint i=0; i<pluginPages.count(); i++)
376 if ( pluginPages.at(i)->plugin == plugin )
378 TQWidget *w = pluginPages.at(i)->page->parentWidget();
379 delete pluginPages.at(i)->page;
381 pluginPages.remove(pluginPages.at(i));
387void KateConfigDialog::slotOk()
393void KateConfigDialog::slotApply()
400 config->setGroup(
"General");
402 config->writeEntry(
"Restore Window Configuration", cb_restoreVC->isChecked());
404 int bu = sessions_start->id (sessions_start->selected());
407 config->writeEntry (
"Startup Session",
"new");
409 config->writeEntry (
"Startup Session",
"last");
411 config->writeEntry (
"Startup Session",
"manual");
413 bu = sessions_exit->id (sessions_exit->selected());
416 config->writeEntry (
"Session Exit",
"discard");
418 config->writeEntry (
"Session Exit",
"save");
420 config->writeEntry (
"Session Exit",
"ask");
422 config->writeEntry(
"Save Meta Infos", cb_saveMetaInfos->isChecked());
423 KateDocManager::self()->setSaveMetaInfos(cb_saveMetaInfos->isChecked());
425 config->writeEntry(
"Days Meta Infos", sb_daysMetaInfos->value() );
426 KateDocManager::self()->setDaysMetaInfos(sb_daysMetaInfos->value());
428 config->writeEntry(
"Modified Notification", cb_modNotifications->isChecked());
429 mainWindow->modNotification = cb_modNotifications->isChecked();
431 mainWindow->showSessionName = cb_showSessionName->isChecked();
432 mainWindow->syncKonsole = cb_syncKonsole->isChecked();
433 mainWindow->useInstance = cb_useInstance->isChecked();
434 mainWindow->filelist->setSortType(cb_sortFiles->isChecked() ? KateFileList::sortByName : KateFileList::sortByID);
436 config->writeEntry(
"Number of recent files", sb_numRecentFiles->value() );
437 mainWindow->fileOpenRecent->setMaxItems( sb_numRecentFiles->value() );
439 fileSelConfigPage->apply();
441 filelistConfigPage->apply();
443 configExternalToolsPage->apply();
444 KateExternalToolsCommand::self()->reload();
448 win->externalTools->
reload();
452 mainWindow->viewManager()->setShowFullPath(cb_fullPath->isChecked());
454 mainWindow->saveOptions ();
463 for (uint i=0; i<editorPages.count(); i++)
465 editorPages.at(i)->apply();
468 v->getDoc()->writeConfig(config);
473 for (uint i=0; i<pluginPages.count(); i++)
475 pluginPages.at(i)->page->apply();
481 actionButton( KDialogBase::Apply)->setEnabled(
false );
484void KateConfigDialog::slotChanged()
487 actionButton( KDialogBase::Apply)->setEnabled(
true );
KateMainWindow * mainWindow(uint n)
give back the window you want
static KateApp * self()
static accessor to avoid casting ;)
KatePluginManager * pluginManager()
other accessors for global unique instances
uint mainWindows() const
give back number of existing main windows