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 <tdetexteditor/configinterfaceextension.h>
39 #include <tdetexteditor/plugin.h>
41 #include <tdeio/job.h>
42 #include <tdeio/jobclasses.h>
43 #include <tdeio/netaccess.h>
46 #include <tdeapplication.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>
53 #include <tdeconfig.h>
55 #include <tdefontdialog.h>
56 #include <tdeglobal.h>
57 #include <tdeglobalsettings.h>
58 #include <kiconloader.h>
59 #include <kkeybutton.h>
60 #include <kkeydialog.h>
61 #include <klineedit.h>
62 #include <tdelistview.h>
64 #include <tdemessagebox.h>
65 #include <kmimetypechooser.h>
66 #include <knuminput.h>
67 #include <tdeparts/componentfactory.h>
68 #include <tdepopupmenu.h>
69 #include <tdeprocess.h>
71 #include <kregexpeditorinterface.h>
73 #include <kseparator.h>
74 #include <kstandarddirs.h>
75 #include <tdetempfile.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>
111 #define HLDOWNLOADPATH "http://git.trinitydesktop.org/cgit/tdelibs/plain/kate/data/update-files.xml"
116 KateConfigPage::KateConfigPage ( TQWidget *parent,
const char *name )
120 connect (
this, TQ_SIGNAL(changed()),
this, TQ_SLOT(somethingHasChanged ()));
123 KateConfigPage::~KateConfigPage ()
127 void KateConfigPage::somethingHasChanged ()
130 kdDebug (13000) <<
"TEST: something changed on the config page: " <<
this <<
endl;
135 const int KateIndentConfigTab::flags[] = {
136 KateDocument::cfSpaceIndent,
137 KateDocument::cfKeepIndentProfile,
138 KateDocument::cfKeepExtraSpaces,
139 KateDocument::cfTabIndents,
140 KateDocument::cfBackspaceIndents,
141 KateDocumentConfig::cfDoxygenAutoTyping,
142 KateDocumentConfig::cfMixedIndent,
143 KateDocumentConfig::cfIndentPastedText
146 KateIndentConfigTab::KateIndentConfigTab(TQWidget *parent)
147 : KateConfigPage(parent)
150 int configFlags = KateDocumentConfig::global()->configFlags();
152 TQVGroupBox *gbAuto =
new TQVGroupBox(i18n(
"Automatic Indentation"),
this);
154 TQHBox *indentLayout =
new TQHBox(gbAuto);
156 TQLabel *indentLabel =
new TQLabel(i18n(
"&Indentation mode:"), indentLayout);
157 m_indentMode =
new KComboBox (indentLayout);
159 indentLabel->setBuddy(m_indentMode);
160 m_configPage =
new TQPushButton(SmallIconSet(
"configure"), i18n(
"Configure..."), indentLayout);
162 opt[5] =
new TQCheckBox(i18n(
"Insert leading Doxygen \"*\" when typing"), gbAuto);
163 opt[7] =
new TQCheckBox(i18n(
"Adjust indentation of code pasted from the clipboard"), gbAuto);
165 TQVGroupBox *gbSpaces =
new TQVGroupBox(i18n(
"Indentation with Spaces"),
this);
166 TQVBox *spaceLayout =
new TQVBox(gbSpaces);
167 opt[0] =
new TQCheckBox(i18n(
"Use &spaces instead of tabs to indent"), spaceLayout );
168 opt[6] =
new TQCheckBox(i18n(
"Emacs style mixed mode"), spaceLayout);
170 indentationWidth =
new KIntNumInput(KateDocumentConfig::global()->indentationWidth(), spaceLayout);
171 indentationWidth->setRange(1, 16, 1,
false);
172 indentationWidth->setLabel(i18n(
"Number of spaces:"), AlignVCenter);
174 opt[1] =
new TQCheckBox(i18n(
"Keep indent &profile"),
this);
175 opt[2] =
new TQCheckBox(i18n(
"&Keep extra spaces"),
this);
177 TQVGroupBox *keys =
new TQVGroupBox(i18n(
"Keys to Use"),
this);
178 opt[3] =
new TQCheckBox(i18n(
"&Tab key indents"), keys);
179 opt[4] =
new TQCheckBox(i18n(
"&Backspace key indents"), keys);
181 TQRadioButton *rb1, *rb2, *rb3;
182 m_tabs =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Tab Key Mode if Nothing Selected"),
this );
183 m_tabs->setRadioButtonExclusive(
true );
184 m_tabs->insert( rb1=
new TQRadioButton( i18n(
"Insert indent &characters"), m_tabs ), 0 );
185 m_tabs->insert( rb2=
new TQRadioButton( i18n(
"I&nsert tab character"), m_tabs ), 1 );
186 m_tabs->insert( rb3=
new TQRadioButton( i18n(
"Indent current &line"), m_tabs ), 2 );
188 opt[0]->setChecked(configFlags & flags[0]);
189 opt[1]->setChecked(configFlags & flags[1]);
190 opt[2]->setChecked(configFlags & flags[2]);
191 opt[3]->setChecked(configFlags & flags[3]);
192 opt[4]->setChecked(configFlags & flags[4]);
193 opt[5]->setChecked(configFlags & flags[5]);
194 opt[6]->setChecked(configFlags & flags[6]);
195 opt[7]->setChecked(configFlags & flags[7]);
197 layout->addWidget(gbAuto);
198 layout->addWidget(gbSpaces);
199 layout->addWidget(opt[1]);
200 layout->addWidget(opt[2]);
201 layout->addWidget(keys);
202 layout->addWidget(m_tabs, 0);
204 layout->addStretch();
207 TQWhatsThis::add(opt[0], i18n(
208 "Check this if you want to indent with spaces rather than tabs."));
209 TQWhatsThis::add(opt[2], i18n(
210 "Indentations of more than the selected number of spaces will not be "
212 TQWhatsThis::add(opt[3], i18n(
213 "This allows the <b>Tab</b> key to be used to increase the indentation "
215 TQWhatsThis::add(opt[4], i18n(
216 "This allows the <b>Backspace</b> key to be used to decrease the "
217 "indentation level."));
218 TQWhatsThis::add(opt[5], i18n(
219 "Automatically inserts a leading \"*\" while typing within a Doxygen "
221 TQWhatsThis::add( opt[6], i18n(
222 "Use a mix of tab and space characters for indentation.") );
223 TQWhatsThis::add( opt[7], i18n(
224 "If this option is selected, pasted code from the clipboard is indented. "
225 "Triggering the <b>undo</b>-action removes the indentation.") );
226 TQWhatsThis::add(indentationWidth, i18n(
"The number of spaces to indent with."));
228 TQWhatsThis::add(m_configPage, i18n(
229 "If this button is enabled, additional indenter specific options are "
230 "available and can be configured in an extra dialog.") );
238 connect(m_indentMode, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChanged()));
239 connect(m_indentMode, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(indenterSelected(
int)));
241 connect( opt[0], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(somethingToggled()));
243 connect( opt[0], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
244 connect( opt[1], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
245 connect( opt[2], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
246 connect( opt[3], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
247 connect( opt[4], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
248 connect( opt[5], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
249 connect( opt[6], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
250 connect( opt[7], TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
252 connect(indentationWidth, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
254 connect(rb1, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
255 connect(rb2, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
256 connect(rb3, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
258 connect(m_configPage, TQ_SIGNAL(clicked()),
this, TQ_SLOT(configPage()));
261 void KateIndentConfigTab::somethingToggled() {
262 indentationWidth->setEnabled(opt[0]->isChecked());
263 opt[6]->setEnabled(opt[0]->isChecked());
266 void KateIndentConfigTab::indenterSelected (
int index)
268 if (index == KateDocumentConfig::imCStyle || index == KateDocumentConfig::imCSAndS)
269 opt[5]->setEnabled(
true);
271 opt[5]->setEnabled(
false);
276 void KateIndentConfigTab::configPage()
278 uint index = m_indentMode->currentItem();
281 KDialogBase dlg(
this,
"indenter_config_dialog",
true, i18n(
"Configure Indenter"),
284 TQVBox *box =
new TQVBox(&dlg);
286 dlg.setMainWidget(box);
293 box->setStretchFactor(page, 1);
295 connect( &dlg, TQ_SIGNAL(okClicked()), page, TQ_SLOT(apply()) );
297 dlg.resize(400, 300);
302 void KateIndentConfigTab::apply ()
309 KateDocumentConfig::global()->configStart ();
313 configFlags = KateDocumentConfig::global()->configFlags();
314 for (z = 0; z < numFlags; z++) {
315 configFlags &= ~flags[z];
316 if (opt[z]->isChecked()) configFlags |= flags[z];
319 KateDocumentConfig::global()->setConfigFlags(configFlags);
320 KateDocumentConfig::global()->setIndentationWidth(indentationWidth->value());
322 KateDocumentConfig::global()->setIndentationMode(m_indentMode->currentItem());
324 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabIndentsMode, 2 == m_tabs->id (m_tabs->selected()));
325 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabInsertsTab, 1 == m_tabs->id (m_tabs->selected()));
327 KateDocumentConfig::global()->configEnd ();
330 void KateIndentConfigTab::reload ()
332 if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabIndentsMode)
333 m_tabs->setButton (2);
334 else if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabInsertsTab)
335 m_tabs->setButton (1);
337 m_tabs->setButton (0);
339 m_indentMode->setCurrentItem (KateDocumentConfig::global()->indentationMode());
342 indenterSelected (m_indentMode->currentItem());
347 const int KateSelectConfigTab::flags[] = {};
349 KateSelectConfigTab::KateSelectConfigTab(TQWidget *parent)
350 : KateConfigPage(parent)
352 int configFlags = KateDocumentConfig::global()->configFlags();
356 TQVGroupBox *gbCursor =
new TQVGroupBox(i18n(
"Text Cursor Movement"),
this);
358 opt[0] =
new TQCheckBox(i18n(
"Smart ho&me and smart end"), gbCursor);
359 opt[0]->setChecked(configFlags & KateDocumentConfig::cfSmartHome);
360 connect(opt[0], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
362 opt[1] =
new TQCheckBox(i18n(
"Wrap c&ursor"), gbCursor);
363 opt[1]->setChecked(configFlags & KateDocumentConfig::cfWrapCursor);
364 connect(opt[1], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
366 e6 =
new TQCheckBox(i18n(
"&PageUp/PageDown moves cursor"), gbCursor);
367 e6->setChecked(KateDocumentConfig::global()->pageUpDownMovesCursor());
368 connect(e6, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
370 e4 =
new KIntNumInput(KateViewConfig::global()->autoCenterLines(), gbCursor);
371 e4->setRange(0, 1000000, 1,
false);
372 e4->setLabel(i18n(
"Autocenter cursor (lines):"), AlignVCenter);
373 connect(e4, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
375 layout->addWidget(gbCursor);
377 TQRadioButton *rb1, *rb2;
379 m_tabs =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Selection Mode"),
this );
380 layout->add (m_tabs);
382 m_tabs->setRadioButtonExclusive(
true );
383 m_tabs->insert( rb1=
new TQRadioButton( i18n(
"&Normal"), m_tabs ), 0 );
384 m_tabs->insert( rb2=
new TQRadioButton( i18n(
"&Persistent"), m_tabs ), 1 );
386 layout->addStretch();
388 TQWhatsThis::add(rb1, i18n(
389 "Selections will be overwritten by typed text and will be lost on "
390 "cursor movement."));
391 TQWhatsThis::add(rb2, i18n(
392 "Selections will stay even after cursor movement and typing."));
394 TQWhatsThis::add(e4, i18n(
395 "Sets the number of lines to maintain visible above and below the "
396 "cursor when possible."));
398 TQWhatsThis::add(opt[0], i18n(
399 "When selected, pressing the home key will cause the cursor to skip "
400 "whitespace and go to the start of a line's text. "
401 "The same applies for the end key."));
403 TQWhatsThis::add(opt[1], i18n(
404 "When on, moving the insertion cursor using the <b>Left</b> and "
405 "<b>Right</b> keys will go on to previous/next line at beginning/end of "
406 "the line, similar to most editors.<p>When off, the insertion cursor "
407 "cannot be moved left of the line start, but it can be moved off the "
408 "line end, which can be very handy for programmers."));
410 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."));
419 connect(rb1, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
420 connect(rb2, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
423 void KateSelectConfigTab::apply ()
430 KateViewConfig::global()->configStart ();
431 KateDocumentConfig::global()->configStart ();
433 int configFlags = KateDocumentConfig::global()->configFlags();
435 configFlags &= ~KateDocumentConfig::cfSmartHome;
436 configFlags &= ~KateDocumentConfig::cfWrapCursor;
438 if (opt[0]->isChecked()) configFlags |= KateDocumentConfig::cfSmartHome;
439 if (opt[1]->isChecked()) configFlags |= KateDocumentConfig::cfWrapCursor;
441 KateDocumentConfig::global()->setConfigFlags(configFlags);
443 KateViewConfig::global()->setAutoCenterLines(kMax(0, e4->value()));
444 KateDocumentConfig::global()->setPageUpDownMovesCursor(e6->isChecked());
446 KateViewConfig::global()->setPersistentSelection (m_tabs->id (m_tabs->selected()) == 1);
448 KateDocumentConfig::global()->configEnd ();
449 KateViewConfig::global()->configEnd ();
452 void KateSelectConfigTab::reload ()
454 if (KateViewConfig::global()->persistentSelection())
455 m_tabs->setButton (1);
457 m_tabs->setButton (0);
462 const int KateEditConfigTab::flags[] = {KateDocument::cfWordWrap,
463 KateDocument::cfAutoBrackets, KateDocument::cfShowTabs,
464 KateDocumentConfig::cfReplaceTabsDyn, KateDocumentConfig::cfRemoveTrailingDyn};
466 KateEditConfigTab::KateEditConfigTab(TQWidget *parent)
467 : KateConfigPage(parent)
470 int configFlags = KateDocumentConfig::global()->configFlags();
472 TQVGroupBox *gbWhiteSpace =
new TQVGroupBox(i18n(
"Tabulators"),
this);
474 opt[3] =
new TQCheckBox( i18n(
"&Insert spaces instead of tabulators"), gbWhiteSpace );
475 opt[3]->setChecked( configFlags & KateDocumentConfig::cfReplaceTabsDyn );
476 connect( opt[3], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()) );
478 opt[2] =
new TQCheckBox(i18n(
"&Show tabulators"), gbWhiteSpace);
479 opt[2]->setChecked(configFlags & flags[2]);
480 connect(opt[2], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
482 e2 =
new KIntNumInput(KateDocumentConfig::global()->tabWidth(), gbWhiteSpace);
483 e2->setRange(1, 16, 1,
false);
484 e2->setLabel(i18n(
"Tab width:"), AlignVCenter);
485 connect(e2, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
487 mainLayout->addWidget(gbWhiteSpace);
489 TQVGroupBox *gbWordWrap =
new TQVGroupBox(i18n(
"Static Word Wrap"),
this);
491 opt[0] =
new TQCheckBox(i18n(
"Enable static &word wrap"), gbWordWrap);
492 opt[0]->setChecked(KateDocumentConfig::global()->wordWrap());
493 connect(opt[0], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
495 m_wwmarker =
new TQCheckBox( i18n(
"&Show static word wrap marker (if applicable)"), gbWordWrap );
496 m_wwmarker->setChecked( KateRendererConfig::global()->wordWrapMarker() );
497 connect(m_wwmarker, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
499 e1 =
new KIntNumInput(KateDocumentConfig::global()->wordWrapAt(), gbWordWrap);
500 e1->setRange(20, 200, 1,
false);
501 e1->setLabel(i18n(
"Wrap words at:"), AlignVCenter);
502 connect(e1, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
504 mainLayout->addWidget(gbWordWrap);
506 opt[4] =
new TQCheckBox( i18n(
"Remove &trailing spaces"),
this );
507 mainLayout->addWidget( opt[4] );
508 opt[4]->setChecked( configFlags & KateDocumentConfig::cfRemoveTrailingDyn );
509 connect( opt[4], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()) );
511 opt[1] =
new TQCheckBox(i18n(
"Auto &brackets"),
this);
512 mainLayout->addWidget(opt[1]);
513 opt[1]->setChecked(configFlags & flags[1]);
514 connect(opt[1], TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
516 e3 =
new KIntNumInput(e2, KateDocumentConfig::global()->undoSteps(),
this);
517 e3->setRange(0, 1000000, 1,
false);
518 e3->setSpecialValueText( i18n(
"Unlimited") );
519 e3->setLabel(i18n(
"Maximum undo steps:"), AlignVCenter);
520 mainLayout->addWidget(e3);
521 connect(e3, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
523 TQHBoxLayout *e5Layout =
new TQHBoxLayout(mainLayout);
524 TQLabel *e5Label =
new TQLabel(i18n(
"Smart search t&ext from:"),
this);
525 e5Layout->addWidget(e5Label);
527 e5->insertItem( i18n(
"Nowhere") );
528 e5->insertItem( i18n(
"Selection Only") );
529 e5->insertItem( i18n(
"Selection, then Current Word") );
530 e5->insertItem( i18n(
"Current Word Only") );
531 e5->insertItem( i18n(
"Current Word, then Selection") );
532 e5->setCurrentItem(KateViewConfig::global()->textToSearchMode());
533 e5Layout->addWidget(e5);
534 e5Label->setBuddy(e5);
535 connect(e5, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChanged()));
537 mainLayout->addStretch();
540 TQWhatsThis::add(opt[0], i18n(
541 "Automatically start a new line of text when the current line exceeds "
542 "the length specified by the <b>Wrap words at:</b> option."
543 "<p>This option does not wrap existing lines of text - use the <b>Apply "
544 "Static Word Wrap</b> option in the <b>Tools</b> menu for that purpose."
545 "<p>If you want lines to be <i>visually wrapped</i> instead, according "
546 "to the width of the view, enable <b>Dynamic Word Wrap</b> in the "
547 "<b>View Defaults</b> config page."));
548 TQWhatsThis::add(e1, i18n(
549 "If the Word Wrap option is selected this entry determines the length "
550 "(in characters) at which the editor will automatically start a new line."));
551 TQWhatsThis::add(opt[1], i18n(
552 "When the user types a left bracket ([,(, or {) KateView automatically "
553 "enters the right bracket (}, ), or ]) to the right of the cursor."));
554 TQWhatsThis::add(opt[2], i18n(
555 "The editor will display a symbol to indicate the presence of a tab in "
558 TQWhatsThis::add(e3, i18n(
559 "Sets the number of undo/redo steps to record. More steps uses more memory."));
561 TQString gstfwt = i18n(
562 "This determines where KateView will get the search text from "
563 "(this will be automatically entered into the Find Text dialog): "
566 "<li><b>Nowhere:</b> Don't guess the search text."
568 "<li><b>Selection Only:</b> Use the current text selection, "
571 "<li><b>Selection, then Current Word:</b> Use the current "
572 "selection if available, otherwise use the current word."
574 "<li><b>Current Word Only:</b> Use the word that the cursor "
575 "is currently resting on, if available."
577 "<li><b>Current Word, then Selection:</b> Use the current "
578 "word if available, otherwise use the current selection."
581 "Note that, in all the above modes, if a search string has "
582 "not been or cannot be determined, then the Find Text Dialog "
583 "will fall back to the last search text.");
584 TQWhatsThis::add(e5Label, gstfwt);
585 TQWhatsThis::add(e5, gstfwt);
586 TQWhatsThis::add( opt[3], i18n(
587 "If this is enabled, the editor will calculate the number of spaces up to "
588 "the next tab position as defined by the tab width, and insert that number "
589 "of spaces instead of a TAB character." ) );
590 TQWhatsThis::add( opt[4], i18n(
591 "If this is enabled, the editor will remove any trailing whitespace on "
592 "lines when they are left by the insertion cursor.") );
593 TQWhatsThis::add( m_wwmarker, i18n(
594 "<p>If this option is checked, a vertical line will be drawn at the word "
595 "wrap column as defined in the <strong>Editing</strong> properties."
596 "<p>Note that the word wrap marker is only drawn if you use a fixed "
600 void KateEditConfigTab::apply ()
607 KateViewConfig::global()->configStart ();
608 KateDocumentConfig::global()->configStart ();
612 configFlags = KateDocumentConfig::global()->configFlags();
613 for (z = 1; z < numFlags; z++) {
614 configFlags &= ~flags[z];
615 if (opt[z]->isChecked()) configFlags |= flags[z];
617 KateDocumentConfig::global()->setConfigFlags(configFlags);
619 KateDocumentConfig::global()->setWordWrapAt(e1->value());
620 KateDocumentConfig::global()->setWordWrap (opt[0]->isChecked());
621 KateDocumentConfig::global()->setTabWidth(e2->value());
623 if (e3->value() <= 0)
624 KateDocumentConfig::global()->setUndoSteps(0);
626 KateDocumentConfig::global()->setUndoSteps(e3->value());
628 KateViewConfig::global()->setTextToSearchMode(e5->currentItem());
630 KateRendererConfig::global()->setWordWrapMarker (m_wwmarker->isChecked());
632 KateDocumentConfig::global()->configEnd ();
633 KateViewConfig::global()->configEnd ();
636 void KateEditConfigTab::reload ()
642 KateViewDefaultsConfig::KateViewDefaultsConfig(TQWidget *parent)
643 :KateConfigPage(parent)
650 TQVGroupBox *gbWordWrap =
new TQVGroupBox(i18n(
"Word Wrap"),
this);
652 m_dynwrap=
new TQCheckBox(i18n(
"&Dynamic word wrap"),gbWordWrap);
654 TQHBox *m_dynwrapIndicatorsLay =
new TQHBox (gbWordWrap);
655 m_dynwrapIndicatorsLabel =
new TQLabel( i18n(
"Dynamic word wrap indicators (if applicable):"), m_dynwrapIndicatorsLay );
656 m_dynwrapIndicatorsCombo =
new KComboBox( m_dynwrapIndicatorsLay );
657 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Off") );
658 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Follow Line Numbers") );
659 m_dynwrapIndicatorsCombo->insertItem( i18n(
"Always On") );
660 m_dynwrapIndicatorsLabel->setBuddy(m_dynwrapIndicatorsCombo);
663 m_dynwrapAlignLevel->setLabel(i18n(
"Vertically align dynamically wrapped lines to indentation depth:"));
664 m_dynwrapAlignLevel->setRange(0, 80, 10);
666 m_dynwrapAlignLevel->setSuffix(i18n(
"% of View Width"));
667 m_dynwrapAlignLevel->setSpecialValueText(i18n(
"Disabled"));
669 blay->addWidget(gbWordWrap);
671 TQVGroupBox *gbFold =
new TQVGroupBox(i18n(
"Code Folding"),
this);
673 m_folding=
new TQCheckBox(i18n(
"Show &folding markers (if available)"), gbFold );
674 m_collapseTopLevel =
new TQCheckBox( i18n(
"Collapse toplevel folding nodes"), gbFold );
675 m_collapseTopLevel->hide ();
677 blay->addWidget(gbFold);
679 TQVGroupBox *gbBar =
new TQVGroupBox(i18n(
"Borders"),
this);
681 m_icons=
new TQCheckBox(i18n(
"Show &icon border"),gbBar);
682 m_line=
new TQCheckBox(i18n(
"Show &line numbers"),gbBar);
683 m_scrollBarMarks=
new TQCheckBox(i18n(
"Show &scrollbar marks"),gbBar);
685 blay->addWidget(gbBar);
687 m_bmSort =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Sort Bookmarks Menu"),
this );
688 m_bmSort->setRadioButtonExclusive(
true );
689 m_bmSort->insert( rb1=
new TQRadioButton( i18n(
"By &position"), m_bmSort ), 0 );
690 m_bmSort->insert( rb2=
new TQRadioButton( i18n(
"By c&reation"), m_bmSort ), 1 );
692 blay->addWidget(m_bmSort, 0 );
694 m_showIndentLines =
new TQCheckBox(i18n(
"Show indentation lines"),
this);
695 m_showIndentLines->setChecked(KateRendererConfig::global()->showIndentationLines());
696 blay->addWidget(m_showIndentLines);
698 blay->addStretch(1000);
700 TQWhatsThis::add(m_dynwrap,i18n(
701 "If this option is checked, the text lines will be wrapped at the view "
702 "border on the screen."));
703 TQString wtstr = i18n(
"Choose when the Dynamic Word Wrap Indicators should be displayed");
704 TQWhatsThis::add(m_dynwrapIndicatorsLabel, wtstr);
705 TQWhatsThis::add(m_dynwrapIndicatorsCombo, wtstr);
707 TQWhatsThis::add(m_dynwrapAlignLevel, i18n(
708 "<p>Enables the start of dynamically wrapped lines to be aligned "
709 "vertically to the indentation level of the first line. This can help "
710 "to make code and markup more readable.</p><p>Additionally, this allows "
711 "you to set a maximum width of the screen, as a percentage, after which "
712 "dynamically wrapped lines will no longer be vertically aligned. For "
713 "example, at 50%, lines whose indentation levels are deeper than 50% of "
714 "the width of the screen will not have vertical alignment applied to "
715 "subsequent wrapped lines.</p>"));
716 TQWhatsThis::add(m_line,i18n(
717 "If this option is checked, every new view will display line numbers "
718 "on the left hand side."));
719 TQWhatsThis::add(m_icons,i18n(
720 "If this option is checked, every new view will display an icon border "
721 "on the left hand side.<br><br>The icon border shows bookmark signs, "
723 TQWhatsThis::add(m_scrollBarMarks,i18n(
724 "If this option is checked, every new view will show marks on the "
725 "vertical scrollbar.<br><br>These marks will, for instance, show "
727 TQWhatsThis::add(m_folding,i18n(
728 "If this option is checked, every new view will display marks for code "
729 "folding, if code folding is available."));
730 TQWhatsThis::add(m_bmSort,i18n(
731 "Choose how the bookmarks should be ordered in the <b>Bookmarks</b> menu."));
732 TQWhatsThis::add(rb1,i18n(
733 "The bookmarks will be ordered by the line numbers they are placed at."));
734 TQWhatsThis::add(rb2,i18n(
735 "Each new bookmark will be added to the bottom, independently from "
736 "where it is placed in the document."));
737 TQWhatsThis::add(m_showIndentLines, i18n(
738 "If this is enabled, the editor will display vertical lines to help "
739 "identify indent lines.") );
747 connect(m_dynwrap, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
748 connect(m_dynwrapIndicatorsCombo, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChanged()));
749 connect(m_dynwrapAlignLevel, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
750 connect(m_icons, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
751 connect(m_scrollBarMarks, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
752 connect(m_line, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
753 connect(m_folding, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
754 connect(m_collapseTopLevel, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()) );
755 connect(rb1, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
756 connect(rb2, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
757 connect(m_showIndentLines, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
760 KateViewDefaultsConfig::~KateViewDefaultsConfig()
764 void KateViewDefaultsConfig::apply ()
771 KateViewConfig::global()->configStart ();
772 KateRendererConfig::global()->configStart ();
774 KateViewConfig::global()->setDynWordWrap (m_dynwrap->isChecked());
775 KateViewConfig::global()->setDynWordWrapIndicators (m_dynwrapIndicatorsCombo->currentItem ());
776 KateViewConfig::global()->setDynWordWrapAlignIndent(m_dynwrapAlignLevel->value());
777 KateViewConfig::global()->setLineNumbers (m_line->isChecked());
778 KateViewConfig::global()->setIconBar (m_icons->isChecked());
779 KateViewConfig::global()->setScrollBarMarks (m_scrollBarMarks->isChecked());
780 KateViewConfig::global()->setFoldingBar (m_folding->isChecked());
781 KateViewConfig::global()->setBookmarkSort (m_bmSort->id (m_bmSort->selected()));
783 KateRendererConfig::global()->setShowIndentationLines(m_showIndentLines->isChecked());
785 KateRendererConfig::global()->configEnd ();
786 KateViewConfig::global()->configEnd ();
789 void KateViewDefaultsConfig::reload ()
791 m_dynwrap->setChecked(KateViewConfig::global()->dynWordWrap());
792 m_dynwrapIndicatorsCombo->setCurrentItem( KateViewConfig::global()->dynWordWrapIndicators() );
793 m_dynwrapAlignLevel->setValue(KateViewConfig::global()->dynWordWrapAlignIndent());
794 m_line->setChecked(KateViewConfig::global()->lineNumbers());
795 m_icons->setChecked(KateViewConfig::global()->iconBar());
796 m_scrollBarMarks->setChecked(KateViewConfig::global()->scrollBarMarks());
797 m_folding->setChecked(KateViewConfig::global()->foldingBar());
798 m_bmSort->setButton( KateViewConfig::global()->bookmarkSort() );
799 m_showIndentLines->setChecked(KateRendererConfig::global()->showIndentationLines());
802 void KateViewDefaultsConfig::reset () {;}
804 void KateViewDefaultsConfig::defaults (){;}
809 KateEditKeyConfiguration::KateEditKeyConfiguration( TQWidget* parent, KateDocument* doc )
810 : KateConfigPage( parent )
816 void KateEditKeyConfiguration::showEvent ( TQShowEvent * )
820 (
new TQVBoxLayout(
this))->setAutoAdd(
true);
821 KateView* view = (KateView*)m_doc->views().at(0);
822 m_ac = view->editActionCollection();
823 m_keyChooser =
new KKeyChooser( m_ac,
this,
false );
824 connect( m_keyChooser, TQ_SIGNAL( keyChange() ),
this, TQ_SLOT( slotChanged() ) );
825 m_keyChooser->show ();
833 void KateEditKeyConfiguration::apply()
841 m_keyChooser->commitChanges();
842 m_ac->writeShortcutSettings(
"Katepart Shortcuts" );
848 KateSaveConfigTab::KateSaveConfigTab( TQWidget *parent )
849 : KateConfigPage( parent )
851 int configFlags = KateDocumentConfig::global()->configFlags();
854 TQVGroupBox *gbEnc =
new TQVGroupBox(i18n(
"File Format"),
this);
855 layout->addWidget( gbEnc );
857 TQHBox *e5Layout =
new TQHBox(gbEnc);
858 TQLabel *e5Label =
new TQLabel(i18n(
"&Encoding:"), e5Layout);
860 e5Label->setBuddy(m_encoding);
862 e5Layout =
new TQHBox(gbEnc);
863 e5Label =
new TQLabel(i18n(
"End &of line:"), e5Layout);
865 e5Label->setBuddy(m_eol);
867 allowEolDetection =
new TQCheckBox(i18n(
"&Automatic end of line detection"), gbEnc);
869 m_eol->insertItem (i18n(
"UNIX"));
870 m_eol->insertItem (i18n(
"DOS/Windows"));
871 m_eol->insertItem (i18n(
"Macintosh"));
873 TQVGroupBox *gbMem =
new TQVGroupBox(i18n(
"Memory Usage"),
this);
874 layout->addWidget( gbMem );
876 e5Layout =
new TQHBox(gbMem);
877 e5Layout->setSpacing (32);
878 blockCountLabel =
new TQLabel(i18n(
"Maximum loaded &blocks per file:"), e5Layout);
879 blockCount =
new TQSpinBox (4, 512, 4, e5Layout);
882 blockCountLabel->setBuddy(blockCount);
884 TQVGroupBox *gbWhiteSpace =
new TQVGroupBox(i18n(
"Automatic Cleanups on Load/Save"),
this);
885 layout->addWidget( gbWhiteSpace );
887 removeSpaces =
new TQCheckBox(i18n(
"Re&move trailing spaces"), gbWhiteSpace);
888 removeSpaces->setChecked(configFlags & KateDocument::cfRemoveSpaces);
890 TQVGroupBox *dirConfigBox =
new TQVGroupBox(i18n(
"Folder Config File"),
this);
891 layout->addWidget( dirConfigBox );
893 dirSearchDepth =
new KIntNumInput(KateDocumentConfig::global()->searchDirConfigDepth(), dirConfigBox);
894 dirSearchDepth->setRange(-1, 64, 1,
false);
895 dirSearchDepth->setSpecialValueText( i18n(
"Do not use config file") );
896 dirSearchDepth->setLabel(i18n(
"Se&arch depth for config file:"), AlignVCenter);
898 TQGroupBox *gb =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"Backup on Save"),
this );
899 layout->addWidget( gb );
900 cbLocalFiles =
new TQCheckBox( i18n(
"&Local files"), gb );
901 cbRemoteFiles =
new TQCheckBox( i18n(
"&Remote files"), gb );
903 TQHBox *hbBuPrefix =
new TQHBox( gb );
904 TQLabel *lBuPrefix =
new TQLabel( i18n(
"&Prefix:"), hbBuPrefix );
905 leBuPrefix =
new TQLineEdit( hbBuPrefix );
906 lBuPrefix->setBuddy( leBuPrefix );
908 TQHBox *hbBuSuffix =
new TQHBox( gb );
909 TQLabel *lBuSuffix =
new TQLabel( i18n(
"&Suffix:"), hbBuSuffix );
910 leBuSuffix =
new TQLineEdit( hbBuSuffix );
911 lBuSuffix->setBuddy( leBuSuffix );
913 layout->addStretch();
915 TQWhatsThis::add(removeSpaces, i18n(
916 "The editor will automatically eliminate extra spaces at the ends of "
917 "lines of text while loading/saving the file."));
918 TQWhatsThis::add( gb, i18n(
919 "<p>Backing up on save will cause Kate to copy the disk file to "
920 "'<prefix><filename><suffix>' before saving changes."
921 "<p>The suffix defaults to <strong>~</strong> and prefix is empty by default" ) );
922 TQWhatsThis::add( allowEolDetection, i18n(
923 "Check this if you want the editor to autodetect the end of line type."
924 "The first found end of line type will be used for the whole file.") );
925 TQWhatsThis::add( cbLocalFiles, i18n(
926 "Check this if you want backups of local files when saving") );
927 TQWhatsThis::add( cbRemoteFiles, i18n(
928 "Check this if you want backups of remote files when saving") );
929 TQWhatsThis::add( leBuPrefix, i18n(
930 "Enter the prefix to prepend to the backup file names" ) );
931 TQWhatsThis::add( leBuSuffix, i18n(
932 "Enter the suffix to add to the backup file names" ) );
933 TQWhatsThis::add(dirSearchDepth, i18n(
934 "The editor will search the given number of folder levels upwards for .kateconfig file"
935 " and load the settings line from it." ));
936 TQWhatsThis::add(blockCount, i18n(
937 "The editor will load given number of blocks (of around 2048 lines) of text into memory;"
938 " if the filesize is bigger than this the other blocks are swapped "
939 " to disk and loaded transparently as-needed.<br>"
940 " This can cause little delays while navigating in the document; a larger block count"
941 " increases the editing speed at the cost of memory. <br>For normal usage, just choose the highest possible"
942 " block count: limit it only if you have problems with the memory usage."));
950 connect(m_encoding, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChanged()));
951 connect(m_eol, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotChanged()));
952 connect( allowEolDetection, TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
953 connect(blockCount, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
954 connect(removeSpaces, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(slotChanged()));
955 connect( cbLocalFiles, TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
956 connect( cbRemoteFiles, TQ_SIGNAL( toggled(
bool) ),
this, TQ_SLOT( slotChanged() ) );
957 connect(dirSearchDepth, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(slotChanged()));
958 connect( leBuPrefix, TQ_SIGNAL( textChanged (
const TQString & ) ),
this, TQ_SLOT( slotChanged() ) );
959 connect( leBuSuffix, TQ_SIGNAL( textChanged (
const TQString & ) ),
this, TQ_SLOT( slotChanged() ) );
962 void KateSaveConfigTab::apply()
971 KateDocumentConfig::global()->configStart ();
973 if ( leBuSuffix->text().isEmpty() && leBuPrefix->text().isEmpty() ) {
976 i18n(
"You did not provide a backup suffix or prefix. Using default suffix: '~'"),
977 i18n(
"No Backup Suffix or Prefix")
979 leBuSuffix->setText(
"~" );
983 if ( cbLocalFiles->isChecked() )
984 f |= KateDocumentConfig::LocalFiles;
985 if ( cbRemoteFiles->isChecked() )
986 f |= KateDocumentConfig::RemoteFiles;
988 KateDocumentConfig::global()->setBackupFlags(f);
989 KateDocumentConfig::global()->setBackupPrefix(leBuPrefix->text());
990 KateDocumentConfig::global()->setBackupSuffix(leBuSuffix->text());
992 KateDocumentConfig::global()->setSearchDirConfigDepth(dirSearchDepth->value());
994 int configFlags = KateDocumentConfig::global()->configFlags();
996 configFlags &= ~KateDocument::cfRemoveSpaces;
997 if (removeSpaces->isChecked()) configFlags |= KateDocument::cfRemoveSpaces;
999 KateDocumentConfig::global()->setConfigFlags(configFlags);
1003 KateDocumentConfig::global()->setEol(m_eol->currentItem());
1004 KateDocumentConfig::global()->setAllowEolDetection(allowEolDetection->isChecked());
1006 KateDocumentConfig::global()->configEnd ();
1009 void KateSaveConfigTab::reload()
1012 m_encoding->clear ();
1013 m_encoding->insertItem (i18n(
"TDE Default"));
1014 m_encoding->setCurrentItem(0);
1017 for (uint i=0; i < encodings.count(); i++)
1024 m_encoding->insertItem (encodings[i]);
1026 if ( codecForEnc->name() == KateDocumentConfig::global()->encoding() )
1028 m_encoding->setCurrentItem(insert);
1036 m_eol->setCurrentItem(KateDocumentConfig::global()->eol());
1037 allowEolDetection->setChecked(KateDocumentConfig::global()->allowEolDetection());
1039 dirSearchDepth->setValue(KateDocumentConfig::global()->searchDirConfigDepth());
1042 uint f ( KateDocumentConfig::global()->backupFlags() );
1043 cbLocalFiles->setChecked( f & KateDocumentConfig::LocalFiles );
1044 cbRemoteFiles->setChecked( f & KateDocumentConfig::RemoteFiles );
1045 leBuPrefix->setText( KateDocumentConfig::global()->backupPrefix() );
1046 leBuSuffix->setText( KateDocumentConfig::global()->backupSuffix() );
1049 void KateSaveConfigTab::reset()
1053 void KateSaveConfigTab::defaults()
1055 cbLocalFiles->setChecked(
true );
1056 cbRemoteFiles->setChecked(
false );
1057 leBuPrefix->setText(
"" );
1058 leBuSuffix->setText(
"~" );
1064 class KatePartPluginListItem :
public TQCheckListItem
1067 KatePartPluginListItem(
bool checked, uint i,
const TQString &name, TQListView *parent);
1068 uint pluginIndex ()
const {
return index; }
1071 void stateChange(
bool);
1075 bool silentStateChange;
1078 KatePartPluginListItem::KatePartPluginListItem(
bool checked, uint i,
const TQString &name, TQListView *parent)
1079 : TQCheckListItem(parent,
name, CheckBox)
1081 , silentStateChange(false)
1083 silentStateChange =
true;
1085 silentStateChange =
false;
1088 void KatePartPluginListItem::stateChange(
bool b)
1090 if(!silentStateChange)
1091 static_cast<KatePartPluginListView *
>(listView())->stateChanged(
this, b);
1096 KatePartPluginListView::KatePartPluginListView(TQWidget *parent,
const char *name)
1101 void KatePartPluginListView::stateChanged(KatePartPluginListItem *item,
bool b)
1103 emit stateChange(item, b);
1108 KatePartPluginConfigPage::KatePartPluginConfigPage (TQWidget *parent) : KateConfigPage (parent,
"")
1111 TQGridLayout *grid =
new TQGridLayout(
this, 1, 1 );
1114 listView =
new KatePartPluginListView(
this);
1115 listView->addColumn(i18n(
"Name"));
1116 listView->addColumn(i18n(
"Comment"));
1118 grid->addWidget( listView, 0, 0);
1120 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
1122 KatePartPluginListItem *item =
new KatePartPluginListItem(KateDocumentConfig::global()->plugin(i), i, (KateFactory::self()->plugins())[i]->
name(), listView);
1123 item->setText(0, (KateFactory::self()->plugins())[i]->
name());
1124 item->setText(1, (KateFactory::self()->plugins())[i]->comment());
1126 m_items.append (item);
1131 btnConfigure =
new TQPushButton( i18n(
"Configure..."),
this );
1132 btnConfigure->setEnabled(
false );
1133 grid->addWidget( btnConfigure, 1, 0, TQt::AlignRight );
1134 connect( btnConfigure, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotConfigure()) );
1136 connect( listView, TQ_SIGNAL(selectionChanged(TQListViewItem*)),
this, TQ_SLOT(slotCurrentChanged(TQListViewItem*)) );
1137 connect( listView, TQ_SIGNAL(stateChange(KatePartPluginListItem *,
bool)),
1138 this, TQ_SLOT(slotStateChanged(KatePartPluginListItem *,
bool)));
1139 connect(listView, TQ_SIGNAL(stateChange(KatePartPluginListItem *,
bool)),
this, TQ_SLOT(slotChanged()));
1142 KatePartPluginConfigPage::~KatePartPluginConfigPage ()
1146 void KatePartPluginConfigPage::apply ()
1153 KateDocumentConfig::global()->configStart ();
1155 for (uint i=0; i < m_items.count(); i++)
1156 KateDocumentConfig::global()->setPlugin (m_items.at(i)->pluginIndex(), m_items.at(i)->isOn());
1158 KateDocumentConfig::global()->configEnd ();
1161 void KatePartPluginConfigPage::slotStateChanged( KatePartPluginListItem *item,
bool b )
1164 slotCurrentChanged( (TQListViewItem*)item );
1167 void KatePartPluginConfigPage::slotCurrentChanged( TQListViewItem* i )
1169 KatePartPluginListItem *item =
static_cast<KatePartPluginListItem *
>(i);
1170 if ( ! item )
return;
1177 KTextEditor::Plugin *plugin = KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1179 KTextEditor::ConfigInterfaceExtension *cie = KTextEditor::configInterfaceExtension( plugin );
1180 b = ( cie && cie->configPages() );
1184 btnConfigure->setEnabled( b );
1187 void KatePartPluginConfigPage::slotConfigure()
1189 KatePartPluginListItem *item =
static_cast<KatePartPluginListItem*
>(listView->currentItem());
1190 KTextEditor::Plugin *plugin =
1191 KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1193 if ( ! plugin )
return;
1195 KTextEditor::ConfigInterfaceExtension *cife =
1196 KTextEditor::configInterfaceExtension( plugin );
1201 if ( ! cife->configPages() )
1206 cife->configPages() > 1 ?
1207 KDialogBase::IconList :
1210 TQString
name = (KateFactory::self()->plugins())[item->pluginIndex()]->name();
1212 i18n(
"Configure %1").arg( name ),
1217 TQPtrList<KTextEditor::ConfigPage> editorPages;
1219 for (uint i = 0; i < cife->configPages (); i++)
1222 if ( dt == KDialogBase::IconList )
1226 path << cife->configPageName( i );
1227 page = kd->
addVBoxPage( path, cife->configPageFullName (i),
1233 TQVBoxLayout *_l =
new TQVBoxLayout( page );
1234 _l->setAutoAdd(
true );
1237 editorPages.append( cife->configPage( i, page ) );
1243 for( uint i=0; i<editorPages.count(); i++ )
1245 editorPages.at( i )->apply();
1254 KateHlConfigPage::KateHlConfigPage (TQWidget *parent, KateDocument *doc)
1255 : KateConfigPage (parent,
"")
1262 TQHBox *hbHl =
new TQHBox(
this );
1266 TQLabel *lHl =
new TQLabel( i18n(
"H&ighlight:"), hbHl );
1267 hlCombo =
new TQComboBox(
false, hbHl );
1268 lHl->setBuddy( hlCombo );
1269 connect( hlCombo, TQ_SIGNAL(activated(
int)),
1270 this, TQ_SLOT(hlChanged(
int)) );
1272 for(
int i = 0; i < KateHlManager::self()->highlights(); i++) {
1273 if (KateHlManager::self()->hlSection(i).length() > 0)
1274 hlCombo->insertItem(KateHlManager::self()->hlSection(i) + TQString (
"/") + KateHlManager::self()->hlNameTranslated(i));
1276 hlCombo->insertItem(KateHlManager::self()->hlNameTranslated(i));
1279 TQGroupBox *gbInfo =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"Information"),
this );
1280 layout->add (gbInfo);
1283 TQHBox *hb1 =
new TQHBox( gbInfo);
1284 new TQLabel( i18n(
"Author:"), hb1 );
1285 author =
new TQLabel (hb1);
1286 author->setTextFormat (TQt::RichText);
1289 TQHBox *hb2 =
new TQHBox( gbInfo);
1290 new TQLabel( i18n(
"License:"), hb2 );
1291 license =
new TQLabel (hb2);
1293 TQGroupBox *gbProps =
new TQGroupBox( 1, TQt::Horizontal, i18n(
"Properties"),
this );
1294 layout->add (gbProps);
1297 TQHBox *hbFE =
new TQHBox( gbProps);
1298 TQLabel *lFileExts =
new TQLabel( i18n(
"File e&xtensions:"), hbFE );
1299 wildcards =
new TQLineEdit( hbFE );
1300 lFileExts->setBuddy( wildcards );
1302 TQHBox *hbMT =
new TQHBox( gbProps );
1303 TQLabel *lMimeTypes =
new TQLabel( i18n(
"MIME &types:"), hbMT);
1304 mimetypes =
new TQLineEdit( hbMT );
1305 lMimeTypes->setBuddy( mimetypes );
1307 TQHBox *hbMT2 =
new TQHBox( gbProps );
1308 TQLabel *lprio =
new TQLabel( i18n(
"Prio&rity:"), hbMT2);
1311 lprio->setBuddy( priority );
1313 TQToolButton *btnMTW =
new TQToolButton(hbMT);
1314 btnMTW->setIconSet(TQIconSet(SmallIcon(
"wizard")));
1315 connect(btnMTW, TQ_SIGNAL(clicked()),
this, TQ_SLOT(showMTDlg()));
1318 TQHBox *hbBtns =
new TQHBox(
this );
1319 layout->add (hbBtns);
1321 ((TQBoxLayout*)hbBtns->layout())->addStretch(1);
1323 TQPushButton *btnDl =
new TQPushButton(i18n(
"Do&wnload..."), hbBtns);
1324 connect( btnDl, TQ_SIGNAL(clicked()),
this, TQ_SLOT(hlDownload()) );
1326 int currentHl = m_doc ? m_doc->hlMode() : 0;
1327 hlCombo->setCurrentItem( currentHl );
1328 hlChanged( currentHl );
1330 TQWhatsThis::add( hlCombo, i18n(
1331 "Choose a <em>Syntax Highlight mode</em> from this list to view its "
1332 "properties below.") );
1333 TQWhatsThis::add( wildcards, i18n(
1334 "The list of file extensions used to determine which files to highlight "
1335 "using the current syntax highlight mode.") );
1336 TQWhatsThis::add( mimetypes, i18n(
1337 "The list of Mime Types used to determine which files to highlight "
1338 "using the current highlight mode.<p>Click the wizard button on the "
1339 "left of the entry field to display the MimeType selection dialog.") );
1340 TQWhatsThis::add( btnMTW, i18n(
1341 "Display a dialog with a list of all available mime types to choose from."
1342 "<p>The <strong>File Extensions</strong> entry will automatically be "
1343 "edited as well.") );
1344 TQWhatsThis::add( btnDl, i18n(
1345 "Click this button to download new or updated syntax highlight "
1346 "descriptions from the Kate website.") );
1348 layout->addStretch ();
1350 connect( wildcards, TQ_SIGNAL( textChanged (
const TQString & ) ),
this, TQ_SLOT( slotChanged() ) );
1351 connect( mimetypes, TQ_SIGNAL( textChanged (
const TQString & ) ),
this, TQ_SLOT( slotChanged() ) );
1352 connect( priority, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( slotChanged() ) );
1355 KateHlConfigPage::~KateHlConfigPage ()
1359 void KateHlConfigPage::apply ()
1368 for ( TQIntDictIterator<KateHlData> it( hlDataDict ); it.current(); ++it )
1369 KateHlManager::self()->getHl( it.currentKey() )->setData( it.current() );
1371 KateHlManager::self()->getTDEConfig()->sync ();
1374 void KateHlConfigPage::reload ()
1378 void KateHlConfigPage::hlChanged(
int z)
1382 KateHighlighting *hl = KateHlManager::self()->getHl( z );
1390 if ( !hlDataDict.find( z ) )
1391 hlDataDict.insert( z, hl->getData() );
1393 hlData = hlDataDict.find( z );
1394 wildcards->setText(hlData->wildcards);
1395 mimetypes->setText(hlData->mimetypes);
1396 priority->setValue(hlData->priority);
1399 TQStringList l= TQStringList::split (TQRegExp(
"[,;]"), hl->author());
1400 author->setText (l.join (
"<br>"));
1402 license->setText (hl->license());
1405 void KateHlConfigPage::writeback()
1409 hlData->wildcards = wildcards->text();
1410 hlData->mimetypes = mimetypes->text();
1411 hlData->priority = priority->value();
1415 void KateHlConfigPage::hlDownload()
1417 KateHlDownloadDialog diag(
this,
"hlDownload",
true);
1421 void KateHlConfigPage::showMTDlg()
1423 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() );
1424 TQStringList list = TQStringList::split( TQRegExp(
"\\s*;\\s*"), mimetypes->text() );
1425 KMimeTypeChooserDialog d( i18n(
"Select Mime Types"), text, list,
"text",
this );
1427 if ( d.exec() == KDialogBase::Accepted ) {
1430 wildcards->setText(d.chooser()->patterns().join(
";"));
1431 mimetypes->setText(d.chooser()->mimeTypes().join(
";"));
1437 KateHlDownloadDialog::KateHlDownloadDialog(TQWidget *parent,
const char *name,
bool modal)
1438 :
KDialogBase(
KDialogBase::Swallow, i18n(
"Highlight Download"), User1|Close, User1, parent,
name, modal, true, i18n(
"&Install"))
1440 TQVBox* vbox =
new TQVBox(
this);
1441 setMainWidget(vbox);
1442 vbox->setSpacing(spacingHint());
1443 new TQLabel(i18n(
"Select the syntax highlighting files you want to update:"), vbox);
1444 list =
new TQListView(vbox);
1445 list->addColumn(
"");
1446 list->addColumn(i18n(
"Name"));
1447 list->addColumn(i18n(
"Installed"));
1448 list->addColumn(i18n(
"Latest"));
1449 list->setSelectionMode(TQListView::Multi);
1450 list->setAllColumnsShowFocus(
true);
1452 new TQLabel(i18n(
"<b>Note:</b> New versions are selected automatically."), vbox);
1453 actionButton (User1)->setIconSet(SmallIconSet(
"ok"));
1455 transferJob = TDEIO::get(
KURL(TQString(HLDOWNLOADPATH)),
true,
true);
1456 connect(transferJob, TQ_SIGNAL(data(TDEIO::Job *,
const TQByteArray &)),
1457 this, TQ_SLOT(listDataReceived(TDEIO::Job *,
const TQByteArray &)));
1462 KateHlDownloadDialog::~KateHlDownloadDialog(){}
1464 void KateHlDownloadDialog::listDataReceived(TDEIO::Job *,
const TQByteArray &data)
1466 if (!transferJob || transferJob->isErrorPage())
1468 actionButton(User1)->setEnabled(
false);
1472 listData+=TQString(data);
1474 kdDebug(13000)<<TQString(TQString(
"Data length: %1").arg(data.size()))<<
endl;
1475 kdDebug(13000)<<TQString(TQString(
"listData length: %1").arg(listData.length()))<<
endl;
1478 if (listData.length()>0)
1480 TQString installedVersion;
1481 KateHlManager *hlm=KateHlManager::self();
1483 doc.setContent(listData);
1484 TQDomElement DocElem=doc.documentElement();
1485 TQDomNode n=DocElem.firstChild();
1486 KateHighlighting *hl = 0;
1488 if (n.isNull())
kdDebug(13000)<<
"There is no usable childnode"<<
endl;
1491 installedVersion=
" --";
1493 TQDomElement e=n.toElement();
1495 kdDebug(13000)<<TQString(
"NAME: ")<<e.tagName()<<TQString(
" - ")<<e.attribute(
"name")<<
endl;
1498 TQString Name=e.attribute(
"name");
1500 for (
int i=0;i<hlm->highlights();i++)
1503 if (hl && hl->name()==Name)
1505 installedVersion=
" "+hl->version();
1512 TQListViewItem* entry =
new TQListViewItem(
1513 list,
"", e.attribute(
"name"), installedVersion,
1514 e.attribute(
"version"),e.attribute(
"url"));
1515 if (!hl || hl->version() < e.attribute(
"version"))
1517 entry->setSelected(
true);
1518 entry->setPixmap(0, SmallIcon((
"knewstuff")));
1525 void KateHlDownloadDialog::slotUser1()
1528 for (TQListViewItem *it=list->firstChild();it;it=it->nextSibling())
1530 if (list->isSelected(it))
1532 KURL src(it->text(4));
1533 TQString filename=src.fileName(
false);
1534 TQString dest = destdir+filename;
1536 TDEIO::NetAccess::download(src,dest,
this);
1546 KateGotoLineDialog::KateGotoLineDialog(TQWidget *parent,
int line,
int max)
1547 :
KDialogBase(parent, 0L, true, i18n(
"Go to Line"), Ok | Cancel, Ok) {
1549 TQWidget *page =
new TQWidget(
this);
1550 setMainWidget(page);
1552 TQVBoxLayout *topLayout =
new TQVBoxLayout( page, 0, spacingHint() );
1554 e1->setRange(1, max);
1555 e1->setEditFocus(
true);
1557 TQLabel *
label =
new TQLabel( e1,i18n(
"&Go to line:"), page );
1558 topLayout->addWidget(label);
1559 topLayout->addWidget(e1);
1560 topLayout->addSpacing(spacingHint());
1561 topLayout->addStretch(10);
1565 int KateGotoLineDialog::getLine() {
1571 KateModOnHdPrompt::KateModOnHdPrompt( KateDocument *doc,
1573 const TQString &reason,
1575 :
KDialogBase( parent,
"", true,
"", Ok|Apply|Cancel|User1 ),
1577 m_modtype ( modtype ),
1580 TQString title, btnOK, whatisok;
1583 title = i18n(
"File Was Deleted on Disk");
1584 btnOK = i18n(
"&Save File As...");
1585 whatisok = i18n(
"Lets you select a location and save the file again.");
1587 title = i18n(
"File Changed on Disk");
1588 btnOK = i18n(
"&Reload File");
1589 whatisok = i18n(
"Reload the file from disk. If you have unsaved changes, "
1590 "they will be lost.");
1593 setButtonText( Ok, btnOK);
1594 setButtonText( Apply, i18n(
"&Ignore") );
1596 setButtonWhatsThis( Ok, whatisok );
1597 setButtonWhatsThis( Apply, i18n(
"Ignore the changes. You will not be prompted again.") );
1598 setButtonWhatsThis( Cancel, i18n(
"Do nothing. Next time you focus the file, "
1599 "or try to save it or close it, you will be prompted again.") );
1601 enableButtonSeparator(
true );
1602 setCaption( title );
1604 TQFrame *w = makeMainWidget();
1605 TQVBoxLayout *lo =
new TQVBoxLayout( w );
1606 TQHBoxLayout *lo1 =
new TQHBoxLayout( lo );
1607 TQLabel *icon =
new TQLabel( w );
1608 icon->setPixmap( DesktopIcon(
"messagebox_warning" ) );
1609 lo1->addWidget( icon );
1610 lo1->addWidget(
new TQLabel( reason +
"\n\n" + i18n(
"What do you want to do?"), w ) );
1615 TQHBoxLayout *lo2 =
new TQHBoxLayout( lo );
1616 TQPushButton *btnDiff =
new TQPushButton( i18n(
"&View Difference"), w );
1617 lo2->addStretch( 1 );
1618 lo2->addWidget( btnDiff );
1619 connect( btnDiff, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotDiff()) );
1620 TQWhatsThis::add( btnDiff, i18n(
1621 "Calculates the difference between the editor contents and the disk "
1622 "file using diff(1) and opens the diff file with the default application "
1625 setButtonText( User1, i18n(
"Overwrite") );
1626 setButtonWhatsThis( User1, i18n(
"Overwrite the disk file with the editor content.") );
1629 showButton( User1,
false );
1632 KateModOnHdPrompt::~KateModOnHdPrompt()
1640 p->
setComm( TDEProcess::All );
1641 *p <<
"diff" <<
"-u" <<
"-" << m_doc->url().path();
1643 connect( p, TQ_SIGNAL(readReady(
KProcIO*)),
this, TQ_SLOT(slotPRead(
KProcIO*)) );
1645 setCursor( WaitCursor );
1649 uint lastln = m_doc->numLines();
1650 for ( uint l = 0; l < lastln; l++ )
1656 void KateModOnHdPrompt::slotPRead(
KProcIO *p)
1663 bool dataRead =
false;
1664 while ( p->
readln( stmp,
false ) > -1 )
1676 void KateModOnHdPrompt::slotPDone(
TDEProcess *p )
1678 setCursor( ArrowCursor );
1694 i18n(
"The diff command failed. Please make sure that "
1695 "diff(1) is installed and in your PATH."),
1696 i18n(
"Error Creating Diff") );
1702 KRun::runURL( m_tmpfile->
name(),
"text/x-diff",
true );
1707 void KateModOnHdPrompt::slotApply()
1711 i18n(
"Ignoring means that you will not be warned again (unless "
1712 "the disk file changes once more): if you save the document, you "
1713 "will overwrite the file on disk; if you do not save then the disk file "
1714 "(if present) is what you have."),
1715 i18n(
"You Are on Your Own"),
1717 "kate_ignore_modonhd" ) != KMessageBox::Continue )
1723 void KateModOnHdPrompt::slotOk()
1725 done( m_modtype == 3 ? Save : Reload );
1728 void KateModOnHdPrompt::slotUser1()
This widget will be embedded into a modal dialog when clicking the "Configure..." button in the inden...
TQString encodingForName(const TQString &descriptiveName)
TQTextCodec * codecForName(const TQString &name) const
TQVBox * addVBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
static void information(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
static void sorry(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
bool writeStdin(const TQString &line, bool appendnewline=true)
bool start(RunMode runmode=NotifyOnExit, bool includeStderr=false)
void setComm(Communication comm)
int readln(TQString &line, bool autoAck=true, bool *partial=0)
TQTextStream * textStream()
static bool hasConfigPage(uint mode)
Config page support.
static TQStringList listModes()
List all possible modes by name.
static IndenterConfigPage * configPage(TQWidget *parent, uint mode)
Support for a config page.
static TQString modeDescription(uint mode)
Return the mode description.
static void setMaxLoadedBlocks(uint count)
modifier for max loaded blocks limit
static uint maxLoadedBlocks()
maximal loaded block count
void slotDiff()
Show a diff between the document text and the disk file.
Store and manage the information about Syntax Highlighting.
static TDEStandardDirs * dirs()
static KCharsets * charsets()
TQString saveLocation(const char *type, const TQString &suffix=TQString::null, bool create=true) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
Kate namespace All classes in this namespace must stay BC during one major release series (e....
const TDEShortcut & insert()
TQString name(StdAccel id)
const TDEShortcut & reload()
TQString label(StdAccel id)