Mercurial > hg > easyhg-kdiff3
comparison kdiff3/src/optiondialog.cpp @ 8:86d21651c8db
KDiff3 version 0.9.70
author | joachim99 |
---|---|
date | Mon, 06 Oct 2003 18:50:45 +0000 |
parents | |
children | 3d2965e0fb9c |
comparison
equal
deleted
inserted
replaced
7:ff98a43bbfea | 8:86d21651c8db |
---|---|
1 /* | |
2 * kdiff3 - Text Diff And Merge Tool | |
3 * This file only: Copyright (C) 2002 Joachim Eibl, joachim.eibl@gmx.de | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 * | |
19 */ | |
20 | |
21 /*************************************************************************** | |
22 * $Log$ | |
23 * Revision 1.1 2003/10/06 18:38:48 joachim99 | |
24 * KDiff3 version 0.9.70 | |
25 * * | |
26 ***************************************************************************/ | |
27 | |
28 #include <qcheckbox.h> | |
29 #include <qcombobox.h> | |
30 #include <qfont.h> | |
31 #include <qframe.h> | |
32 #include <qlayout.h> | |
33 #include <qlabel.h> | |
34 #include <qlineedit.h> | |
35 #include <qvbox.h> | |
36 #include <qvalidator.h> | |
37 #include <qtooltip.h> | |
38 | |
39 #include <kapplication.h> | |
40 #include <kcolorbtn.h> | |
41 #include <kfontdialog.h> // For KFontChooser | |
42 #include <kiconloader.h> | |
43 #include <klocale.h> | |
44 #include <kconfig.h> | |
45 #include <kmessagebox.h> | |
46 //#include <kkeydialog.h> | |
47 | |
48 #include "optiondialog.h" | |
49 #include "diff.h" | |
50 | |
51 void OptionDialog::addOptionItem(OptionItem* p) | |
52 { | |
53 m_optionItemList.push_back(p); | |
54 } | |
55 | |
56 class OptionItem | |
57 { | |
58 public: | |
59 OptionItem( OptionDialog* pOptionDialog, QString saveName ) | |
60 { | |
61 assert(pOptionDialog!=0); | |
62 pOptionDialog->addOptionItem( this ); | |
63 m_saveName = saveName; | |
64 } | |
65 virtual ~OptionItem(){} | |
66 virtual void setToDefault()=0; | |
67 virtual void setToCurrent()=0; | |
68 virtual void apply()=0; | |
69 virtual void write(KConfig*)=0; | |
70 virtual void read(KConfig*)=0; | |
71 protected: | |
72 QString m_saveName; | |
73 }; | |
74 | |
75 class OptionCheckBox : public QCheckBox, public OptionItem | |
76 { | |
77 public: | |
78 OptionCheckBox( QString text, bool bDefaultVal, const QString& saveName, bool* pbVar, | |
79 QWidget* pParent, OptionDialog* pOD ) | |
80 : QCheckBox( text, pParent ), OptionItem( pOD, saveName ) | |
81 { | |
82 m_pbVar = pbVar; | |
83 m_bDefaultVal = bDefaultVal; | |
84 } | |
85 void setToDefault(){ setChecked( m_bDefaultVal ); } | |
86 void setToCurrent(){ setChecked( *m_pbVar ); } | |
87 void apply() { *m_pbVar = isChecked(); } | |
88 void write(KConfig* config){ config->writeEntry(m_saveName, *m_pbVar ); } | |
89 void read (KConfig* config){ *m_pbVar = config->readBoolEntry( m_saveName, *m_pbVar ); } | |
90 private: | |
91 OptionCheckBox( const OptionCheckBox& ); // private copy constructor without implementation | |
92 bool* m_pbVar; | |
93 bool m_bDefaultVal; | |
94 }; | |
95 | |
96 class OptionColorButton : public KColorButton, public OptionItem | |
97 { | |
98 public: | |
99 OptionColorButton( QColor defaultVal, const QString& saveName, QColor* pVar, QWidget* pParent, OptionDialog* pOD ) | |
100 : KColorButton( pParent ), OptionItem( pOD, saveName ) | |
101 { | |
102 m_pVar = pVar; | |
103 m_defaultVal = defaultVal; | |
104 } | |
105 void setToDefault(){ setColor( m_defaultVal ); } | |
106 void setToCurrent(){ setColor( *m_pVar ); } | |
107 void apply() { *m_pVar = color(); } | |
108 void write(KConfig* config){ config->writeEntry(m_saveName, *m_pVar ); } | |
109 void read (KConfig* config){ *m_pVar = config->readColorEntry( m_saveName, m_pVar ); } | |
110 private: | |
111 OptionColorButton( const OptionColorButton& ); // private copy constructor without implementation | |
112 QColor* m_pVar; | |
113 QColor m_defaultVal; | |
114 }; | |
115 | |
116 class OptionLineEdit : public QLineEdit, public OptionItem | |
117 { | |
118 public: | |
119 OptionLineEdit( const QString& defaultVal, const QString& saveName, QString* pVar, | |
120 QWidget* pParent, OptionDialog* pOD ) | |
121 : QLineEdit( pParent ), OptionItem( pOD, saveName ) | |
122 { | |
123 m_pVar = pVar; | |
124 m_defaultVal = defaultVal; | |
125 } | |
126 void setToDefault(){ setText( m_defaultVal ); } | |
127 void setToCurrent(){ setText( *m_pVar ); } | |
128 void apply() { *m_pVar = text(); } | |
129 void write(KConfig* config){ config->writeEntry(m_saveName, *m_pVar ); } | |
130 void read (KConfig* config){ *m_pVar = config->readEntry( m_saveName, *m_pVar ); } | |
131 private: | |
132 OptionLineEdit( const OptionLineEdit& ); // private copy constructor without implementation | |
133 QString* m_pVar; | |
134 QString m_defaultVal; | |
135 }; | |
136 | |
137 #if defined QT_NO_VALIDATOR | |
138 #error No validator | |
139 #endif | |
140 class OptionIntEdit : public QLineEdit, public OptionItem | |
141 { | |
142 public: | |
143 OptionIntEdit( int defaultVal, const QString& saveName, int* pVar, int rangeMin, int rangeMax, | |
144 QWidget* pParent, OptionDialog* pOD ) | |
145 : QLineEdit( pParent ), OptionItem( pOD, saveName ) | |
146 { | |
147 m_pVar = pVar; | |
148 m_defaultVal = defaultVal; | |
149 QIntValidator* v = new QIntValidator(this); | |
150 v->setRange( rangeMin, rangeMax ); | |
151 setValidator( v ); | |
152 } | |
153 void setToDefault(){ QString s; s.setNum(m_defaultVal); setText( s ); } | |
154 void setToCurrent(){ QString s; s.setNum(*m_pVar); setText( s ); } | |
155 void apply() { const QIntValidator* v=static_cast<const QIntValidator*>(validator()); | |
156 *m_pVar = minMaxLimiter( text().toInt(), v->bottom(), v->top()); | |
157 setText( QString::number(*m_pVar) ); } | |
158 void write(KConfig* config){ config->writeEntry(m_saveName, *m_pVar ); } | |
159 void read (KConfig* config){ *m_pVar = config->readNumEntry( m_saveName, *m_pVar ); } | |
160 private: | |
161 OptionIntEdit( const OptionIntEdit& ); // private copy constructor without implementation | |
162 int* m_pVar; | |
163 int m_defaultVal; | |
164 }; | |
165 | |
166 | |
167 OptionDialog::OptionDialog( bool bShowDirMergeSettings, QWidget *parent, char *name ) | |
168 :KDialogBase( IconList, i18n("Configure"), Help|Default|Apply|Ok|Cancel, | |
169 Ok, parent, name, true /*modal*/, true ) | |
170 { | |
171 setHelp( "kdiff3/index.html", QString::null ); | |
172 | |
173 setupFontPage(); | |
174 setupColorPage(); | |
175 setupEditPage(); | |
176 setupDiffPage(); | |
177 if (bShowDirMergeSettings) | |
178 setupDirectoryMergePage(); | |
179 //setupKeysPage(); | |
180 | |
181 // Initialize all values in the dialog | |
182 resetToDefaults(); | |
183 slotApply(); | |
184 } | |
185 | |
186 OptionDialog::~OptionDialog( void ) | |
187 { | |
188 } | |
189 | |
190 | |
191 void OptionDialog::setupFontPage( void ) | |
192 { | |
193 QFrame *page = addPage( i18n("Font"), i18n("Editor and diff output font" ), | |
194 BarIcon("fonts", KIcon::SizeMedium ) ); | |
195 | |
196 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
197 | |
198 m_fontChooser = new KFontChooser( page,"font",true/*onlyFixed*/,QStringList(),false,6 ); | |
199 topLayout->addWidget( m_fontChooser ); | |
200 | |
201 QGridLayout *gbox = new QGridLayout( 1, 2 ); | |
202 topLayout->addLayout( gbox ); | |
203 int line=0; | |
204 | |
205 OptionCheckBox* pItalicDeltas = new OptionCheckBox( i18n("Italic Font For Deltas"), false, "ItalicForDeltas", &m_bItalicForDeltas, page, this ); | |
206 gbox->addMultiCellWidget( pItalicDeltas, line, line, 0, 1 ); | |
207 QToolTip::add( pItalicDeltas, i18n( | |
208 "Selects the italic version of the font for differences.\n" | |
209 "If the font doesn't support italic characters, then this does nothing.") | |
210 ); | |
211 } | |
212 | |
213 | |
214 void OptionDialog::setupColorPage( void ) | |
215 { | |
216 QFrame *page = addPage( i18n("Color"), i18n("Colors in editor and diff output"), | |
217 BarIcon("colorize", KIcon::SizeMedium ) ); | |
218 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
219 | |
220 QGridLayout *gbox = new QGridLayout( 7, 2 ); | |
221 topLayout->addLayout(gbox); | |
222 | |
223 QLabel* label; | |
224 int line = 0; | |
225 | |
226 int depth = QColor::numBitPlanes(); | |
227 bool bLowColor = depth<=8; | |
228 | |
229 OptionColorButton* pFgColor = new OptionColorButton( black,"FgColor", &m_fgColor, page, this ); | |
230 label = new QLabel( pFgColor, i18n("Foreground color:"), page ); | |
231 gbox->addWidget( label, line, 0 ); | |
232 gbox->addWidget( pFgColor, line, 1 ); | |
233 ++line; | |
234 | |
235 OptionColorButton* pBgColor = new OptionColorButton( white, "BgColor", &m_bgColor, page, this ); | |
236 label = new QLabel( pBgColor, i18n("Background color:"), page ); | |
237 gbox->addWidget( label, line, 0 ); | |
238 gbox->addWidget( pBgColor, line, 1 ); | |
239 | |
240 ++line; | |
241 | |
242 OptionColorButton* pDiffBgColor = new OptionColorButton( lightGray, "DiffBgColor", &m_diffBgColor, page, this ); | |
243 label = new QLabel( pDiffBgColor, i18n("Diff background color:"), page ); | |
244 gbox->addWidget( label, line, 0 ); | |
245 gbox->addWidget( pDiffBgColor, line, 1 ); | |
246 ++line; | |
247 | |
248 OptionColorButton* pColorA = new OptionColorButton( | |
249 bLowColor ? qRgb(0,0,255) : qRgb(0,0,200)/*blue*/, "ColorA", &m_colorA, page, this ); | |
250 label = new QLabel( pColorA, i18n("Color A:"), page ); | |
251 gbox->addWidget( label, line, 0 ); | |
252 gbox->addWidget( pColorA, line, 1 ); | |
253 ++line; | |
254 | |
255 OptionColorButton* pColorB = new OptionColorButton( | |
256 bLowColor ? qRgb(0,128,0) : qRgb(0,150,0)/*green*/, "ColorB", &m_colorB, page, this ); | |
257 label = new QLabel( pColorB, i18n("Color B:"), page ); | |
258 gbox->addWidget( label, line, 0 ); | |
259 gbox->addWidget( pColorB, line, 1 ); | |
260 ++line; | |
261 | |
262 OptionColorButton* pColorC = new OptionColorButton( | |
263 bLowColor ? qRgb(128,0,128) : qRgb(150,0,150)/*magenta*/, "ColorC", &m_colorC, page, this ); | |
264 label = new QLabel( pColorC, i18n("Color C:"), page ); | |
265 gbox->addWidget( label, line, 0 ); | |
266 gbox->addWidget( pColorC, line, 1 ); | |
267 ++line; | |
268 | |
269 OptionColorButton* pColorForConflict = new OptionColorButton( red, "ColorForConflict", &m_colorForConflict, page, this ); | |
270 label = new QLabel( pColorForConflict, i18n("Conflict Color:"), page ); | |
271 gbox->addWidget( label, line, 0 ); | |
272 gbox->addWidget( pColorForConflict, line, 1 ); | |
273 ++line; | |
274 | |
275 OptionColorButton* pColor = new OptionColorButton( | |
276 bLowColor ? qRgb(192,192,192) : qRgb(220,220,100), "CurrentRangeBgColor", &m_currentRangeBgColor, page, this ); | |
277 label = new QLabel( pColor, i18n("Current range background color:"), page ); | |
278 gbox->addWidget( label, line, 0 ); | |
279 gbox->addWidget( pColor, line, 1 ); | |
280 ++line; | |
281 | |
282 pColor = new OptionColorButton( | |
283 bLowColor ? qRgb(255,255,0) : qRgb(255,255,150), "CurrentRangeDiffBgColor", &m_currentRangeDiffBgColor, page, this ); | |
284 label = new QLabel( pColor, i18n("Current range diff background color:"), page ); | |
285 gbox->addWidget( label, line, 0 ); | |
286 gbox->addWidget( pColor, line, 1 ); | |
287 ++line; | |
288 | |
289 topLayout->addStretch(10); | |
290 } | |
291 | |
292 | |
293 void OptionDialog::setupEditPage( void ) | |
294 { | |
295 QFrame *page = addPage( i18n("Editor Settings"), i18n("Editor behaviour"), | |
296 BarIcon("edit", KIcon::SizeMedium ) ); | |
297 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
298 | |
299 QGridLayout *gbox = new QGridLayout( 4, 2 ); | |
300 topLayout->addLayout( gbox ); | |
301 QLabel* label; | |
302 int line=0; | |
303 | |
304 OptionCheckBox* pReplaceTabs = new OptionCheckBox( i18n("Tab inserts spaces"), false, "ReplaceTabs", &m_bReplaceTabs, page, this ); | |
305 gbox->addMultiCellWidget( pReplaceTabs, line, line, 0, 1 ); | |
306 QToolTip::add( pReplaceTabs, i18n( | |
307 "On: Pressing tab generates the appropriate number of spaces.\n" | |
308 "Off: A Tab-character will be inserted.") | |
309 ); | |
310 ++line; | |
311 | |
312 OptionIntEdit* pTabSize = new OptionIntEdit( 8, "TabSize", &m_tabSize, 1, 100, page, this ); | |
313 label = new QLabel( pTabSize, i18n("Tab size:"), page ); | |
314 gbox->addWidget( label, line, 0 ); | |
315 gbox->addWidget( pTabSize, line, 1 ); | |
316 ++line; | |
317 | |
318 OptionCheckBox* pAutoIndentation = new OptionCheckBox( i18n("Auto Indentation"), true, "AutoIndentation", &m_bAutoIndentation, page, this ); | |
319 gbox->addMultiCellWidget( pAutoIndentation, line, line, 0, 1 ); | |
320 QToolTip::add( pAutoIndentation, i18n( | |
321 "On: The indentation of the previous line is used for a new line.\n" | |
322 )); | |
323 ++line; | |
324 | |
325 OptionCheckBox* pAutoCopySelection = new OptionCheckBox( i18n("Auto Copy Selection"), false, "AutoCopySelection", &m_bAutoCopySelection, page, this ); | |
326 gbox->addMultiCellWidget( pAutoCopySelection, line, line, 0, 1 ); | |
327 QToolTip::add( pAutoCopySelection, i18n( | |
328 "On: Any selection is immediately written to the clipboard.\n" | |
329 "Off: You must explicitely copy e.g. via Ctrl-C." | |
330 )); | |
331 ++line; | |
332 | |
333 topLayout->addStretch(10); | |
334 } | |
335 | |
336 | |
337 void OptionDialog::setupDiffPage( void ) | |
338 { | |
339 QFrame *page = addPage( i18n("Diff & Merge Settings"), i18n("Diff & Merge Settings"), | |
340 BarIcon("misc", KIcon::SizeMedium ) ); | |
341 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
342 | |
343 QGridLayout *gbox = new QGridLayout( 3, 2 ); | |
344 topLayout->addLayout( gbox ); | |
345 int line=0; | |
346 | |
347 OptionCheckBox* pIgnoreWhiteSpace = new OptionCheckBox( i18n("Ignore white space"), true, "IgnoreWhiteSpace", &m_bIgnoreWhiteSpace, page, this ); | |
348 gbox->addMultiCellWidget( pIgnoreWhiteSpace, line, line, 0, 1 ); | |
349 QToolTip::add( pIgnoreWhiteSpace, i18n( | |
350 "On: Text that differs only in white space will match and\n" | |
351 "be shown on the same line in the different output windows.\n" | |
352 "Off is useful when whitespace is very important.\n" | |
353 "On is good for C/C++ and similar languages." ) | |
354 ); | |
355 ++line; | |
356 | |
357 OptionCheckBox* pPreserveCarriageReturn = new OptionCheckBox( i18n("Preserve Carriage Return"), false, "PreserveCarriageReturn", &m_bPreserveCarriageReturn, page, this ); | |
358 gbox->addMultiCellWidget( pPreserveCarriageReturn, line, line, 0, 1 ); | |
359 QToolTip::add( pPreserveCarriageReturn, | |
360 "Show carriage return characters '\\r' if they exist.\n" | |
361 "Helps to compare files that were modified under different operating systems." | |
362 ); | |
363 ++line; | |
364 | |
365 OptionCheckBox* pIgnoreNumbers = new OptionCheckBox( i18n("Ignore Numbers"), false, "IgnoreNumbers", &m_bIgnoreNumbers, page, this ); | |
366 gbox->addMultiCellWidget( pIgnoreNumbers, line, line, 0, 1 ); | |
367 QToolTip::add( pIgnoreNumbers, | |
368 "Ignore number characters during line matching phase. (Similar to Ignore white space.)\n" | |
369 "Might help to compare files with numeric data." | |
370 ); | |
371 ++line; | |
372 | |
373 OptionCheckBox* pUpCase = new OptionCheckBox( i18n("Convert to Upper Case"), false, "UpCase", &m_bUpCase, page, this ); | |
374 gbox->addMultiCellWidget( pUpCase, line, line, 0, 1 ); | |
375 QToolTip::add( pUpCase, | |
376 "Turn all lower case characters to upper case on reading. (e.g.: 'a'->'A')" | |
377 ); | |
378 ++line; | |
379 | |
380 QLabel* label = new QLabel( i18n("Preprocessor-Command"), page ); | |
381 gbox->addWidget( label, line, 0 ); | |
382 OptionLineEdit* pLE = new OptionLineEdit( "", "PreProcessorCmd", &m_PreProcessorCmd, page, this ); | |
383 gbox->addWidget( pLE, line, 1 ); | |
384 QToolTip::add( label, i18n("User defined pre-processing. (See the docs for details.)") ); | |
385 ++line; | |
386 | |
387 label = new QLabel( i18n("Line-Matching Preprocessor-Command"), page ); | |
388 gbox->addWidget( label, line, 0 ); | |
389 pLE = new OptionLineEdit( "", "LineMatchingPreProcessorCmd", &m_LineMatchingPreProcessorCmd, page, this ); | |
390 gbox->addWidget( pLE, line, 1 ); | |
391 QToolTip::add( label, i18n("This pre-processor is only used during line matching.\n(See the docs for details.)") ); | |
392 ++line; | |
393 | |
394 OptionCheckBox* pUseExternalDiff = new OptionCheckBox( i18n("Use external diff"), true, "UseExternalDiff", &m_bUseExternalDiff, page, this ); | |
395 gbox->addMultiCellWidget( pUseExternalDiff, line, line, 0, 1 ); | |
396 QToolTip::add( pUseExternalDiff, | |
397 "Since for complicated files the internal algorithm is not so good yet,\n" | |
398 "you probably want to use the normal diff tool as line matcher." | |
399 ); | |
400 ++line; | |
401 | |
402 OptionCheckBox* pTryHard = new OptionCheckBox( i18n("Try Hard (slow)"), true, "TryHard", &m_bTryHard, page, this ); | |
403 gbox->addMultiCellWidget( pTryHard, line, line, 0, 1 ); | |
404 QToolTip::add( pTryHard, | |
405 "Enables the --minimal option for the external diff.\n" | |
406 "The analysis of big files will be much slower." | |
407 ); | |
408 ++line; | |
409 | |
410 OptionCheckBox* pIgnoreTrivialMatches = new OptionCheckBox( i18n("Ignore trivial matches"), true, "IgnoreTrivialMatches", &m_bIgnoreTrivialMatches, page, this ); | |
411 gbox->addMultiCellWidget( pIgnoreTrivialMatches, line, line, 0, 1 ); | |
412 QToolTip::add( pIgnoreTrivialMatches, i18n( | |
413 "When a difference was found, the algorithm searches for matching lines\n" | |
414 "Short or trivial lines match even when the differences still continue.\n" | |
415 "Ignoring trivial lines avoids this. Good for C/C++ and similar languages." ) | |
416 ); | |
417 ++line; | |
418 | |
419 label = new QLabel( i18n("Max search length"), page ); | |
420 gbox->addWidget( label, line, 0 ); | |
421 OptionIntEdit* pMaxSearchLength = new OptionIntEdit( 1000, "MaxSearchLength", &m_maxSearchLength, 100, 100000, page, this ); | |
422 gbox->addWidget( pMaxSearchLength, line, 1 ); | |
423 QToolTip::add( label, i18n( | |
424 "Diff might fail for too small values but might take too long for big values.\n" ) | |
425 ); | |
426 ++line; | |
427 | |
428 connect( pUseExternalDiff, SIGNAL( toggled(bool)), pTryHard, SLOT(setEnabled(bool))); | |
429 connect( pUseExternalDiff, SIGNAL( toggled(bool)), pMaxSearchLength, SLOT(setDisabled(bool))); | |
430 | |
431 connect( pUseExternalDiff, SIGNAL( toggled(bool)), label, SLOT(setDisabled(bool))); | |
432 connect( pUseExternalDiff, SIGNAL( toggled(bool)), pIgnoreTrivialMatches, SLOT(setDisabled(bool))); | |
433 | |
434 label = new QLabel( i18n("Auto Advance Delay (ms)"), page ); | |
435 gbox->addWidget( label, line, 0 ); | |
436 OptionIntEdit* pAutoAdvanceDelay = new OptionIntEdit( 500, "AutoAdvanceDelay", &m_autoAdvanceDelay, 0, 2000, page, this ); | |
437 gbox->addWidget( pAutoAdvanceDelay, line, 1 ); | |
438 QToolTip::add( label,i18n( | |
439 "When in Auto-Advance mode the result of the current selection is shown \n" | |
440 "for the specified time, before jumping to the next conflict. Range: 0-2000 ms") | |
441 ); | |
442 ++line; | |
443 | |
444 topLayout->addStretch(10); | |
445 } | |
446 | |
447 void OptionDialog::setupDirectoryMergePage( void ) | |
448 { | |
449 QFrame *page = addPage( i18n("Directory Merge Settings"), i18n("Directory Merge"), | |
450 BarIcon("folder", KIcon::SizeMedium ) ); | |
451 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
452 | |
453 QGridLayout *gbox = new QGridLayout( 11, 2 ); | |
454 topLayout->addLayout( gbox ); | |
455 int line=0; | |
456 | |
457 OptionCheckBox* pRecursiveDirs = new OptionCheckBox( i18n("Recursive Directories"), true, "RecursiveDirs", &m_bDmRecursiveDirs, page, this ); | |
458 gbox->addMultiCellWidget( pRecursiveDirs, line, line, 0, 1 ); | |
459 QToolTip::add( pRecursiveDirs, i18n("Whether to analyze subdirectories or not.") ); | |
460 ++line; | |
461 QLabel* label = new QLabel( i18n("File Pattern(s)"), page ); | |
462 gbox->addWidget( label, line, 0 ); | |
463 OptionLineEdit* pFilePattern = new OptionLineEdit( "*", "FilePattern", &m_DmFilePattern, page, this ); | |
464 gbox->addWidget( pFilePattern, line, 1 ); | |
465 QToolTip::add( label, i18n( | |
466 "Pattern(s) of files to be analyzed. \n" | |
467 "Wildcards: '*' and '?'\n" | |
468 "Several Patterns can be specified by using the separator: ';'" | |
469 )); | |
470 ++line; | |
471 | |
472 label = new QLabel( i18n("File-Anti-Pattern(s)"), page ); | |
473 gbox->addWidget( label, line, 0 ); | |
474 OptionLineEdit* pFileAntiPattern = new OptionLineEdit( "*.orig;*.o", "FileAntiPattern", &m_DmFileAntiPattern, page, this ); | |
475 gbox->addWidget( pFileAntiPattern, line, 1 ); | |
476 QToolTip::add( label, i18n( | |
477 "Pattern(s) of files to be excluded from analysis. \n" | |
478 "Wildcards: '*' and '?'\n" | |
479 "Several Patterns can be specified by using the separator: ';'" | |
480 )); | |
481 ++line; | |
482 | |
483 label = new QLabel( i18n("Dir-Anti-Pattern(s)"), page ); | |
484 gbox->addWidget( label, line, 0 ); | |
485 OptionLineEdit* pDirAntiPattern = new OptionLineEdit( "CVS;.deps", "DirAntiPattern", &m_DmDirAntiPattern, page, this ); | |
486 gbox->addWidget( pDirAntiPattern, line, 1 ); | |
487 QToolTip::add( label, i18n( | |
488 "Pattern(s) of directories to be excluded from analysis. \n" | |
489 "Wildcards: '*' and '?'\n" | |
490 "Several Patterns can be specified by using the separator: ';'" | |
491 )); | |
492 ++line; | |
493 | |
494 OptionCheckBox* pUseCvsIgnore = new OptionCheckBox( i18n("Use CVS-Ignore"), false, "UseCvsIgnore", &m_bDmUseCvsIgnore, page, this ); | |
495 gbox->addMultiCellWidget( pUseCvsIgnore, line, line, 0, 1 ); | |
496 QToolTip::add( pUseCvsIgnore, i18n( | |
497 "Extends the antipattern to anything that would be ignored by CVS.\n" | |
498 "Via local \".cvsignore\"-files this can be directory specific." | |
499 )); | |
500 ++line; | |
501 | |
502 OptionCheckBox* pFindHidden = new OptionCheckBox( i18n("Find Hidden Files and Directories"), true, "FindHidden", &m_bDmFindHidden, page, this ); | |
503 gbox->addMultiCellWidget( pFindHidden, line, line, 0, 1 ); | |
504 #ifdef _WIN32 | |
505 QToolTip::add( pFindHidden, i18n("Finds files and directories with the hidden attribute.") ); | |
506 #else | |
507 QToolTip::add( pFindHidden, i18n("Finds files and directories starting with '.'.") ); | |
508 #endif | |
509 ++line; | |
510 | |
511 OptionCheckBox* pFollowFileLinks = new OptionCheckBox( i18n("Follow File Links"), false, "FollowFileLinks", &m_bDmFollowFileLinks, page, this ); | |
512 gbox->addMultiCellWidget( pFollowFileLinks, line, line, 0, 1 ); | |
513 QToolTip::add( pFollowFileLinks, i18n( | |
514 "On: Compare the file the link points to.\n" | |
515 "Off: Compare the links." | |
516 )); | |
517 ++line; | |
518 | |
519 OptionCheckBox* pFollowDirLinks = new OptionCheckBox( i18n("Follow Directory Links"), false, "FollowDirLinks", &m_bDmFollowDirLinks, page, this ); | |
520 gbox->addMultiCellWidget( pFollowDirLinks, line, line, 0, 1 ); | |
521 QToolTip::add( pFollowDirLinks, i18n( | |
522 "On: Compare the directory the link points to.\n" | |
523 "Off: Compare the links." | |
524 )); | |
525 ++line; | |
526 | |
527 OptionCheckBox* pShowOnlyDeltas = new OptionCheckBox( i18n("List only deltas"),false,"ListOnlyDeltas", &m_bDmShowOnlyDeltas, page, this ); | |
528 gbox->addMultiCellWidget( pShowOnlyDeltas, line, line, 0, 1 ); | |
529 QToolTip::add( pShowOnlyDeltas, i18n( | |
530 "Files and directories without change will not appear in the list.")); | |
531 ++line; | |
532 | |
533 OptionCheckBox* pTrustDate = new OptionCheckBox( i18n("Trust the modification date. (Unsafe)."), false, "TrustDate", &m_bDmTrustDate, page, this ); | |
534 gbox->addMultiCellWidget( pTrustDate, line, line, 0, 1 ); | |
535 QToolTip::add( pTrustDate, i18n("Assume that files are equal if the modification date and file length are equal.\n" | |
536 "Useful for big directories or slow networks.") ); | |
537 ++line; | |
538 | |
539 // Some two Dir-options: Affects only the default actions. | |
540 OptionCheckBox* pSyncMode = new OptionCheckBox( i18n("Synchronize Directories."), false,"SyncMode", &m_bDmSyncMode, page, this ); | |
541 gbox->addMultiCellWidget( pSyncMode, line, line, 0, 1 ); | |
542 QToolTip::add( pSyncMode, i18n( | |
543 "Offers to store files in both directories so that\n" | |
544 "both directories are the same afterwards.\n" | |
545 "Works only when comparing two directories without specifying a destination." ) ); | |
546 ++line; | |
547 | |
548 OptionCheckBox* pCopyNewer = new OptionCheckBox( i18n("Copy newer instead of merging. (Unsafe)."), false, "CopyNewer", &m_bDmCopyNewer, page, this ); | |
549 gbox->addMultiCellWidget( pCopyNewer, line, line, 0, 1 ); | |
550 QToolTip::add( pCopyNewer, i18n( | |
551 "Don't look inside, just take the newer file.\n" | |
552 "(Use this only if you know what you are doing!)\n" | |
553 "Only effective when comparing two directories." ) ); | |
554 ++line; | |
555 | |
556 OptionCheckBox* pCreateBakFiles = new OptionCheckBox( i18n("Backup files (.orig)"), true, "CreateBakFiles", &m_bDmCreateBakFiles, page, this ); | |
557 gbox->addMultiCellWidget( pCreateBakFiles, line, line, 0, 1 ); | |
558 QToolTip::add( pCreateBakFiles, i18n( | |
559 "When a file would be saved over an old file, then the old file\n" | |
560 "will be renamed with a '.orig'-extension instead of being deleted.")); | |
561 ++line; | |
562 | |
563 topLayout->addStretch(10); | |
564 } | |
565 | |
566 void OptionDialog::setupKeysPage( void ) | |
567 { | |
568 //QVBox *page = addVBoxPage( i18n("Keys"), i18n("KeyDialog" ), | |
569 // BarIcon("fonts", KIcon::SizeMedium ) ); | |
570 | |
571 //QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); | |
572 // new KFontChooser( page,"font",false/*onlyFixed*/,QStringList(),false,6 ); | |
573 //m_pKeyDialog=new KKeyDialog( false, 0 ); | |
574 //topLayout->addWidget( m_pKeyDialog ); | |
575 } | |
576 | |
577 void OptionDialog::slotOk( void ) | |
578 { | |
579 slotApply(); | |
580 | |
581 // My system returns variable width fonts even though I | |
582 // disabled this. Even QFont::fixedPitch() doesn't work. | |
583 QFontMetrics fm(m_font); | |
584 if ( fm.width('W')!=fm.width('i') ) | |
585 { | |
586 int result = KMessageBox::warningYesNo(this, i18n( | |
587 "You selected a variable width font.\n\n" | |
588 "Because this program doesn't handle variable width fonts\n" | |
589 "correctly, you might experience problems while editing.\n\n" | |
590 "Do you want to continue or do you want to select another font."), | |
591 i18n("Incompatible font."), | |
592 i18n("Continue at my own risk"), i18n("Select another font")); | |
593 if (result==KMessageBox::No) | |
594 return; | |
595 } | |
596 | |
597 accept(); | |
598 } | |
599 | |
600 | |
601 /** Copy the values from the widgets to the public variables.*/ | |
602 void OptionDialog::slotApply( void ) | |
603 { | |
604 std::list<OptionItem*>::iterator i; | |
605 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i) | |
606 { | |
607 (*i)->apply(); | |
608 } | |
609 | |
610 // FontConfigDlg | |
611 m_font = m_fontChooser->font(); | |
612 | |
613 emit applyClicked(); | |
614 } | |
615 | |
616 /** Set the default values in the widgets only, while the | |
617 public variables remain unchanged. */ | |
618 void OptionDialog::slotDefault() | |
619 { | |
620 int result = KMessageBox::warningContinueCancel(this, i18n("This resets all options. Not only those of the current topic.") ); | |
621 if ( result==KMessageBox::Cancel ) return; | |
622 else resetToDefaults(); | |
623 } | |
624 | |
625 void OptionDialog::resetToDefaults() | |
626 { | |
627 std::list<OptionItem*>::iterator i; | |
628 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i) | |
629 { | |
630 (*i)->setToDefault(); | |
631 } | |
632 | |
633 m_fontChooser->setFont( QFont("Courier", 10 ), true /*only fixed*/ ); | |
634 | |
635 m_bAutoAdvance = false; | |
636 m_bShowWhiteSpace = true; | |
637 m_bShowLineNumbers = false; | |
638 m_bHorizDiffWindowSplitting = true; | |
639 } | |
640 | |
641 /** Initialise the widgets using the values in the public varibles. */ | |
642 void OptionDialog::setState() | |
643 { | |
644 std::list<OptionItem*>::iterator i; | |
645 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i) | |
646 { | |
647 (*i)->setToCurrent(); | |
648 } | |
649 | |
650 m_fontChooser->setFont( m_font, true /*only fixed*/ ); | |
651 } | |
652 | |
653 void OptionDialog::saveOptions( KConfig* config ) | |
654 { | |
655 // No i18n()-Translations here! | |
656 | |
657 config->setGroup("KDiff3 Options"); | |
658 | |
659 std::list<OptionItem*>::iterator i; | |
660 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i) | |
661 { | |
662 (*i)->write(config); | |
663 } | |
664 | |
665 // FontConfigDlg | |
666 config->writeEntry("Font", m_font ); | |
667 | |
668 config->writeEntry("AutoAdvance", m_bAutoAdvance ); | |
669 config->writeEntry("ShowWhiteSpace", m_bShowWhiteSpace ); | |
670 config->writeEntry("ShowLineNumbers", m_bShowLineNumbers ); | |
671 config->writeEntry("HorizDiffWindowSplitting", m_bHorizDiffWindowSplitting ); | |
672 | |
673 // Recent files (selectable in the OpenDialog) | |
674 config->writeEntry( "RecentAFiles", m_recentAFiles, '|' ); | |
675 config->writeEntry( "RecentBFiles", m_recentBFiles, '|' ); | |
676 config->writeEntry( "RecentCFiles", m_recentCFiles, '|' ); | |
677 config->writeEntry( "RecentOutputFiles", m_recentOutputFiles, '|' ); | |
678 } | |
679 | |
680 void OptionDialog::readOptions( KConfig* config ) | |
681 { | |
682 // No i18n()-Translations here! | |
683 | |
684 config->setGroup("KDiff3 Options"); | |
685 | |
686 std::list<OptionItem*>::iterator i; | |
687 | |
688 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i) | |
689 { | |
690 (*i)->read(config); | |
691 } | |
692 | |
693 // Use the current values as default settings. | |
694 | |
695 // FontConfigDlg | |
696 m_font = config->readFontEntry( "Font", &m_font); | |
697 | |
698 // DiffConfigDlg | |
699 | |
700 m_bAutoAdvance = config->readBoolEntry("AutoAdvance", m_bAutoAdvance ); | |
701 m_bShowWhiteSpace = config->readBoolEntry("ShowWhiteSpace", m_bShowWhiteSpace ); | |
702 m_bShowLineNumbers = config->readBoolEntry("ShowLineNumbers", m_bShowLineNumbers ); | |
703 m_bHorizDiffWindowSplitting = config->readBoolEntry("HorizDiffWindowSplitting", m_bHorizDiffWindowSplitting); | |
704 | |
705 // Recent files (selectable in the OpenDialog) | |
706 m_recentAFiles = config->readListEntry( "RecentAFiles", '|' ); | |
707 m_recentBFiles = config->readListEntry( "RecentBFiles", '|' ); | |
708 m_recentCFiles = config->readListEntry( "RecentCFiles", '|' ); | |
709 m_recentOutputFiles = config->readListEntry( "RecentOutputFiles", '|' ); | |
710 | |
711 setState(); | |
712 } | |
713 | |
714 void OptionDialog::slotHelp( void ) | |
715 { | |
716 KDialogBase::slotHelp(); | |
717 } | |
718 | |
719 | |
720 #include "optiondialog.moc" |