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