00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "katedialogs.h"
00026 #include "katedialogs.moc"
00027
00028 #include "kateautoindent.h"
00029 #include "katebuffer.h"
00030 #include "kateconfig.h"
00031 #include "katedocument.h"
00032 #include "katefactory.h"
00033 #include "kateschema.h"
00034 #include "katesyntaxdocument.h"
00035 #include "kateview.h"
00036
00037
00038 #include <ktexteditor/configinterfaceextension.h>
00039 #include <ktexteditor/plugin.h>
00040
00041 #include <kio/job.h>
00042 #include <kio/jobclasses.h>
00043 #include <kio/netaccess.h>
00044
00045 #include <kaccel.h>
00046 #include <kapplication.h>
00047 #include <kbuttonbox.h>
00048 #include <kcharsets.h>
00049 #include <kcolorbutton.h>
00050 #include <kcolorcombo.h>
00051 #include <kcolordialog.h>
00052 #include <kcombobox.h>
00053 #include <kconfig.h>
00054 #include <kdebug.h>
00055 #include <kfontdialog.h>
00056 #include <kglobal.h>
00057 #include <kglobalsettings.h>
00058 #include <kiconloader.h>
00059 #include <kkeybutton.h>
00060 #include <kkeydialog.h>
00061 #include <klineedit.h>
00062 #include <klistview.h>
00063 #include <klocale.h>
00064 #include <kmessagebox.h>
00065 #include <kmimetypechooser.h>
00066 #include <knuminput.h>
00067 #include <kparts/componentfactory.h>
00068 #include <kpopupmenu.h>
00069 #include <kprocess.h>
00070 #include <kprocio.h>
00071 #include <kregexpeditorinterface.h>
00072 #include <krun.h>
00073 #include <kspell.h>
00074 #include <kstandarddirs.h>
00075 #include <ktempfile.h>
00076
00077 #include <qbuttongroup.h>
00078 #include <qcheckbox.h>
00079 #include <qcombobox.h>
00080 #include <qdialog.h>
00081 #include <qdom.h>
00082 #include <qfile.h>
00083 #include <qgrid.h>
00084 #include <qgroupbox.h>
00085 #include <qhbox.h>
00086 #include <qheader.h>
00087 #include <qhgroupbox.h>
00088 #include <qlabel.h>
00089 #include <qlayout.h>
00090 #include <qlineedit.h>
00091 #include <qlistbox.h>
00092 #include <qlistview.h>
00093 #include <qmap.h>
00094 #include <qobjectlist.h>
00095 #include <qpainter.h>
00096 #include <qpointarray.h>
00097 #include <qptrcollection.h>
00098 #include <qpushbutton.h>
00099 #include <qradiobutton.h>
00100 #include <qslider.h>
00101 #include <qspinbox.h>
00102 #include <qstringlist.h>
00103 #include <qtabwidget.h>
00104 #include <qtextcodec.h>
00105 #include <qtoolbutton.h>
00106 #include <qvbox.h>
00107 #include <qvgroupbox.h>
00108 #include <qwhatsthis.h>
00109 #include <qwidgetstack.h>
00110
00111
00112 #define HLDOWNLOADPATH "http://www.kde.org/apps/kate/syntax/"
00113
00114
00115
00116
00117 KateConfigPage::KateConfigPage ( QWidget *parent, const char *name )
00118 : Kate::ConfigPage (parent, name)
00119 , m_changed (false)
00120 {
00121 connect (this, SIGNAL(changed()), this, SLOT(somethingHasChanged ()));
00122 }
00123
00124 KateConfigPage::~KateConfigPage ()
00125 {
00126 }
00127
00128 void KateConfigPage::somethingHasChanged ()
00129 {
00130 m_changed = true;
00131 kdDebug (13000) << "TEST: something changed on the config page: " << this << endl;
00132 }
00133
00134
00135
00136 KateSpellConfigPage::KateSpellConfigPage( QWidget* parent )
00137 : KateConfigPage( parent)
00138 {
00139 QVBoxLayout* l = new QVBoxLayout( this );
00140 cPage = new KSpellConfig( this, 0L, 0L, false );
00141 l->addWidget( cPage );
00142 connect( cPage, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
00143 }
00144
00145 void KateSpellConfigPage::apply ()
00146 {
00147
00148 if (!changed())
00149 return;
00150
00151 m_changed = false;
00152
00153 cPage->writeGlobalSettings ();
00154 }
00155
00156
00157
00158 const int KateIndentConfigTab::flags[] = {
00159 KateDocument::cfSpaceIndent,
00160 KateDocument::cfKeepIndentProfile,
00161 KateDocument::cfKeepExtraSpaces,
00162 KateDocument::cfTabIndents,
00163 KateDocument::cfBackspaceIndents,
00164 KateDocumentConfig::cfDoxygenAutoTyping,
00165 KateDocumentConfig::cfMixedIndent
00166 };
00167
00168 KateIndentConfigTab::KateIndentConfigTab(QWidget *parent)
00169 : KateConfigPage(parent)
00170 {
00171 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
00172 int configFlags = KateDocumentConfig::global()->configFlags();
00173
00174 QVGroupBox *gbAuto = new QVGroupBox(i18n("Automatic Indentation"), this);
00175
00176 QHBox *indentLayout = new QHBox(gbAuto);
00177 QLabel *indentLabel = new QLabel(i18n("&Indentation mode:"), indentLayout);
00178 m_indentMode = new KComboBox (indentLayout);
00179 m_indentMode->insertStringList (KateAutoIndent::listModes());
00180 indentLabel->setBuddy(m_indentMode);
00181
00182 opt[5] = new QCheckBox(i18n("Insert leading Doxygen \"*\" when typing"), gbAuto);
00183
00184 QVGroupBox *gbSpaces = new QVGroupBox(i18n("Indentation with Spaces"), this);
00185 QVBox *spaceLayout = new QVBox(gbSpaces);
00186 opt[0] = new QCheckBox(i18n("Use &spaces instead of tabs to indent"), spaceLayout );
00187 opt[6] = new QCheckBox(i18n("Emacs style mixed mode"), spaceLayout);
00188
00189 indentationWidth = new KIntNumInput(KateDocumentConfig::global()->indentationWidth(), spaceLayout);
00190 indentationWidth->setRange(1, 16, 1, false);
00191 indentationWidth->setLabel(i18n("Number of spaces:"), AlignVCenter);
00192
00193 opt[1] = new QCheckBox(i18n("Keep indent &profile"), this);
00194 opt[2] = new QCheckBox(i18n("&Keep extra spaces"), this);
00195
00196 QVGroupBox *keys = new QVGroupBox(i18n("Keys to Use"), this);
00197 opt[3] = new QCheckBox(i18n("&Tab key indents"), keys);
00198 opt[4] = new QCheckBox(i18n("&Backspace key indents"), keys);
00199
00200 QRadioButton *rb1, *rb2, *rb3;
00201 m_tabs = new QButtonGroup( 1, Qt::Horizontal, i18n("Tab Key Mode if Nothing Selected"), this );
00202 m_tabs->setRadioButtonExclusive( true );
00203 m_tabs->insert( rb1=new QRadioButton( i18n("Insert indent &characters"), m_tabs ), 0 );
00204 m_tabs->insert( rb2=new QRadioButton( i18n("I&nsert tab character"), m_tabs ), 1 );
00205 m_tabs->insert( rb3=new QRadioButton( i18n("Indent current &line"), m_tabs ), 2 );
00206
00207 opt[0]->setChecked(configFlags & flags[0]);
00208 opt[1]->setChecked(configFlags & flags[1]);
00209 opt[2]->setChecked(configFlags & flags[2]);
00210 opt[3]->setChecked(configFlags & flags[3]);
00211 opt[4]->setChecked(configFlags & flags[4]);
00212 opt[5]->setChecked(configFlags & flags[5]);
00213 opt[6]->setChecked(configFlags & flags[6]);
00214
00215 layout->addWidget(gbAuto);
00216 layout->addWidget(gbSpaces);
00217 layout->addWidget(opt[1]);
00218 layout->addWidget(opt[2]);
00219 layout->addWidget(keys);
00220 layout->addWidget(m_tabs, 0);
00221
00222 layout->addStretch();
00223
00224
00225 QWhatsThis::add(opt[0], i18n(
00226 "Check this if you want to indent with spaces rather than tabs."));
00227 QWhatsThis::add(opt[2], i18n(
00228 "Indentations of more than the selected number of spaces will not be "
00229 "shortened."));
00230 QWhatsThis::add(opt[3], i18n(
00231 "This allows the <b>Tab</b> key to be used to increase the indentation "
00232 "level."));
00233 QWhatsThis::add(opt[4], i18n(
00234 "This allows the <b>Backspace</b> key to be used to decrease the "
00235 "indentation level."));
00236 QWhatsThis::add(opt[5], i18n(
00237 "Automatically inserts a leading \"*\" while typing within a Doxygen "
00238 "style comment."));
00239 QWhatsThis::add( opt[6], i18n(
00240 "Use a mix of tab and space characters for indentation.") );
00241 QWhatsThis::add(indentationWidth, i18n("The number of spaces to indent with."));
00242
00243 reload ();
00244
00245
00246
00247
00248
00249 connect(m_indentMode, SIGNAL(activated(int)), this, SLOT(slotChanged()));
00250 connect(m_indentMode, SIGNAL(activated(int)), this, SLOT(indenterSelected(int)));
00251
00252 connect( opt[0], SIGNAL(toggled(bool)), this, SLOT(somethingToggled()));
00253
00254 connect( opt[0], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00255 connect( opt[1], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00256 connect( opt[2], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00257 connect( opt[3], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00258 connect( opt[4], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00259 connect( opt[5], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00260 connect( opt[6], SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00261
00262 connect(indentationWidth, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00263
00264 connect(rb1, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00265 connect(rb2, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00266 connect(rb3, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00267 }
00268
00269 void KateIndentConfigTab::somethingToggled() {
00270 indentationWidth->setEnabled(opt[0]->isChecked());
00271 opt[6]->setEnabled(opt[0]->isChecked());
00272 }
00273
00274 void KateIndentConfigTab::indenterSelected (int index)
00275 {
00276 if (index == KateDocumentConfig::imCStyle || index == KateDocumentConfig::imCSAndS)
00277 opt[5]->setEnabled(true);
00278 else
00279 opt[5]->setEnabled(false);
00280 }
00281
00282 void KateIndentConfigTab::apply ()
00283 {
00284
00285 if (!changed())
00286 return;
00287 m_changed = false;
00288
00289 KateDocumentConfig::global()->configStart ();
00290
00291 int configFlags, z;
00292
00293 configFlags = KateDocumentConfig::global()->configFlags();
00294 for (z = 0; z < numFlags; z++) {
00295 configFlags &= ~flags[z];
00296 if (opt[z]->isChecked()) configFlags |= flags[z];
00297 }
00298
00299 KateDocumentConfig::global()->setConfigFlags(configFlags);
00300 KateDocumentConfig::global()->setIndentationWidth(indentationWidth->value());
00301
00302 KateDocumentConfig::global()->setIndentationMode(m_indentMode->currentItem());
00303
00304 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabIndentsMode, 2 == m_tabs->id (m_tabs->selected()));
00305 KateDocumentConfig::global()->setConfigFlags (KateDocumentConfig::cfTabInsertsTab, 1 == m_tabs->id (m_tabs->selected()));
00306
00307 KateDocumentConfig::global()->configEnd ();
00308 }
00309
00310 void KateIndentConfigTab::reload ()
00311 {
00312 if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabIndentsMode)
00313 m_tabs->setButton (2);
00314 else if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfTabInsertsTab)
00315 m_tabs->setButton (1);
00316 else
00317 m_tabs->setButton (0);
00318
00319 m_indentMode->setCurrentItem (KateDocumentConfig::global()->indentationMode());
00320
00321 somethingToggled ();
00322 indenterSelected (m_indentMode->currentItem());
00323 }
00324
00325
00326
00327 KateSelectConfigTab::KateSelectConfigTab(QWidget *parent)
00328 : KateConfigPage(parent)
00329 {
00330 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
00331
00332 QRadioButton *rb1, *rb2;
00333
00334 m_tabs = new QButtonGroup( 1, Qt::Horizontal, i18n("Selection Mode"), this );
00335 layout->add (m_tabs);
00336
00337 m_tabs->setRadioButtonExclusive( true );
00338 m_tabs->insert( rb1=new QRadioButton( i18n("&Normal"), m_tabs ), 0 );
00339 m_tabs->insert( rb2=new QRadioButton( i18n("&Persistent"), m_tabs ), 1 );
00340
00341
00342 layout->addStretch();
00343
00344 QWhatsThis::add(rb1, i18n(
00345 "Selections will be overwritten by typed text and will be lost on "
00346 "cursor movement."));
00347 QWhatsThis::add(rb2, i18n(
00348 "Selections will stay even after cursor movement and typing."));
00349
00350 reload ();
00351
00352
00353
00354
00355
00356 connect(rb1, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00357 connect(rb2, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00358 }
00359
00360 void KateSelectConfigTab::apply ()
00361 {
00362
00363 if (!changed())
00364 return;
00365 m_changed = false;
00366
00367 KateDocumentConfig::global()->configStart ();
00368
00369 int configFlags = KateDocumentConfig::global()->configFlags();
00370
00371 configFlags &= ~KateDocumentConfig::cfPersistent;
00372
00373 if (m_tabs->id (m_tabs->selected()) == 1)
00374 configFlags |= KateDocumentConfig::cfPersistent;
00375
00376 KateDocumentConfig::global()->setConfigFlags(configFlags);
00377
00378 KateDocumentConfig::global()->configEnd ();
00379 }
00380
00381 void KateSelectConfigTab::reload ()
00382 {
00383 if (KateDocumentConfig::global()->configFlags() & KateDocumentConfig::cfPersistent)
00384 m_tabs->setButton (1);
00385 else
00386 m_tabs->setButton (0);
00387 }
00388
00389
00390
00391 const int KateEditConfigTab::flags[] = {KateDocument::cfWordWrap,
00392 KateDocument::cfAutoBrackets, KateDocument::cfShowTabs, KateDocument::cfSmartHome,
00393 KateDocument::cfWrapCursor, KateDocumentConfig::cfReplaceTabsDyn, KateDocumentConfig::cfRemoveTrailingDyn};
00394
00395 KateEditConfigTab::KateEditConfigTab(QWidget *parent)
00396 : KateConfigPage(parent)
00397 {
00398 QVBoxLayout *mainLayout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
00399 int configFlags = KateDocumentConfig::global()->configFlags();
00400
00401 QVGroupBox *gbWhiteSpace = new QVGroupBox(i18n("Tabulators"), this);
00402
00403 opt[2] = new QCheckBox(i18n("&Show tabs"), gbWhiteSpace);
00404 opt[2]->setChecked(configFlags & flags[2]);
00405 connect(opt[2], SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00406
00407 opt[5] = new QCheckBox( i18n("&Replace tabs with spaces"), gbWhiteSpace );
00408 opt[5]->setChecked( configFlags & KateDocumentConfig::cfReplaceTabsDyn );
00409 connect( opt[5], SIGNAL(toggled(bool)), this, SLOT(slotChanged()) );
00410
00411 e2 = new KIntNumInput(KateDocumentConfig::global()->tabWidth(), gbWhiteSpace);
00412 e2->setRange(1, 16, 1, false);
00413 e2->setLabel(i18n("Tab width:"), AlignVCenter);
00414 connect(e2, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00415
00416 mainLayout->addWidget(gbWhiteSpace);
00417
00418 QVGroupBox *gbWordWrap = new QVGroupBox(i18n("Static Word Wrap"), this);
00419
00420 opt[0] = new QCheckBox(i18n("Enable static &word wrap"), gbWordWrap);
00421 opt[0]->setChecked(KateDocumentConfig::global()->wordWrap());
00422 connect(opt[0], SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00423
00424 e1 = new KIntNumInput(KateDocumentConfig::global()->wordWrapAt(), gbWordWrap);
00425 e1->setRange(20, 200, 1, false);
00426 e1->setLabel(i18n("Wrap words at:"), AlignVCenter);
00427 connect(e1, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00428
00429 mainLayout->addWidget(gbWordWrap);
00430
00431 QVGroupBox *gbCursor = new QVGroupBox(i18n("Text Cursor Movement"), this);
00432
00433 opt[3] = new QCheckBox(i18n("Smart ho&me"), gbCursor);
00434 opt[3]->setChecked(configFlags & flags[3]);
00435 connect(opt[3], SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00436
00437 opt[4] = new QCheckBox(i18n("Wrap c&ursor"), gbCursor);
00438 opt[4]->setChecked(configFlags & flags[4]);
00439 connect(opt[4], SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00440
00441 e6 = new QCheckBox(i18n("&PageUp/PageDown moves cursor"), gbCursor);
00442 e6->setChecked(KateDocumentConfig::global()->pageUpDownMovesCursor());
00443 connect(e6, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00444
00445 e4 = new KIntNumInput(KateViewConfig::global()->autoCenterLines(), gbCursor);
00446 e4->setRange(0, 1000000, 1, false);
00447 e4->setLabel(i18n("Autocenter cursor (lines):"), AlignVCenter);
00448 connect(e4, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00449
00450 mainLayout->addWidget(gbCursor);
00451
00452 opt[6] = new QCheckBox( i18n("Remove &trailing spaces"), this );
00453 mainLayout->addWidget( opt[6] );
00454 opt[6]->setChecked( configFlags & KateDocumentConfig::cfRemoveTrailingDyn );
00455 connect( opt[6], SIGNAL(toggled(bool)), this, SLOT(slotChanged()) );
00456
00457 opt[1] = new QCheckBox(i18n("Auto &brackets"), this);
00458 mainLayout->addWidget(opt[1]);
00459 opt[1]->setChecked(configFlags & flags[1]);
00460 connect(opt[1], SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00461
00462 e3 = new KIntNumInput(e2, KateDocumentConfig::global()->undoSteps(), this);
00463 e3->setRange(0, 1000000, 1, false);
00464 e3->setSpecialValueText( i18n("Unlimited") );
00465 e3->setLabel(i18n("Maximum undo steps:"), AlignVCenter);
00466 mainLayout->addWidget(e3);
00467 connect(e3, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00468
00469 QHBoxLayout *e5Layout = new QHBoxLayout(mainLayout);
00470 QLabel *e5Label = new QLabel(i18n("Smart search t&ext from:"), this);
00471 e5Layout->addWidget(e5Label);
00472 e5 = new KComboBox (this);
00473 e5->insertItem( i18n("Nowhere") );
00474 e5->insertItem( i18n("Selection Only") );
00475 e5->insertItem( i18n("Selection, then Current Word") );
00476 e5->insertItem( i18n("Current Word Only") );
00477 e5->insertItem( i18n("Current Word, then Selection") );
00478 e5->setCurrentItem(KateViewConfig::global()->textToSearchMode());
00479 e5Layout->addWidget(e5);
00480 e5Label->setBuddy(e5);
00481 connect(e5, SIGNAL(activated(int)), this, SLOT(slotChanged()));
00482
00483 mainLayout->addStretch();
00484
00485
00486 QWhatsThis::add(opt[0], i18n(
00487 "Automatically start a new line of text when the current line exceeds "
00488 "the length specified by the <b>Wrap words at:</b> option."
00489 "<p>This option does not wrap existing lines of text - use the <b>Apply "
00490 "Static Word Wrap</b> option in the <b>Tools</b> menu for that purpose."
00491 "<p>If you want lines to be <i>visually wrapped</i> instead, according "
00492 "to the width of the view, enable <b>Dynamic Word Wrap</b> in the "
00493 "<b>View Defaults</b> config page."));
00494 QWhatsThis::add(e1, i18n(
00495 "If the Word Wrap option is selected this entry determines the length "
00496 "(in characters) at which the editor will automatically start a new line."));
00497 QWhatsThis::add(opt[1], i18n(
00498 "When the user types a left bracket ([,(, or {) KateView automatically "
00499 "enters the right bracket (}, ), or ]) to the right of the cursor."));
00500 QWhatsThis::add(opt[2], i18n(
00501 "The editor will display a symbol to indicate the presence of a tab in "
00502 "the text."));
00503 QWhatsThis::add(opt[3], i18n(
00504 "When selected, pressing the home key will cause the cursor to skip "
00505 "whitespace and go to the start of a line's text."));
00506 QWhatsThis::add(e3, i18n(
00507 "Sets the number of undo/redo steps to record. More steps uses more memory."));
00508 QWhatsThis::add(e4, i18n(
00509 "Sets the number of lines to maintain visible above and below the "
00510 "cursor when possible."));
00511 QWhatsThis::add(opt[4], i18n(
00512 "When on, moving the insertion cursor using the <b>Left</b> and "
00513 "<b>Right</b> keys will go on to previous/next line at beginning/end of "
00514 "the line, similar to most editors.<p>When off, the insertion cursor "
00515 "cannot be moved left of the line start, but it can be moved off the "
00516 "line end, which can be very handy for programmers."));
00517 QWhatsThis::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."));
00518 QString gstfwt = i18n(
00519 "This determines where KateView will get the search text from "
00520 "(this will be automatically entered into the Find Text dialog): "
00521 "<br>"
00522 "<ul>"
00523 "<li><b>Nowhere:</b> Don't guess the search text."
00524 "</li>"
00525 "<li><b>Selection Only:</b> Use the current text selection, "
00526 "if available."
00527 "</li>"
00528 "<li><b>Selection, then Current Word:</b> Use the current "
00529 "selection if available, otherwise use the current word."
00530 "</li>"
00531 "<li><b>Current Word Only:</b> Use the word that the cursor "
00532 "is currently resting on, if available."
00533 "</li>"
00534 "<li><b>Current Word, then Selection:</b> Use the current "
00535 "word if available, otherwise use the current selection."
00536 "</li>"
00537 "</ul>"
00538 "Note that, in all the above modes, if a search string has "
00539 "not been or cannot be determined, then the Find Text Dialog "
00540 "will fall back to the last search text.");
00541 QWhatsThis::add(e5Label, gstfwt);
00542 QWhatsThis::add(e5, gstfwt);
00543 QWhatsThis::add( opt[5], i18n(
00544 "If this is enabled, the editor will calculate the number of spaces up to "
00545 "the next tab position as defined by the tab width, and insert that number "
00546 "of spaces instead of a TAB character." ) );
00547 QWhatsThis::add( opt[6], i18n(
00548 "If this is enabled, the editor will remove any trailing whitespace on "
00549 "lines when they are left by the insertion cursor.") );
00550 }
00551
00552 void KateEditConfigTab::apply ()
00553 {
00554
00555 if (!changed())
00556 return;
00557 m_changed = false;
00558
00559 KateViewConfig::global()->configStart ();
00560 KateDocumentConfig::global()->configStart ();
00561
00562 int configFlags, z;
00563
00564 configFlags = KateDocumentConfig::global()->configFlags();
00565 for (z = 1; z < numFlags; z++) {
00566 configFlags &= ~flags[z];
00567 if (opt[z]->isChecked()) configFlags |= flags[z];
00568 }
00569 KateDocumentConfig::global()->setConfigFlags(configFlags);
00570
00571 KateDocumentConfig::global()->setWordWrapAt(e1->value());
00572 KateDocumentConfig::global()->setWordWrap (opt[0]->isChecked());
00573 KateDocumentConfig::global()->setTabWidth(e2->value());
00574
00575 if (e3->value() <= 0)
00576 KateDocumentConfig::global()->setUndoSteps(0);
00577 else
00578 KateDocumentConfig::global()->setUndoSteps(e3->value());
00579
00580 KateViewConfig::global()->setAutoCenterLines(QMAX(0, e4->value()));
00581 KateViewConfig::global()->setTextToSearchMode(e5->currentItem());
00582 KateDocumentConfig::global()->setPageUpDownMovesCursor(e6->isChecked());
00583
00584 KateDocumentConfig::global()->configEnd ();
00585 KateViewConfig::global()->configEnd ();
00586 }
00587
00588 void KateEditConfigTab::reload ()
00589 {
00590
00591 }
00592
00593
00594
00595 KateViewDefaultsConfig::KateViewDefaultsConfig(QWidget *parent)
00596 :KateConfigPage(parent)
00597 {
00598 QRadioButton *rb1;
00599 QRadioButton *rb2;
00600
00601 QVBoxLayout *blay=new QVBoxLayout(this,0,KDialog::spacingHint());
00602
00603 QVGroupBox *gbWordWrap = new QVGroupBox(i18n("Word Wrap"), this);
00604
00605 m_dynwrap=new QCheckBox(i18n("&Dynamic word wrap"),gbWordWrap);
00606
00607 QHBox *m_dynwrapIndicatorsLay = new QHBox (gbWordWrap);
00608 m_dynwrapIndicatorsLabel = new QLabel( i18n("Dynamic word wrap indicators (if applicable):"), m_dynwrapIndicatorsLay );
00609 m_dynwrapIndicatorsCombo = new KComboBox( m_dynwrapIndicatorsLay );
00610 m_dynwrapIndicatorsCombo->insertItem( i18n("Off") );
00611 m_dynwrapIndicatorsCombo->insertItem( i18n("Follow Line Numbers") );
00612 m_dynwrapIndicatorsCombo->insertItem( i18n("Always On") );
00613 m_dynwrapIndicatorsLabel->setBuddy(m_dynwrapIndicatorsCombo);
00614
00615 m_dynwrapAlignLevel = new KIntNumInput(gbWordWrap);
00616 m_dynwrapAlignLevel->setLabel(i18n("Vertically align dynamically wrapped lines to indentation depth:"));
00617 m_dynwrapAlignLevel->setRange(0, 80, 10);
00618
00619 m_dynwrapAlignLevel->setSuffix(i18n("% of View Width"));
00620 m_dynwrapAlignLevel->setSpecialValueText(i18n("Disabled"));
00621
00622 m_wwmarker = new QCheckBox( i18n("&Show static word wrap marker (if applicable)"), gbWordWrap );
00623
00624 blay->addWidget(gbWordWrap);
00625
00626 QVGroupBox *gbFold = new QVGroupBox(i18n("Code Folding"), this);
00627
00628 m_folding=new QCheckBox(i18n("Show &folding markers (if available)"), gbFold );
00629 m_collapseTopLevel = new QCheckBox( i18n("Collapse toplevel folding nodes"), gbFold );
00630 m_collapseTopLevel->hide ();
00631
00632 blay->addWidget(gbFold);
00633
00634 QVGroupBox *gbBar = new QVGroupBox(i18n("Borders"), this);
00635
00636 m_icons=new QCheckBox(i18n("Show &icon border"),gbBar);
00637 m_line=new QCheckBox(i18n("Show &line numbers"),gbBar);
00638 m_scrollBarMarks=new QCheckBox(i18n("Show &scrollbar marks"),gbBar);
00639
00640 blay->addWidget(gbBar);
00641
00642 m_bmSort = new QButtonGroup( 1, Qt::Horizontal, i18n("Sort Bookmarks Menu"), this );
00643 m_bmSort->setRadioButtonExclusive( true );
00644 m_bmSort->insert( rb1=new QRadioButton( i18n("By &position"), m_bmSort ), 0 );
00645 m_bmSort->insert( rb2=new QRadioButton( i18n("By c&reation"), m_bmSort ), 1 );
00646
00647 blay->addWidget(m_bmSort, 0 );
00648 blay->addStretch(1000);
00649
00650 QWhatsThis::add(m_dynwrap,i18n(
00651 "If this option is checked, the text lines will be wrapped at the view "
00652 "border on the screen."));
00653 QString wtstr = i18n("Choose when the Dynamic Word Wrap Indicators should be displayed");
00654 QWhatsThis::add(m_dynwrapIndicatorsLabel, wtstr);
00655 QWhatsThis::add(m_dynwrapIndicatorsCombo, wtstr);
00656
00657 QWhatsThis::add(m_dynwrapAlignLevel, i18n(
00658 "<p>Enables the start of dynamically wrapped lines to be aligned "
00659 "vertically to the indentation level of the first line. This can help "
00660 "to make code and markup more readable.</p><p>Additionally, this allows "
00661 "you to set a maximum width of the screen, as a percentage, after which "
00662 "dynamically wrapped lines will no longer be vertically aligned. For "
00663 "example, at 50%, lines whose indentation levels are deeper than 50% of "
00664 "the width of the screen will not have vertical alignment applied to "
00665 "subsequent wrapped lines.</p>"));
00666 QWhatsThis::add( m_wwmarker, i18n(
00667 "<p>If this option is checked, a vertical line will be drawn at the word "
00668 "wrap column as defined in the <strong>Editing</strong> properties."
00669 "<p>Note that the word wrap marker is only drawn if you use a fixed "
00670 "pitch font." ));
00671 QWhatsThis::add(m_line,i18n(
00672 "If this option is checked, every new view will display line numbers "
00673 "on the left hand side."));
00674 QWhatsThis::add(m_icons,i18n(
00675 "If this option is checked, every new view will display an icon border "
00676 "on the left hand side.<br><br>The icon border shows bookmark signs, "
00677 "for instance."));
00678 QWhatsThis::add(m_scrollBarMarks,i18n(
00679 "If this option is checked, every new view will show marks on the "
00680 "vertical scrollbar.<br><br>These marks will, for instance, show "
00681 "bookmarks."));
00682 QWhatsThis::add(m_folding,i18n(
00683 "If this option is checked, every new view will display marks for code "
00684 "folding, if code folding is available."));
00685 QWhatsThis::add(m_bmSort,i18n(
00686 "Choose how the bookmarks should be ordered in the <b>Bookmarks</b> menu."));
00687 QWhatsThis::add(rb1,i18n(
00688 "The bookmarks will be ordered by the line numbers they are placed at."));
00689 QWhatsThis::add(rb2,i18n(
00690 "Each new bookmark will be added to the bottom, independently from "
00691 "where it is placed in the document."));
00692
00693 reload();
00694
00695
00696
00697
00698
00699 connect(m_dynwrap, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00700 connect(m_dynwrapIndicatorsCombo, SIGNAL(activated(int)), this, SLOT(slotChanged()));
00701 connect(m_dynwrapAlignLevel, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00702 connect(m_wwmarker, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00703 connect(m_icons, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00704 connect(m_scrollBarMarks, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00705 connect(m_line, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00706 connect(m_folding, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00707 connect(m_collapseTopLevel, SIGNAL(toggled(bool)), this, SLOT(slotChanged()) );
00708 connect(rb1, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00709 connect(rb2, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00710 }
00711
00712 KateViewDefaultsConfig::~KateViewDefaultsConfig()
00713 {
00714 }
00715
00716 void KateViewDefaultsConfig::apply ()
00717 {
00718
00719 if (!changed())
00720 return;
00721 m_changed = false;
00722
00723 KateViewConfig::global()->configStart ();
00724 KateRendererConfig::global()->configStart ();
00725
00726 KateViewConfig::global()->setDynWordWrap (m_dynwrap->isChecked());
00727 KateViewConfig::global()->setDynWordWrapIndicators (m_dynwrapIndicatorsCombo->currentItem ());
00728 KateViewConfig::global()->setDynWordWrapAlignIndent(m_dynwrapAlignLevel->value());
00729 KateRendererConfig::global()->setWordWrapMarker (m_wwmarker->isChecked());
00730 KateViewConfig::global()->setLineNumbers (m_line->isChecked());
00731 KateViewConfig::global()->setIconBar (m_icons->isChecked());
00732 KateViewConfig::global()->setScrollBarMarks (m_scrollBarMarks->isChecked());
00733 KateViewConfig::global()->setFoldingBar (m_folding->isChecked());
00734 KateViewConfig::global()->setBookmarkSort (m_bmSort->id (m_bmSort->selected()));
00735
00736 KateRendererConfig::global()->configEnd ();
00737 KateViewConfig::global()->configEnd ();
00738 }
00739
00740 void KateViewDefaultsConfig::reload ()
00741 {
00742 m_dynwrap->setChecked(KateViewConfig::global()->dynWordWrap());
00743 m_dynwrapIndicatorsCombo->setCurrentItem( KateViewConfig::global()->dynWordWrapIndicators() );
00744 m_dynwrapAlignLevel->setValue(KateViewConfig::global()->dynWordWrapAlignIndent());
00745 m_wwmarker->setChecked( KateRendererConfig::global()->wordWrapMarker() );
00746 m_line->setChecked(KateViewConfig::global()->lineNumbers());
00747 m_icons->setChecked(KateViewConfig::global()->iconBar());
00748 m_scrollBarMarks->setChecked(KateViewConfig::global()->scrollBarMarks());
00749 m_folding->setChecked(KateViewConfig::global()->foldingBar());
00750 m_bmSort->setButton( KateViewConfig::global()->bookmarkSort() );
00751 }
00752
00753 void KateViewDefaultsConfig::reset () {;}
00754
00755 void KateViewDefaultsConfig::defaults (){;}
00756
00757
00758
00759
00760 KateEditKeyConfiguration::KateEditKeyConfiguration( QWidget* parent, KateDocument* doc )
00761 : KateConfigPage( parent )
00762 {
00763 m_doc = doc;
00764 m_ready = false;
00765 }
00766
00767 void KateEditKeyConfiguration::showEvent ( QShowEvent * )
00768 {
00769 if (!m_ready)
00770 {
00771 (new QVBoxLayout(this))->setAutoAdd(true);
00772 KateView* view = (KateView*)m_doc->views().at(0);
00773 m_ac = view->editActionCollection();
00774 m_keyChooser = new KKeyChooser( m_ac, this, false );
00775 connect( m_keyChooser, SIGNAL( keyChange() ), this, SLOT( slotChanged() ) );
00776 m_keyChooser->show ();
00777
00778 m_ready = true;
00779 }
00780
00781 QWidget::show ();
00782 }
00783
00784 void KateEditKeyConfiguration::apply()
00785 {
00786 if ( ! changed() )
00787 return;
00788 m_changed = false;
00789
00790 if (m_ready)
00791 {
00792 m_keyChooser->commitChanges();
00793 m_ac->writeShortcutSettings( "Katepart Shortcuts" );
00794 }
00795 }
00796
00797
00798
00799 KateSaveConfigTab::KateSaveConfigTab( QWidget *parent )
00800 : KateConfigPage( parent )
00801 {
00802 int configFlags = KateDocumentConfig::global()->configFlags();
00803 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
00804
00805 QVGroupBox *gbEnc = new QVGroupBox(i18n("File Format"), this);
00806 layout->addWidget( gbEnc );
00807
00808 QHBox *e5Layout = new QHBox(gbEnc);
00809 QLabel *e5Label = new QLabel(i18n("&Encoding:"), e5Layout);
00810 m_encoding = new KComboBox (e5Layout);
00811 e5Label->setBuddy(m_encoding);
00812
00813 e5Layout = new QHBox(gbEnc);
00814 e5Label = new QLabel(i18n("End &of line:"), e5Layout);
00815 m_eol = new KComboBox (e5Layout);
00816 e5Label->setBuddy(m_eol);
00817
00818 m_eol->insertItem (i18n("UNIX"));
00819 m_eol->insertItem (i18n("DOS/Windows"));
00820 m_eol->insertItem (i18n("Macintosh"));
00821
00822 QVGroupBox *gbMem = new QVGroupBox(i18n("Memory Usage"), this);
00823 layout->addWidget( gbMem );
00824
00825 e5Layout = new QHBox(gbMem);
00826 e5Layout->setSpacing (32);
00827 blockCountLabel = new QLabel(i18n("Maximum loaded &blocks per file:"), e5Layout);
00828 blockCount = new QSpinBox (4, 512, 4, e5Layout);
00829
00830 blockCount->setValue (KateBuffer::maxLoadedBlocks());
00831 blockCountLabel->setBuddy(blockCount);
00832
00833 QVGroupBox *gbWhiteSpace = new QVGroupBox(i18n("Automatic Cleanups on Save"), this);
00834 layout->addWidget( gbWhiteSpace );
00835
00836 replaceTabs = new QCheckBox(i18n("Replace &tabs with spaces"), gbWhiteSpace);
00837 replaceTabs->setChecked(configFlags & KateDocument::cfReplaceTabs);
00838
00839 removeSpaces = new QCheckBox(i18n("Re&move trailing spaces"), gbWhiteSpace);
00840 removeSpaces->setChecked(configFlags & KateDocument::cfRemoveSpaces);
00841
00842 QVGroupBox *dirConfigBox = new QVGroupBox(i18n("Folder Config File"), this);
00843 layout->addWidget( dirConfigBox );
00844
00845 dirSearchDepth = new KIntNumInput(KateDocumentConfig::global()->searchDirConfigDepth(), dirConfigBox);
00846 dirSearchDepth->setRange(-1, 64, 1, false);
00847 dirSearchDepth->setSpecialValueText( i18n("Do not use config file") );
00848 dirSearchDepth->setLabel(i18n("Se&arch depth for config file:"), AlignVCenter);
00849
00850 QGroupBox *gb = new QGroupBox( 1, Qt::Horizontal, i18n("Backup on Save"), this );
00851 layout->addWidget( gb );
00852 cbLocalFiles = new QCheckBox( i18n("&Local files"), gb );
00853 cbRemoteFiles = new QCheckBox( i18n("&Remote files"), gb );
00854
00855 QHBox *hbBuPrefix = new QHBox( gb );
00856 QLabel *lBuPrefix = new QLabel( i18n("&Prefix:"), hbBuPrefix );
00857 leBuPrefix = new QLineEdit( hbBuPrefix );
00858 lBuPrefix->setBuddy( leBuPrefix );
00859
00860 QHBox *hbBuSuffix = new QHBox( gb );
00861 QLabel *lBuSuffix = new QLabel( i18n("&Suffix:"), hbBuSuffix );
00862 leBuSuffix = new QLineEdit( hbBuSuffix );
00863 lBuSuffix->setBuddy( leBuSuffix );
00864
00865 layout->addStretch();
00866
00867 QWhatsThis::add(replaceTabs, i18n(
00868 "KateView will replace any tabs with the number of spaces indicated in "
00869 "the Tab Width: entry."));
00870 QWhatsThis::add(removeSpaces, i18n(
00871 "KateView will automatically eliminate extra spaces at the ends of "
00872 "lines of text."));
00873 QWhatsThis::add( gb, i18n(
00874 "<p>Backing up on save will cause Kate to copy the disk file to "
00875 "'<prefix><filename><suffix>' before saving changes."
00876 "<p>The suffix defaults to <strong>~</strong> and prefix is empty by default" ) );
00877 QWhatsThis::add( cbLocalFiles, i18n(
00878 "Check this if you want backups of local files when saving") );
00879 QWhatsThis::add( cbRemoteFiles, i18n(
00880 "Check this if you want backups of remote files when saving") );
00881 QWhatsThis::add( leBuPrefix, i18n(
00882 "Enter the prefix to prepend to the backup file names" ) );
00883 QWhatsThis::add( leBuSuffix, i18n(
00884 "Enter the suffix to add to the backup file names" ) );
00885 QWhatsThis::add(dirSearchDepth, i18n(
00886 "The editor will search the given number of folder levels upwards for .kateconfig file"
00887 " and load the settings line from it." ));
00888 QWhatsThis::add(blockCount, i18n(
00889 "The editor will load given number of blocks (of around 2048 lines) of text into memory;"
00890 " if the filesize is bigger than this the other blocks are swapped "
00891 " to disk and loaded transparently as-needed.<br>"
00892 " This can cause little delays while navigating in the document; a larger block count"
00893 " increases the editing speed at the cost of memory. <br>For normal usage, just choose the highest possible"
00894 " block count: limit it only if you have problems with the memory usage."));
00895
00896 reload();
00897
00898
00899
00900
00901
00902 connect(m_encoding, SIGNAL(activated(int)), this, SLOT(slotChanged()));
00903 connect(m_eol, SIGNAL(activated(int)), this, SLOT(slotChanged()));
00904 connect(blockCount, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00905 connect(replaceTabs, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00906 connect(removeSpaces, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
00907 connect( cbLocalFiles, SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00908 connect( cbRemoteFiles, SIGNAL( toggled(bool) ), this, SLOT( slotChanged() ) );
00909 connect(dirSearchDepth, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00910 connect( leBuPrefix, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
00911 connect( leBuSuffix, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
00912 }
00913
00914 void KateSaveConfigTab::apply()
00915 {
00916
00917 if (!changed())
00918 return;
00919 m_changed = false;
00920
00921 KateBuffer::setMaxLoadedBlocks (blockCount->value());
00922
00923 KateDocumentConfig::global()->configStart ();
00924
00925 if ( leBuSuffix->text().isEmpty() && leBuPrefix->text().isEmpty() ) {
00926 KMessageBox::information(
00927 this,
00928 i18n("You did not provide a backup suffix or prefix. Using default suffix: '~'"),
00929 i18n("No Backup Suffix or Prefix")
00930 );
00931 leBuSuffix->setText( "~" );
00932 }
00933
00934 uint f( 0 );
00935 if ( cbLocalFiles->isChecked() )
00936 f |= KateDocumentConfig::LocalFiles;
00937 if ( cbRemoteFiles->isChecked() )
00938 f |= KateDocumentConfig::RemoteFiles;
00939
00940 KateDocumentConfig::global()->setBackupFlags(f);
00941 KateDocumentConfig::global()->setBackupPrefix(leBuPrefix->text());
00942 KateDocumentConfig::global()->setBackupSuffix(leBuSuffix->text());
00943
00944 KateDocumentConfig::global()->setSearchDirConfigDepth(dirSearchDepth->value());
00945
00946 int configFlags = KateDocumentConfig::global()->configFlags();
00947
00948 configFlags &= ~KateDocument::cfReplaceTabs;
00949 if (replaceTabs->isChecked()) configFlags |= KateDocument::cfReplaceTabs;
00950
00951 configFlags &= ~KateDocument::cfRemoveSpaces;
00952 if (removeSpaces->isChecked()) configFlags |= KateDocument::cfRemoveSpaces;
00953
00954 KateDocumentConfig::global()->setConfigFlags(configFlags);
00955
00956 KateDocumentConfig::global()->setEncoding((m_encoding->currentItem() == 0) ? "" : KGlobal::charsets()->encodingForName(m_encoding->currentText()));
00957
00958 KateDocumentConfig::global()->setEol(m_eol->currentItem());
00959
00960 KateDocumentConfig::global()->configEnd ();
00961 }
00962
00963 void KateSaveConfigTab::reload()
00964 {
00965
00966 m_encoding->clear ();
00967 m_encoding->insertItem (i18n("KDE Default"));
00968 m_encoding->setCurrentItem(0);
00969 QStringList encodings (KGlobal::charsets()->descriptiveEncodingNames());
00970 int insert = 1;
00971 for (uint i=0; i < encodings.count(); i++)
00972 {
00973 bool found = false;
00974 QTextCodec *codecForEnc = KGlobal::charsets()->codecForName(KGlobal::charsets()->encodingForName(encodings[i]), found);
00975
00976 if (found)
00977 {
00978 m_encoding->insertItem (encodings[i]);
00979
00980 if ( codecForEnc->name() == KateDocumentConfig::global()->encoding() )
00981 {
00982 m_encoding->setCurrentItem(insert);
00983 }
00984
00985 insert++;
00986 }
00987 }
00988
00989
00990 m_eol->setCurrentItem(KateDocumentConfig::global()->eol());
00991
00992 dirSearchDepth->setValue(KateDocumentConfig::global()->searchDirConfigDepth());
00993
00994
00995 uint f ( KateDocumentConfig::global()->backupFlags() );
00996 cbLocalFiles->setChecked( f & KateDocumentConfig::LocalFiles );
00997 cbRemoteFiles->setChecked( f & KateDocumentConfig::RemoteFiles );
00998 leBuPrefix->setText( KateDocumentConfig::global()->backupPrefix() );
00999 leBuSuffix->setText( KateDocumentConfig::global()->backupSuffix() );
01000 }
01001
01002 void KateSaveConfigTab::reset()
01003 {
01004 }
01005
01006 void KateSaveConfigTab::defaults()
01007 {
01008 cbLocalFiles->setChecked( true );
01009 cbRemoteFiles->setChecked( false );
01010 leBuPrefix->setText( "" );
01011 leBuSuffix->setText( "~" );
01012 }
01013
01014
01015
01016
01017 class KatePartPluginListItem : public QCheckListItem
01018 {
01019 public:
01020 KatePartPluginListItem(bool checked, uint i, const QString &name, QListView *parent);
01021 uint pluginIndex () const { return index; }
01022
01023 protected:
01024 void stateChange(bool);
01025
01026 private:
01027 uint index;
01028 bool silentStateChange;
01029 };
01030
01031 KatePartPluginListItem::KatePartPluginListItem(bool checked, uint i, const QString &name, QListView *parent)
01032 : QCheckListItem(parent, name, CheckBox)
01033 , index(i)
01034 , silentStateChange(false)
01035 {
01036 silentStateChange = true;
01037 setOn(checked);
01038 silentStateChange = false;
01039 }
01040
01041 void KatePartPluginListItem::stateChange(bool b)
01042 {
01043 if(!silentStateChange)
01044 static_cast<KatePartPluginListView *>(listView())->stateChanged(this, b);
01045 }
01046
01047
01048
01049 KatePartPluginListView::KatePartPluginListView(QWidget *parent, const char *name)
01050 : KListView(parent, name)
01051 {
01052 }
01053
01054 void KatePartPluginListView::stateChanged(KatePartPluginListItem *item, bool b)
01055 {
01056 emit stateChange(item, b);
01057 }
01058
01059
01060
01061 KatePartPluginConfigPage::KatePartPluginConfigPage (QWidget *parent) : KateConfigPage (parent, "")
01062 {
01063
01064 QGridLayout *grid = new QGridLayout( this, 1, 1 );
01065 grid->setSpacing( KDialogBase::spacingHint() );
01066
01067 listView = new KatePartPluginListView(this);
01068 listView->addColumn(i18n("Name"));
01069 listView->addColumn(i18n("Comment"));
01070
01071 grid->addWidget( listView, 0, 0);
01072
01073 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
01074 {
01075 KatePartPluginListItem *item = new KatePartPluginListItem(KateDocumentConfig::global()->plugin(i), i, (KateFactory::self()->plugins())[i]->name(), listView);
01076 item->setText(0, (KateFactory::self()->plugins())[i]->name());
01077 item->setText(1, (KateFactory::self()->plugins())[i]->comment());
01078
01079 m_items.append (item);
01080 }
01081
01082
01083
01084 btnConfigure = new QPushButton( i18n("Configure..."), this );
01085 btnConfigure->setEnabled( false );
01086 grid->addWidget( btnConfigure, 1, 0, Qt::AlignRight );
01087 connect( btnConfigure, SIGNAL(clicked()), this, SLOT(slotConfigure()) );
01088
01089 connect( listView, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotCurrentChanged(QListViewItem*)) );
01090 connect( listView, SIGNAL(stateChange(KatePartPluginListItem *, bool)),
01091 this, SLOT(slotStateChanged(KatePartPluginListItem *, bool)));
01092 connect(listView, SIGNAL(stateChange(KatePartPluginListItem *, bool)), this, SLOT(slotChanged()));
01093 }
01094
01095 KatePartPluginConfigPage::~KatePartPluginConfigPage ()
01096 {
01097 }
01098
01099 void KatePartPluginConfigPage::apply ()
01100 {
01101
01102 if (!changed())
01103 return;
01104 m_changed = false;
01105
01106 KateDocumentConfig::global()->configStart ();
01107
01108 for (uint i=0; i < m_items.count(); i++)
01109 KateDocumentConfig::global()->setPlugin (m_items.at(i)->pluginIndex(), m_items.at(i)->isOn());
01110
01111 KateDocumentConfig::global()->configEnd ();
01112 }
01113
01114 void KatePartPluginConfigPage::slotStateChanged( KatePartPluginListItem *item, bool b )
01115 {
01116 if ( b )
01117 slotCurrentChanged( (QListViewItem*)item );
01118 }
01119
01120 void KatePartPluginConfigPage::slotCurrentChanged( QListViewItem* i )
01121 {
01122 KatePartPluginListItem *item = static_cast<KatePartPluginListItem *>(i);
01123 if ( ! item ) return;
01124
01125 bool b = false;
01126 if ( item->isOn() )
01127 {
01128
01129
01130 KTextEditor::Plugin *plugin = KTextEditor::createPlugin(QFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
01131 if ( plugin ) {
01132 KTextEditor::ConfigInterfaceExtension *cie = KTextEditor::configInterfaceExtension( plugin );
01133 b = ( cie && cie->configPages() );
01134 }
01135
01136 }
01137 btnConfigure->setEnabled( b );
01138 }
01139
01140 void KatePartPluginConfigPage::slotConfigure()
01141 {
01142 KatePartPluginListItem *item = static_cast<KatePartPluginListItem*>(listView->currentItem());
01143 KTextEditor::Plugin *plugin =
01144 KTextEditor::createPlugin(QFile::encodeName((KateFactory::self()->plugins())[item->pluginIndex()]->library()));
01145
01146 if ( ! plugin ) return;
01147
01148 KTextEditor::ConfigInterfaceExtension *cife =
01149 KTextEditor::configInterfaceExtension( plugin );
01150
01151 if ( ! cife )
01152 return;
01153
01154 if ( ! cife->configPages() )
01155 return;
01156
01157
01158 KDialogBase::DialogType dt =
01159 cife->configPages() > 1 ?
01160 KDialogBase::IconList :
01161 KDialogBase::Plain;
01162
01163 QString name = (KateFactory::self()->plugins())[item->pluginIndex()]->name();
01164 KDialogBase *kd = new KDialogBase ( dt,
01165 i18n("Configure %1").arg( name ),
01166 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help,
01167 KDialogBase::Ok,
01168 this );
01169
01170 QPtrList<KTextEditor::ConfigPage> editorPages;
01171
01172 for (uint i = 0; i < cife->configPages (); i++)
01173 {
01174 QWidget *page;
01175 if ( dt == KDialogBase::IconList )
01176 {
01177 QStringList path;
01178 path.clear();
01179 path << cife->configPageName( i );
01180 page = kd->addVBoxPage( path, cife->configPageFullName (i),
01181 cife->configPagePixmap(i, KIcon::SizeMedium) );
01182 }
01183 else
01184 {
01185 page = kd->plainPage();
01186 QVBoxLayout *_l = new QVBoxLayout( page );
01187 _l->setAutoAdd( true );
01188 }
01189
01190 editorPages.append( cife->configPage( i, page ) );
01191 }
01192
01193 if (kd->exec())
01194 {
01195
01196 for( uint i=0; i<editorPages.count(); i++ )
01197 {
01198 editorPages.at( i )->apply();
01199 }
01200 }
01201
01202 delete kd;
01203 }
01204
01205
01206
01207 KateHlConfigPage::KateHlConfigPage (QWidget *parent)
01208 : KateConfigPage (parent, "")
01209 , hlData (0)
01210 {
01211 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
01212
01213
01214 QHBox *hbHl = new QHBox( this );
01215 layout->add (hbHl);
01216
01217 hbHl->setSpacing( KDialog::spacingHint() );
01218 QLabel *lHl = new QLabel( i18n("H&ighlight:"), hbHl );
01219 hlCombo = new QComboBox( false, hbHl );
01220 lHl->setBuddy( hlCombo );
01221 connect( hlCombo, SIGNAL(activated(int)),
01222 this, SLOT(hlChanged(int)) );
01223
01224 for( int i = 0; i < KateHlManager::self()->highlights(); i++) {
01225 if (KateHlManager::self()->hlSection(i).length() > 0)
01226 hlCombo->insertItem(KateHlManager::self()->hlSection(i) + QString ("/") + KateHlManager::self()->hlNameTranslated(i));
01227 else
01228 hlCombo->insertItem(KateHlManager::self()->hlNameTranslated(i));
01229 }
01230 hlCombo->setCurrentItem(0);
01231
01232 QGroupBox *gbInfo = new QGroupBox( 1, Qt::Horizontal, i18n("Information"), this );
01233 layout->add (gbInfo);
01234
01235
01236 QHBox *hb1 = new QHBox( gbInfo);
01237 new QLabel( i18n("Author:"), hb1 );
01238 author = new QLabel (hb1);
01239 author->setTextFormat (Qt::RichText);
01240
01241
01242 QHBox *hb2 = new QHBox( gbInfo);
01243 new QLabel( i18n("License:"), hb2 );
01244 license = new QLabel (hb2);
01245
01246 QGroupBox *gbProps = new QGroupBox( 1, Qt::Horizontal, i18n("Properties"), this );
01247 layout->add (gbProps);
01248
01249
01250 QHBox *hbFE = new QHBox( gbProps);
01251 QLabel *lFileExts = new QLabel( i18n("File e&xtensions:"), hbFE );
01252 wildcards = new QLineEdit( hbFE );
01253 lFileExts->setBuddy( wildcards );
01254
01255 QHBox *hbMT = new QHBox( gbProps );
01256 QLabel *lMimeTypes = new QLabel( i18n("MIME &types:"), hbMT);
01257 mimetypes = new QLineEdit( hbMT );
01258 lMimeTypes->setBuddy( mimetypes );
01259
01260 QHBox *hbMT2 = new QHBox( gbProps );
01261 QLabel *lprio = new QLabel( i18n("Prio&rity:"), hbMT2);
01262 priority = new KIntNumInput( hbMT2 );
01263
01264 lprio->setBuddy( priority );
01265
01266 QToolButton *btnMTW = new QToolButton(hbMT);
01267 btnMTW->setIconSet(QIconSet(SmallIcon("wizard")));
01268 connect(btnMTW, SIGNAL(clicked()), this, SLOT(showMTDlg()));
01269
01270
01271 QHBox *hbBtns = new QHBox( this );
01272 layout->add (hbBtns);
01273
01274 ((QBoxLayout*)hbBtns->layout())->addStretch(1);
01275 hbBtns->setSpacing( KDialog::spacingHint() );
01276 QPushButton *btnDl = new QPushButton(i18n("Do&wnload..."), hbBtns);
01277 connect( btnDl, SIGNAL(clicked()), this, SLOT(hlDownload()) );
01278
01279 hlCombo->setCurrentItem( 0 );
01280 hlChanged(0);
01281
01282 QWhatsThis::add( hlCombo, i18n(
01283 "Choose a <em>Syntax Highlight mode</em> from this list to view its "
01284 "properties below.") );
01285 QWhatsThis::add( wildcards, i18n(
01286 "The list of file extensions used to determine which files to highlight "
01287 "using the current syntax highlight mode.") );
01288 QWhatsThis::add( mimetypes, i18n(
01289 "The list of Mime Types used to determine which files to highlight "
01290 "using the current highlight mode.<p>Click the wizard button on the "
01291 "left of the entry field to display the MimeType selection dialog.") );
01292 QWhatsThis::add( btnMTW, i18n(
01293 "Display a dialog with a list of all available mime types to choose from."
01294 "<p>The <strong>File Extensions</strong> entry will automatically be "
01295 "edited as well.") );
01296 QWhatsThis::add( btnDl, i18n(
01297 "Click this button to download new or updated syntax highlight "
01298 "descriptions from the Kate website.") );
01299
01300 layout->addStretch ();
01301
01302 connect( wildcards, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
01303 connect( mimetypes, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotChanged() ) );
01304 connect( priority, SIGNAL( valueChanged ( int ) ), this, SLOT( slotChanged() ) );
01305 }
01306
01307 KateHlConfigPage::~KateHlConfigPage ()
01308 {
01309 }
01310
01311 void KateHlConfigPage::apply ()
01312 {
01313
01314 if (!changed())
01315 return;
01316 m_changed = false;
01317
01318 writeback();
01319
01320 for ( QIntDictIterator<KateHlData> it( hlDataDict ); it.current(); ++it )
01321 KateHlManager::self()->getHl( it.currentKey() )->setData( it.current() );
01322
01323 KateHlManager::self()->getKConfig()->sync ();
01324 }
01325
01326 void KateHlConfigPage::reload ()
01327 {
01328 }
01329
01330 void KateHlConfigPage::hlChanged(int z)
01331 {
01332 writeback();
01333
01334 KateHighlighting *hl = KateHlManager::self()->getHl( z );
01335
01336 if (!hl)
01337 {
01338 hlData = 0;
01339 return;
01340 }
01341
01342 if ( !hlDataDict.find( z ) )
01343 hlDataDict.insert( z, hl->getData() );
01344
01345 hlData = hlDataDict.find( z );
01346 wildcards->setText(hlData->wildcards);
01347 mimetypes->setText(hlData->mimetypes);
01348 priority->setValue(hlData->priority);
01349
01350
01351 QStringList l= QStringList::split (QRegExp("[,;]"), hl->author());
01352 author->setText (l.join ("<br>"));
01353
01354 license->setText (hl->license());
01355 }
01356
01357 void KateHlConfigPage::writeback()
01358 {
01359 if (hlData)
01360 {
01361 hlData->wildcards = wildcards->text();
01362 hlData->mimetypes = mimetypes->text();
01363 hlData->priority = priority->value();
01364 }
01365 }
01366
01367 void KateHlConfigPage::hlDownload()
01368 {
01369 KateHlDownloadDialog diag(this,"hlDownload",true);
01370 diag.exec();
01371 }
01372
01373 void KateHlConfigPage::showMTDlg()
01374 {
01375 QString 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() );
01376 QStringList list = QStringList::split( QRegExp("\\s*;\\s*"), mimetypes->text() );
01377 KMimeTypeChooserDialog *d = new KMimeTypeChooserDialog( i18n("Select Mime Types"), text, list, "text", this );
01378
01379 if ( d->exec() == KDialogBase::Accepted ) {
01380
01381
01382 wildcards->setText(d->chooser()->patterns().join(";"));
01383 mimetypes->setText(d->chooser()->mimeTypes().join(";"));
01384 }
01385 }
01386
01387
01388
01389 KateHlDownloadDialog::KateHlDownloadDialog(QWidget *parent, const char *name, bool modal)
01390 :KDialogBase(KDialogBase::Swallow, i18n("Highlight Download"), User1|Close, User1, parent, name, modal, true, i18n("&Install"))
01391 {
01392 QVBox* vbox = new QVBox(this);
01393 setMainWidget(vbox);
01394 vbox->setSpacing(spacingHint());
01395 new QLabel(i18n("Select the syntax highlighting files you want to update:"), vbox);
01396 list = new QListView(vbox);
01397 list->addColumn("");
01398 list->addColumn(i18n("Name"));
01399 list->addColumn(i18n("Installed"));
01400 list->addColumn(i18n("Latest"));
01401 list->setSelectionMode(QListView::Multi);
01402 list->setAllColumnsShowFocus(true);
01403
01404 new QLabel(i18n("<b>Note:</b> New versions are selected automatically."), vbox);
01405 actionButton (User1)->setIconSet(SmallIconSet("ok"));
01406
01407 transferJob = KIO::get(
01408 KURL(QString(HLDOWNLOADPATH)
01409 + QString("update-")
01410 + QString(KATEPART_VERSION)
01411 + QString(".xml")), true, true );
01412 connect(transferJob, SIGNAL(data(KIO::Job *, const QByteArray &)),
01413 this, SLOT(listDataReceived(KIO::Job *, const QByteArray &)));
01414
01415 resize(450, 400);
01416 }
01417
01418 KateHlDownloadDialog::~KateHlDownloadDialog(){}
01419
01420 void KateHlDownloadDialog::listDataReceived(KIO::Job *, const QByteArray &data)
01421 {
01422 if (!transferJob || transferJob->isErrorPage())
01423 {
01424 actionButton(User1)->setEnabled(false);
01425 return;
01426 }
01427
01428 listData+=QString(data);
01429 kdDebug(13000)<<QString("CurrentListData: ")<<listData<<endl<<endl;
01430 kdDebug(13000)<<QString("Data length: %1").arg(data.size())<<endl;
01431 kdDebug(13000)<<QString("listData length: %1").arg(listData.length())<<endl;
01432 if (data.size()==0)
01433 {
01434 if (listData.length()>0)
01435 {
01436 QString installedVersion;
01437 KateHlManager *hlm=KateHlManager::self();
01438 QDomDocument doc;
01439 doc.setContent(listData);
01440 QDomElement DocElem=doc.documentElement();
01441 QDomNode n=DocElem.firstChild();
01442 KateHighlighting *hl = 0;
01443
01444 if (n.isNull()) kdDebug(13000)<<"There is no usable childnode"<<endl;
01445 while (!n.isNull())
01446 {
01447 installedVersion=" --";
01448
01449 QDomElement e=n.toElement();
01450 if (!e.isNull())
01451 kdDebug(13000)<<QString("NAME: ")<<e.tagName()<<QString(" - ")<<e.attribute("name")<<endl;
01452 n=n.nextSibling();
01453
01454 QString Name=e.attribute("name");
01455
01456 for (int i=0;i<hlm->highlights();i++)
01457 {
01458 hl=hlm->getHl(i);
01459 if (hl && hl->name()==Name)
01460 {
01461 installedVersion=" "+hl->version();
01462 break;
01463 }
01464 else hl = 0;
01465 }
01466
01467
01468 QListViewItem* entry = new QListViewItem(
01469 list, "", e.attribute("name"), installedVersion,
01470 e.attribute("version"),e.attribute("url"));
01471 if (!hl || hl->version() < e.attribute("version"))
01472 {
01473 entry->setSelected(true);
01474 entry->setPixmap(0, SmallIcon(("knewstuff")));
01475 }
01476 }
01477 }
01478 }
01479 }
01480
01481 void KateHlDownloadDialog::slotUser1()
01482 {
01483 QString destdir=KGlobal::dirs()->saveLocation("data","katepart/syntax/");
01484 for (QListViewItem *it=list->firstChild();it;it=it->nextSibling())
01485 {
01486 if (list->isSelected(it))
01487 {
01488 KURL src(it->text(4));
01489 QString filename=src.fileName(false);
01490 QString dest = destdir+filename;
01491
01492 KIO::NetAccess::download(src,dest, this);
01493 }
01494 }
01495
01496
01497 KateSyntaxDocument doc (true);
01498 }
01499
01500
01501
01502 KateGotoLineDialog::KateGotoLineDialog(QWidget *parent, int line, int max)
01503 : KDialogBase(parent, 0L, true, i18n("Go to Line"), Ok | Cancel, Ok) {
01504
01505 QWidget *page = new QWidget(this);
01506 setMainWidget(page);
01507
01508 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
01509 e1 = new KIntNumInput(line, page);
01510 e1->setRange(1, max);
01511 e1->setEditFocus(true);
01512
01513 QLabel *label = new QLabel( e1,i18n("&Go to line:"), page );
01514 topLayout->addWidget(label);
01515 topLayout->addWidget(e1);
01516 topLayout->addSpacing(spacingHint());
01517 topLayout->addStretch(10);
01518 e1->setFocus();
01519 }
01520
01521 int KateGotoLineDialog::getLine() {
01522 return e1->value();
01523 }
01524
01525
01526
01527 KateModOnHdPrompt::KateModOnHdPrompt( KateDocument *doc,
01528 int modtype,
01529 const QString &reason,
01530 QWidget *parent )
01531 : KDialogBase( parent, "", true, "", Ok|Apply|Cancel|User1 ),
01532 m_doc( doc ),
01533 m_modtype ( modtype ),
01534 m_tmpfile( 0 )
01535 {
01536 QString title, btnOK, whatisok;
01537 if ( modtype == 3 )
01538 {
01539 title = i18n("File Was Deleted on Disk");
01540 btnOK = i18n("&Save File As...");
01541 whatisok = i18n("Lets you select a location and save the file again.");
01542 } else {
01543 title = i18n("File Changed on Disk");
01544 btnOK = i18n("&Reload File");
01545 whatisok = i18n("Reload the file from disk. If you have unsaved changes, "
01546 "they will be lost.");
01547 }
01548
01549 setButtonText( Ok, btnOK);
01550 setButtonText( Apply, i18n("&Ignore") );
01551
01552 setButtonWhatsThis( Ok, whatisok );
01553 setButtonWhatsThis( Apply, i18n("Ignore the changes. You will not be prompted again.") );
01554 setButtonWhatsThis( Cancel, i18n("Do nothing. Next time you focus the file, "
01555 "or try to save it or close it, you will be prompted again.") );
01556
01557 enableButtonSeparator( true );
01558 setCaption( title );
01559
01560 QFrame *w = makeMainWidget();
01561 QVBoxLayout *lo = new QVBoxLayout( w );
01562 QHBoxLayout *lo1 = new QHBoxLayout( lo );
01563 QLabel *icon = new QLabel( w );
01564 icon->setPixmap( DesktopIcon("messagebox_warning" ) );
01565 lo1->addWidget( icon );
01566 lo1->addWidget( new QLabel( reason + "\n\n" + i18n("What do you want to do?"), w ) );
01567
01568
01569 if ( modtype != 3 )
01570 {
01571 QHBoxLayout *lo2 = new QHBoxLayout( lo );
01572 QPushButton *btnDiff = new QPushButton( i18n("&View Difference"), w );
01573 lo2->addStretch( 1 );
01574 lo2->addWidget( btnDiff );
01575 connect( btnDiff, SIGNAL(clicked()), this, SLOT(slotDiff()) );
01576 QWhatsThis::add( btnDiff, i18n(
01577 "Calculates the difference between the editor contents and the disk "
01578 "file using diff(1) and opens the diff file with the default application "
01579 "for that.") );
01580
01581 setButtonText( User1, i18n("Overwrite") );
01582 setButtonWhatsThis( User1, i18n("Overwrite the disk file with the editor content.") );
01583 }
01584 else
01585 showButton( User1, false );
01586 }
01587
01588 KateModOnHdPrompt::~KateModOnHdPrompt()
01589 {
01590 }
01591
01592 void KateModOnHdPrompt::slotDiff()
01593 {
01594
01595 KProcIO *p = new KProcIO();
01596 p->setComm( KProcess::All );
01597 *p << "diff" << "-ub" << "-" << m_doc->url().path();
01598 connect( p, SIGNAL(processExited(KProcess*)), this, SLOT(slotPDone(KProcess*)) );
01599 connect( p, SIGNAL(readReady(KProcIO*)), this, SLOT(slotPRead(KProcIO*)) );
01600
01601 setCursor( WaitCursor );
01602
01603 p->start( KProcess::NotifyOnExit, true );
01604
01605 uint lastln = m_doc->numLines();
01606 for ( uint l = 0; l < lastln; l++ )
01607 p->writeStdin( m_doc->textLine( l ), l < lastln );
01608
01609 p->closeWhenDone();
01610 }
01611
01612 void KateModOnHdPrompt::slotPRead( KProcIO *p)
01613 {
01614
01615 if ( ! m_tmpfile )
01616 m_tmpfile = new KTempFile();
01617
01618 QString stmp;
01619 while ( p->readln( stmp, false ) > -1 )
01620 *m_tmpfile->textStream() << stmp << endl;
01621
01622 p->ackRead();
01623 }
01624
01625 void KateModOnHdPrompt::slotPDone( KProcess *p )
01626 {
01627 setCursor( ArrowCursor );
01628 m_tmpfile->close();
01629
01630 if ( ! p->normalExit() )
01631 {
01632 KMessageBox::sorry( this,
01633 i18n("The diff command failed. Please make sure that "
01634 "diff(1) is installed and in your PATH."),
01635 i18n("Error Creating Diff") );
01636 return;
01637 }
01638
01639 KRun::runURL( m_tmpfile->name(), "text/x-diff", true );
01640 delete m_tmpfile;
01641 m_tmpfile = 0;
01642 }
01643
01644 void KateModOnHdPrompt::slotApply()
01645 {
01646 if ( KMessageBox::warningContinueCancel(
01647 this,
01648 i18n("Ignoring means that you will not be warned again (unless "
01649 "the disk file changes once more): if you save the document, you "
01650 "will overwrite the file on disk; if you do not save then the disk file "
01651 "(if present) is what you have."),
01652 i18n("You Are on Your Own"),
01653 KStdGuiItem::cont(),
01654 "kate_ignore_modonhd" ) != KMessageBox::Continue )
01655 return;
01656
01657 done(Ignore);
01658 }
01659
01660 void KateModOnHdPrompt::slotOk()
01661 {
01662 done( m_modtype == 3 ? Save : Reload );
01663 }
01664
01665 void KateModOnHdPrompt::slotUser1()
01666 {
01667 done( Overwrite );
01668 }
01669
01670
01671
01672