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