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