25 #include "katedialogs.h"
26 #include "katedialogs.moc"
28 #include "kateautoindent.h"
29 #include "katebuffer.h"
30 #include "kateconfig.h"
31 #include "katedocument.h"
32 #include "katefactory.h"
33 #include "kateschema.h"
34 #include "katesyntaxdocument.h"
38 #include <ktexteditor/configinterfaceextension.h>
39 #include <ktexteditor/plugin.h>
42 #include <kio/jobclasses.h>
43 #include <kio/netaccess.h>
46 #include <kapplication.h>
47 #include <kbuttonbox.h>
48 #include <kcharsets.h>
49 #include <kcolorbutton.h>
50 #include <kcolorcombo.h>
51 #include <kcolordialog.h>
52 #include <kcombobox.h>
55 #include <kfontdialog.h>
57 #include <kglobalsettings.h>
58 #include <kiconloader.h>
59 #include <kkeybutton.h>
60 #include <kkeydialog.h>
61 #include <klineedit.h>
62 #include <klistview.h>
64 #include <kmessagebox.h>
65 #include <kmimetypechooser.h>
66 #include <knuminput.h>
67 #include <kparts/componentfactory.h>
68 #include <kpopupmenu.h>
71 #include <kregexpeditorinterface.h>
73 #include <kseparator.h>
74 #include <kstandarddirs.h>
75 #include <ktempfile.h>
77 #include <tqbuttongroup.h>
78 #include <tqcheckbox.h>
79 #include <tqcombobox.h>
84 #include <tqgroupbox.h>
87 #include <tqhgroupbox.h>
90 #include <tqlineedit.h>
91 #include <tqlistbox.h>
92 #include <tqlistview.h>
94 #include <tqobjectlist.h>
95 #include <tqpainter.h>
96 #include <tqpointarray.h>
97 #include <tqptrcollection.h>
98 #include <tqpushbutton.h>
99 #include <tqradiobutton.h>
100 #include <tqslider.h>
101 #include <tqspinbox.h>
102 #include <tqstringlist.h>
103 #include <tqtabwidget.h>
104 #include <tqtextcodec.h>
105 #include <tqtoolbutton.h>
107 #include <tqvgroupbox.h>
108 #include <tqwhatsthis.h>
109 #include <tqwidgetstack.h>
112 #define HLDOWNLOADPATH "http://kate.kde.org/syntax/"
117 KateConfigPage::KateConfigPage ( TQWidget *parent,
const char *name )
118 : Kate::ConfigPage (parent, name)
121 connect (
this, TQT_SIGNAL(changed()),
this, TQT_SLOT(somethingHasChanged ()));
124 KateConfigPage::~KateConfigPage ()
128 void KateConfigPage::somethingHasChanged ()
131 kdDebug (13000) <<
"TEST: something changed on the config page: " <<
this <<
endl;
136 const int KateIndentConfigTab::flags[] = {
137 KateDocument::cfSpaceIndent,
138 KateDocument::cfKeepIndentProfile,
139 KateDocument::cfKeepExtraSpaces,
140 KateDocument::cfTabIndents,
141 KateDocument::cfBackspaceIndents,
142 KateDocumentConfig::cfDoxygenAutoTyping,
143 KateDocumentConfig::cfMixedIndent,
144 KateDocumentConfig::cfIndentPastedText
147 KateIndentConfigTab::KateIndentConfigTab(TQWidget *parent)
148 : KateConfigPage(parent)
150 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
151 int configFlags = KateDocumentConfig::global()->configFlags();
153 TQVGroupBox *gbAuto =
new TQVGroupBox(i18n(
"Automatic Indentation"),
this);
155 TQHBox *indentLayout =
new TQHBox(gbAuto);
156 indentLayout->setSpacing(KDialog::spacingHint());
157 TQLabel *indentLabel =
new TQLabel(i18n(
"&Indentation mode:"), indentLayout);
158 m_indentMode =
new KComboBox (indentLayout);
160 indentLabel->setBuddy(m_indentMode);
161 m_configPage =
new TQPushButton(SmallIconSet(
"configure"), i18n(
"Configure..."), indentLayout);
163 opt[5] =
new TQCheckBox(i18n(
"Insert leading Doxygen \"*\" when typing"), gbAuto);
164 opt[7] =
new TQCheckBox(i18n(
"Adjust indentation of code pasted from the clipboard"), gbAuto);
166 TQVGroupBox *gbSpaces =
new TQVGroupBox(i18n(
"Indentation with Spaces"),
this);
167 TQVBox *spaceLayout =
new TQVBox(gbSpaces);
168 opt[0] =
new TQCheckBox(i18n(
"Use &spaces instead of tabs to indent"), spaceLayout );
169 opt[6] =
new TQCheckBox(i18n(
"Emacs style mixed mode"), spaceLayout);
171 indentationWidth =
new KIntNumInput(KateDocumentConfig::global()->indentationWidth(), spaceLayout);
172 indentationWidth->setRange(1, 16, 1,
false);
173 indentationWidth->setLabel(i18n(
"Number of spaces:"), AlignVCenter);
175 opt[1] =
new TQCheckBox(i18n(
"Keep indent &profile"),
this);
176 opt[2] =
new TQCheckBox(i18n(
"&Keep extra spaces"),
this);
178 TQVGroupBox *keys =
new TQVGroupBox(i18n(
"Keys to Use"),
this);
179 opt[3] =
new TQCheckBox(i18n(
"&Tab key indents"), keys);
180 opt[4] =
new TQCheckBox(i18n(
"&Backspace key indents"), keys);
182 TQRadioButton *rb1, *rb2, *rb3;
183 m_tabs =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Tab Key Mode if Nothing Selected"),
this );
184 m_tabs->setRadioButtonExclusive(
true );
185 m_tabs->insert( rb1=
new TQRadioButton( i18n(
"Insert indent &characters"), m_tabs ), 0 );
186 m_tabs->insert( rb2=
new TQRadioButton( i18n(
"I&nsert tab character"), m_tabs ), 1 );
187 m_tabs->insert( rb3=
new TQRadioButton( i18n(
"Indent current &line"), m_tabs ), 2 );
189 opt[0]->setChecked(configFlags & flags[0]);
190 opt[1]->setChecked(configFlags & flags[1]);
191 opt[2]->setChecked(configFlags & flags[2]);
192 opt[3]->setChecked(configFlags & flags[3]);
193 opt[4]->setChecked(configFlags & flags[4]);
194 opt[5]->setChecked(configFlags & flags[5]);
195 opt[6]->setChecked(configFlags & flags[6]);
196 opt[7]->setChecked(configFlags & flags[7]);
198 layout->addWidget(gbAuto);
199 layout->addWidget(gbSpaces);
200 layout->addWidget(opt[1]);
201 layout->addWidget(opt[2]);
202 layout->addWidget(keys);
203 layout->addWidget(m_tabs, 0);
205 layout->addStretch();
208 TQWhatsThis::add(opt[0], i18n(
209 "Check this if you want to indent with spaces rather than tabs."));
210 TQWhatsThis::add(opt[2], i18n(
211 "Indentations of more than the selected number of spaces will not be "
213 TQWhatsThis::add(opt[3], i18n(
214 "This allows the <b>Tab</b> key to be used to increase the indentation "
216 TQWhatsThis::add(opt[4], i18n(
217 "This allows the <b>Backspace</b> key to be used to decrease the "
218 "indentation level."));
219 TQWhatsThis::add(opt[5], i18n(
220 "Automatically inserts a leading \"*\" while typing within a Doxygen "
222 TQWhatsThis::add( opt[6], i18n(
223 "Use a mix of tab and space characters for indentation.") );
224 TQWhatsThis::add( opt[7], i18n(
225 "If this option is selected, pasted code from the clipboard is indented. "
226 "Triggering the <b>undo</b>-action removes the indentation.") );
227 TQWhatsThis::add(indentationWidth, i18n(
"The number of spaces to indent with."));
229 TQWhatsThis::add(m_configPage, i18n(
230 "If this button is enabled, additional indenter specific options are "
231 "available and can be configured in an extra dialog.") );
239 connect(m_indentMode, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChanged()));
240 connect(m_indentMode, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(indenterSelected(
int)));
242 connect( opt[0], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(somethingToggled()));
244 connect( opt[0], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
245 connect( opt[1], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
246 connect( opt[2], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
247 connect( opt[3], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
248 connect( opt[4], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
249 connect( opt[5], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
250 connect( opt[6], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
251 connect( opt[7], TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
253 connect(indentationWidth, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
255 connect(rb1, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
256 connect(rb2, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
257 connect(rb3, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
259 connect(m_configPage, TQT_SIGNAL(clicked()),
this, TQT_SLOT(configPage()));
262 void KateIndentConfigTab::somethingToggled() {
263 indentationWidth->setEnabled(opt[0]->isChecked());
264 opt[6]->setEnabled(opt[0]->isChecked());
267 void KateIndentConfigTab::indenterSelected (
int index)
269 if (index == KateDocumentConfig::imCStyle || index == KateDocumentConfig::imCSAndS)
270 opt[5]->setEnabled(
true);
272 opt[5]->setEnabled(
false);
277 void KateIndentConfigTab::configPage()
279 uint index = m_indentMode->currentItem();
282 KDialogBase dlg(
this,
"indenter_config_dialog",
true, i18n(
"Configure Indenter"),
283 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Cancel,
true);
285 TQVBox *box =
new TQVBox(&dlg);
286 box->setSpacing( KDialog::spacingHint() );
287 dlg.setMainWidget(box);
294 box->setStretchFactor(page, 1);
296 connect( &dlg, TQT_SIGNAL(okClicked()), page, TQT_SLOT(apply()) );
298 dlg.resize(400, 300);
303 void KateIndentConfigTab::apply ()
310 KateDocumentConfig::global()->configStart ();
314 configFlags = KateDocumentConfig::global()->configFlags();
315 for (z = 0; z < numFlags; z++) {
316 configFlags &= ~flags[z];
317 if (opt[z]->isChecked()) configFlags |= flags[z];
320 KateDocumentConfig::global()->setConfigFlags(configFlags);
321 KateDocumentConfig::global()->setIndentationWidth(indentationWidth->value());
323 KateDocumentConfig::global()->setIndentationMode(m_indentMode->currentItem());
325 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabIndentsMode, 2 == m_tabs->id (m_tabs->selected()));
326 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabInsertsTab, 1 == m_tabs->id (m_tabs->selected()));
328 KateDocumentConfig::global()->configEnd ();
331 void KateIndentConfigTab::reload ()
333 if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabIndentsMode)
334 m_tabs->setButton (2);
335 else if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabInsertsTab)
336 m_tabs->setButton (1);
338 m_tabs->setButton (0);
340 m_indentMode->setCurrentItem (KateDocumentConfig::global()->indentationMode());
343 indenterSelected (m_indentMode->currentItem());
348 const int KateSelectConfigTab::flags[] = {};
350 KateSelectConfigTab::KateSelectConfigTab(TQWidget *parent)
351 : KateConfigPage(parent)
353 int configFlags = KateDocumentConfig::global()->configFlags();
355 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
357 TQVGroupBox *gbCursor =
new TQVGroupBox(i18n(
"Text Cursor Movement"),
this);
359 opt[0] =
new TQCheckBox(i18n(
"Smart ho&me and smart end"), gbCursor);
360 opt[0]->setChecked(configFlags & KateDocumentConfig::cfSmartHome);
361 connect(opt[0], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
363 opt[1] =
new TQCheckBox(i18n(
"Wrap c&ursor"), gbCursor);
364 opt[1]->setChecked(configFlags & KateDocumentConfig::cfWrapCursor);
365 connect(opt[1], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
367 e6 =
new TQCheckBox(i18n(
"&PageUp/PageDown moves cursor"), gbCursor);
368 e6->setChecked(KateDocumentConfig::global()->pageUpDownMovesCursor());
369 connect(e6, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
371 e4 =
new KIntNumInput(KateViewConfig::global()->autoCenterLines(), gbCursor);
372 e4->setRange(0, 1000000, 1,
false);
373 e4->setLabel(i18n(
"Autocenter cursor (lines):"), AlignVCenter);
374 connect(e4, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
376 layout->addWidget(gbCursor);
378 TQRadioButton *rb1, *rb2;
380 m_tabs =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Selection Mode"),
this );
381 layout->add (m_tabs);
383 m_tabs->setRadioButtonExclusive(
true );
384 m_tabs->insert( rb1=
new TQRadioButton( i18n(
"&Normal"), m_tabs ), 0 );
385 m_tabs->insert( rb2=
new TQRadioButton( i18n(
"&Persistent"), m_tabs ), 1 );
387 layout->addStretch();
389 TQWhatsThis::add(rb1, i18n(
390 "Selections will be overwritten by typed text and will be lost on "
391 "cursor movement."));
392 TQWhatsThis::add(rb2, i18n(
393 "Selections will stay even after cursor movement and typing."));
395 TQWhatsThis::add(e4, i18n(
396 "Sets the number of lines to maintain visible above and below the "
397 "cursor when possible."));
399 TQWhatsThis::add(opt[0], i18n(
400 "When selected, pressing the home key will cause the cursor to skip "
401 "whitespace and go to the start of a line's text. "
402 "The same applies for the end key."));
404 TQWhatsThis::add(opt[1], i18n(
405 "When on, moving the insertion cursor using the <b>Left</b> and "
406 "<b>Right</b> keys will go on to previous/next line at beginning/end of "
407 "the line, similar to most editors.<p>When off, the insertion cursor "
408 "cannot be moved left of the line start, but it can be moved off the "
409 "line end, which can be very handy for programmers."));
411 TQWhatsThis::add(e6, i18n(
"Selects whether the PageUp and PageDown keys should alter the vertical position of the cursor relative to the top of the view."));
420 connect(rb1, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
421 connect(rb2, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
424 void KateSelectConfigTab::apply ()
431 KateViewConfig::global()->configStart ();
432 KateDocumentConfig::global()->configStart ();
434 int configFlags = KateDocumentConfig::global()->configFlags();
436 configFlags &= ~KateDocumentConfig::cfSmartHome;
437 configFlags &= ~KateDocumentConfig::cfWrapCursor;
439 if (opt[0]->isChecked()) configFlags |= KateDocumentConfig::cfSmartHome;
440 if (opt[1]->isChecked()) configFlags |= KateDocumentConfig::cfWrapCursor;
442 KateDocumentConfig::global()->setConfigFlags(configFlags);
444 KateViewConfig::global()->setAutoCenterLines(kMax(0, e4->value()));
445 KateDocumentConfig::global()->setPageUpDownMovesCursor(e6->isChecked());
447 KateViewConfig::global()->setPersistentSelection (m_tabs->id (m_tabs->selected()) == 1);
449 KateDocumentConfig::global()->configEnd ();
450 KateViewConfig::global()->configEnd ();
453 void KateSelectConfigTab::reload ()
455 if (KateViewConfig::global()->persistentSelection())
456 m_tabs->setButton (1);
458 m_tabs->setButton (0);
463 const int KateEditConfigTab::flags[] = {KateDocument::cfWordWrap,
464 KateDocument::cfAutoBrackets, KateDocument::cfShowTabs,
465 KateDocumentConfig::cfReplaceTabsDyn, KateDocumentConfig::cfRemoveTrailingDyn};
467 KateEditConfigTab::KateEditConfigTab(TQWidget *parent)
468 : KateConfigPage(parent)
470 TQVBoxLayout *mainLayout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
471 int configFlags = KateDocumentConfig::global()->configFlags();
473 TQVGroupBox *gbWhiteSpace =
new TQVGroupBox(i18n(
"Tabulators"),
this);
475 opt[3] =
new TQCheckBox( i18n(
"&Insert spaces instead of tabulators"), gbWhiteSpace );
476 opt[3]->setChecked( configFlags & KateDocumentConfig::cfReplaceTabsDyn );
477 connect( opt[3], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()) );
479 opt[2] =
new TQCheckBox(i18n(
"&Show tabulators"), gbWhiteSpace);
480 opt[2]->setChecked(configFlags & flags[2]);
481 connect(opt[2], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
483 e2 =
new KIntNumInput(KateDocumentConfig::global()->tabWidth(), gbWhiteSpace);
484 e2->setRange(1, 16, 1,
false);
485 e2->setLabel(i18n(
"Tab width:"), AlignVCenter);
486 connect(e2, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
488 mainLayout->addWidget(gbWhiteSpace);
490 TQVGroupBox *gbWordWrap =
new TQVGroupBox(i18n(
"Static Word Wrap"),
this);
492 opt[0] =
new TQCheckBox(i18n(
"Enable static &word wrap"), gbWordWrap);
493 opt[0]->setChecked(KateDocumentConfig::global()->wordWrap());
494 connect(opt[0], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
496 m_wwmarker =
new TQCheckBox( i18n(
"&Show static word wrap marker (if applicable)"), gbWordWrap );
497 m_wwmarker->setChecked( KateRendererConfig::global()->wordWrapMarker() );
498 connect(m_wwmarker, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
500 e1 =
new KIntNumInput(KateDocumentConfig::global()->wordWrapAt(), gbWordWrap);
501 e1->setRange(20, 200, 1,
false);
502 e1->setLabel(i18n(
"Wrap words at:"), AlignVCenter);
503 connect(e1, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
505 mainLayout->addWidget(gbWordWrap);
507 opt[4] =
new TQCheckBox( i18n(
"Remove &trailing spaces"),
this );
508 mainLayout->addWidget( opt[4] );
509 opt[4]->setChecked( configFlags & KateDocumentConfig::cfRemoveTrailingDyn );
510 connect( opt[4], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()) );
512 opt[1] =
new TQCheckBox(i18n(
"Auto &brackets"),
this);
513 mainLayout->addWidget(opt[1]);
514 opt[1]->setChecked(configFlags & flags[1]);
515 connect(opt[1], TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
517 e3 =
new KIntNumInput(e2, KateDocumentConfig::global()->undoSteps(),
this);
518 e3->setRange(0, 1000000, 1,
false);
519 e3->setSpecialValueText( i18n(
"Unlimited") );
520 e3->setLabel(i18n(
"Maximum undo steps:"), AlignVCenter);
521 mainLayout->addWidget(e3);
522 connect(e3, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
524 TQHBoxLayout *e5Layout =
new TQHBoxLayout(mainLayout);
525 TQLabel *e5Label =
new TQLabel(i18n(
"Smart search t&ext from:"),
this);
526 e5Layout->addWidget(e5Label);
528 e5->insertItem( i18n(
"Nowhere") );
529 e5->insertItem( i18n(
"Selection Only") );
530 e5->insertItem( i18n(
"Selection, then Current Word") );
531 e5->insertItem( i18n(
"Current Word Only") );
532 e5->insertItem( i18n(
"Current Word, then Selection") );
533 e5->setCurrentItem(KateViewConfig::global()->textToSearchMode());
534 e5Layout->addWidget(e5);
535 e5Label->setBuddy(e5);
536 connect(e5, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChanged()));
538 mainLayout->addStretch();
541 TQWhatsThis::add(opt[0], i18n(
542 "Automatically start a new line of text when the current line exceeds "
543 "the length specified by the <b>Wrap words at:</b> option."
544 "<p>This option does not wrap existing lines of text - use the <b>Apply "
545 "Static Word Wrap</b> option in the <b>Tools</b> menu for that purpose."
546 "<p>If you want lines to be <i>visually wrapped</i> instead, according "
547 "to the width of the view, enable <b>Dynamic Word Wrap</b> in the "
548 "<b>View Defaults</b> config page."));
549 TQWhatsThis::add(e1, i18n(
550 "If the Word Wrap option is selected this entry determines the length "
551 "(in characters) at which the editor will automatically start a new line."));
552 TQWhatsThis::add(opt[1], i18n(
553 "When the user types a left bracket ([,(, or {) KateView automatically "
554 "enters the right bracket (}, ), or ]) to the right of the cursor."));
555 TQWhatsThis::add(opt[2], i18n(
556 "The editor will display a symbol to indicate the presence of a tab in "
559 TQWhatsThis::add(e3, i18n(
560 "Sets the number of undo/redo steps to record. More steps uses more memory."));
562 TQString gstfwt = i18n(
563 "This determines where KateView will get the search text from "
564 "(this will be automatically entered into the Find Text dialog): "
567 "<li><b>Nowhere:</b> Don't guess the search text."
569 "<li><b>Selection Only:</b> Use the current text selection, "
572 "<li><b>Selection, then Current Word:</b> Use the current "
573 "selection if available, otherwise use the current word."
575 "<li><b>Current Word Only:</b> Use the word that the cursor "
576 "is currently resting on, if available."
578 "<li><b>Current Word, then Selection:</b> Use the current "
579 "word if available, otherwise use the current selection."
582 "Note that, in all the above modes, if a search string has "
583 "not been or cannot be determined, then the Find Text Dialog "
584 "will fall back to the last search text.");
585 TQWhatsThis::add(e5Label, gstfwt);
586 TQWhatsThis::add(e5, gstfwt);
587 TQWhatsThis::add( opt[3], i18n(
588 "If this is enabled, the editor will calculate the number of spaces up to "
589 "the next tab position as defined by the tab width, and insert that number "
590 "of spaces instead of a TAB character." ) );
591 TQWhatsThis::add( opt[4], i18n(
592 "If this is enabled, the editor will remove any trailing whitespace on "
593 "lines when they are left by the insertion cursor.") );
594 TQWhatsThis::add( m_wwmarker, i18n(
595 "<p>If this option is checked, a vertical line will be drawn at the word "
596 "wrap column as defined in the <strong>Editing</strong> properties."
597 "<p>Note that the word wrap marker is only drawn if you use a fixed "
601 void KateEditConfigTab::apply ()
608 KateViewConfig::global()->configStart ();
609 KateDocumentConfig::global()->configStart ();
613 configFlags = KateDocumentConfig::global()->configFlags();
614 for (z = 1; z < numFlags; z++) {
615 configFlags &= ~flags[z];
616 if (opt[z]->isChecked()) configFlags |= flags[z];
618 KateDocumentConfig::global()->setConfigFlags(configFlags);
620 KateDocumentConfig::global()->setWordWrapAt(e1->value());
621 KateDocumentConfig::global()->setWordWrap (opt[0]->isChecked());
622 KateDocumentConfig::global()->setTabWidth(e2->value());
624 if (e3->value() <= 0)
625 KateDocumentConfig::global()->setUndoSteps(0);
627 KateDocumentConfig::global()->setUndoSteps(e3->value());
629 KateViewConfig::global()->setTextToSearchMode(e5->currentItem());
631 KateRendererConfig::global()->setWordWrapMarker (m_wwmarker->isChecked());
633 KateDocumentConfig::global()->configEnd ();
634 KateViewConfig::global()->configEnd ();
637 void KateEditConfigTab::reload ()
643 KateViewDefaultsConfig::KateViewDefaultsConfig(TQWidget *parent)
644 :KateConfigPage(parent)
649 TQVBoxLayout *blay=
new TQVBoxLayout(
this,0,KDialog::spacingHint());
651 TQVGroupBox *gbWordWrap =
new TQVGroupBox(i18n(
"Word Wrap"),
this);
653 m_dynwrap=
new TQCheckBox(i18n(
"&Dynamic word wrap"),gbWordWrap);
655 TQHBox *m_dynwrapIndicatorsLay =
new TQHBox (gbWordWrap);
656 m_dynwrapIndicatorsLabel =
new TQLabel( i18n(
"Dynamic word wrap indicators (if applicable):"), m_dynwrapIndicatorsLay );
657 m_dynwrapIndicatorsCombo =
new KComboBox( m_dynwrapIndicatorsLay );
658 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Off") );
659 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Follow Line Numbers") );
660 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Always On") );
661 m_dynwrapIndicatorsLabel->setBuddy(m_dynwrapIndicatorsCombo);
664 m_dynwrapAlignLevel->setLabel(i18n(
"Vertically align dynamically wrapped lines to indentation depth:"));
665 m_dynwrapAlignLevel->setRange(0, 80, 10);
667 m_dynwrapAlignLevel->setSuffix(i18n(
"% of View Width"));
668 m_dynwrapAlignLevel->setSpecialValueText(i18n(
"Disabled"));
670 blay->addWidget(gbWordWrap);
672 TQVGroupBox *gbFold =
new TQVGroupBox(i18n(
"Code Folding"),
this);
674 m_folding=
new TQCheckBox(i18n(
"Show &folding markers (if available)"), gbFold );
675 m_collapseTopLevel =
new TQCheckBox( i18n(
"Collapse toplevel folding nodes"), gbFold );
676 m_collapseTopLevel->hide ();
678 blay->addWidget(gbFold);
680 TQVGroupBox *gbBar =
new TQVGroupBox(i18n(
"Borders"),
this);
682 m_icons=
new TQCheckBox(i18n(
"Show &icon border"),gbBar);
683 m_line=
new TQCheckBox(i18n(
"Show &line numbers"),gbBar);
684 m_scrollBarMarks=
new TQCheckBox(i18n(
"Show &scrollbar marks"),gbBar);
686 blay->addWidget(gbBar);
688 m_bmSort =
new TQButtonGroup( 1, Qt::Horizontal, i18n(
"Sort Bookmarks Menu"),
this );
689 m_bmSort->setRadioButtonExclusive(
true );
690 m_bmSort->insert( rb1=
new TQRadioButton( i18n(
"By &position"), m_bmSort ), 0 );
691 m_bmSort->insert( rb2=
new TQRadioButton( i18n(
"By c&reation"), m_bmSort ), 1 );
693 blay->addWidget(m_bmSort, 0 );
695 m_showIndentLines =
new TQCheckBox(i18n(
"Show indentation lines"),
this);
696 m_showIndentLines->setChecked(KateRendererConfig::global()->showIndentationLines());
697 blay->addWidget(m_showIndentLines);
699 blay->addStretch(1000);
701 TQWhatsThis::add(m_dynwrap,i18n(
702 "If this option is checked, the text lines will be wrapped at the view "
703 "border on the screen."));
704 TQString wtstr = i18n(
"Choose when the Dynamic Word Wrap Indicators should be displayed");
705 TQWhatsThis::add(m_dynwrapIndicatorsLabel, wtstr);
706 TQWhatsThis::add(m_dynwrapIndicatorsCombo, wtstr);
708 TQWhatsThis::add(m_dynwrapAlignLevel, i18n(
709 "<p>Enables the start of dynamically wrapped lines to be aligned "
710 "vertically to the indentation level of the first line. This can help "
711 "to make code and markup more readable.</p><p>Additionally, this allows "
712 "you to set a maximum width of the screen, as a percentage, after which "
713 "dynamically wrapped lines will no longer be vertically aligned. For "
714 "example, at 50%, lines whose indentation levels are deeper than 50% of "
715 "the width of the screen will not have vertical alignment applied to "
716 "subsequent wrapped lines.</p>"));
717 TQWhatsThis::add(m_line,i18n(
718 "If this option is checked, every new view will display line numbers "
719 "on the left hand side."));
720 TQWhatsThis::add(m_icons,i18n(
721 "If this option is checked, every new view will display an icon border "
722 "on the left hand side.<br><br>The icon border shows bookmark signs, "
724 TQWhatsThis::add(m_scrollBarMarks,i18n(
725 "If this option is checked, every new view will show marks on the "
726 "vertical scrollbar.<br><br>These marks will, for instance, show "
728 TQWhatsThis::add(m_folding,i18n(
729 "If this option is checked, every new view will display marks for code "
730 "folding, if code folding is available."));
731 TQWhatsThis::add(m_bmSort,i18n(
732 "Choose how the bookmarks should be ordered in the <b>Bookmarks</b> menu."));
733 TQWhatsThis::add(rb1,i18n(
734 "The bookmarks will be ordered by the line numbers they are placed at."));
735 TQWhatsThis::add(rb2,i18n(
736 "Each new bookmark will be added to the bottom, independently from "
737 "where it is placed in the document."));
738 TQWhatsThis::add(m_showIndentLines, i18n(
739 "If this is enabled, the editor will display vertical lines to help "
740 "identify indent lines.") );
748 connect(m_dynwrap, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
749 connect(m_dynwrapIndicatorsCombo, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChanged()));
750 connect(m_dynwrapAlignLevel, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
751 connect(m_icons, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
752 connect(m_scrollBarMarks, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
753 connect(m_line, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
754 connect(m_folding, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
755 connect(m_collapseTopLevel, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()) );
756 connect(rb1, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
757 connect(rb2, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
758 connect(m_showIndentLines, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
761 KateViewDefaultsConfig::~KateViewDefaultsConfig()
765 void KateViewDefaultsConfig::apply ()
772 KateViewConfig::global()->configStart ();
773 KateRendererConfig::global()->configStart ();
775 KateViewConfig::global()->setDynWordWrap (m_dynwrap->isChecked());
776 KateViewConfig::global()->setDynWordWrapIndicators (m_dynwrapIndicatorsCombo->currentItem ());
777 KateViewConfig::global()->setDynWordWrapAlignIndent(m_dynwrapAlignLevel->value());
778 KateViewConfig::global()->setLineNumbers (m_line->isChecked());
779 KateViewConfig::global()->setIconBar (m_icons->isChecked());
780 KateViewConfig::global()->setScrollBarMarks (m_scrollBarMarks->isChecked());
781 KateViewConfig::global()->setFoldingBar (m_folding->isChecked());
782 KateViewConfig::global()->setBookmarkSort (m_bmSort->id (m_bmSort->selected()));
784 KateRendererConfig::global()->setShowIndentationLines(m_showIndentLines->isChecked());
786 KateRendererConfig::global()->configEnd ();
787 KateViewConfig::global()->configEnd ();
790 void KateViewDefaultsConfig::reload ()
792 m_dynwrap->setChecked(KateViewConfig::global()->dynWordWrap());
793 m_dynwrapIndicatorsCombo->setCurrentItem( KateViewConfig::global()->dynWordWrapIndicators() );
794 m_dynwrapAlignLevel->setValue(KateViewConfig::global()->dynWordWrapAlignIndent());
795 m_line->setChecked(KateViewConfig::global()->lineNumbers());
796 m_icons->setChecked(KateViewConfig::global()->iconBar());
797 m_scrollBarMarks->setChecked(KateViewConfig::global()->scrollBarMarks());
798 m_folding->setChecked(KateViewConfig::global()->foldingBar());
799 m_bmSort->setButton( KateViewConfig::global()->bookmarkSort() );
800 m_showIndentLines->setChecked(KateRendererConfig::global()->showIndentationLines());
803 void KateViewDefaultsConfig::reset () {;}
805 void KateViewDefaultsConfig::defaults (){;}
810 KateEditKeyConfiguration::KateEditKeyConfiguration( TQWidget* parent, KateDocument* doc )
811 : KateConfigPage( parent )
817 void KateEditKeyConfiguration::showEvent ( TQShowEvent * )
821 (
new TQVBoxLayout(
this))->setAutoAdd(
true);
822 KateView* view = (KateView*)m_doc->views().at(0);
823 m_ac = view->editActionCollection();
824 m_keyChooser =
new KKeyChooser( m_ac,
this,
false );
825 connect( m_keyChooser, TQT_SIGNAL( keyChange() ),
this, TQT_SLOT( slotChanged() ) );
826 m_keyChooser->show ();
834 void KateEditKeyConfiguration::apply()
842 m_keyChooser->commitChanges();
843 m_ac->writeShortcutSettings(
"Katepart Shortcuts" );
849 KateSaveConfigTab::KateSaveConfigTab( TQWidget *parent )
850 : KateConfigPage( parent )
852 int configFlags = KateDocumentConfig::global()->configFlags();
853 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
855 TQVGroupBox *gbEnc =
new TQVGroupBox(i18n(
"File Format"),
this);
856 layout->addWidget( gbEnc );
858 TQHBox *e5Layout =
new TQHBox(gbEnc);
859 TQLabel *e5Label =
new TQLabel(i18n(
"&Encoding:"), e5Layout);
861 e5Label->setBuddy(m_encoding);
863 e5Layout =
new TQHBox(gbEnc);
864 e5Label =
new TQLabel(i18n(
"End &of line:"), e5Layout);
866 e5Label->setBuddy(m_eol);
868 allowEolDetection =
new TQCheckBox(i18n(
"&Automatic end of line detection"), gbEnc);
870 m_eol->insertItem (i18n(
"UNIX"));
871 m_eol->insertItem (i18n(
"DOS/Windows"));
872 m_eol->insertItem (i18n(
"Macintosh"));
874 TQVGroupBox *gbMem =
new TQVGroupBox(i18n(
"Memory Usage"),
this);
875 layout->addWidget( gbMem );
877 e5Layout =
new TQHBox(gbMem);
878 e5Layout->setSpacing (32);
879 blockCountLabel =
new TQLabel(i18n(
"Maximum loaded &blocks per file:"), e5Layout);
880 blockCount =
new TQSpinBox (4, 512, 4, e5Layout);
883 blockCountLabel->setBuddy(blockCount);
885 TQVGroupBox *gbWhiteSpace =
new TQVGroupBox(i18n(
"Automatic Cleanups on Load/Save"),
this);
886 layout->addWidget( gbWhiteSpace );
888 removeSpaces =
new TQCheckBox(i18n(
"Re&move trailing spaces"), gbWhiteSpace);
889 removeSpaces->setChecked(configFlags & KateDocument::cfRemoveSpaces);
891 TQVGroupBox *dirConfigBox =
new TQVGroupBox(i18n(
"Folder Config File"),
this);
892 layout->addWidget( dirConfigBox );
894 dirSearchDepth =
new KIntNumInput(KateDocumentConfig::global()->searchDirConfigDepth(), dirConfigBox);
895 dirSearchDepth->setRange(-1, 64, 1,
false);
896 dirSearchDepth->setSpecialValueText( i18n(
"Do not use config file") );
897 dirSearchDepth->setLabel(i18n(
"Se&arch depth for config file:"), AlignVCenter);
899 TQGroupBox *gb =
new TQGroupBox( 1, Qt::Horizontal, i18n(
"Backup on Save"),
this );
900 layout->addWidget( gb );
901 cbLocalFiles =
new TQCheckBox( i18n(
"&Local files"), gb );
902 cbRemoteFiles =
new TQCheckBox( i18n(
"&Remote files"), gb );
904 TQHBox *hbBuPrefix =
new TQHBox( gb );
905 TQLabel *lBuPrefix =
new TQLabel( i18n(
"&Prefix:"), hbBuPrefix );
906 leBuPrefix =
new TQLineEdit( hbBuPrefix );
907 lBuPrefix->setBuddy( leBuPrefix );
909 TQHBox *hbBuSuffix =
new TQHBox( gb );
910 TQLabel *lBuSuffix =
new TQLabel( i18n(
"&Suffix:"), hbBuSuffix );
911 leBuSuffix =
new TQLineEdit( hbBuSuffix );
912 lBuSuffix->setBuddy( leBuSuffix );
914 layout->addStretch();
916 TQWhatsThis::add(removeSpaces, i18n(
917 "The editor will automatically eliminate extra spaces at the ends of "
918 "lines of text while loading/saving the file."));
919 TQWhatsThis::add( gb, i18n(
920 "<p>Backing up on save will cause Kate to copy the disk file to "
921 "'<prefix><filename><suffix>' before saving changes."
922 "<p>The suffix defaults to <strong>~</strong> and prefix is empty by default" ) );
923 TQWhatsThis::add( allowEolDetection, i18n(
924 "Check this if you want the editor to autodetect the end of line type."
925 "The first found end of line type will be used for the whole file.") );
926 TQWhatsThis::add( cbLocalFiles, i18n(
927 "Check this if you want backups of local files when saving") );
928 TQWhatsThis::add( cbRemoteFiles, i18n(
929 "Check this if you want backups of remote files when saving") );
930 TQWhatsThis::add( leBuPrefix, i18n(
931 "Enter the prefix to prepend to the backup file names" ) );
932 TQWhatsThis::add( leBuSuffix, i18n(
933 "Enter the suffix to add to the backup file names" ) );
934 TQWhatsThis::add(dirSearchDepth, i18n(
935 "The editor will search the given number of folder levels upwards for .kateconfig file"
936 " and load the settings line from it." ));
937 TQWhatsThis::add(blockCount, i18n(
938 "The editor will load given number of blocks (of around 2048 lines) of text into memory;"
939 " if the filesize is bigger than this the other blocks are swapped "
940 " to disk and loaded transparently as-needed.<br>"
941 " This can cause little delays while navigating in the document; a larger block count"
942 " increases the editing speed at the cost of memory. <br>For normal usage, just choose the highest possible"
943 " block count: limit it only if you have problems with the memory usage."));
951 connect(m_encoding, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChanged()));
952 connect(m_eol, TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotChanged()));
953 connect( allowEolDetection, TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
954 connect(blockCount, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
955 connect(removeSpaces, TQT_SIGNAL(toggled(
bool)),
this, TQT_SLOT(slotChanged()));
956 connect( cbLocalFiles, TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
957 connect( cbRemoteFiles, TQT_SIGNAL( toggled(
bool) ),
this, TQT_SLOT( slotChanged() ) );
958 connect(dirSearchDepth, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(slotChanged()));
959 connect( leBuPrefix, TQT_SIGNAL( textChanged (
const TQString & ) ),
this, TQT_SLOT( slotChanged() ) );
960 connect( leBuSuffix, TQT_SIGNAL( textChanged (
const TQString & ) ),
this, TQT_SLOT( slotChanged() ) );
963 void KateSaveConfigTab::apply()
972 KateDocumentConfig::global()->configStart ();
974 if ( leBuSuffix->text().isEmpty() && leBuPrefix->text().isEmpty() ) {
977 i18n(
"You did not provide a backup suffix or prefix. Using default suffix: '~'"),
978 i18n(
"No Backup Suffix or Prefix")
980 leBuSuffix->setText(
"~" );
984 if ( cbLocalFiles->isChecked() )
985 f |= KateDocumentConfig::LocalFiles;
986 if ( cbRemoteFiles->isChecked() )
987 f |= KateDocumentConfig::RemoteFiles;
989 KateDocumentConfig::global()->setBackupFlags(f);
990 KateDocumentConfig::global()->setBackupPrefix(leBuPrefix->text());
991 KateDocumentConfig::global()->setBackupSuffix(leBuSuffix->text());
993 KateDocumentConfig::global()->setSearchDirConfigDepth(dirSearchDepth->value());
995 int configFlags = KateDocumentConfig::global()->configFlags();
997 configFlags &= ~KateDocument::cfRemoveSpaces;
998 if (removeSpaces->isChecked()) configFlags |= KateDocument::cfRemoveSpaces;
1000 KateDocumentConfig::global()->setConfigFlags(configFlags);
1004 KateDocumentConfig::global()->setEol(m_eol->currentItem());
1005 KateDocumentConfig::global()->setAllowEolDetection(allowEolDetection->isChecked());
1007 KateDocumentConfig::global()->configEnd ();
1010 void KateSaveConfigTab::reload()
1013 m_encoding->clear ();
1014 m_encoding->insertItem (i18n(
"KDE Default"));
1015 m_encoding->setCurrentItem(0);
1018 for (uint i=0; i < encodings.count(); i++)
1025 m_encoding->insertItem (encodings[i]);
1027 if ( codecForEnc->name() == KateDocumentConfig::global()->encoding() )
1029 m_encoding->setCurrentItem(insert);
1037 m_eol->setCurrentItem(KateDocumentConfig::global()->eol());
1038 allowEolDetection->setChecked(KateDocumentConfig::global()->allowEolDetection());
1040 dirSearchDepth->setValue(KateDocumentConfig::global()->searchDirConfigDepth());
1043 uint f ( KateDocumentConfig::global()->backupFlags() );
1044 cbLocalFiles->setChecked( f & KateDocumentConfig::LocalFiles );
1045 cbRemoteFiles->setChecked( f & KateDocumentConfig::RemoteFiles );
1046 leBuPrefix->setText( KateDocumentConfig::global()->backupPrefix() );
1047 leBuSuffix->setText( KateDocumentConfig::global()->backupSuffix() );
1050 void KateSaveConfigTab::reset()
1054 void KateSaveConfigTab::defaults()
1056 cbLocalFiles->setChecked(
true );
1057 cbRemoteFiles->setChecked(
false );
1058 leBuPrefix->setText(
"" );
1059 leBuSuffix->setText(
"~" );
1065 class KatePartPluginListItem :
public TQCheckListItem
1068 KatePartPluginListItem(
bool checked, uint i,
const TQString &name, TQListView *parent);
1069 uint pluginIndex ()
const {
return index; }
1072 void stateChange(
bool);
1076 bool silentStateChange;
1079 KatePartPluginListItem::KatePartPluginListItem(
bool checked, uint i,
const TQString &name, TQListView *parent)
1080 : TQCheckListItem(parent, name, CheckBox)
1082 , silentStateChange(false)
1084 silentStateChange =
true;
1086 silentStateChange =
false;
1089 void KatePartPluginListItem::stateChange(
bool b)
1091 if(!silentStateChange)
1092 static_cast<KatePartPluginListView *
>(listView())->stateChanged(
this, b);
1097 KatePartPluginListView::KatePartPluginListView(TQWidget *parent,
const char *name)
1102 void KatePartPluginListView::stateChanged(KatePartPluginListItem *item,
bool b)
1104 emit stateChange(item, b);
1109 KatePartPluginConfigPage::KatePartPluginConfigPage (TQWidget *parent) : KateConfigPage (parent,
"")
1112 TQGridLayout *grid =
new TQGridLayout(
this, 1, 1 );
1113 grid->setSpacing( KDialogBase::spacingHint() );
1115 listView =
new KatePartPluginListView(
this);
1116 listView->addColumn(i18n(
"Name"));
1117 listView->addColumn(i18n(
"Comment"));
1119 grid->addWidget( listView, 0, 0);
1121 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
1123 KatePartPluginListItem *item =
new KatePartPluginListItem(KateDocumentConfig::global()->plugin(i), i, (KateFactory::self()->plugins())[i]->name(), listView);
1124 item->setText(0, (KateFactory::self()->plugins())[i]->name());
1125 item->setText(1, (KateFactory::self()->plugins())[i]->comment());
1127 m_items.append (item);
1132 btnConfigure =
new TQPushButton( i18n(
"Configure..."),
this );
1133 btnConfigure->setEnabled(
false );
1134 grid->addWidget( btnConfigure, 1, 0, Qt::AlignRight );
1135 connect( btnConfigure, TQT_SIGNAL(clicked()),
this, TQT_SLOT(slotConfigure()) );
1137 connect( listView, TQT_SIGNAL(selectionChanged(TQListViewItem*)),
this, TQT_SLOT(slotCurrentChanged(TQListViewItem*)) );
1138 connect( listView, TQT_SIGNAL(stateChange(KatePartPluginListItem *,
bool)),
1139 this, TQT_SLOT(slotStateChanged(KatePartPluginListItem *,
bool)));
1140 connect(listView, TQT_SIGNAL(stateChange(KatePartPluginListItem *,
bool)),
this, TQT_SLOT(slotChanged()));
1143 KatePartPluginConfigPage::~KatePartPluginConfigPage ()
1147 void KatePartPluginConfigPage::apply ()
1154 KateDocumentConfig::global()->configStart ();
1156 for (uint i=0; i < m_items.count(); i++)
1157 KateDocumentConfig::global()->setPlugin (m_items.at(i)->pluginIndex(), m_items.at(i)->isOn());
1159 KateDocumentConfig::global()->configEnd ();
1162 void KatePartPluginConfigPage::slotStateChanged( KatePartPluginListItem *item,
bool b )
1165 slotCurrentChanged( (TQListViewItem*)item );
1168 void KatePartPluginConfigPage::slotCurrentChanged( TQListViewItem* i )
1170 KatePartPluginListItem *item =
static_cast<KatePartPluginListItem *
>(i);
1171 if ( ! item )
return;
1178 KTextEditor::Plugin *plugin = KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1180 KTextEditor::ConfigInterfaceExtension *cie = KTextEditor::configInterfaceExtension( plugin );
1181 b = ( cie && cie->configPages() );
1185 btnConfigure->setEnabled( b );
1188 void KatePartPluginConfigPage::slotConfigure()
1190 KatePartPluginListItem *item =
static_cast<KatePartPluginListItem*
>(listView->currentItem());
1191 KTextEditor::Plugin *plugin =
1192 KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1194 if ( ! plugin )
return;
1196 KTextEditor::ConfigInterfaceExtension *cife =
1197 KTextEditor::configInterfaceExtension( plugin );
1202 if ( ! cife->configPages() )
1206 KDialogBase::DialogType dt =
1207 cife->configPages() > 1 ?
1208 KDialogBase::IconList :
1211 TQString name = (KateFactory::self()->plugins())[item->pluginIndex()]->name();
1213 i18n(
"Configure %1").arg( name ),
1214 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help,
1218 TQPtrList<KTextEditor::ConfigPage> editorPages;
1220 for (uint i = 0; i < cife->configPages (); i++)
1223 if ( dt == KDialogBase::IconList )
1227 path << cife->configPageName( i );
1228 page = kd->addVBoxPage( path, cife->configPageFullName (i),
1233 page = kd->plainPage();
1234 TQVBoxLayout *_l =
new TQVBoxLayout( page );
1235 _l->setAutoAdd(
true );
1238 editorPages.append( cife->configPage( i, page ) );
1244 for( uint i=0; i<editorPages.count(); i++ )
1246 editorPages.at( i )->apply();
1255 KateHlConfigPage::KateHlConfigPage (TQWidget *parent, KateDocument *doc)
1256 : KateConfigPage (parent,
"")
1260 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
1263 TQHBox *hbHl =
new TQHBox(
this );
1266 hbHl->setSpacing( KDialog::spacingHint() );
1267 TQLabel *lHl =
new TQLabel( i18n(
"H&ighlight:"), hbHl );
1268 hlCombo =
new TQComboBox(
false, hbHl );
1269 lHl->setBuddy( hlCombo );
1270 connect( hlCombo, TQT_SIGNAL(activated(
int)),
1271 this, TQT_SLOT(hlChanged(
int)) );
1273 for(
int i = 0; i < KateHlManager::self()->highlights(); i++) {
1274 if (KateHlManager::self()->hlSection(i).length() > 0)
1275 hlCombo->insertItem(KateHlManager::self()->hlSection(i) + TQString (
"/") + KateHlManager::self()->hlNameTranslated(i));
1277 hlCombo->insertItem(KateHlManager::self()->hlNameTranslated(i));
1280 TQGroupBox *gbInfo =
new TQGroupBox( 1, Qt::Horizontal, i18n(
"Information"),
this );
1281 layout->add (gbInfo);
1284 TQHBox *hb1 =
new TQHBox( gbInfo);
1285 new TQLabel( i18n(
"Author:"), hb1 );
1286 author =
new TQLabel (hb1);
1287 author->setTextFormat (TQt::RichText);
1290 TQHBox *hb2 =
new TQHBox( gbInfo);
1291 new TQLabel( i18n(
"License:"), hb2 );
1292 license =
new TQLabel (hb2);
1294 TQGroupBox *gbProps =
new TQGroupBox( 1, Qt::Horizontal, i18n(
"Properties"),
this );
1295 layout->add (gbProps);
1298 TQHBox *hbFE =
new TQHBox( gbProps);
1299 TQLabel *lFileExts =
new TQLabel( i18n(
"File e&xtensions:"), hbFE );
1300 wildcards =
new TQLineEdit( hbFE );
1301 lFileExts->setBuddy( wildcards );
1303 TQHBox *hbMT =
new TQHBox( gbProps );
1304 TQLabel *lMimeTypes =
new TQLabel( i18n(
"MIME &types:"), hbMT);
1305 mimetypes =
new TQLineEdit( hbMT );
1306 lMimeTypes->setBuddy( mimetypes );
1308 TQHBox *hbMT2 =
new TQHBox( gbProps );
1309 TQLabel *lprio =
new TQLabel( i18n(
"Prio&rity:"), hbMT2);
1312 lprio->setBuddy( priority );
1314 TQToolButton *btnMTW =
new TQToolButton(hbMT);
1315 btnMTW->setIconSet(TQIconSet(SmallIcon(
"wizard")));
1316 connect(btnMTW, TQT_SIGNAL(clicked()),
this, TQT_SLOT(showMTDlg()));
1319 TQHBox *hbBtns =
new TQHBox(
this );
1320 layout->add (hbBtns);
1322 ((TQBoxLayout*)hbBtns->layout())->addStretch(1);
1323 hbBtns->setSpacing( KDialog::spacingHint() );
1324 TQPushButton *btnDl =
new TQPushButton(i18n(
"Do&wnload..."), hbBtns);
1325 connect( btnDl, TQT_SIGNAL(clicked()),
this, TQT_SLOT(hlDownload()) );
1327 int currentHl = m_doc ? m_doc->hlMode() : 0;
1328 hlCombo->setCurrentItem( currentHl );
1329 hlChanged( currentHl );
1331 TQWhatsThis::add( hlCombo, i18n(
1332 "Choose a <em>Syntax Highlight mode</em> from this list to view its "
1333 "properties below.") );
1334 TQWhatsThis::add( wildcards, i18n(
1335 "The list of file extensions used to determine which files to highlight "
1336 "using the current syntax highlight mode.") );
1337 TQWhatsThis::add( mimetypes, i18n(
1338 "The list of Mime Types used to determine which files to highlight "
1339 "using the current highlight mode.<p>Click the wizard button on the "
1340 "left of the entry field to display the MimeType selection dialog.") );
1341 TQWhatsThis::add( btnMTW, i18n(
1342 "Display a dialog with a list of all available mime types to choose from."
1343 "<p>The <strong>File Extensions</strong> entry will automatically be "
1344 "edited as well.") );
1345 TQWhatsThis::add( btnDl, i18n(
1346 "Click this button to download new or updated syntax highlight "
1347 "descriptions from the Kate website.") );
1349 layout->addStretch ();
1351 connect( wildcards, TQT_SIGNAL( textChanged (
const TQString & ) ),
this, TQT_SLOT( slotChanged() ) );
1352 connect( mimetypes, TQT_SIGNAL( textChanged (
const TQString & ) ),
this, TQT_SLOT( slotChanged() ) );
1353 connect( priority, TQT_SIGNAL( valueChanged (
int ) ),
this, TQT_SLOT( slotChanged() ) );
1356 KateHlConfigPage::~KateHlConfigPage ()
1360 void KateHlConfigPage::apply ()
1369 for ( TQIntDictIterator<KateHlData> it( hlDataDict ); it.current(); ++it )
1370 KateHlManager::self()->getHl( it.currentKey() )->setData( it.current() );
1372 KateHlManager::self()->getKConfig()->sync ();
1375 void KateHlConfigPage::reload ()
1379 void KateHlConfigPage::hlChanged(
int z)
1383 KateHighlighting *hl = KateHlManager::self()->getHl( z );
1391 if ( !hlDataDict.find( z ) )
1392 hlDataDict.insert( z, hl->getData() );
1394 hlData = hlDataDict.find( z );
1395 wildcards->setText(hlData->wildcards);
1396 mimetypes->setText(hlData->mimetypes);
1397 priority->setValue(hlData->priority);
1400 TQStringList l= TQStringList::split (TQRegExp(
"[,;]"), hl->author());
1401 author->setText (l.join (
"<br>"));
1403 license->setText (hl->license());
1406 void KateHlConfigPage::writeback()
1410 hlData->wildcards = wildcards->text();
1411 hlData->mimetypes = mimetypes->text();
1412 hlData->priority = priority->value();
1416 void KateHlConfigPage::hlDownload()
1418 KateHlDownloadDialog diag(
this,
"hlDownload",
true);
1422 void KateHlConfigPage::showMTDlg()
1424 TQString text = i18n(
"Select the MimeTypes you want highlighted using the '%1' syntax highlight rules.\nPlease note that this will automatically edit the associated file extensions as well.").arg( hlCombo->currentText() );
1425 TQStringList list = TQStringList::split( TQRegExp(
"\\s*;\\s*"), mimetypes->text() );
1426 KMimeTypeChooserDialog d( i18n(
"Select Mime Types"), text, list,
"text",
this );
1428 if ( d.exec() == KDialogBase::Accepted ) {
1431 wildcards->setText(d.chooser()->patterns().join(
";"));
1432 mimetypes->setText(d.chooser()->mimeTypes().join(
";"));
1438 KateHlDownloadDialog::KateHlDownloadDialog(TQWidget *parent,
const char *name,
bool modal)
1441 TQVBox* vbox =
new TQVBox(
this);
1442 setMainWidget(vbox);
1443 vbox->setSpacing(spacingHint());
1444 new TQLabel(i18n(
"Select the syntax highlighting files you want to update:"), vbox);
1445 list =
new TQListView(vbox);
1446 list->addColumn(
"");
1447 list->addColumn(i18n(
"Name"));
1448 list->addColumn(i18n(
"Installed"));
1449 list->addColumn(i18n(
"Latest"));
1450 list->setSelectionMode(TQListView::Multi);
1451 list->setAllColumnsShowFocus(
true);
1453 new TQLabel(i18n(
"<b>Note:</b> New versions are selected automatically."), vbox);
1454 actionButton (User1)->setIconSet(SmallIconSet(
"ok"));
1456 transferJob = KIO::get(
1457 KURL(TQString(HLDOWNLOADPATH)
1458 + TQString(
"update-")
1459 + TQString(KATEPART_VERSION)
1460 + TQString(
".xml")),
true,
true );
1461 connect(transferJob, TQT_SIGNAL(data(KIO::Job *,
const TQByteArray &)),
1462 this, TQT_SLOT(listDataReceived(KIO::Job *,
const TQByteArray &)));
1467 KateHlDownloadDialog::~KateHlDownloadDialog(){}
1469 void KateHlDownloadDialog::listDataReceived(KIO::Job *,
const TQByteArray &data)
1471 if (!transferJob || transferJob->isErrorPage())
1473 actionButton(User1)->setEnabled(
false);
1477 listData+=TQString(data);
1479 kdDebug(13000)<<TQString(TQString(
"Data length: %1").arg(data.size()))<<
endl;
1480 kdDebug(13000)<<TQString(TQString(
"listData length: %1").arg(listData.length()))<<
endl;
1483 if (listData.length()>0)
1485 TQString installedVersion;
1486 KateHlManager *hlm=KateHlManager::self();
1488 doc.setContent(listData);
1489 TQDomElement DocElem=doc.documentElement();
1490 TQDomNode n=DocElem.firstChild();
1491 KateHighlighting *hl = 0;
1493 if (n.isNull())
kdDebug(13000)<<
"There is no usable childnode"<<
endl;
1496 installedVersion=
" --";
1498 TQDomElement e=n.toElement();
1500 kdDebug(13000)<<TQString(
"NAME: ")<<e.tagName()<<TQString(
" - ")<<e.attribute(
"name")<<
endl;
1503 TQString Name=e.attribute(
"name");
1505 for (
int i=0;i<hlm->highlights();i++)
1508 if (hl && hl->name()==Name)
1510 installedVersion=
" "+hl->version();
1517 TQListViewItem* entry =
new TQListViewItem(
1518 list,
"", e.attribute(
"name"), installedVersion,
1519 e.attribute(
"version"),e.attribute(
"url"));
1520 if (!hl || hl->version() < e.attribute(
"version"))
1522 entry->setSelected(
true);
1523 entry->setPixmap(0, SmallIcon((
"knewstuff")));
1530 void KateHlDownloadDialog::slotUser1()
1533 for (TQListViewItem *it=list->firstChild();it;it=it->nextSibling())
1535 if (list->isSelected(it))
1537 KURL src(it->text(4));
1538 TQString filename=src.
fileName(
false);
1539 TQString dest = destdir+filename;
1541 KIO::NetAccess::download(src,dest,
this);
1551 KateGotoLineDialog::KateGotoLineDialog(TQWidget *parent,
int line,
int max)
1552 :
KDialogBase(parent, 0L, true, i18n(
"Go to Line"), Ok | Cancel, Ok) {
1554 TQWidget *page =
new TQWidget(
this);
1555 setMainWidget(page);
1557 TQVBoxLayout *topLayout =
new TQVBoxLayout( page, 0, spacingHint() );
1559 e1->setRange(1, max);
1560 e1->setEditFocus(
true);
1562 TQLabel *
label =
new TQLabel( e1,i18n(
"&Go to line:"), page );
1563 topLayout->addWidget(label);
1564 topLayout->addWidget(e1);
1565 topLayout->addSpacing(spacingHint());
1566 topLayout->addStretch(10);
1570 int KateGotoLineDialog::getLine() {
1576 KateModOnHdPrompt::KateModOnHdPrompt( KateDocument *doc,
1578 const TQString &reason,
1580 :
KDialogBase( parent,
"", true,
"", Ok|Apply|Cancel|User1 ),
1582 m_modtype ( modtype ),
1585 TQString title, btnOK, whatisok;
1588 title = i18n(
"File Was Deleted on Disk");
1589 btnOK = i18n(
"&Save File As...");
1590 whatisok = i18n(
"Lets you select a location and save the file again.");
1592 title = i18n(
"File Changed on Disk");
1593 btnOK = i18n(
"&Reload File");
1594 whatisok = i18n(
"Reload the file from disk. If you have unsaved changes, "
1595 "they will be lost.");
1598 setButtonText( Ok, btnOK);
1599 setButtonText( Apply, i18n(
"&Ignore") );
1601 setButtonWhatsThis( Ok, whatisok );
1602 setButtonWhatsThis( Apply, i18n(
"Ignore the changes. You will not be prompted again.") );
1603 setButtonWhatsThis( Cancel, i18n(
"Do nothing. Next time you focus the file, "
1604 "or try to save it or close it, you will be prompted again.") );
1606 enableButtonSeparator(
true );
1607 setCaption( title );
1609 TQFrame *w = makeMainWidget();
1610 TQVBoxLayout *lo =
new TQVBoxLayout( w );
1611 TQHBoxLayout *lo1 =
new TQHBoxLayout( lo );
1612 TQLabel *icon =
new TQLabel( w );
1613 icon->setPixmap( DesktopIcon(
"messagebox_warning" ) );
1614 lo1->addWidget( icon );
1615 lo1->addWidget(
new TQLabel( reason +
"\n\n" + i18n(
"What do you want to do?"), w ) );
1620 TQHBoxLayout *lo2 =
new TQHBoxLayout( lo );
1621 TQPushButton *btnDiff =
new TQPushButton( i18n(
"&View Difference"), w );
1622 lo2->addStretch( 1 );
1623 lo2->addWidget( btnDiff );
1624 connect( btnDiff, TQT_SIGNAL(clicked()),
this, TQT_SLOT(slotDiff()) );
1625 TQWhatsThis::add( btnDiff, i18n(
1626 "Calculates the difference between the editor contents and the disk "
1627 "file using diff(1) and opens the diff file with the default application "
1630 setButtonText( User1, i18n(
"Overwrite") );
1631 setButtonWhatsThis( User1, i18n(
"Overwrite the disk file with the editor content.") );
1634 showButton( User1,
false );
1637 KateModOnHdPrompt::~KateModOnHdPrompt()
1646 *p <<
"diff" <<
"-u" <<
"-" << m_doc->url().path();
1647 connect( p, TQT_SIGNAL(processExited(
KProcess*)),
this, TQT_SLOT(slotPDone(
KProcess*)) );
1648 connect( p, TQT_SIGNAL(readReady(
KProcIO*)),
this, TQT_SLOT(slotPRead(
KProcIO*)) );
1650 setCursor( WaitCursor );
1654 uint lastln = m_doc->numLines();
1655 for ( uint l = 0; l < lastln; l++ )
1661 void KateModOnHdPrompt::slotPRead(
KProcIO *p)
1668 bool dataRead =
false;
1669 while ( p->
readln( stmp,
false ) > -1 )
1681 void KateModOnHdPrompt::slotPDone(
KProcess *p )
1683 setCursor( ArrowCursor );
1699 i18n(
"The diff command failed. Please make sure that "
1700 "diff(1) is installed and in your PATH."),
1701 i18n(
"Error Creating Diff") );
1707 KRun::runURL( m_tmpfile->
name(),
"text/x-diff", true );
1712 void KateModOnHdPrompt::slotApply()
1716 i18n(
"Ignoring means that you will not be warned again (unless "
1717 "the disk file changes once more): if you save the document, you "
1718 "will overwrite the file on disk; if you do not save then the disk file "
1719 "(if present) is what you have."),
1720 i18n(
"You Are on Your Own"),
1728 void KateModOnHdPrompt::slotOk()
1730 done( m_modtype == 3 ? Save : Reload );
1733 void KateModOnHdPrompt::slotUser1()