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

kate

  • kate
  • part
katedialogs.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2002, 2003 Anders Lund <anders.lund@lund.tdcadsl.dk>
3 Copyright (C) 2003 Christoph Cullmann <cullmann@kde.org>
4 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
5
6 Based on work of:
7 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License version 2 as published by the Free Software Foundation.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22*/
23
24//BEGIN Includes
25#include "katedialogs.h"
26#include "katedialogs.moc"
27
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"
35#include "kateview.h"
36
37
38#include <tdetexteditor/configinterfaceextension.h>
39#include <tdetexteditor/plugin.h>
40
41#include <tdeio/job.h>
42#include <tdeio/jobclasses.h>
43#include <tdeio/netaccess.h>
44
45#include <tdeaccel.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>
54#include <kdebug.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>
63#include <tdelocale.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>
70#include <tdeprocio.h>
71#include <kregexpeditorinterface.h>
72#include <krun.h>
73#include <kseparator.h>
74#include <tdestandarddirs.h>
75#include <tdetempfile.h>
76
77#include <tqbuttongroup.h>
78#include <tqcheckbox.h>
79#include <tqcombobox.h>
80#include <tqdialog.h>
81#include <tqdom.h>
82#include <tqfile.h>
83#include <tqgrid.h>
84#include <tqgroupbox.h>
85#include <tqhbox.h>
86#include <tqheader.h>
87#include <tqhgroupbox.h>
88#include <tqlabel.h>
89#include <tqlayout.h>
90#include <tqlineedit.h>
91#include <tqlistbox.h>
92#include <tqlistview.h>
93#include <tqmap.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>
106#include <tqvbox.h>
107#include <tqvgroupbox.h>
108#include <tqwhatsthis.h>
109#include <tqwidgetstack.h>
110
111#define HLDOWNLOADPATH "http://git.trinitydesktop.org/cgit/tdelibs/plain/kate/data/update-files.xml"
112
113//END
114
115//BEGIN KateConfigPage
116KateConfigPage::KateConfigPage ( TQWidget *parent, const char *name )
117 : Kate::ConfigPage (parent, name)
118 , m_changed (false)
119{
120 connect (this, TQ_SIGNAL(changed()), this, TQ_SLOT(somethingHasChanged ()));
121}
122
123KateConfigPage::~KateConfigPage ()
124{
125}
126
127void KateConfigPage::somethingHasChanged ()
128{
129 m_changed = true;
130 kdDebug (13000) << "TEST: something changed on the config page: " << this << endl;
131}
132//END KateConfigPage
133
134//BEGIN KateIndentConfigTab
135const 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
144};
145
146KateIndentConfigTab::KateIndentConfigTab(TQWidget *parent)
147 : KateConfigPage(parent)
148{
149 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint() );
150 int configFlags = KateDocumentConfig::global()->configFlags();
151
152 TQVGroupBox *gbAuto = new TQVGroupBox(i18n("Automatic Indentation"), this);
153
154 TQHBox *indentLayout = new TQHBox(gbAuto);
155 indentLayout->setSpacing(KDialog::spacingHint());
156 TQLabel *indentLabel = new TQLabel(i18n("&Indentation mode:"), indentLayout);
157 m_indentMode = new KComboBox (indentLayout);
158 m_indentMode->insertStringList (KateAutoIndent::listModes());
159 indentLabel->setBuddy(m_indentMode);
160 m_configPage = new TQPushButton(SmallIconSet("configure"), i18n("Configure..."), indentLayout);
161
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);
164
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);
169
170 indentationWidth = new KIntNumInput(KateDocumentConfig::global()->indentationWidth(), spaceLayout);
171 indentationWidth->setRange(1, 16, 1, false);
172 indentationWidth->setLabel(i18n("Number of spaces:"), AlignVCenter);
173
174 opt[1] = new TQCheckBox(i18n("Keep indent &profile"), this);
175 opt[2] = new TQCheckBox(i18n("&Keep extra spaces"), this);
176
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);
180
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 );
187
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]);
196
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);
203
204 layout->addStretch();
205
206 // What is this? help
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 "
211 "shortened."));
212 TQWhatsThis::add(opt[3], i18n(
213 "This allows the <b>Tab</b> key to be used to increase the indentation "
214 "level."));
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 "
220 "style comment."));
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."));
227
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.") );
231
232 reload ();
233
234 //
235 // after initial reload, connect the stuff for the changed () signal
236 //
237
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)));
240
241 connect( opt[0], TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(somethingToggled()));
242
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() ) );
251
252 connect(indentationWidth, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotChanged()));
253
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()));
257
258 connect(m_configPage, TQ_SIGNAL(clicked()), this, TQ_SLOT(configPage()));
259}
260
261void KateIndentConfigTab::somethingToggled() {
262 indentationWidth->setEnabled(opt[0]->isChecked());
263 opt[6]->setEnabled(opt[0]->isChecked());
264}
265
266void KateIndentConfigTab::indenterSelected (int index)
267{
268 if (index == KateDocumentConfig::imCStyle || index == KateDocumentConfig::imCSAndS)
269 opt[5]->setEnabled(true);
270 else
271 opt[5]->setEnabled(false);
272
273 m_configPage->setEnabled( KateAutoIndent::hasConfigPage(index) );
274}
275
276void KateIndentConfigTab::configPage()
277{
278 uint index = m_indentMode->currentItem();
279 if ( KateAutoIndent::hasConfigPage(index) )
280 {
281 KDialogBase dlg(this, "indenter_config_dialog", true, i18n("Configure Indenter"),
282 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Cancel, true);
283
284 TQVBox *box = new TQVBox(&dlg);
285 box->setSpacing( KDialog::spacingHint() );
286 dlg.setMainWidget(box);
287 new TQLabel("<qt><b>" + KateAutoIndent::modeDescription(index) + "</b></qt>", box);
288 new KSeparator(KSeparator::HLine, box);
289
290 IndenterConfigPage* page = KateAutoIndent::configPage(box, index);
291
292 if (!page) return;
293 box->setStretchFactor(page, 1);
294
295 connect( &dlg, TQ_SIGNAL(okClicked()), page, TQ_SLOT(apply()) );
296
297 dlg.resize(400, 300);
298 dlg.exec();
299 }
300}
301
302void KateIndentConfigTab::apply ()
303{
304 // nothing changed, no need to apply stuff
305 if (!changed())
306 return;
307 m_changed = false;
308
309 KateDocumentConfig::global()->configStart ();
310
311 int configFlags, z;
312
313 configFlags = KateDocumentConfig::global()->configFlags();
314 for (z = 0; z < numFlags; z++) {
315 configFlags &= ~flags[z];
316 if (opt[z]->isChecked()) configFlags |= flags[z];
317 }
318
319 KateDocumentConfig::global()->setConfigFlags(configFlags);
320 KateDocumentConfig::global()->setIndentationWidth(indentationWidth->value());
321
322 KateDocumentConfig::global()->setIndentationMode(m_indentMode->currentItem());
323
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()));
326
327 KateDocumentConfig::global()->configEnd ();
328}
329
330void KateIndentConfigTab::reload ()
331{
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);
336 else
337 m_tabs->setButton (0);
338
339 m_indentMode->setCurrentItem (KateDocumentConfig::global()->indentationMode());
340
341 somethingToggled ();
342 indenterSelected (m_indentMode->currentItem());
343}
344//END KateIndentConfigTab
345
346//BEGIN KateSelectConfigTab
347const int KateSelectConfigTab::flags[] = {};
348
349KateSelectConfigTab::KateSelectConfigTab(TQWidget *parent)
350 : KateConfigPage(parent)
351{
352 int configFlags = KateDocumentConfig::global()->configFlags();
353
354 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint() );
355
356 TQVGroupBox *gbCursor = new TQVGroupBox(i18n("Text Cursor Movement"), this);
357
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()));
361
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()));
365
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()));
369
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()));
374
375 layout->addWidget(gbCursor);
376
377 TQRadioButton *rb1, *rb2;
378
379 m_tabs = new TQButtonGroup( 1, TQt::Horizontal, i18n("Selection Mode"), this );
380 layout->add (m_tabs);
381
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 );
385
386 layout->addStretch();
387
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."));
393
394 TQWhatsThis::add(e4, i18n(
395 "Sets the number of lines to maintain visible above and below the "
396 "cursor when possible."));
397
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."));
402
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."));
409
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."));
411
412
413 reload ();
414
415 //
416 // after initial reload, connect the stuff for the changed () signal
417 //
418
419 connect(rb1, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
420 connect(rb2, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotChanged()));
421}
422
423void KateSelectConfigTab::apply ()
424{
425 // nothing changed, no need to apply stuff
426 if (!changed())
427 return;
428 m_changed = false;
429
430 KateViewConfig::global()->configStart ();
431 KateDocumentConfig::global()->configStart ();
432
433 int configFlags = KateDocumentConfig::global()->configFlags();
434
435 configFlags &= ~KateDocumentConfig::cfSmartHome;
436 configFlags &= ~KateDocumentConfig::cfWrapCursor;
437
438 if (opt[0]->isChecked()) configFlags |= KateDocumentConfig::cfSmartHome;
439 if (opt[1]->isChecked()) configFlags |= KateDocumentConfig::cfWrapCursor;
440
441 KateDocumentConfig::global()->setConfigFlags(configFlags);
442
443 KateViewConfig::global()->setAutoCenterLines(kMax(0, e4->value()));
444 KateDocumentConfig::global()->setPageUpDownMovesCursor(e6->isChecked());
445
446 KateViewConfig::global()->setPersistentSelection (m_tabs->id (m_tabs->selected()) == 1);
447
448 KateDocumentConfig::global()->configEnd ();
449 KateViewConfig::global()->configEnd ();
450}
451
452void KateSelectConfigTab::reload ()
453{
454 if (KateViewConfig::global()->persistentSelection())
455 m_tabs->setButton (1);
456 else
457 m_tabs->setButton (0);
458}
459//END KateSelectConfigTab
460
461//BEGIN KateEditConfigTab
462const int KateEditConfigTab::flags[] = {KateDocument::cfWordWrap,
463 KateDocument::cfAutoBrackets, KateDocument::cfShowTabs,
464 KateDocumentConfig::cfReplaceTabsDyn, KateDocumentConfig::cfRemoveTrailingDyn};
465
466KateEditConfigTab::KateEditConfigTab(TQWidget *parent)
467 : KateConfigPage(parent)
468{
469 TQVBoxLayout *mainLayout = new TQVBoxLayout(this, 0, KDialog::spacingHint() );
470 int configFlags = KateDocumentConfig::global()->configFlags();
471
472 TQVGroupBox *gbWhiteSpace = new TQVGroupBox(i18n("Tabulators"), this);
473
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()) );
477
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()));
481
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()));
486
487 mainLayout->addWidget(gbWhiteSpace);
488
489 TQVGroupBox *gbWordWrap = new TQVGroupBox(i18n("Static Word Wrap"), this);
490
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()));
494
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()));
498
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()));
503
504 mainLayout->addWidget(gbWordWrap);
505
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()) );
510
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()));
515
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()));
522
523 TQHBoxLayout *e5Layout = new TQHBoxLayout(mainLayout);
524 TQLabel *e5Label = new TQLabel(i18n("Smart search t&ext from:"), this);
525 e5Layout->addWidget(e5Label);
526 e5 = new KComboBox (this);
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()));
536
537 mainLayout->addStretch();
538
539 // What is this? help
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 "
556 "the text."));
557
558 TQWhatsThis::add(e3, i18n(
559 "Sets the number of undo/redo steps to record. More steps uses more memory."));
560
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): "
564 "<br>"
565 "<ul>"
566 "<li><b>Nowhere:</b> Don't guess the search text."
567 "</li>"
568 "<li><b>Selection Only:</b> Use the current text selection, "
569 "if available."
570 "</li>"
571 "<li><b>Selection, then Current Word:</b> Use the current "
572 "selection if available, otherwise use the current word."
573 "</li>"
574 "<li><b>Current Word Only:</b> Use the word that the cursor "
575 "is currently resting on, if available."
576 "</li>"
577 "<li><b>Current Word, then Selection:</b> Use the current "
578 "word if available, otherwise use the current selection."
579 "</li>"
580 "</ul>"
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 "
597 "pitch font." ));
598}
599
600void KateEditConfigTab::apply ()
601{
602 // nothing changed, no need to apply stuff
603 if (!changed())
604 return;
605 m_changed = false;
606
607 KateViewConfig::global()->configStart ();
608 KateDocumentConfig::global()->configStart ();
609
610 int configFlags, z;
611
612 configFlags = KateDocumentConfig::global()->configFlags();
613 for (z = 1; z < numFlags; z++) {
614 configFlags &= ~flags[z];
615 if (opt[z]->isChecked()) configFlags |= flags[z];
616 }
617 KateDocumentConfig::global()->setConfigFlags(configFlags);
618
619 KateDocumentConfig::global()->setWordWrapAt(e1->value());
620 KateDocumentConfig::global()->setWordWrap (opt[0]->isChecked());
621 KateDocumentConfig::global()->setTabWidth(e2->value());
622
623 if (e3->value() <= 0)
624 KateDocumentConfig::global()->setUndoSteps(0);
625 else
626 KateDocumentConfig::global()->setUndoSteps(e3->value());
627
628 KateViewConfig::global()->setTextToSearchMode(e5->currentItem());
629
630 KateRendererConfig::global()->setWordWrapMarker (m_wwmarker->isChecked());
631
632 KateDocumentConfig::global()->configEnd ();
633 KateViewConfig::global()->configEnd ();
634}
635
636void KateEditConfigTab::reload ()
637{
638}
639//END KateEditConfigTab
640
641//BEGIN KateViewDefaultsConfig
642KateViewDefaultsConfig::KateViewDefaultsConfig(TQWidget *parent)
643 :KateConfigPage(parent)
644{
645 TQRadioButton *rb1;
646 TQRadioButton *rb2;
647
648 TQVBoxLayout *blay=new TQVBoxLayout(this,0,KDialog::spacingHint());
649
650 TQVGroupBox *gbWordWrap = new TQVGroupBox(i18n("Word Wrap"), this);
651
652 m_dynwrap=new TQCheckBox(i18n("&Dynamic word wrap"),gbWordWrap);
653
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);
661
662 m_dynwrapAlignLevel = new KIntNumInput(gbWordWrap);
663 m_dynwrapAlignLevel->setLabel(i18n("Vertically align dynamically wrapped lines to indentation depth:"));
664 m_dynwrapAlignLevel->setRange(0, 80, 10);
665 // xgettext:no-c-format
666 m_dynwrapAlignLevel->setSuffix(i18n("% of View Width"));
667 m_dynwrapAlignLevel->setSpecialValueText(i18n("Disabled"));
668
669 blay->addWidget(gbWordWrap);
670
671 TQVGroupBox *gbFold = new TQVGroupBox(i18n("Code Folding"), this);
672
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 ();
676
677 blay->addWidget(gbFold);
678
679 TQVGroupBox *gbBar = new TQVGroupBox(i18n("Borders"), this);
680
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);
684
685 blay->addWidget(gbBar);
686
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 );
691
692 blay->addWidget(m_bmSort, 0 );
693
694 m_showIndentLines = new TQCheckBox(i18n("Show indentation lines"), this);
695 m_showIndentLines->setChecked(KateRendererConfig::global()->showIndentationLines());
696 blay->addWidget(m_showIndentLines);
697
698 blay->addStretch(1000);
699
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);
706 // xgettext:no-c-format
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, "
722 "for instance."));
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 "
726 "bookmarks."));
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.") );
740
741 reload();
742
743 //
744 // after initial reload, connect the stuff for the changed () signal
745 //
746
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()));
758}
759
760KateViewDefaultsConfig::~KateViewDefaultsConfig()
761{
762}
763
764void KateViewDefaultsConfig::apply ()
765{
766 // nothing changed, no need to apply stuff
767 if (!changed())
768 return;
769 m_changed = false;
770
771 KateViewConfig::global()->configStart ();
772 KateRendererConfig::global()->configStart ();
773
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()));
782
783 KateRendererConfig::global()->setShowIndentationLines(m_showIndentLines->isChecked());
784
785 KateRendererConfig::global()->configEnd ();
786 KateViewConfig::global()->configEnd ();
787}
788
789void KateViewDefaultsConfig::reload ()
790{
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());
800}
801
802void KateViewDefaultsConfig::reset () {;}
803
804void KateViewDefaultsConfig::defaults (){;}
805//END KateViewDefaultsConfig
806
807//BEGIN KateEditKeyConfiguration
808
809KateEditKeyConfiguration::KateEditKeyConfiguration( TQWidget* parent, KateDocument* doc )
810 : KateConfigPage( parent )
811{
812 m_doc = doc;
813 m_ready = false;
814}
815
816void KateEditKeyConfiguration::showEvent ( TQShowEvent * )
817{
818 if (!m_ready)
819 {
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 ();
826
827 m_ready = true;
828 }
829
830 TQWidget::show ();
831}
832
833void KateEditKeyConfiguration::apply()
834{
835 if ( ! changed() )
836 return;
837 m_changed = false;
838
839 if (m_ready)
840 {
841 m_keyChooser->commitChanges();
842 m_ac->writeShortcutSettings( "Katepart Shortcuts" );
843 }
844}
845//END KateEditKeyConfiguration
846
847//BEGIN KateSaveConfigTab
848KateSaveConfigTab::KateSaveConfigTab( TQWidget *parent )
849 : KateConfigPage( parent )
850{
851 int configFlags = KateDocumentConfig::global()->configFlags();
852 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint() );
853
854 TQVGroupBox *gbEnc = new TQVGroupBox(i18n("File Format"), this);
855 layout->addWidget( gbEnc );
856
857 TQHBox *e5Layout = new TQHBox(gbEnc);
858 TQLabel *e5Label = new TQLabel(i18n("&Encoding:"), e5Layout);
859 m_encoding = new KComboBox (e5Layout);
860 e5Label->setBuddy(m_encoding);
861
862 e5Layout = new TQHBox(gbEnc);
863 e5Label = new TQLabel(i18n("End &of line:"), e5Layout);
864 m_eol = new KComboBox (e5Layout);
865 e5Label->setBuddy(m_eol);
866
867 allowEolDetection = new TQCheckBox(i18n("&Automatic end of line detection"), gbEnc);
868
869 m_eol->insertItem (i18n("UNIX"));
870 m_eol->insertItem (i18n("DOS/Windows"));
871 m_eol->insertItem (i18n("Macintosh"));
872
873 TQVGroupBox *gbMem = new TQVGroupBox(i18n("Memory Usage"), this);
874 layout->addWidget( gbMem );
875
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);
880
881 blockCount->setValue (KateBuffer::maxLoadedBlocks());
882 blockCountLabel->setBuddy(blockCount);
883
884 TQVGroupBox *gbWhiteSpace = new TQVGroupBox(i18n("Automatic Cleanups on Load/Save"), this);
885 layout->addWidget( gbWhiteSpace );
886
887 removeSpaces = new TQCheckBox(i18n("Re&move trailing spaces"), gbWhiteSpace);
888 removeSpaces->setChecked(configFlags & KateDocument::cfRemoveSpaces);
889
890 TQVGroupBox *dirConfigBox = new TQVGroupBox(i18n("Folder Config File"), this);
891 layout->addWidget( dirConfigBox );
892
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);
897
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 );
902
903 TQHBox *hbBuPrefix = new TQHBox( gb );
904 TQLabel *lBuPrefix = new TQLabel( i18n("&Prefix:"), hbBuPrefix );
905 leBuPrefix = new TQLineEdit( hbBuPrefix );
906 lBuPrefix->setBuddy( leBuPrefix );
907
908 TQHBox *hbBuSuffix = new TQHBox( gb );
909 TQLabel *lBuSuffix = new TQLabel( i18n("&Suffix:"), hbBuSuffix );
910 leBuSuffix = new TQLineEdit( hbBuSuffix );
911 lBuSuffix->setBuddy( leBuSuffix );
912
913 layout->addStretch();
914
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 "'&lt;prefix&gt;&lt;filename&gt;&lt;suffix&gt;' 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."));
943
944 reload();
945
946 //
947 // after initial reload, connect the stuff for the changed () signal
948 //
949
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() ) );
960}
961
962void KateSaveConfigTab::apply()
963{
964 // nothing changed, no need to apply stuff
965 if (!changed())
966 return;
967 m_changed = false;
968
969 KateBuffer::setMaxLoadedBlocks (blockCount->value());
970
971 KateDocumentConfig::global()->configStart ();
972
973 if ( leBuSuffix->text().isEmpty() && leBuPrefix->text().isEmpty() ) {
974 KMessageBox::information(
975 this,
976 i18n("You did not provide a backup suffix or prefix. Using default suffix: '~'"),
977 i18n("No Backup Suffix or Prefix")
978 );
979 leBuSuffix->setText( "~" );
980 }
981
982 uint f( 0 );
983 if ( cbLocalFiles->isChecked() )
984 f |= KateDocumentConfig::LocalFiles;
985 if ( cbRemoteFiles->isChecked() )
986 f |= KateDocumentConfig::RemoteFiles;
987
988 KateDocumentConfig::global()->setBackupFlags(f);
989 KateDocumentConfig::global()->setBackupPrefix(leBuPrefix->text());
990 KateDocumentConfig::global()->setBackupSuffix(leBuSuffix->text());
991
992 KateDocumentConfig::global()->setSearchDirConfigDepth(dirSearchDepth->value());
993
994 int configFlags = KateDocumentConfig::global()->configFlags();
995
996 configFlags &= ~KateDocument::cfRemoveSpaces; // clear flag
997 if (removeSpaces->isChecked()) configFlags |= KateDocument::cfRemoveSpaces; // set flag if checked
998
999 KateDocumentConfig::global()->setConfigFlags(configFlags);
1000
1001 KateDocumentConfig::global()->setEncoding((m_encoding->currentItem() == 0) ? "" : TDEGlobal::charsets()->encodingForName(m_encoding->currentText()));
1002
1003 KateDocumentConfig::global()->setEol(m_eol->currentItem());
1004 KateDocumentConfig::global()->setAllowEolDetection(allowEolDetection->isChecked());
1005
1006 KateDocumentConfig::global()->configEnd ();
1007}
1008
1009void KateSaveConfigTab::reload()
1010{
1011 // encoding
1012 m_encoding->clear ();
1013 m_encoding->insertItem (i18n("TDE Default"));
1014 m_encoding->setCurrentItem(0);
1015 TQStringList encodings (TDEGlobal::charsets()->descriptiveEncodingNames());
1016 int insert = 1;
1017 for (uint i=0; i < encodings.count(); i++)
1018 {
1019 bool found = false;
1020 TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encodings[i]), found);
1021
1022 if (found)
1023 {
1024 m_encoding->insertItem (encodings[i]);
1025
1026 if ( codecForEnc->name() == KateDocumentConfig::global()->encoding() )
1027 {
1028 m_encoding->setCurrentItem(insert);
1029 }
1030
1031 insert++;
1032 }
1033 }
1034
1035 // eol
1036 m_eol->setCurrentItem(KateDocumentConfig::global()->eol());
1037 allowEolDetection->setChecked(KateDocumentConfig::global()->allowEolDetection());
1038
1039 dirSearchDepth->setValue(KateDocumentConfig::global()->searchDirConfigDepth());
1040
1041 // other stuff
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() );
1047}
1048
1049void KateSaveConfigTab::reset()
1050{
1051}
1052
1053void KateSaveConfigTab::defaults()
1054{
1055 cbLocalFiles->setChecked( true );
1056 cbRemoteFiles->setChecked( false );
1057 leBuPrefix->setText( "" );
1058 leBuSuffix->setText( "~" );
1059}
1060
1061//END KateSaveConfigTab
1062
1063//BEGIN PluginListItem
1064class KatePartPluginListItem : public TQCheckListItem
1065{
1066 public:
1067 KatePartPluginListItem(bool checked, uint i, const TQString &name, TQListView *parent);
1068 uint pluginIndex () const { return index; }
1069
1070 protected:
1071 void stateChange(bool);
1072
1073 private:
1074 uint index;
1075 bool silentStateChange;
1076};
1077
1078KatePartPluginListItem::KatePartPluginListItem(bool checked, uint i, const TQString &name, TQListView *parent)
1079 : TQCheckListItem(parent, name, CheckBox)
1080 , index(i)
1081 , silentStateChange(false)
1082{
1083 silentStateChange = true;
1084 setOn(checked);
1085 silentStateChange = false;
1086}
1087
1088void KatePartPluginListItem::stateChange(bool b)
1089{
1090 if(!silentStateChange)
1091 static_cast<KatePartPluginListView *>(listView())->stateChanged(this, b);
1092}
1093//END
1094
1095//BEGIN PluginListView
1096KatePartPluginListView::KatePartPluginListView(TQWidget *parent, const char *name)
1097 : TDEListView(parent, name)
1098{
1099}
1100
1101void KatePartPluginListView::stateChanged(KatePartPluginListItem *item, bool b)
1102{
1103 emit stateChange(item, b);
1104}
1105//END
1106
1107//BEGIN KatePartPluginConfigPage
1108KatePartPluginConfigPage::KatePartPluginConfigPage (TQWidget *parent) : KateConfigPage (parent, "")
1109{
1110 // sizemanagment
1111 TQGridLayout *grid = new TQGridLayout( this, 1, 1 );
1112 grid->setSpacing( KDialogBase::spacingHint() );
1113
1114 listView = new KatePartPluginListView(this);
1115 listView->addColumn(i18n("Name"));
1116 listView->addColumn(i18n("Comment"));
1117
1118 grid->addWidget( listView, 0, 0);
1119
1120 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
1121 {
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());
1125
1126 m_items.append (item);
1127 }
1128
1129 // configure button
1130
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()) );
1135
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()));
1140}
1141
1142KatePartPluginConfigPage::~KatePartPluginConfigPage ()
1143{
1144}
1145
1146void KatePartPluginConfigPage::apply ()
1147{
1148 // nothing changed, no need to apply stuff
1149 if (!changed())
1150 return;
1151 m_changed = false;
1152
1153 KateDocumentConfig::global()->configStart ();
1154
1155 for (uint i=0; i < m_items.count(); i++)
1156 KateDocumentConfig::global()->setPlugin (m_items.at(i)->pluginIndex(), m_items.at(i)->isOn());
1157
1158 KateDocumentConfig::global()->configEnd ();
1159}
1160
1161void KatePartPluginConfigPage::slotStateChanged( KatePartPluginListItem *item, bool b )
1162{
1163 if ( b )
1164 slotCurrentChanged( (TQListViewItem*)item );
1165}
1166
1167void KatePartPluginConfigPage::slotCurrentChanged( TQListViewItem* i )
1168{
1169 KatePartPluginListItem *item = static_cast<KatePartPluginListItem *>(i);
1170 if ( ! item ) return;
1171
1172 bool b = false;
1173 if ( item->isOn() )
1174 {
1175
1176 // load this plugin, and see if it has config pages
1177 KTextEditor::Plugin *plugin = KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1178 if ( plugin ) {
1179 KTextEditor::ConfigInterfaceExtension *cie = KTextEditor::configInterfaceExtension( plugin );
1180 b = ( cie && cie->configPages() );
1181 }
1182
1183 }
1184 btnConfigure->setEnabled( b );
1185}
1186
1187void KatePartPluginConfigPage::slotConfigure()
1188{
1189 KatePartPluginListItem *item = static_cast<KatePartPluginListItem*>(listView->currentItem());
1190 KTextEditor::Plugin *plugin =
1191 KTextEditor::createPlugin(TQFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
1192
1193 if ( ! plugin ) return;
1194
1195 KTextEditor::ConfigInterfaceExtension *cife =
1196 KTextEditor::configInterfaceExtension( plugin );
1197
1198 if ( ! cife )
1199 return;
1200
1201 if ( ! cife->configPages() )
1202 return;
1203
1204 // If we have only one page, we use a simple dialog, else an icon list type
1205 KDialogBase::DialogType dt =
1206 cife->configPages() > 1 ?
1207 KDialogBase::IconList : // still untested
1208 KDialogBase::Plain;
1209
1210 TQString name = (KateFactory::self()->plugins())[item->pluginIndex()]->name();
1211 KDialogBase *kd = new KDialogBase ( dt,
1212 i18n("Configure %1").arg( name ),
1213 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help,
1214 KDialogBase::Ok,
1215 this );
1216
1217 TQPtrList<KTextEditor::ConfigPage> editorPages;
1218
1219 for (uint i = 0; i < cife->configPages (); i++)
1220 {
1221 TQWidget *page;
1222 if ( dt == KDialogBase::IconList )
1223 {
1224 TQStringList path;
1225 path.clear();
1226 path << cife->configPageName( i );
1227 page = kd->addVBoxPage( path, cife->configPageFullName (i),
1228 cife->configPagePixmap(i, TDEIcon::SizeMedium) );
1229 }
1230 else
1231 {
1232 page = kd->plainPage();
1233 TQVBoxLayout *_l = new TQVBoxLayout( page );
1234 _l->setAutoAdd( true );
1235 }
1236
1237 editorPages.append( cife->configPage( i, page ) );
1238 }
1239
1240 if (kd->exec())
1241 {
1242
1243 for( uint i=0; i<editorPages.count(); i++ )
1244 {
1245 editorPages.at( i )->apply();
1246 }
1247 }
1248
1249 delete kd;
1250}
1251//END KatePartPluginConfigPage
1252
1253//BEGIN KateHlConfigPage
1254KateHlConfigPage::KateHlConfigPage (TQWidget *parent, KateDocument *doc)
1255 : KateConfigPage (parent, "")
1256 , hlData (0)
1257 , m_doc (doc)
1258{
1259 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint() );
1260
1261 // hl chooser
1262 TQHBox *hbHl = new TQHBox( this );
1263 layout->add (hbHl);
1264
1265 hbHl->setSpacing( KDialog::spacingHint() );
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)) );
1271
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));
1275 else
1276 hlCombo->insertItem(KateHlManager::self()->hlNameTranslated(i));
1277 }
1278
1279 TQGroupBox *gbInfo = new TQGroupBox( 1, TQt::Horizontal, i18n("Information"), this );
1280 layout->add (gbInfo);
1281
1282 // author
1283 TQHBox *hb1 = new TQHBox( gbInfo);
1284 new TQLabel( i18n("Author:"), hb1 );
1285 author = new TQLabel (hb1);
1286 author->setTextFormat (TQt::RichText);
1287
1288 // license
1289 TQHBox *hb2 = new TQHBox( gbInfo);
1290 new TQLabel( i18n("License:"), hb2 );
1291 license = new TQLabel (hb2);
1292
1293 TQGroupBox *gbProps = new TQGroupBox( 1, TQt::Horizontal, i18n("Properties"), this );
1294 layout->add (gbProps);
1295
1296 // file & mime types
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 );
1301
1302 TQHBox *hbMT = new TQHBox( gbProps );
1303 TQLabel *lMimeTypes = new TQLabel( i18n("MIME &types:"), hbMT);
1304 mimetypes = new TQLineEdit( hbMT );
1305 lMimeTypes->setBuddy( mimetypes );
1306
1307 TQHBox *hbMT2 = new TQHBox( gbProps );
1308 TQLabel *lprio = new TQLabel( i18n("Prio&rity:"), hbMT2);
1309 priority = new KIntNumInput( hbMT2 );
1310
1311 lprio->setBuddy( priority );
1312
1313 TQToolButton *btnMTW = new TQToolButton(hbMT);
1314 btnMTW->setIconSet(TQIconSet(SmallIcon("wizard")));
1315 connect(btnMTW, TQ_SIGNAL(clicked()), this, TQ_SLOT(showMTDlg()));
1316
1317 // download/new buttons
1318 TQHBox *hbBtns = new TQHBox( this );
1319 layout->add (hbBtns);
1320
1321 ((TQBoxLayout*)hbBtns->layout())->addStretch(1); // hmm.
1322 hbBtns->setSpacing( KDialog::spacingHint() );
1323 TQPushButton *btnDl = new TQPushButton(i18n("Do&wnload..."), hbBtns);
1324 connect( btnDl, TQ_SIGNAL(clicked()), this, TQ_SLOT(hlDownload()) );
1325
1326 int currentHl = m_doc ? m_doc->hlMode() : 0;
1327 hlCombo->setCurrentItem( currentHl );
1328 hlChanged( currentHl );
1329
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.") );
1347
1348 layout->addStretch ();
1349
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() ) );
1353}
1354
1355KateHlConfigPage::~KateHlConfigPage ()
1356{
1357}
1358
1359void KateHlConfigPage::apply ()
1360{
1361 // nothing changed, no need to apply stuff
1362 if (!changed())
1363 return;
1364 m_changed = false;
1365
1366 writeback();
1367
1368 for ( TQIntDictIterator<KateHlData> it( hlDataDict ); it.current(); ++it )
1369 KateHlManager::self()->getHl( it.currentKey() )->setData( it.current() );
1370
1371 KateHlManager::self()->getTDEConfig()->sync ();
1372}
1373
1374void KateHlConfigPage::reload ()
1375{
1376}
1377
1378void KateHlConfigPage::hlChanged(int z)
1379{
1380 writeback();
1381
1382 KateHighlighting *hl = KateHlManager::self()->getHl( z );
1383
1384 if (!hl)
1385 {
1386 hlData = 0;
1387 return;
1388 }
1389
1390 if ( !hlDataDict.find( z ) )
1391 hlDataDict.insert( z, hl->getData() );
1392
1393 hlData = hlDataDict.find( z );
1394 wildcards->setText(hlData->wildcards);
1395 mimetypes->setText(hlData->mimetypes);
1396 priority->setValue(hlData->priority);
1397
1398 // split author string if needed into multiple lines !
1399 TQStringList l= TQStringList::split (TQRegExp("[,;]"), hl->author());
1400 author->setText (l.join ("<br>"));
1401
1402 license->setText (hl->license());
1403}
1404
1405void KateHlConfigPage::writeback()
1406{
1407 if (hlData)
1408 {
1409 hlData->wildcards = wildcards->text();
1410 hlData->mimetypes = mimetypes->text();
1411 hlData->priority = priority->value();
1412 }
1413}
1414
1415void KateHlConfigPage::hlDownload()
1416{
1417 KateHlDownloadDialog diag(this,"hlDownload",true);
1418 diag.exec();
1419}
1420
1421void KateHlConfigPage::showMTDlg()
1422{
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 );
1426
1427 if ( d.exec() == KDialogBase::Accepted ) {
1428 // do some checking, warn user if mime types or patterns are removed.
1429 // if the lists are empty, and the fields not, warn.
1430 wildcards->setText(d.chooser()->patterns().join(";"));
1431 mimetypes->setText(d.chooser()->mimeTypes().join(";"));
1432 }
1433}
1434//END KateHlConfigPage
1435
1436//BEGIN KateHlDownloadDialog
1437KateHlDownloadDialog::KateHlDownloadDialog(TQWidget *parent, const char *name, bool modal)
1438 :KDialogBase(KDialogBase::Swallow, i18n("Highlight Download"), User1|Close, User1, parent, name, modal, true, i18n("&Install"))
1439{
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);
1451
1452 new TQLabel(i18n("<b>Note:</b> New versions are selected automatically."), vbox);
1453 actionButton (User1)->setIconSet(SmallIconSet("ok"));
1454
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 &)));
1458// void data( TDEIO::Job *, const TQByteArray &data);
1459 resize(450, 400);
1460}
1461
1462KateHlDownloadDialog::~KateHlDownloadDialog(){}
1463
1464void KateHlDownloadDialog::listDataReceived(TDEIO::Job *, const TQByteArray &data)
1465{
1466 if (!transferJob || transferJob->isErrorPage())
1467 {
1468 actionButton(User1)->setEnabled(false);
1469 return;
1470 }
1471
1472 listData+=TQString(data);
1473 kdDebug(13000)<<TQString("CurrentListData: ")<<listData<<endl<<endl;
1474 kdDebug(13000)<<TQString(TQString("Data length: %1").arg(data.size()))<<endl;
1475 kdDebug(13000)<<TQString(TQString("listData length: %1").arg(listData.length()))<<endl;
1476 if (data.size()==0)
1477 {
1478 if (listData.length()>0)
1479 {
1480 TQString installedVersion;
1481 KateHlManager *hlm=KateHlManager::self();
1482 TQDomDocument doc;
1483 doc.setContent(listData);
1484 TQDomElement DocElem=doc.documentElement();
1485 TQDomNode n=DocElem.firstChild();
1486 KateHighlighting *hl = 0;
1487
1488 if (n.isNull()) kdDebug(13000)<<"There is no usable childnode"<<endl;
1489 while (!n.isNull())
1490 {
1491 installedVersion=" --";
1492
1493 TQDomElement e=n.toElement();
1494 if (!e.isNull())
1495 kdDebug(13000)<<TQString("NAME: ")<<e.tagName()<<TQString(" - ")<<e.attribute("name")<<endl;
1496 n=n.nextSibling();
1497
1498 TQString Name=e.attribute("name");
1499
1500 for (int i=0;i<hlm->highlights();i++)
1501 {
1502 hl=hlm->getHl(i);
1503 if (hl && hl->name()==Name)
1504 {
1505 installedVersion=" "+hl->version();
1506 break;
1507 }
1508 else hl = 0;
1509 }
1510
1511 // autoselect entry if new or updated.
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"))
1516 {
1517 entry->setSelected(true);
1518 entry->setPixmap(0, SmallIcon(("knewstuff")));
1519 }
1520 }
1521 }
1522 }
1523}
1524
1525void KateHlDownloadDialog::slotUser1()
1526{
1527 TQString destdir=TDEGlobal::dirs()->saveLocation("data","katepart/syntax/");
1528 for (TQListViewItem *it=list->firstChild();it;it=it->nextSibling())
1529 {
1530 if (list->isSelected(it))
1531 {
1532 KURL src(it->text(4));
1533 TQString filename=src.fileName(false);
1534 TQString dest = destdir+filename;
1535
1536 TDEIO::NetAccess::download(src,dest, this);
1537 }
1538 }
1539
1540 // update Config !!
1541 KateSyntaxDocument doc (true);
1542}
1543//END KateHlDownloadDialog
1544
1545//BEGIN KateGotoLineDialog
1546KateGotoLineDialog::KateGotoLineDialog(TQWidget *parent, int line, int max)
1547 : KDialogBase(parent, 0L, true, i18n("Go to Line"), Ok | Cancel, Ok) {
1548
1549 TQWidget *page = new TQWidget(this);
1550 setMainWidget(page);
1551
1552 TQVBoxLayout *topLayout = new TQVBoxLayout( page, 0, spacingHint() );
1553 e1 = new KIntNumInput(line, page);
1554 e1->setRange(1, max);
1555 e1->setEditFocus(true);
1556
1557 TQLabel *label = new TQLabel( e1,i18n("&Go to line:"), page );
1558 topLayout->addWidget(label);
1559 topLayout->addWidget(e1);
1560 topLayout->addSpacing(spacingHint()); // A little bit extra space
1561 topLayout->addStretch(10);
1562 e1->setFocus();
1563}
1564
1565int KateGotoLineDialog::getLine() {
1566 return e1->value();
1567}
1568//END KateGotoLineDialog
1569
1570//BEGIN KateModOnHdPrompt
1571KateModOnHdPrompt::KateModOnHdPrompt( KateDocument *doc,
1572 int modtype,
1573 const TQString &reason,
1574 TQWidget *parent )
1575 : KDialogBase( parent, "", true, "", Ok|Apply|Cancel|User1 ),
1576 m_doc( doc ),
1577 m_modtype ( modtype ),
1578 m_tmpfile( 0 )
1579{
1580 TQString title, btnOK, whatisok;
1581 if ( modtype == 3 ) // deleted
1582 {
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.");
1586 } else {
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.");
1591 }
1592
1593 setButtonText( Ok, btnOK);
1594 setButtonText( Apply, i18n("&Ignore") );
1595
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.") );
1600
1601 enableButtonSeparator( true );
1602 setCaption( title );
1603
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 ) );
1611
1612 // If the file isn't deleted, present a diff button, and a overwrite action.
1613 if ( modtype != 3 )
1614 {
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 "
1623 "for that.") );
1624
1625 setButtonText( User1, i18n("Overwrite") );
1626 setButtonWhatsThis( User1, i18n("Overwrite the disk file with the editor content.") );
1627 }
1628 else
1629 showButton( User1, false );
1630}
1631
1632KateModOnHdPrompt::~KateModOnHdPrompt()
1633{
1634}
1635
1636void KateModOnHdPrompt::slotDiff()
1637{
1638 // Start a TDEProcess that creates a diff
1639 TDEProcIO *p = new TDEProcIO();
1640 p->setComm( TDEProcess::All );
1641 *p << "diff" << "-u" << "-" << m_doc->url().path();
1642 connect( p, TQ_SIGNAL(processExited(TDEProcess*)), this, TQ_SLOT(slotPDone(TDEProcess*)) );
1643 connect( p, TQ_SIGNAL(readReady(TDEProcIO*)), this, TQ_SLOT(slotPRead(TDEProcIO*)) );
1644
1645 setCursor( WaitCursor );
1646
1647 p->start( TDEProcess::NotifyOnExit, true );
1648
1649 uint lastln = m_doc->numLines();
1650 for ( uint l = 0; l < lastln; l++ )
1651 p->writeStdin( m_doc->textLine( l ) );
1652
1653 p->closeWhenDone();
1654}
1655
1656void KateModOnHdPrompt::slotPRead( TDEProcIO *p)
1657{
1658 // create a file for the diff if we haven't one allready
1659 if ( ! m_tmpfile )
1660 m_tmpfile = new KTempFile();
1661 // put all the data we have in it
1662 TQString stmp;
1663 bool dataRead = false;
1664 while ( p->readln( stmp, false ) > -1 )
1665 {
1666 *m_tmpfile->textStream() << stmp << endl;
1667 dataRead = true;
1668 }
1669
1670 // dominik: only ackRead(), when we *really* read data, otherwise, this slot
1671 // is called initity times, which leads to a crash
1672 if( dataRead )
1673 p->ackRead();
1674}
1675
1676void KateModOnHdPrompt::slotPDone( TDEProcess *p )
1677{
1678 setCursor( ArrowCursor );
1679 if( ! m_tmpfile )
1680 {
1681 // dominik: there were only whitespace changes, so that the diff returned by
1682 // diff(1) has 0 bytes. So slotPRead() is never called, as there is
1683 // no data, so that m_tmpfile was never created and thus is NULL.
1684 // NOTE: would be nice, if we could produce a fake-diff, so that kompare
1685 // tells us "The files are identical". Right now, we get an ugly
1686 // "Could not parse diff output".
1687 m_tmpfile = new KTempFile();
1688 }
1689 m_tmpfile->close();
1690
1691 if ( ! p->normalExit() /*|| p->exitStatus()*/ )
1692 {
1693 KMessageBox::sorry( this,
1694 i18n("The diff command failed. Please make sure that "
1695 "diff(1) is installed and in your PATH."),
1696 i18n("Error Creating Diff") );
1697 delete m_tmpfile;
1698 m_tmpfile = 0;
1699 return;
1700 }
1701
1702 KRun::runURL( m_tmpfile->name(), "text/x-diff", true );
1703 delete m_tmpfile;
1704 m_tmpfile = 0;
1705}
1706
1707void KateModOnHdPrompt::slotApply()
1708{
1709 if ( KMessageBox::warningContinueCancel(
1710 this,
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"),
1716 KStdGuiItem::cont(),
1717 "kate_ignore_modonhd" ) != KMessageBox::Continue )
1718 return;
1719
1720 done(Ignore);
1721}
1722
1723void KateModOnHdPrompt::slotOk()
1724{
1725 done( m_modtype == 3 ? Save : Reload );
1726}
1727
1728void KateModOnHdPrompt::slotUser1()
1729{
1730 done( Overwrite );
1731}
1732
1733//END KateModOnHdPrompt
IndenterConfigPage
This widget will be embedded into a modal dialog when clicking the "Configure..." button in the inden...
Definition: kateautoindent.h:45
KCharsets::encodingForName
TQString encodingForName(const TQString &descriptiveName)
KCharsets::codecForName
TQTextCodec * codecForName(const TQString &name) const
KComboBox
KDialogBase
KDialogBase::addVBoxPage
TQVBox * addVBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
KDialogBase::plainPage
TQFrame * plainPage()
KDialogBase::Help
Help
KDialogBase::Ok
Ok
KDialogBase::Cancel
Cancel
KDialogBase::DialogType
DialogType
KDialog::spacingHint
static int spacingHint()
KIntNumInput
KKeyChooser
KMessageBox::information
static void information(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
KMessageBox::sorry
static void sorry(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
KMessageBox::warningContinueCancel
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)
KSeparator
KStdGuiItem::cont
static KGuiItem cont()
KTempFile
KTempFile::textStream
TQTextStream * textStream()
KTempFile::close
bool close()
KTempFile::name
TQString name() const
KURL
KateAutoIndent::hasConfigPage
static bool hasConfigPage(uint mode)
Config page support.
Definition: kateautoindent.cpp:134
KateAutoIndent::listModes
static TQStringList listModes()
List all possible modes by name.
Definition: kateautoindent.cpp:58
KateAutoIndent::configPage
static IndenterConfigPage * configPage(TQWidget *parent, uint mode)
Support for a config page.
Definition: kateautoindent.cpp:142
KateAutoIndent::modeDescription
static TQString modeDescription(uint mode)
Return the mode description.
Definition: kateautoindent.cpp:94
KateBuffer::setMaxLoadedBlocks
static void setMaxLoadedBlocks(uint count)
modifier for max loaded blocks limit
Definition: katebuffer.cpp:79
KateBuffer::maxLoadedBlocks
static uint maxLoadedBlocks()
maximal loaded block count
Definition: katebuffer.h:352
KateModOnHdPrompt::slotDiff
void slotDiff()
Show a diff between the document text and the disk file.
Definition: katedialogs.cpp:1636
KateSyntaxDocument
Store and manage the information about Syntax Highlighting.
Definition: katesyntaxdocument.h:65
TDEGlobal::dirs
static TDEStandardDirs * dirs()
TDEGlobal::charsets
static KCharsets * charsets()
TDEIcon::SizeMedium
SizeMedium
TDEListView
TDEProcIO
TDEProcIO::closeWhenDone
void closeWhenDone()
TDEProcIO::readln
int readln(TQString &line, bool autoAck=true, bool *partial=0)
TDEProcIO::setComm
void setComm(Communication comm)
TDEProcIO::writeStdin
bool writeStdin(const TQString &line, bool appendnewline=true)
TDEProcIO::start
bool start(RunMode runmode=NotifyOnExit, bool includeStderr=false)
TDEProcIO::ackRead
void ackRead()
TDEProcess
TDEProcess::NotifyOnExit
NotifyOnExit
TDEProcess::normalExit
bool normalExit() const
TDEStandardDirs::saveLocation
TQString saveLocation(const char *type, const TQString &suffix=TQString::null, bool create=true) const
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
Kate
Kate namespace All classes in this namespace must stay BC during one major release series (e....
Definition: document.h:51
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::insert
const TDEShortcut & insert()
TDEStdAccel::reload
const TDEShortcut & reload()
TDEStdAccel::label
TQString label(StdAccel id)
tdelocale.h

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.