joachim99@8
|
1 /*
|
joachim99@8
|
2 * kdiff3 - Text Diff And Merge Tool
|
joachim99@92
|
3 * Copyright (C) 2002-2009 Joachim Eibl, joachim.eibl at 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@69
|
17 * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
|
joachim99@8
|
18 *
|
joachim99@8
|
19 */
|
joachim99@8
|
20
|
joachim99@75
|
21 #include <QCheckBox>
|
joachim99@75
|
22 #include <QComboBox>
|
joachim99@75
|
23 #include <QLabel>
|
joachim99@75
|
24 #include <QLayout>
|
joachim99@75
|
25 #include <QLineEdit>
|
joachim99@75
|
26 #include <QToolTip>
|
joachim99@75
|
27 #include <QRadioButton>
|
joachim99@75
|
28 #include <QGroupBox>
|
joachim99@75
|
29 #include <QTextCodec>
|
joachim99@95
|
30 #include <QDir>
|
joachim99@75
|
31 #include <QSettings>
|
joachim99@75
|
32 #include <QLocale>
|
joachim99@80
|
33 #include <QGridLayout>
|
joachim99@80
|
34 #include <QPixmap>
|
joachim99@80
|
35 #include <QFrame>
|
joachim99@80
|
36 #include <QVBoxLayout>
|
joachim99@8
|
37
|
joachim99@8
|
38 #include <kapplication.h>
|
joachim99@80
|
39 #include <kcolorbutton.h>
|
joachim99@8
|
40 #include <kfontdialog.h> // For KFontChooser
|
joachim99@8
|
41 #include <kiconloader.h>
|
joachim99@8
|
42 #include <klocale.h>
|
joachim99@8
|
43 #include <kconfig.h>
|
joachim99@8
|
44 #include <kmessagebox.h>
|
joachim99@69
|
45 #include <kmainwindow.h> //For ktoolbar.h
|
joachim99@80
|
46 #include <ktoolbar.h>
|
joachim99@69
|
47
|
joachim99@8
|
48 //#include <kkeydialog.h>
|
joachim99@58
|
49 #include <map>
|
joachim99@8
|
50
|
joachim99@8
|
51 #include "optiondialog.h"
|
joachim99@8
|
52 #include "diff.h"
|
joachim99@69
|
53 #include "smalldialogs.h"
|
joachim99@69
|
54
|
joachim99@69
|
55 #include <iostream>
|
joachim99@8
|
56
|
joachim99@66
|
57 #ifndef KREPLACEMENTS_H
|
joachim99@66
|
58 #include <kglobalsettings.h>
|
joachim99@66
|
59 #endif
|
joachim99@66
|
60
|
joachim99@80
|
61 #define KDIFF3_CONFIG_GROUP "KDiff3 Options"
|
joachim99@80
|
62
|
joachim99@69
|
63 static QString s_historyEntryStartRegExpToolTip;
|
joachim99@69
|
64 static QString s_historyEntryStartSortKeyOrderToolTip;
|
joachim99@69
|
65 static QString s_autoMergeRegExpToolTip;
|
joachim99@69
|
66 static QString s_historyStartRegExpToolTip;
|
joachim99@69
|
67
|
joachim99@8
|
68 void OptionDialog::addOptionItem(OptionItem* p)
|
joachim99@8
|
69 {
|
joachim99@8
|
70 m_optionItemList.push_back(p);
|
joachim99@8
|
71 }
|
joachim99@8
|
72
|
joachim99@8
|
73 class OptionItem
|
joachim99@8
|
74 {
|
joachim99@8
|
75 public:
|
joachim99@69
|
76 OptionItem( OptionDialog* pOptionDialog, const QString& saveName )
|
joachim99@8
|
77 {
|
joachim99@8
|
78 assert(pOptionDialog!=0);
|
joachim99@8
|
79 pOptionDialog->addOptionItem( this );
|
joachim99@8
|
80 m_saveName = saveName;
|
joachim99@8
|
81 }
|
joachim99@8
|
82 virtual ~OptionItem(){}
|
joachim99@8
|
83 virtual void setToDefault()=0;
|
joachim99@8
|
84 virtual void setToCurrent()=0;
|
joachim99@8
|
85 virtual void apply()=0;
|
joachim99@69
|
86 virtual void write(ValueMap*)=0;
|
joachim99@69
|
87 virtual void read(ValueMap*)=0;
|
joachim99@69
|
88 QString getSaveName(){return m_saveName;}
|
joachim99@8
|
89 protected:
|
joachim99@8
|
90 QString m_saveName;
|
joachim99@8
|
91 };
|
joachim99@8
|
92
|
joachim99@8
|
93 class OptionCheckBox : public QCheckBox, public OptionItem
|
joachim99@8
|
94 {
|
joachim99@8
|
95 public:
|
joachim99@8
|
96 OptionCheckBox( QString text, bool bDefaultVal, const QString& saveName, bool* pbVar,
|
joachim99@8
|
97 QWidget* pParent, OptionDialog* pOD )
|
joachim99@8
|
98 : QCheckBox( text, pParent ), OptionItem( pOD, saveName )
|
joachim99@8
|
99 {
|
joachim99@8
|
100 m_pbVar = pbVar;
|
joachim99@8
|
101 m_bDefaultVal = bDefaultVal;
|
joachim99@8
|
102 }
|
joachim99@8
|
103 void setToDefault(){ setChecked( m_bDefaultVal ); }
|
joachim99@8
|
104 void setToCurrent(){ setChecked( *m_pbVar ); }
|
joachim99@8
|
105 void apply() { *m_pbVar = isChecked(); }
|
joachim99@69
|
106 void write(ValueMap* config){ config->writeEntry(m_saveName, *m_pbVar ); }
|
joachim99@69
|
107 void read (ValueMap* config){ *m_pbVar = config->readBoolEntry( m_saveName, *m_pbVar ); }
|
joachim99@8
|
108 private:
|
joachim99@8
|
109 OptionCheckBox( const OptionCheckBox& ); // private copy constructor without implementation
|
joachim99@8
|
110 bool* m_pbVar;
|
joachim99@8
|
111 bool m_bDefaultVal;
|
joachim99@8
|
112 };
|
joachim99@8
|
113
|
joachim99@66
|
114 class OptionRadioButton : public QRadioButton, public OptionItem
|
joachim99@66
|
115 {
|
joachim99@66
|
116 public:
|
joachim99@66
|
117 OptionRadioButton( QString text, bool bDefaultVal, const QString& saveName, bool* pbVar,
|
joachim99@66
|
118 QWidget* pParent, OptionDialog* pOD )
|
joachim99@66
|
119 : QRadioButton( text, pParent ), OptionItem( pOD, saveName )
|
joachim99@66
|
120 {
|
joachim99@66
|
121 m_pbVar = pbVar;
|
joachim99@66
|
122 m_bDefaultVal = bDefaultVal;
|
joachim99@66
|
123 }
|
joachim99@66
|
124 void setToDefault(){ setChecked( m_bDefaultVal ); }
|
joachim99@66
|
125 void setToCurrent(){ setChecked( *m_pbVar ); }
|
joachim99@66
|
126 void apply() { *m_pbVar = isChecked(); }
|
joachim99@69
|
127 void write(ValueMap* config){ config->writeEntry(m_saveName, *m_pbVar ); }
|
joachim99@69
|
128 void read (ValueMap* config){ *m_pbVar = config->readBoolEntry( m_saveName, *m_pbVar ); }
|
joachim99@66
|
129 private:
|
joachim99@66
|
130 OptionRadioButton( const OptionRadioButton& ); // private copy constructor without implementation
|
joachim99@66
|
131 bool* m_pbVar;
|
joachim99@66
|
132 bool m_bDefaultVal;
|
joachim99@66
|
133 };
|
joachim99@66
|
134
|
joachim99@69
|
135
|
joachim99@69
|
136 template<class T>
|
joachim99@69
|
137 class OptionT : public OptionItem
|
joachim99@51
|
138 {
|
joachim99@51
|
139 public:
|
joachim99@69
|
140 OptionT( const T& defaultVal, const QString& saveName, T* pVar, OptionDialog* pOD )
|
joachim99@51
|
141 : OptionItem( pOD, saveName )
|
joachim99@51
|
142 {
|
joachim99@69
|
143 m_pVar = pVar;
|
joachim99@69
|
144 *m_pVar = defaultVal;
|
joachim99@69
|
145 }
|
joachim99@69
|
146 OptionT( const QString& saveName, T* pVar, OptionDialog* pOD )
|
joachim99@69
|
147 : OptionItem( pOD, saveName )
|
joachim99@69
|
148 {
|
joachim99@69
|
149 m_pVar = pVar;
|
joachim99@51
|
150 }
|
joachim99@51
|
151 void setToDefault(){}
|
joachim99@51
|
152 void setToCurrent(){}
|
joachim99@51
|
153 void apply() {}
|
joachim99@69
|
154 void write(ValueMap* vm){ writeEntry( vm, m_saveName, *m_pVar ); }
|
joachim99@80
|
155 void read (ValueMap* vm){ *m_pVar = vm->readEntry ( m_saveName, *m_pVar ); }
|
joachim99@51
|
156 private:
|
joachim99@69
|
157 OptionT( const OptionT& ); // private copy constructor without implementation
|
joachim99@69
|
158 T* m_pVar;
|
joachim99@51
|
159 };
|
joachim99@51
|
160
|
joachim99@69
|
161 template <class T> void writeEntry(ValueMap* vm, const QString& saveName, const T& v ) { vm->writeEntry( saveName, v ); }
|
joachim99@69
|
162 static void writeEntry(ValueMap* vm, const QString& saveName, const QStringList& v ) { vm->writeEntry( saveName, v, '|' ); }
|
joachim99@69
|
163
|
joachim99@80
|
164 //static void readEntry(ValueMap* vm, const QString& saveName, bool& v ) { v = vm->readBoolEntry( saveName, v ); }
|
joachim99@80
|
165 //static void readEntry(ValueMap* vm, const QString& saveName, int& v ) { v = vm->readNumEntry( saveName, v ); }
|
joachim99@80
|
166 //static void readEntry(ValueMap* vm, const QString& saveName, QSize& v ) { v = vm->readSizeEntry( saveName, &v ); }
|
joachim99@80
|
167 //static void readEntry(ValueMap* vm, const QString& saveName, QPoint& v ) { v = vm->readPointEntry( saveName, &v ); }
|
joachim99@80
|
168 //static void readEntry(ValueMap* vm, const QString& saveName, QStringList& v ){ v = vm->readListEntry( saveName, QStringList(), '|' ); }
|
joachim99@69
|
169
|
joachim99@69
|
170 typedef OptionT<bool> OptionToggleAction;
|
joachim99@69
|
171 typedef OptionT<int> OptionNum;
|
joachim99@69
|
172 typedef OptionT<QPoint> OptionPoint;
|
joachim99@69
|
173 typedef OptionT<QSize> OptionSize;
|
joachim99@69
|
174 typedef OptionT<QStringList> OptionStringList;
|
joachim99@69
|
175
|
joachim99@69
|
176 class OptionFontChooser : public KFontChooser, public OptionItem
|
joachim99@69
|
177 {
|
joachim99@69
|
178 public:
|
joachim99@80
|
179 OptionFontChooser( const QFont& defaultVal, const QString& saveName, QFont* pbVar, QWidget* pParent, OptionDialog* pOD ) :
|
joachim99@80
|
180 KFontChooser( pParent ),
|
joachim99@80
|
181 OptionItem( pOD, saveName )
|
joachim99@69
|
182 {
|
joachim99@69
|
183 m_pbVar = pbVar;
|
joachim99@69
|
184 *m_pbVar = defaultVal;
|
joachim99@69
|
185 m_default = defaultVal;
|
joachim99@69
|
186 }
|
joachim99@69
|
187 void setToDefault(){ setFont( m_default, true /*only fixed*/ ); }
|
joachim99@69
|
188 void setToCurrent(){ setFont( *m_pbVar, true /*only fixed*/ ); }
|
joachim99@69
|
189 void apply() { *m_pbVar = font();}
|
joachim99@69
|
190 void write(ValueMap* config){ config->writeEntry(m_saveName, *m_pbVar ); }
|
joachim99@69
|
191 void read (ValueMap* config){ *m_pbVar = config->readFontEntry( m_saveName, m_pbVar ); }
|
joachim99@69
|
192 private:
|
joachim99@69
|
193 OptionFontChooser( const OptionToggleAction& ); // private copy constructor without implementation
|
joachim99@69
|
194 QFont* m_pbVar;
|
joachim99@69
|
195 QFont m_default;
|
joachim99@69
|
196 };
|
joachim99@51
|
197
|
joachim99@8
|
198 class OptionColorButton : public KColorButton, public OptionItem
|
joachim99@8
|
199 {
|
joachim99@8
|
200 public:
|
joachim99@8
|
201 OptionColorButton( QColor defaultVal, const QString& saveName, QColor* pVar, QWidget* pParent, OptionDialog* pOD )
|
joachim99@8
|
202 : KColorButton( pParent ), OptionItem( pOD, saveName )
|
joachim99@8
|
203 {
|
joachim99@8
|
204 m_pVar = pVar;
|
joachim99@8
|
205 m_defaultVal = defaultVal;
|
joachim99@8
|
206 }
|
joachim99@8
|
207 void setToDefault(){ setColor( m_defaultVal ); }
|
joachim99@8
|
208 void setToCurrent(){ setColor( *m_pVar ); }
|
joachim99@8
|
209 void apply() { *m_pVar = color(); }
|
joachim99@69
|
210 void write(ValueMap* config){ config->writeEntry(m_saveName, *m_pVar ); }
|
joachim99@69
|
211 void read (ValueMap* config){ *m_pVar = config->readColorEntry( m_saveName, m_pVar ); }
|
joachim99@8
|
212 private:
|
joachim99@8
|
213 OptionColorButton( const OptionColorButton& ); // private copy constructor without implementation
|
joachim99@8
|
214 QColor* m_pVar;
|
joachim99@8
|
215 QColor m_defaultVal;
|
joachim99@8
|
216 };
|
joachim99@8
|
217
|
joachim99@58
|
218 class OptionLineEdit : public QComboBox, public OptionItem
|
joachim99@8
|
219 {
|
joachim99@8
|
220 public:
|
joachim99@8
|
221 OptionLineEdit( const QString& defaultVal, const QString& saveName, QString* pVar,
|
joachim99@8
|
222 QWidget* pParent, OptionDialog* pOD )
|
joachim99@58
|
223 : QComboBox( pParent ), OptionItem( pOD, saveName )
|
joachim99@8
|
224 {
|
joachim99@69
|
225 setMinimumWidth(50);
|
joachim99@69
|
226 setEditable(true);
|
joachim99@8
|
227 m_pVar = pVar;
|
joachim99@8
|
228 m_defaultVal = defaultVal;
|
joachim99@58
|
229 m_list.push_back(defaultVal);
|
joachim99@69
|
230 insertText();
|
joachim99@8
|
231 }
|
joachim99@75
|
232 void setToDefault(){ setEditText( m_defaultVal ); }
|
joachim99@75
|
233 void setToCurrent(){ setEditText( *m_pVar ); }
|
joachim99@58
|
234 void apply() { *m_pVar = currentText(); insertText(); }
|
joachim99@69
|
235 void write(ValueMap* config){ config->writeEntry( m_saveName, m_list, '|' ); }
|
joachim99@69
|
236 void read (ValueMap* config){
|
joachim99@70
|
237 m_list = config->readListEntry( m_saveName, QStringList(m_defaultVal), '|' );
|
joachim99@69
|
238 if ( !m_list.empty() ) *m_pVar = m_list.front();
|
joachim99@58
|
239 clear();
|
joachim99@75
|
240 insertItems(0,m_list);
|
joachim99@58
|
241 }
|
joachim99@8
|
242 private:
|
joachim99@58
|
243 void insertText()
|
joachim99@69
|
244 { // Check if the text exists. If yes remove it and push it in as first element
|
joachim99@58
|
245 QString current = currentText();
|
joachim99@75
|
246 m_list.removeAll( current );
|
joachim99@58
|
247 m_list.push_front( current );
|
joachim99@58
|
248 clear();
|
joachim99@69
|
249 if ( m_list.size()>10 )
|
joachim99@70
|
250 m_list.erase( m_list.begin()+10, m_list.end() );
|
joachim99@75
|
251 insertItems(0,m_list);
|
joachim99@58
|
252 }
|
joachim99@8
|
253 OptionLineEdit( const OptionLineEdit& ); // private copy constructor without implementation
|
joachim99@8
|
254 QString* m_pVar;
|
joachim99@8
|
255 QString m_defaultVal;
|
joachim99@58
|
256 QStringList m_list;
|
joachim99@8
|
257 };
|
joachim99@8
|
258
|
joachim99@8
|
259 #if defined QT_NO_VALIDATOR
|
joachim99@8
|
260 #error No validator
|
joachim99@8
|
261 #endif
|
joachim99@8
|
262 class OptionIntEdit : public QLineEdit, public OptionItem
|
joachim99@8
|
263 {
|
joachim99@8
|
264 public:
|
joachim99@8
|
265 OptionIntEdit( int defaultVal, const QString& saveName, int* pVar, int rangeMin, int rangeMax,
|
joachim99@8
|
266 QWidget* pParent, OptionDialog* pOD )
|
joachim99@8
|
267 : QLineEdit( pParent ), OptionItem( pOD, saveName )
|
joachim99@8
|
268 {
|
joachim99@8
|
269 m_pVar = pVar;
|
joachim99@8
|
270 m_defaultVal = defaultVal;
|
joachim99@51
|
271 QIntValidator* v = new QIntValidator(this);
|
joachim99@8
|
272 v->setRange( rangeMin, rangeMax );
|
joachim99@8
|
273 setValidator( v );
|
joachim99@8
|
274 }
|
joachim99@8
|
275 void setToDefault(){ QString s; s.setNum(m_defaultVal); setText( s ); }
|
joachim99@8
|
276 void setToCurrent(){ QString s; s.setNum(*m_pVar); setText( s ); }
|
joachim99@8
|
277 void apply() { const QIntValidator* v=static_cast<const QIntValidator*>(validator());
|
joachim99@8
|
278 *m_pVar = minMaxLimiter( text().toInt(), v->bottom(), v->top());
|
joachim99@8
|
279 setText( QString::number(*m_pVar) ); }
|
joachim99@69
|
280 void write(ValueMap* config){ config->writeEntry(m_saveName, *m_pVar ); }
|
joachim99@69
|
281 void read (ValueMap* config){ *m_pVar = config->readNumEntry( m_saveName, *m_pVar ); }
|
joachim99@8
|
282 private:
|
joachim99@8
|
283 OptionIntEdit( const OptionIntEdit& ); // private copy constructor without implementation
|
joachim99@8
|
284 int* m_pVar;
|
joachim99@8
|
285 int m_defaultVal;
|
joachim99@8
|
286 };
|
joachim99@8
|
287
|
joachim99@51
|
288 class OptionComboBox : public QComboBox, public OptionItem
|
joachim99@51
|
289 {
|
joachim99@51
|
290 public:
|
joachim99@58
|
291 OptionComboBox( int defaultVal, const QString& saveName, int* pVarNum,
|
joachim99@51
|
292 QWidget* pParent, OptionDialog* pOD )
|
joachim99@51
|
293 : QComboBox( pParent ), OptionItem( pOD, saveName )
|
joachim99@51
|
294 {
|
joachim99@69
|
295 setMinimumWidth(50);
|
joachim99@58
|
296 m_pVarNum = pVarNum;
|
joachim99@58
|
297 m_pVarStr = 0;
|
joachim99@51
|
298 m_defaultVal = defaultVal;
|
joachim99@51
|
299 setEditable(false);
|
joachim99@51
|
300 }
|
joachim99@58
|
301 OptionComboBox( int defaultVal, const QString& saveName, QString* pVarStr,
|
joachim99@58
|
302 QWidget* pParent, OptionDialog* pOD )
|
joachim99@58
|
303 : QComboBox( pParent ), OptionItem( pOD, saveName )
|
joachim99@58
|
304 {
|
joachim99@58
|
305 m_pVarNum = 0;
|
joachim99@58
|
306 m_pVarStr = pVarStr;
|
joachim99@58
|
307 m_defaultVal = defaultVal;
|
joachim99@58
|
308 setEditable(false);
|
joachim99@58
|
309 }
|
joachim99@58
|
310 void setToDefault()
|
joachim99@58
|
311 {
|
joachim99@75
|
312 setCurrentIndex( m_defaultVal );
|
joachim99@58
|
313 if (m_pVarStr!=0){ *m_pVarStr=currentText(); }
|
joachim99@58
|
314 }
|
joachim99@58
|
315 void setToCurrent()
|
joachim99@58
|
316 {
|
joachim99@75
|
317 if (m_pVarNum!=0) setCurrentIndex( *m_pVarNum );
|
joachim99@58
|
318 else setText( *m_pVarStr );
|
joachim99@58
|
319 }
|
joachim99@69
|
320 void apply()
|
joachim99@58
|
321 {
|
joachim99@75
|
322 if (m_pVarNum!=0){ *m_pVarNum = currentIndex(); }
|
joachim99@58
|
323 else { *m_pVarStr = currentText(); }
|
joachim99@58
|
324 }
|
joachim99@69
|
325 void write(ValueMap* config)
|
joachim99@58
|
326 {
|
joachim99@58
|
327 if (m_pVarStr!=0) config->writeEntry(m_saveName, *m_pVarStr );
|
joachim99@58
|
328 else config->writeEntry(m_saveName, *m_pVarNum );
|
joachim99@58
|
329 }
|
joachim99@69
|
330 void read (ValueMap* config)
|
joachim99@58
|
331 {
|
joachim99@58
|
332 if (m_pVarStr!=0) setText( config->readEntry( m_saveName, currentText() ) );
|
joachim99@58
|
333 else *m_pVarNum = config->readNumEntry( m_saveName, *m_pVarNum );
|
joachim99@58
|
334 }
|
joachim99@51
|
335 private:
|
joachim99@51
|
336 OptionComboBox( const OptionIntEdit& ); // private copy constructor without implementation
|
joachim99@58
|
337 int* m_pVarNum;
|
joachim99@58
|
338 QString* m_pVarStr;
|
joachim99@51
|
339 int m_defaultVal;
|
joachim99@58
|
340
|
joachim99@58
|
341 void setText(const QString& s)
|
joachim99@58
|
342 {
|
joachim99@58
|
343 // Find the string in the combobox-list, don't change the value if nothing fits.
|
joachim99@58
|
344 for( int i=0; i<count(); ++i )
|
joachim99@58
|
345 {
|
joachim99@75
|
346 if ( itemText(i)==s )
|
joachim99@58
|
347 {
|
joachim99@58
|
348 if (m_pVarNum!=0) *m_pVarNum = i;
|
joachim99@58
|
349 if (m_pVarStr!=0) *m_pVarStr = s;
|
joachim99@75
|
350 setCurrentIndex(i);
|
joachim99@58
|
351 return;
|
joachim99@58
|
352 }
|
joachim99@58
|
353 }
|
joachim99@58
|
354 }
|
joachim99@51
|
355 };
|
joachim99@8
|
356
|
joachim99@68
|
357 class OptionEncodingComboBox : public QComboBox, public OptionItem
|
joachim99@68
|
358 {
|
joachim99@68
|
359 std::vector<QTextCodec*> m_codecVec;
|
joachim99@68
|
360 QTextCodec** m_ppVarCodec;
|
joachim99@68
|
361 public:
|
joachim99@68
|
362 OptionEncodingComboBox( const QString& saveName, QTextCodec** ppVarCodec,
|
joachim99@68
|
363 QWidget* pParent, OptionDialog* pOD )
|
joachim99@68
|
364 : QComboBox( pParent ), OptionItem( pOD, saveName )
|
joachim99@68
|
365 {
|
joachim99@68
|
366 m_ppVarCodec = ppVarCodec;
|
joachim99@68
|
367 insertCodec( i18n("Unicode, 8 bit"), QTextCodec::codecForName("UTF-8") );
|
joachim99@68
|
368 insertCodec( i18n("Unicode"), QTextCodec::codecForName("iso-10646-UCS-2") );
|
joachim99@68
|
369 insertCodec( i18n("Latin1"), QTextCodec::codecForName("iso 8859-1") );
|
joachim99@68
|
370
|
joachim99@68
|
371 // First sort codec names:
|
joachim99@68
|
372 std::map<QString, QTextCodec*> names;
|
joachim99@70
|
373 QList<int> mibs = QTextCodec::availableMibs();
|
joachim99@70
|
374 foreach(int i, mibs)
|
joachim99@68
|
375 {
|
joachim99@70
|
376 QTextCodec* c = QTextCodec::codecForMib(i);
|
joachim99@75
|
377 if ( c!=0 )
|
joachim99@75
|
378 names[QString(c->name()).toUpper()]=c;
|
joachim99@68
|
379 }
|
joachim99@68
|
380
|
joachim99@68
|
381 std::map<QString, QTextCodec*>::iterator it;
|
joachim99@68
|
382 for(it=names.begin();it!=names.end();++it)
|
joachim99@68
|
383 {
|
joachim99@68
|
384 insertCodec( "", it->second );
|
joachim99@68
|
385 }
|
joachim99@68
|
386
|
joachim99@75
|
387 this->setToolTip( i18n(
|
joachim99@68
|
388 "Change this if non-ASCII characters are not displayed correctly."
|
joachim99@68
|
389 ));
|
joachim99@68
|
390 }
|
joachim99@68
|
391 void insertCodec( const QString& visibleCodecName, QTextCodec* c )
|
joachim99@68
|
392 {
|
joachim99@68
|
393 if (c!=0)
|
joachim99@68
|
394 {
|
joachim99@68
|
395 for( unsigned int i=0; i<m_codecVec.size(); ++i )
|
joachim99@68
|
396 {
|
joachim99@68
|
397 if ( c==m_codecVec[i] )
|
joachim99@68
|
398 return; // don't insert any codec twice
|
joachim99@68
|
399 }
|
joachim99@77
|
400 addItem( visibleCodecName.isEmpty() ? QString(c->name()) : visibleCodecName+" ("+c->name()+")", (int)m_codecVec.size() );
|
joachim99@68
|
401 m_codecVec.push_back( c );
|
joachim99@68
|
402 }
|
joachim99@68
|
403 }
|
joachim99@68
|
404 void setToDefault()
|
joachim99@69
|
405 {
|
joachim99@69
|
406 QString defaultName = QTextCodec::codecForLocale()->name();
|
joachim99@69
|
407 for(int i=0;i<count();++i)
|
joachim99@69
|
408 {
|
joachim99@75
|
409 if (defaultName==itemText(i) &&
|
joachim99@69
|
410 m_codecVec[i]==QTextCodec::codecForLocale())
|
joachim99@69
|
411 {
|
joachim99@75
|
412 setCurrentIndex(i);
|
joachim99@69
|
413 if (m_ppVarCodec!=0){ *m_ppVarCodec=m_codecVec[i]; }
|
joachim99@69
|
414 return;
|
joachim99@69
|
415 }
|
joachim99@69
|
416 }
|
joachim99@69
|
417
|
joachim99@75
|
418 setCurrentIndex( 0 );
|
joachim99@69
|
419 if (m_ppVarCodec!=0){ *m_ppVarCodec=m_codecVec[0]; }
|
joachim99@68
|
420 }
|
joachim99@68
|
421 void setToCurrent()
|
joachim99@68
|
422 {
|
joachim99@68
|
423 if (m_ppVarCodec!=0)
|
joachim99@68
|
424 {
|
joachim99@68
|
425 for(unsigned int i=0; i<m_codecVec.size(); ++i)
|
joachim99@68
|
426 {
|
joachim99@68
|
427 if ( *m_ppVarCodec==m_codecVec[i] )
|
joachim99@68
|
428 {
|
joachim99@75
|
429 setCurrentIndex( i );
|
joachim99@68
|
430 break;
|
joachim99@68
|
431 }
|
joachim99@68
|
432 }
|
joachim99@68
|
433 }
|
joachim99@68
|
434 }
|
joachim99@68
|
435 void apply()
|
joachim99@68
|
436 {
|
joachim99@75
|
437 if (m_ppVarCodec!=0){ *m_ppVarCodec = m_codecVec[ currentIndex() ]; }
|
joachim99@68
|
438 }
|
joachim99@69
|
439 void write(ValueMap* config)
|
joachim99@68
|
440 {
|
joachim99@70
|
441 if (m_ppVarCodec!=0) config->writeEntry(m_saveName, QString((*m_ppVarCodec)->name()) );
|
joachim99@68
|
442 }
|
joachim99@69
|
443 void read (ValueMap* config)
|
joachim99@68
|
444 {
|
joachim99@80
|
445 QString codecName = config->readEntry( m_saveName, QString(m_codecVec[ currentIndex() ]->name()) );
|
joachim99@68
|
446 for(unsigned int i=0; i<m_codecVec.size(); ++i)
|
joachim99@68
|
447 {
|
joachim99@68
|
448 if ( codecName == m_codecVec[i]->name() )
|
joachim99@68
|
449 {
|
joachim99@75
|
450 setCurrentIndex( i );
|
joachim99@68
|
451 if (m_ppVarCodec!=0) *m_ppVarCodec = m_codecVec[i];
|
joachim99@68
|
452 break;
|
joachim99@68
|
453 }
|
joachim99@68
|
454 }
|
joachim99@68
|
455 }
|
joachim99@68
|
456 };
|
joachim99@68
|
457
|
joachim99@68
|
458
|
joachim99@80
|
459 OptionDialog::OptionDialog( bool bShowDirMergeSettings, QWidget *parent, char *name ) :
|
joachim99@80
|
460 // KPageDialog( IconList, i18n("Configure"), Help|Default|Apply|Ok|Cancel,
|
joachim99@80
|
461 // Ok, parent, name, true /*modal*/, true )
|
joachim99@80
|
462 KPageDialog( parent )
|
joachim99@8
|
463 {
|
joachim99@80
|
464 setFaceType( List );
|
joachim99@80
|
465 setWindowTitle( i18n("Configure") );
|
joachim99@80
|
466 setButtons( Help|Default|Apply|Ok|Cancel );
|
joachim99@80
|
467 setDefaultButton( Ok );
|
joachim99@80
|
468 setObjectName( name );
|
joachim99@80
|
469 setModal( true );
|
joachim99@80
|
470 showButtonSeparator( true );
|
joachim99@68
|
471 setHelp( "kdiff3/index.html", QString::null );
|
joachim99@8
|
472
|
joachim99@68
|
473 setupFontPage();
|
joachim99@68
|
474 setupColorPage();
|
joachim99@68
|
475 setupEditPage();
|
joachim99@68
|
476 setupDiffPage();
|
joachim99@75
|
477 setupMergePage();
|
joachim99@68
|
478 setupOtherOptions();
|
joachim99@68
|
479 if (bShowDirMergeSettings)
|
joachim99@68
|
480 setupDirectoryMergePage();
|
joachim99@58
|
481
|
joachim99@68
|
482 setupRegionalPage();
|
joachim99@69
|
483 setupIntegrationPage();
|
joachim99@8
|
484
|
joachim99@68
|
485 //setupKeysPage();
|
joachim99@68
|
486
|
joachim99@68
|
487 // Initialize all values in the dialog
|
joachim99@68
|
488 resetToDefaults();
|
joachim99@68
|
489 slotApply();
|
joachim99@80
|
490 connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
|
joachim99@80
|
491 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
|
joachim99@80
|
492 //helpClicked() is connected in KDiff3App::KDiff3App
|
joachim99@80
|
493 connect(this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()));
|
joachim99@8
|
494 }
|
joachim99@8
|
495
|
joachim99@8
|
496 OptionDialog::~OptionDialog( void )
|
joachim99@8
|
497 {
|
joachim99@8
|
498 }
|
joachim99@8
|
499
|
joachim99@51
|
500 void OptionDialog::setupOtherOptions()
|
joachim99@51
|
501 {
|
joachim99@51
|
502 new OptionToggleAction( false, "AutoAdvance", &m_bAutoAdvance, this );
|
joachim99@51
|
503 new OptionToggleAction( true, "ShowWhiteSpaceCharacters", &m_bShowWhiteSpaceCharacters, this );
|
joachim99@51
|
504 new OptionToggleAction( true, "ShowWhiteSpace", &m_bShowWhiteSpace, this );
|
joachim99@51
|
505 new OptionToggleAction( false, "ShowLineNumbers", &m_bShowLineNumbers, this );
|
joachim99@51
|
506 new OptionToggleAction( true, "HorizDiffWindowSplitting", &m_bHorizDiffWindowSplitting, this );
|
joachim99@66
|
507 new OptionToggleAction( false, "WordWrap", &m_bWordWrap, this );
|
joachim99@69
|
508
|
joachim99@69
|
509 new OptionToggleAction( true, "ShowIdenticalFiles", &m_bDmShowIdenticalFiles, this );
|
joachim99@69
|
510
|
joachim99@69
|
511 new OptionToggleAction( true, "Show Toolbar", &m_bShowToolBar, this );
|
joachim99@69
|
512 new OptionToggleAction( true, "Show Statusbar", &m_bShowStatusBar, this );
|
joachim99@69
|
513
|
joachim99@80
|
514 /*
|
joachim99@80
|
515 TODO manage toolbar positioning
|
joachim99@69
|
516 new OptionNum( (int)KToolBar::Top, "ToolBarPos", &m_toolBarPos, this );
|
joachim99@80
|
517 */
|
joachim99@69
|
518 new OptionSize( QSize(600,400),"Geometry", &m_geometry, this );
|
joachim99@69
|
519 new OptionPoint( QPoint(0,22), "Position", &m_position, this );
|
joachim99@75
|
520 new OptionToggleAction( false, "WindowStateMaximised", &m_bMaximised, this );
|
joachim99@69
|
521
|
joachim99@69
|
522 new OptionStringList( "RecentAFiles", &m_recentAFiles, this );
|
joachim99@69
|
523 new OptionStringList( "RecentBFiles", &m_recentBFiles, this );
|
joachim99@69
|
524 new OptionStringList( "RecentCFiles", &m_recentCFiles, this );
|
joachim99@69
|
525 new OptionStringList( "RecentOutputFiles", &m_recentOutputFiles, this );
|
joachim99@51
|
526 }
|
joachim99@8
|
527
|
joachim99@8
|
528 void OptionDialog::setupFontPage( void )
|
joachim99@8
|
529 {
|
joachim99@80
|
530 QFrame* page = new QFrame();
|
joachim99@80
|
531 KPageWidgetItem *pageItem = new KPageWidgetItem( page, i18n("Font") );
|
joachim99@80
|
532 pageItem->setHeader( i18n("Editor & Diff Output Font" ) );
|
joachim99@80
|
533 pageItem->setIcon( KIcon( "preferences-desktop-font" ) );
|
joachim99@80
|
534 addPage( pageItem );
|
joachim99@8
|
535
|
joachim99@75
|
536 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
537 topLayout->setMargin( 5 );
|
joachim99@75
|
538 topLayout->setSpacing( spacingHint() );
|
joachim99@51
|
539
|
joachim99@69
|
540 QFont defaultFont =
|
joachim99@69
|
541 #ifdef _WIN32
|
joachim99@69
|
542 QFont("Courier New", 10 );
|
joachim99@69
|
543 #elif defined( KREPLACEMENTS_H )
|
joachim99@69
|
544 QFont("Courier", 10 );
|
joachim99@69
|
545 #else
|
joachim99@69
|
546 KGlobalSettings::fixedFont();
|
joachim99@69
|
547 #endif
|
joachim99@69
|
548
|
joachim99@69
|
549 OptionFontChooser* pFontChooser = new OptionFontChooser( defaultFont, "Font", &m_font, page, this );
|
joachim99@69
|
550 topLayout->addWidget( pFontChooser );
|
joachim99@8
|
551
|
joachim99@75
|
552 QGridLayout *gbox = new QGridLayout();
|
joachim99@8
|
553 topLayout->addLayout( gbox );
|
joachim99@8
|
554 int line=0;
|
joachim99@8
|
555
|
joachim99@51
|
556 OptionCheckBox* pItalicDeltas = new OptionCheckBox( i18n("Italic font for deltas"), false, "ItalicForDeltas", &m_bItalicForDeltas, page, this );
|
joachim99@75
|
557 gbox->addWidget( pItalicDeltas, line, 0, 1, 2 );
|
joachim99@75
|
558 pItalicDeltas->setToolTip( i18n(
|
joachim99@8
|
559 "Selects the italic version of the font for differences.\n"
|
joachim99@8
|
560 "If the font doesn't support italic characters, then this does nothing.")
|
joachim99@8
|
561 );
|
joachim99@8
|
562 }
|
joachim99@8
|
563
|
joachim99@8
|
564
|
joachim99@8
|
565 void OptionDialog::setupColorPage( void )
|
joachim99@8
|
566 {
|
joachim99@80
|
567 QFrame* page = new QFrame();
|
joachim99@80
|
568 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Color") );
|
joachim99@80
|
569 pageItem->setHeader( i18n("Colors Settings") );
|
joachim99@80
|
570 pageItem->setIcon( KIcon("preferences-desktop-color") );
|
joachim99@80
|
571 addPage( pageItem );
|
joachim99@80
|
572
|
joachim99@75
|
573 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
574 topLayout->setMargin( 5 );
|
joachim99@75
|
575 topLayout->setSpacing( spacingHint() );
|
joachim99@8
|
576
|
joachim99@75
|
577
|
joachim99@75
|
578 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
579 gbox->setColumnStretch(1,5);
|
joachim99@8
|
580 topLayout->addLayout(gbox);
|
joachim99@8
|
581
|
joachim99@8
|
582 QLabel* label;
|
joachim99@8
|
583 int line = 0;
|
joachim99@8
|
584
|
joachim99@70
|
585 int depth = QPixmap::defaultDepth();
|
joachim99@8
|
586 bool bLowColor = depth<=8;
|
joachim99@8
|
587
|
joachim99@69
|
588 label = new QLabel( i18n("Editor and Diff Views:"), page );
|
joachim99@69
|
589 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
590 QFont f( label->font() );
|
joachim99@69
|
591 f.setBold(true);
|
joachim99@69
|
592 label->setFont(f);
|
joachim99@69
|
593 ++line;
|
joachim99@69
|
594
|
joachim99@69
|
595 OptionColorButton* pFgColor = new OptionColorButton( Qt::black,"FgColor", &m_fgColor, page, this );
|
joachim99@75
|
596 label = new QLabel( i18n("Foreground color:"), page );
|
joachim99@75
|
597 label->setBuddy(pFgColor);
|
joachim99@8
|
598 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
599 gbox->addWidget( pFgColor, line, 1 );
|
joachim99@8
|
600 ++line;
|
joachim99@8
|
601
|
joachim99@69
|
602 OptionColorButton* pBgColor = new OptionColorButton( Qt::white, "BgColor", &m_bgColor, page, this );
|
joachim99@75
|
603 label = new QLabel( i18n("Background color:"), page );
|
joachim99@75
|
604 label->setBuddy(pBgColor);
|
joachim99@8
|
605 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
606 gbox->addWidget( pBgColor, line, 1 );
|
joachim99@8
|
607
|
joachim99@8
|
608 ++line;
|
joachim99@8
|
609
|
joachim99@69
|
610 OptionColorButton* pDiffBgColor = new OptionColorButton(
|
joachim99@75
|
611 bLowColor ? QColor(Qt::lightGray) : qRgb(224,224,224), "DiffBgColor", &m_diffBgColor, page, this );
|
joachim99@75
|
612 label = new QLabel( i18n("Diff background color:"), page );
|
joachim99@75
|
613 label->setBuddy(pDiffBgColor);
|
joachim99@8
|
614 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
615 gbox->addWidget( pDiffBgColor, line, 1 );
|
joachim99@8
|
616 ++line;
|
joachim99@8
|
617
|
joachim99@8
|
618 OptionColorButton* pColorA = new OptionColorButton(
|
joachim99@8
|
619 bLowColor ? qRgb(0,0,255) : qRgb(0,0,200)/*blue*/, "ColorA", &m_colorA, page, this );
|
joachim99@75
|
620 label = new QLabel( i18n("Color A:"), page );
|
joachim99@75
|
621 label->setBuddy(pColorA);
|
joachim99@8
|
622 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
623 gbox->addWidget( pColorA, line, 1 );
|
joachim99@8
|
624 ++line;
|
joachim99@8
|
625
|
joachim99@8
|
626 OptionColorButton* pColorB = new OptionColorButton(
|
joachim99@8
|
627 bLowColor ? qRgb(0,128,0) : qRgb(0,150,0)/*green*/, "ColorB", &m_colorB, page, this );
|
joachim99@75
|
628 label = new QLabel( i18n("Color B:"), page );
|
joachim99@75
|
629 label->setBuddy(pColorB);
|
joachim99@8
|
630 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
631 gbox->addWidget( pColorB, line, 1 );
|
joachim99@8
|
632 ++line;
|
joachim99@8
|
633
|
joachim99@8
|
634 OptionColorButton* pColorC = new OptionColorButton(
|
joachim99@8
|
635 bLowColor ? qRgb(128,0,128) : qRgb(150,0,150)/*magenta*/, "ColorC", &m_colorC, page, this );
|
joachim99@75
|
636 label = new QLabel( i18n("Color C:"), page );
|
joachim99@75
|
637 label->setBuddy(pColorC);
|
joachim99@8
|
638 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
639 gbox->addWidget( pColorC, line, 1 );
|
joachim99@8
|
640 ++line;
|
joachim99@8
|
641
|
joachim99@69
|
642 OptionColorButton* pColorForConflict = new OptionColorButton( Qt::red, "ColorForConflict", &m_colorForConflict, page, this );
|
joachim99@75
|
643 label = new QLabel( i18n("Conflict color:"), page );
|
joachim99@75
|
644 label->setBuddy(pColorForConflict);
|
joachim99@8
|
645 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
646 gbox->addWidget( pColorForConflict, line, 1 );
|
joachim99@8
|
647 ++line;
|
joachim99@8
|
648
|
joachim99@8
|
649 OptionColorButton* pColor = new OptionColorButton(
|
joachim99@8
|
650 bLowColor ? qRgb(192,192,192) : qRgb(220,220,100), "CurrentRangeBgColor", &m_currentRangeBgColor, page, this );
|
joachim99@75
|
651 label = new QLabel( i18n("Current range background color:"), page );
|
joachim99@75
|
652 label->setBuddy(pColor);
|
joachim99@8
|
653 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
654 gbox->addWidget( pColor, line, 1 );
|
joachim99@8
|
655 ++line;
|
joachim99@8
|
656
|
joachim99@8
|
657 pColor = new OptionColorButton(
|
joachim99@8
|
658 bLowColor ? qRgb(255,255,0) : qRgb(255,255,150), "CurrentRangeDiffBgColor", &m_currentRangeDiffBgColor, page, this );
|
joachim99@75
|
659 label = new QLabel( i18n("Current range diff background color:"), page );
|
joachim99@75
|
660 label->setBuddy(pColor);
|
joachim99@8
|
661 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
662 gbox->addWidget( pColor, line, 1 );
|
joachim99@8
|
663 ++line;
|
joachim99@8
|
664
|
joachim99@69
|
665 pColor = new OptionColorButton( qRgb(0xff,0xd0,0x80), "ManualAlignmentRangeColor", &m_manualHelpRangeColor, page, this );
|
joachim99@75
|
666 label = new QLabel( i18n("Color for manually aligned difference ranges:"), page );
|
joachim99@75
|
667 label->setBuddy(pColor);
|
joachim99@69
|
668 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
669 gbox->addWidget( pColor, line, 1 );
|
joachim99@69
|
670 ++line;
|
joachim99@69
|
671
|
joachim99@69
|
672 label = new QLabel( i18n("Directory Comparison View:"), page );
|
joachim99@69
|
673 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
674 label->setFont(f);
|
joachim99@69
|
675 ++line;
|
joachim99@69
|
676
|
joachim99@69
|
677 pColor = new OptionColorButton( qRgb(0,0xd0,0), "NewestFileColor", &m_newestFileColor, page, this );
|
joachim99@75
|
678 label = new QLabel( i18n("Newest file color:"), page );
|
joachim99@75
|
679 label->setBuddy(pColor);
|
joachim99@69
|
680 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
681 gbox->addWidget( pColor, line, 1 );
|
joachim99@69
|
682 QString dirColorTip = i18n( "Changing this color will only be effective when starting the next directory comparison.");
|
joachim99@75
|
683 label->setToolTip( dirColorTip );
|
joachim99@69
|
684 ++line;
|
joachim99@69
|
685
|
joachim99@69
|
686 pColor = new OptionColorButton( qRgb(0xf0,0,0), "OldestFileColor", &m_oldestFileColor, page, this );
|
joachim99@75
|
687 label = new QLabel( i18n("Oldest file color:"), page );
|
joachim99@75
|
688 label->setBuddy(pColor);
|
joachim99@69
|
689 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
690 gbox->addWidget( pColor, line, 1 );
|
joachim99@75
|
691 label->setToolTip( dirColorTip );
|
joachim99@69
|
692 ++line;
|
joachim99@69
|
693
|
joachim99@69
|
694 pColor = new OptionColorButton( qRgb(0xc0,0xc0,0), "MidAgeFileColor", &m_midAgeFileColor, page, this );
|
joachim99@75
|
695 label = new QLabel( i18n("Middle age file color:"), page );
|
joachim99@75
|
696 label->setBuddy(pColor);
|
joachim99@69
|
697 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
698 gbox->addWidget( pColor, line, 1 );
|
joachim99@75
|
699 label->setToolTip( dirColorTip );
|
joachim99@69
|
700 ++line;
|
joachim99@69
|
701
|
joachim99@69
|
702 pColor = new OptionColorButton( qRgb(0,0,0), "MissingFileColor", &m_missingFileColor, page, this );
|
joachim99@75
|
703 label = new QLabel( i18n("Color for missing files:"), page );
|
joachim99@75
|
704 label->setBuddy(pColor);
|
joachim99@69
|
705 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
706 gbox->addWidget( pColor, line, 1 );
|
joachim99@75
|
707 label->setToolTip( dirColorTip );
|
joachim99@69
|
708 ++line;
|
joachim99@69
|
709
|
joachim99@8
|
710 topLayout->addStretch(10);
|
joachim99@8
|
711 }
|
joachim99@8
|
712
|
joachim99@8
|
713
|
joachim99@8
|
714 void OptionDialog::setupEditPage( void )
|
joachim99@8
|
715 {
|
joachim99@80
|
716 QFrame* page = new QFrame();
|
joachim99@80
|
717 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Editor") );
|
joachim99@80
|
718 pageItem->setHeader( i18n("Editor Behavior") );
|
joachim99@80
|
719 pageItem->setIcon( KIcon( "accessories-text-editor") );
|
joachim99@80
|
720 addPage( pageItem );
|
joachim99@80
|
721
|
joachim99@75
|
722 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
723 topLayout->setMargin( 5 );
|
joachim99@75
|
724 topLayout->setSpacing( spacingHint() );
|
joachim99@8
|
725
|
joachim99@75
|
726 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
727 gbox->setColumnStretch(1,5);
|
joachim99@8
|
728 topLayout->addLayout( gbox );
|
joachim99@8
|
729 QLabel* label;
|
joachim99@8
|
730 int line=0;
|
joachim99@8
|
731
|
joachim99@8
|
732 OptionCheckBox* pReplaceTabs = new OptionCheckBox( i18n("Tab inserts spaces"), false, "ReplaceTabs", &m_bReplaceTabs, page, this );
|
joachim99@75
|
733 gbox->addWidget( pReplaceTabs, line, 0, 1, 2 );
|
joachim99@75
|
734 pReplaceTabs->setToolTip( i18n(
|
joachim99@8
|
735 "On: Pressing tab generates the appropriate number of spaces.\n"
|
joachim99@8
|
736 "Off: A Tab-character will be inserted.")
|
joachim99@8
|
737 );
|
joachim99@8
|
738 ++line;
|
joachim99@8
|
739
|
joachim99@8
|
740 OptionIntEdit* pTabSize = new OptionIntEdit( 8, "TabSize", &m_tabSize, 1, 100, page, this );
|
joachim99@75
|
741 label = new QLabel( i18n("Tab size:"), page );
|
joachim99@75
|
742 label->setBuddy( pTabSize );
|
joachim99@8
|
743 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
744 gbox->addWidget( pTabSize, line, 1 );
|
joachim99@8
|
745 ++line;
|
joachim99@8
|
746
|
joachim99@51
|
747 OptionCheckBox* pAutoIndentation = new OptionCheckBox( i18n("Auto indentation"), true, "AutoIndentation", &m_bAutoIndentation, page, this );
|
joachim99@75
|
748 gbox->addWidget( pAutoIndentation, line, 0, 1, 2 );
|
joachim99@75
|
749 pAutoIndentation->setToolTip( i18n(
|
joachim99@8
|
750 "On: The indentation of the previous line is used for a new line.\n"
|
joachim99@8
|
751 ));
|
joachim99@8
|
752 ++line;
|
joachim99@8
|
753
|
joachim99@51
|
754 OptionCheckBox* pAutoCopySelection = new OptionCheckBox( i18n("Auto copy selection"), false, "AutoCopySelection", &m_bAutoCopySelection, page, this );
|
joachim99@75
|
755 gbox->addWidget( pAutoCopySelection, line, 0, 1, 2 );
|
joachim99@75
|
756 pAutoCopySelection->setToolTip( i18n(
|
joachim99@8
|
757 "On: Any selection is immediately written to the clipboard.\n"
|
joachim99@8
|
758 "Off: You must explicitely copy e.g. via Ctrl-C."
|
joachim99@8
|
759 ));
|
joachim99@8
|
760 ++line;
|
joachim99@58
|
761
|
joachim99@68
|
762 label = new QLabel( i18n("Line end style:"), page );
|
joachim99@58
|
763 gbox->addWidget( label, line, 0 );
|
joachim99@92
|
764
|
joachim99@80
|
765 OptionComboBox* pLineEndStyle = new OptionComboBox( eLineEndStyleAutoDetect, "LineEndStyle", &m_lineEndStyle, page, this );
|
joachim99@58
|
766 gbox->addWidget( pLineEndStyle, line, 1 );
|
joachim99@80
|
767 pLineEndStyle->insertItem( eLineEndStyleUnix, "Unix" );
|
joachim99@80
|
768 pLineEndStyle->insertItem( eLineEndStyleDos, "Dos/Windows" );
|
joachim99@80
|
769 pLineEndStyle->insertItem( eLineEndStyleAutoDetect, "Autodetect" );
|
joachim99@80
|
770
|
joachim99@75
|
771 label->setToolTip( i18n(
|
joachim99@68
|
772 "Sets the line endings for when an edited file is saved.\n"
|
joachim99@68
|
773 "DOS/Windows: CR+LF; UNIX: LF; with CR=0D, LF=0A")
|
joachim99@58
|
774 );
|
joachim99@58
|
775 ++line;
|
joachim99@58
|
776
|
joachim99@8
|
777 topLayout->addStretch(10);
|
joachim99@8
|
778 }
|
joachim99@8
|
779
|
joachim99@8
|
780
|
joachim99@8
|
781 void OptionDialog::setupDiffPage( void )
|
joachim99@8
|
782 {
|
joachim99@80
|
783 QFrame* page = new QFrame();
|
joachim99@80
|
784 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Diff") );
|
joachim99@80
|
785 pageItem->setHeader( i18n("Diff Settings") );
|
joachim99@80
|
786 pageItem->setIcon( KIcon( "preferences-other" ) );
|
joachim99@80
|
787 addPage( pageItem );
|
joachim99@80
|
788
|
joachim99@80
|
789
|
joachim99@75
|
790 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
791 topLayout->setMargin( 5 );
|
joachim99@75
|
792 topLayout->setSpacing( spacingHint() );
|
joachim99@8
|
793
|
joachim99@75
|
794 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
795 gbox->setColumnStretch(1,5);
|
joachim99@8
|
796 topLayout->addLayout( gbox );
|
joachim99@8
|
797 int line=0;
|
joachim99@8
|
798
|
joachim99@51
|
799 QLabel* label=0;
|
joachim99@51
|
800
|
joachim99@77
|
801 m_bPreserveCarriageReturn = false;
|
joachim99@77
|
802 //OptionCheckBox* pPreserveCarriageReturn = new OptionCheckBox( i18n("Preserve carriage return"), false, "PreserveCarriageReturn", &m_bPreserveCarriageReturn, page, this );
|
joachim99@77
|
803 //gbox->addWidget( pPreserveCarriageReturn, line, 0, 1, 2 );
|
joachim99@77
|
804 //pPreserveCarriageReturn->setToolTip( i18n(
|
joachim99@77
|
805 // "Show carriage return characters '\\r' if they exist.\n"
|
joachim99@77
|
806 // "Helps to compare files that were modified under different operating systems.")
|
joachim99@77
|
807 // );
|
joachim99@77
|
808 //++line;
|
joachim99@77
|
809 QString treatAsWhiteSpace = " ("+i18n("Treat as white space.")+")";
|
joachim99@8
|
810
|
joachim99@77
|
811 OptionCheckBox* pIgnoreNumbers = new OptionCheckBox( i18n("Ignore numbers")+treatAsWhiteSpace, false, "IgnoreNumbers", &m_bIgnoreNumbers, page, this );
|
joachim99@75
|
812 gbox->addWidget( pIgnoreNumbers, line, 0, 1, 2 );
|
joachim99@75
|
813 pIgnoreNumbers->setToolTip( i18n(
|
joachim99@51
|
814 "Ignore number characters during line matching phase. (Similar to Ignore white space.)\n"
|
joachim99@51
|
815 "Might help to compare files with numeric data.")
|
joachim99@8
|
816 );
|
joachim99@8
|
817 ++line;
|
joachim99@8
|
818
|
joachim99@77
|
819 OptionCheckBox* pIgnoreComments = new OptionCheckBox( i18n("Ignore C/C++ comments")+treatAsWhiteSpace, false, "IgnoreComments", &m_bIgnoreComments, page, this );
|
joachim99@75
|
820 gbox->addWidget( pIgnoreComments, line, 0, 1, 2 );
|
joachim99@75
|
821 pIgnoreComments->setToolTip( i18n( "Treat C/C++ comments like white space.")
|
joachim99@8
|
822 );
|
joachim99@8
|
823 ++line;
|
joachim99@8
|
824
|
joachim99@77
|
825 OptionCheckBox* pIgnoreCase = new OptionCheckBox( i18n("Ignore case")+treatAsWhiteSpace, false, "IgnoreCase", &m_bIgnoreCase, page, this );
|
joachim99@75
|
826 gbox->addWidget( pIgnoreCase, line, 0, 1, 2 );
|
joachim99@75
|
827 pIgnoreCase->setToolTip( i18n(
|
joachim99@66
|
828 "Treat case differences like white space changes. ('a'<=>'A')")
|
joachim99@8
|
829 );
|
joachim99@8
|
830 ++line;
|
joachim99@8
|
831
|
joachim99@51
|
832 label = new QLabel( i18n("Preprocessor command:"), page );
|
joachim99@8
|
833 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
834 OptionLineEdit* pLE = new OptionLineEdit( "", "PreProcessorCmd", &m_PreProcessorCmd, page, this );
|
joachim99@8
|
835 gbox->addWidget( pLE, line, 1 );
|
joachim99@75
|
836 label->setToolTip( i18n("User defined pre-processing. (See the docs for details.)") );
|
joachim99@8
|
837 ++line;
|
joachim99@8
|
838
|
joachim99@51
|
839 label = new QLabel( i18n("Line-matching preprocessor command:"), page );
|
joachim99@8
|
840 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
841 pLE = new OptionLineEdit( "", "LineMatchingPreProcessorCmd", &m_LineMatchingPreProcessorCmd, page, this );
|
joachim99@8
|
842 gbox->addWidget( pLE, line, 1 );
|
joachim99@75
|
843 label->setToolTip( i18n("This pre-processor is only used during line matching.\n(See the docs for details.)") );
|
joachim99@8
|
844 ++line;
|
joachim99@8
|
845
|
joachim99@51
|
846 OptionCheckBox* pTryHard = new OptionCheckBox( i18n("Try hard (slower)"), true, "TryHard", &m_bTryHard, page, this );
|
joachim99@75
|
847 gbox->addWidget( pTryHard, line, 0, 1, 2 );
|
joachim99@75
|
848 pTryHard->setToolTip( i18n(
|
joachim99@51
|
849 "Enables the --minimal option for the external diff.\n"
|
joachim99@51
|
850 "The analysis of big files will be much slower.")
|
joachim99@8
|
851 );
|
joachim99@8
|
852 ++line;
|
joachim99@8
|
853
|
joachim99@80
|
854 OptionCheckBox* pDiff3AlignBC = new OptionCheckBox( i18n("Align B and C for 3 input files"), false, "Diff3AlignBC", &m_bDiff3AlignBC, page, this );
|
joachim99@80
|
855 gbox->addWidget( pDiff3AlignBC, line, 0, 1, 2 );
|
joachim99@80
|
856 pDiff3AlignBC->setToolTip( i18n(
|
joachim99@80
|
857 "Try to align B and C when comparing or merging three input files.\n"
|
joachim99@80
|
858 "Not recommended for merging because merge might get more complicated.\n"
|
joachim99@80
|
859 "(Default is off.)")
|
joachim99@80
|
860 );
|
joachim99@80
|
861 ++line;
|
joachim99@80
|
862
|
joachim99@75
|
863 topLayout->addStretch(10);
|
joachim99@75
|
864 }
|
joachim99@75
|
865
|
joachim99@75
|
866 void OptionDialog::setupMergePage( void )
|
joachim99@75
|
867 {
|
joachim99@80
|
868 QFrame* page = new QFrame();
|
joachim99@80
|
869 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Merge") );
|
joachim99@80
|
870 pageItem->setHeader( i18n("Merge Settings") );
|
joachim99@80
|
871 pageItem->setIcon( KIcon( "plasmagik" ) );
|
joachim99@80
|
872 addPage( pageItem );
|
joachim99@80
|
873
|
joachim99@75
|
874 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
875 topLayout->setMargin( 5 );
|
joachim99@75
|
876 topLayout->setSpacing( spacingHint() );
|
joachim99@75
|
877
|
joachim99@75
|
878 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
879 gbox->setColumnStretch(1,5);
|
joachim99@75
|
880 topLayout->addLayout( gbox );
|
joachim99@75
|
881 int line=0;
|
joachim99@75
|
882
|
joachim99@75
|
883 QLabel* label=0;
|
joachim99@75
|
884
|
joachim99@77
|
885 label = new QLabel( i18n("Auto advance delay (ms):"), page );
|
joachim99@77
|
886 gbox->addWidget( label, line, 0 );
|
joachim99@77
|
887 OptionIntEdit* pAutoAdvanceDelay = new OptionIntEdit( 500, "AutoAdvanceDelay", &m_autoAdvanceDelay, 0, 2000, page, this );
|
joachim99@77
|
888 gbox->addWidget( pAutoAdvanceDelay, line, 1 );
|
joachim99@77
|
889 label->setToolTip(i18n(
|
joachim99@77
|
890 "When in Auto-Advance mode the result of the current selection is shown \n"
|
joachim99@77
|
891 "for the specified time, before jumping to the next conflict. Range: 0-2000 ms")
|
joachim99@77
|
892 );
|
joachim99@77
|
893 ++line;
|
joachim99@77
|
894
|
joachim99@80
|
895 OptionCheckBox* pShowInfoDialogs = new OptionCheckBox( i18n("Show info dialogs"), true, "ShowInfoDialogs", &m_bShowInfoDialogs, page, this );
|
joachim99@80
|
896 gbox->addWidget( pShowInfoDialogs, line, 0, 1, 2 );
|
joachim99@80
|
897 pShowInfoDialogs->setToolTip( i18n("Show a dialog with information about the number of conflicts.") );
|
joachim99@80
|
898 ++line;
|
joachim99@80
|
899
|
joachim99@51
|
900 label = new QLabel( i18n("White space 2-file merge default:"), page );
|
joachim99@51
|
901 gbox->addWidget( label, line, 0 );
|
joachim99@51
|
902 OptionComboBox* pWhiteSpace2FileMergeDefault = new OptionComboBox( 0, "WhiteSpace2FileMergeDefault", &m_whiteSpace2FileMergeDefault, page, this );
|
joachim99@51
|
903 gbox->addWidget( pWhiteSpace2FileMergeDefault, line, 1 );
|
joachim99@75
|
904 pWhiteSpace2FileMergeDefault->insertItem( 0, i18n("Manual Choice") );
|
joachim99@75
|
905 pWhiteSpace2FileMergeDefault->insertItem( 1, "A" );
|
joachim99@75
|
906 pWhiteSpace2FileMergeDefault->insertItem( 2, "B" );
|
joachim99@75
|
907 label->setToolTip( i18n(
|
joachim99@75
|
908 "Allow the merge algorithm to automatically select an input for "
|
joachim99@75
|
909 "white-space-only changes." )
|
joachim99@75
|
910 );
|
joachim99@51
|
911 ++line;
|
joachim99@51
|
912
|
joachim99@51
|
913 label = new QLabel( i18n("White space 3-file merge default:"), page );
|
joachim99@51
|
914 gbox->addWidget( label, line, 0 );
|
joachim99@51
|
915 OptionComboBox* pWhiteSpace3FileMergeDefault = new OptionComboBox( 0, "WhiteSpace3FileMergeDefault", &m_whiteSpace3FileMergeDefault, page, this );
|
joachim99@51
|
916 gbox->addWidget( pWhiteSpace3FileMergeDefault, line, 1 );
|
joachim99@75
|
917 pWhiteSpace3FileMergeDefault->insertItem( 0, i18n("Manual Choice") );
|
joachim99@75
|
918 pWhiteSpace3FileMergeDefault->insertItem( 1, "A" );
|
joachim99@75
|
919 pWhiteSpace3FileMergeDefault->insertItem( 2, "B" );
|
joachim99@75
|
920 pWhiteSpace3FileMergeDefault->insertItem( 3, "C" );
|
joachim99@75
|
921 label->setToolTip( i18n(
|
joachim99@75
|
922 "Allow the merge algorithm to automatically select an input for "
|
joachim99@75
|
923 "white-space-only changes." )
|
joachim99@75
|
924 );
|
joachim99@51
|
925 ++line;
|
joachim99@51
|
926
|
joachim99@75
|
927 QGroupBox* pGroupBox = new QGroupBox( i18n("Automatic Merge Regular Expression") );
|
joachim99@75
|
928 gbox->addWidget( pGroupBox, line, 0, 1, 2 );
|
joachim99@69
|
929 ++line;
|
joachim99@69
|
930 {
|
joachim99@75
|
931 QGridLayout* gbox = new QGridLayout( pGroupBox );
|
joachim99@75
|
932 gbox->setMargin(spacingHint());
|
joachim99@75
|
933 gbox->setColumnStretch(1,10);
|
joachim99@69
|
934 int line = 0;
|
joachim99@69
|
935
|
joachim99@69
|
936 label = new QLabel( i18n("Auto merge regular expression:"), page );
|
joachim99@69
|
937 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
938 m_pAutoMergeRegExpLineEdit = new OptionLineEdit( ".*\\$(Version|Header|Date|Author).*\\$.*", "AutoMergeRegExp", &m_autoMergeRegExp, page, this );
|
joachim99@69
|
939 gbox->addWidget( m_pAutoMergeRegExpLineEdit, line, 1 );
|
joachim99@69
|
940 s_autoMergeRegExpToolTip = i18n("Regular expression for lines where KDiff3 should automatically choose one source.\n"
|
joachim99@75
|
941 "When a line with a conflict matches the regular expression then\n"
|
joachim99@75
|
942 "- if available - C, otherwise B will be chosen.");
|
joachim99@75
|
943 label->setToolTip( s_autoMergeRegExpToolTip );
|
joachim99@69
|
944 ++line;
|
joachim99@69
|
945
|
joachim99@69
|
946 OptionCheckBox* pAutoMergeRegExp = new OptionCheckBox( i18n("Run regular expression auto merge on merge start"), false, "RunRegExpAutoMergeOnMergeStart", &m_bRunRegExpAutoMergeOnMergeStart, page, this );
|
joachim99@75
|
947 gbox->addWidget( pAutoMergeRegExp, line, 0, 1, 2 );
|
joachim99@75
|
948 pAutoMergeRegExp->setToolTip( i18n( "Run the merge for auto merge regular expressions\n"
|
joachim99@75
|
949 "immediately when a merge starts.\n"));
|
joachim99@69
|
950 ++line;
|
joachim99@69
|
951 }
|
joachim99@69
|
952
|
joachim99@75
|
953 pGroupBox = new QGroupBox( i18n("Version Control History Merging") );
|
joachim99@75
|
954 gbox->addWidget( pGroupBox, line, 0, 1, 2 );
|
joachim99@69
|
955 ++line;
|
joachim99@69
|
956 {
|
joachim99@75
|
957 QGridLayout* gbox = new QGridLayout( pGroupBox );
|
joachim99@75
|
958 gbox->setMargin( spacingHint() );
|
joachim99@75
|
959 gbox->setColumnStretch(1,10);
|
joachim99@69
|
960 int line = 0;
|
joachim99@69
|
961
|
joachim99@69
|
962 label = new QLabel( i18n("History start regular expression:"), page );
|
joachim99@69
|
963 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
964 m_pHistoryStartRegExpLineEdit = new OptionLineEdit( ".*\\$Log.*\\$.*", "HistoryStartRegExp", &m_historyStartRegExp, page, this );
|
joachim99@69
|
965 gbox->addWidget( m_pHistoryStartRegExpLineEdit, line, 1 );
|
joachim99@69
|
966 s_historyStartRegExpToolTip = i18n("Regular expression for the start of the version control history entry.\n"
|
joachim99@75
|
967 "Usually this line contains the \"$Log$\"-keyword.\n"
|
joachim99@75
|
968 "Default value: \".*\\$Log.*\\$.*\"");
|
joachim99@75
|
969 label->setToolTip( s_historyStartRegExpToolTip );
|
joachim99@69
|
970 ++line;
|
joachim99@69
|
971
|
joachim99@69
|
972 label = new QLabel( i18n("History entry start regular expression:"), page );
|
joachim99@69
|
973 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
974 // Example line: "** \main\rolle_fsp_dev_008\1 17 Aug 2001 10:45:44 rolle"
|
joachim99@69
|
975 QString historyEntryStartDefault =
|
joachim99@75
|
976 "\\s*\\\\main\\\\(\\S+)\\s+" // Start with "\main\"
|
joachim99@75
|
977 "([0-9]+) " // day
|
joachim99@75
|
978 "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) " //month
|
joachim99@75
|
979 "([0-9][0-9][0-9][0-9]) " // year
|
joachim99@75
|
980 "([0-9][0-9]:[0-9][0-9]:[0-9][0-9])\\s+(.*)"; // time, name
|
joachim99@69
|
981
|
joachim99@69
|
982 m_pHistoryEntryStartRegExpLineEdit = new OptionLineEdit( historyEntryStartDefault, "HistoryEntryStartRegExp", &m_historyEntryStartRegExp, page, this );
|
joachim99@69
|
983 gbox->addWidget( m_pHistoryEntryStartRegExpLineEdit, line, 1 );
|
joachim99@69
|
984 s_historyEntryStartRegExpToolTip = i18n("A version control history entry consists of several lines.\n"
|
joachim99@75
|
985 "Specify the regular expression to detect the first line (without the leading comment).\n"
|
joachim99@75
|
986 "Use parentheses to group the keys you want to use for sorting.\n"
|
joachim99@75
|
987 "If left empty, then KDiff3 assumes that empty lines separate history entries.\n"
|
joachim99@75
|
988 "See the documentation for details.");
|
joachim99@75
|
989 label->setToolTip( s_historyEntryStartRegExpToolTip );
|
joachim99@69
|
990 ++line;
|
joachim99@69
|
991
|
joachim99@69
|
992 m_pHistoryMergeSorting = new OptionCheckBox( i18n("History merge sorting"), false, "HistoryMergeSorting", &m_bHistoryMergeSorting, page, this );
|
joachim99@75
|
993 gbox->addWidget( m_pHistoryMergeSorting, line, 0, 1, 2 );
|
joachim99@75
|
994 m_pHistoryMergeSorting->setToolTip( i18n("Sort version control history by a key.") );
|
joachim99@69
|
995 ++line;
|
joachim99@69
|
996 //QString branch = newHistoryEntry.cap(1);
|
joachim99@69
|
997 //int day = newHistoryEntry.cap(2).toInt();
|
joachim99@69
|
998 //int month = QString("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec").find(newHistoryEntry.cap(3))/4 + 1;
|
joachim99@69
|
999 //int year = newHistoryEntry.cap(4).toInt();
|
joachim99@69
|
1000 //QString time = newHistoryEntry.cap(5);
|
joachim99@69
|
1001 //QString name = newHistoryEntry.cap(6);
|
joachim99@69
|
1002 QString defaultSortKeyOrder = "4,3,2,5,1,6"; //QDate(year,month,day).toString(Qt::ISODate) +" "+ time + " " + branch + " " + name;
|
joachim99@69
|
1003
|
joachim99@69
|
1004 label = new QLabel( i18n("History entry start sort key order:"), page );
|
joachim99@69
|
1005 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
1006 m_pHistorySortKeyOrderLineEdit = new OptionLineEdit( defaultSortKeyOrder, "HistoryEntryStartSortKeyOrder", &m_historyEntryStartSortKeyOrder, page, this );
|
joachim99@69
|
1007 gbox->addWidget( m_pHistorySortKeyOrderLineEdit, line, 1 );
|
joachim99@69
|
1008 s_historyEntryStartSortKeyOrderToolTip = i18n("Each parentheses used in the regular expression for the history start entry\n"
|
joachim99@75
|
1009 "groups a key that can be used for sorting.\n"
|
joachim99@75
|
1010 "Specify the list of keys (that are numbered in order of occurrence\n"
|
joachim99@75
|
1011 "starting with 1) using ',' as separator (e.g. \"4,5,6,1,2,3,7\").\n"
|
joachim99@75
|
1012 "If left empty, then no sorting will be done.\n"
|
joachim99@75
|
1013 "See the documentation for details.");
|
joachim99@75
|
1014 label->setToolTip( s_historyEntryStartSortKeyOrderToolTip );
|
joachim99@69
|
1015 m_pHistorySortKeyOrderLineEdit->setEnabled(false);
|
joachim99@69
|
1016 connect( m_pHistoryMergeSorting, SIGNAL(toggled(bool)), m_pHistorySortKeyOrderLineEdit, SLOT(setEnabled(bool)));
|
joachim99@69
|
1017 ++line;
|
joachim99@69
|
1018
|
joachim99@69
|
1019 m_pHistoryAutoMerge = new OptionCheckBox( i18n("Merge version control history on merge start"), false, "RunHistoryAutoMergeOnMergeStart", &m_bRunHistoryAutoMergeOnMergeStart, page, this );
|
joachim99@75
|
1020 gbox->addWidget( m_pHistoryAutoMerge, line, 0, 1, 2 );
|
joachim99@75
|
1021 m_pHistoryAutoMerge->setToolTip( i18n("Run version control history automerge on merge start.") );
|
joachim99@69
|
1022 ++line;
|
joachim99@77
|
1023
|
joachim99@77
|
1024 OptionIntEdit* pMaxNofHistoryEntries = new OptionIntEdit( -1, "MaxNofHistoryEntries", &m_maxNofHistoryEntries, -1, 1000, page, this );
|
joachim99@77
|
1025 label = new QLabel( i18n("Max number of history entries:"), page );
|
joachim99@77
|
1026 gbox->addWidget( label, line, 0 );
|
joachim99@77
|
1027 gbox->addWidget( pMaxNofHistoryEntries, line, 1 );
|
joachim99@77
|
1028 pMaxNofHistoryEntries->setToolTip( i18n("Cut off after specified number. Use -1 for infinite number of entries.") );
|
joachim99@77
|
1029 ++line;
|
joachim99@69
|
1030 }
|
joachim99@69
|
1031
|
joachim99@69
|
1032 QPushButton* pButton = new QPushButton( i18n("Test your regular expressions"), page );
|
joachim99@69
|
1033 gbox->addWidget( pButton, line, 0 );
|
joachim99@69
|
1034 connect( pButton, SIGNAL(clicked()), this, SLOT(slotHistoryMergeRegExpTester()));
|
joachim99@69
|
1035 ++line;
|
joachim99@69
|
1036
|
joachim99@69
|
1037 label = new QLabel( i18n("Irrelevant merge command:"), page );
|
joachim99@69
|
1038 gbox->addWidget( label, line, 0 );
|
joachim99@75
|
1039 OptionLineEdit* pLE = new OptionLineEdit( "", "IrrelevantMergeCmd", &m_IrrelevantMergeCmd, page, this );
|
joachim99@69
|
1040 gbox->addWidget( pLE, line, 1 );
|
joachim99@75
|
1041 label->setToolTip( i18n("If specified this script is run after automerge\n"
|
joachim99@75
|
1042 "when no other relevant changes were detected.\n"
|
joachim99@75
|
1043 "Called with the parameters: filename1 filename2 filename3") );
|
joachim99@69
|
1044 ++line;
|
joachim99@69
|
1045
|
joachim99@77
|
1046
|
joachim99@77
|
1047 OptionCheckBox* pAutoSaveAndQuit = new OptionCheckBox( i18n("Auto save and quit on merge without conflicts"), false,
|
joachim99@77
|
1048 "AutoSaveAndQuitOnMergeWithoutConflicts", &m_bAutoSaveAndQuitOnMergeWithoutConflicts, page, this );
|
joachim99@77
|
1049 gbox->addWidget( pAutoSaveAndQuit, line, 0, 1, 2 );
|
joachim99@77
|
1050 pAutoSaveAndQuit->setToolTip( i18n("When KDiff3 was started for a file-merge from the commandline and all\n"
|
joachim99@77
|
1051 "conflicts are solvable without user interaction then automatically save and quit.\n"
|
joachim99@77
|
1052 "(Similar to command line option \"--auto\".") );
|
joachim99@77
|
1053 ++line;
|
joachim99@77
|
1054
|
joachim99@8
|
1055 topLayout->addStretch(10);
|
joachim99@8
|
1056 }
|
joachim99@8
|
1057
|
joachim99@8
|
1058 void OptionDialog::setupDirectoryMergePage( void )
|
joachim99@8
|
1059 {
|
joachim99@80
|
1060 QFrame* page = new QFrame();
|
joachim99@92
|
1061 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Directory") );
|
joachim99@92
|
1062 pageItem->setHeader( i18n("Directory") );
|
joachim99@80
|
1063 pageItem->setIcon( KIcon( "folder" ) );
|
joachim99@80
|
1064 addPage( pageItem );
|
joachim99@80
|
1065
|
joachim99@75
|
1066 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
1067 topLayout->setMargin( 5 );
|
joachim99@75
|
1068 topLayout->setSpacing( spacingHint() );
|
joachim99@8
|
1069
|
joachim99@75
|
1070 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
1071 gbox->setColumnStretch(1,5);
|
joachim99@8
|
1072 topLayout->addLayout( gbox );
|
joachim99@8
|
1073 int line=0;
|
joachim99@8
|
1074
|
joachim99@51
|
1075 OptionCheckBox* pRecursiveDirs = new OptionCheckBox( i18n("Recursive directories"), true, "RecursiveDirs", &m_bDmRecursiveDirs, page, this );
|
joachim99@75
|
1076 gbox->addWidget( pRecursiveDirs, line, 0, 1, 2 );
|
joachim99@75
|
1077 pRecursiveDirs->setToolTip( i18n("Whether to analyze subdirectories or not.") );
|
joachim99@8
|
1078 ++line;
|
joachim99@51
|
1079 QLabel* label = new QLabel( i18n("File pattern(s):"), page );
|
joachim99@8
|
1080 gbox->addWidget( label, line, 0 );
|
joachim99@8
|
1081 OptionLineEdit* pFilePattern = new OptionLineEdit( "*", "FilePattern", &m_DmFilePattern, page, this );
|
joachim99@8
|
1082 gbox->addWidget( pFilePattern, line, 1 );
|
joachim99@75
|
1083 label->setToolTip( i18n(
|
joachim99@8
|
1084 "Pattern(s) of files to be analyzed. \n"
|
joachim99@8
|
1085 "Wildcards: '*' and '?'\n"
|
joachim99@8
|
1086 "Several Patterns can be specified by using the separator: ';'"
|
joachim99@8
|
1087 ));
|
joachim99@8
|
1088 ++line;
|
joachim99@8
|
1089
|
joachim99@51
|
1090 label = new QLabel( i18n("File-anti-pattern(s):"), page );
|
joachim99@8
|
1091 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
1092 OptionLineEdit* pFileAntiPattern = new OptionLineEdit( "*.orig;*.o;*.obj", "FileAntiPattern", &m_DmFileAntiPattern, page, this );
|
joachim99@8
|
1093 gbox->addWidget( pFileAntiPattern, line, 1 );
|
joachim99@75
|
1094 label->setToolTip( i18n(
|
joachim99@8
|
1095 "Pattern(s) of files to be excluded from analysis. \n"
|
joachim99@8
|
1096 "Wildcards: '*' and '?'\n"
|
joachim99@8
|
1097 "Several Patterns can be specified by using the separator: ';'"
|
joachim99@8
|
1098 ));
|
joachim99@8
|
1099 ++line;
|
joachim99@8
|
1100
|
joachim99@51
|
1101 label = new QLabel( i18n("Dir-anti-pattern(s):"), page );
|
joachim99@8
|
1102 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
1103 OptionLineEdit* pDirAntiPattern = new OptionLineEdit( "CVS;.deps;.svn", "DirAntiPattern", &m_DmDirAntiPattern, page, this );
|
joachim99@8
|
1104 gbox->addWidget( pDirAntiPattern, line, 1 );
|
joachim99@75
|
1105 label->setToolTip( i18n(
|
joachim99@8
|
1106 "Pattern(s) of directories to be excluded from analysis. \n"
|
joachim99@8
|
1107 "Wildcards: '*' and '?'\n"
|
joachim99@8
|
1108 "Several Patterns can be specified by using the separator: ';'"
|
joachim99@8
|
1109 ));
|
joachim99@8
|
1110 ++line;
|
joachim99@8
|
1111
|
joachim99@51
|
1112 OptionCheckBox* pUseCvsIgnore = new OptionCheckBox( i18n("Use .cvsignore"), false, "UseCvsIgnore", &m_bDmUseCvsIgnore, page, this );
|
joachim99@75
|
1113 gbox->addWidget( pUseCvsIgnore, line, 0, 1, 2 );
|
joachim99@75
|
1114 pUseCvsIgnore->setToolTip( i18n(
|
joachim99@8
|
1115 "Extends the antipattern to anything that would be ignored by CVS.\n"
|
joachim99@8
|
1116 "Via local \".cvsignore\"-files this can be directory specific."
|
joachim99@8
|
1117 ));
|
joachim99@8
|
1118 ++line;
|
joachim99@8
|
1119
|
joachim99@51
|
1120 OptionCheckBox* pFindHidden = new OptionCheckBox( i18n("Find hidden files and directories"), true, "FindHidden", &m_bDmFindHidden, page, this );
|
joachim99@75
|
1121 gbox->addWidget( pFindHidden, line, 0, 1, 2 );
|
joachim99@95
|
1122 #if defined(_WIN32) || defined(Q_OS_OS2)
|
joachim99@75
|
1123 pFindHidden->setToolTip( i18n("Finds files and directories with the hidden attribute.") );
|
joachim99@8
|
1124 #else
|
joachim99@75
|
1125 pFindHidden->setToolTip( i18n("Finds files and directories starting with '.'.") );
|
joachim99@8
|
1126 #endif
|
joachim99@8
|
1127 ++line;
|
joachim99@8
|
1128
|
joachim99@51
|
1129 OptionCheckBox* pFollowFileLinks = new OptionCheckBox( i18n("Follow file links"), false, "FollowFileLinks", &m_bDmFollowFileLinks, page, this );
|
joachim99@75
|
1130 gbox->addWidget( pFollowFileLinks, line, 0, 1, 2 );
|
joachim99@75
|
1131 pFollowFileLinks->setToolTip( i18n(
|
joachim99@8
|
1132 "On: Compare the file the link points to.\n"
|
joachim99@8
|
1133 "Off: Compare the links."
|
joachim99@8
|
1134 ));
|
joachim99@8
|
1135 ++line;
|
joachim99@8
|
1136
|
joachim99@51
|
1137 OptionCheckBox* pFollowDirLinks = new OptionCheckBox( i18n("Follow directory links"), false, "FollowDirLinks", &m_bDmFollowDirLinks, page, this );
|
joachim99@75
|
1138 gbox->addWidget( pFollowDirLinks, line, 0, 1, 2 );
|
joachim99@75
|
1139 pFollowDirLinks->setToolTip( i18n(
|
joachim99@8
|
1140 "On: Compare the directory the link points to.\n"
|
joachim99@8
|
1141 "Off: Compare the links."
|
joachim99@8
|
1142 ));
|
joachim99@8
|
1143 ++line;
|
joachim99@8
|
1144
|
joachim99@69
|
1145 //OptionCheckBox* pShowOnlyDeltas = new OptionCheckBox( i18n("List only deltas"),false,"ListOnlyDeltas", &m_bDmShowOnlyDeltas, page, this );
|
joachim99@75
|
1146 //gbox->addWidget( pShowOnlyDeltas, line, 0, 1, 2 );
|
joachim99@75
|
1147 //pShowOnlyDeltas->setToolTip( i18n(
|
joachim99@69
|
1148 // "Files and directories without change will not appear in the list."));
|
joachim99@69
|
1149 //++line;
|
joachim99@69
|
1150
|
joachim99@95
|
1151 #if defined(_WIN32) || defined(Q_OS_OS2)
|
joachim99@69
|
1152 bool bCaseSensitiveFilenameComparison = false;
|
joachim99@69
|
1153 #else
|
joachim99@69
|
1154 bool bCaseSensitiveFilenameComparison = true;
|
joachim99@69
|
1155 #endif
|
joachim99@69
|
1156 OptionCheckBox* pCaseSensitiveFileNames = new OptionCheckBox( i18n("Case sensitive filename comparison"),bCaseSensitiveFilenameComparison,"CaseSensitiveFilenameComparison", &m_bDmCaseSensitiveFilenameComparison, page, this );
|
joachim99@75
|
1157 gbox->addWidget( pCaseSensitiveFileNames, line, 0, 1, 2 );
|
joachim99@75
|
1158 pCaseSensitiveFileNames->setToolTip( i18n(
|
joachim99@69
|
1159 "The directory comparison will compare files or directories when their names match.\n"
|
joachim99@69
|
1160 "Set this option if the case of the names must match. (Default for Windows is off, otherwise on.)"));
|
joachim99@8
|
1161 ++line;
|
joachim99@8
|
1162
|
joachim99@75
|
1163 QGroupBox* pBG = new QGroupBox( i18n("File Comparison Mode") );
|
joachim99@75
|
1164 gbox->addWidget( pBG, line, 0, 1, 2 );
|
joachim99@75
|
1165
|
joachim99@75
|
1166 QVBoxLayout* pBGLayout = new QVBoxLayout( pBG );
|
joachim99@75
|
1167 pBGLayout->setMargin(spacingHint());
|
joachim99@75
|
1168
|
joachim99@75
|
1169 OptionRadioButton* pBinaryComparison = new OptionRadioButton( i18n("Binary comparison"), true, "BinaryComparison", &m_bDmBinaryComparison, pBG, this );
|
joachim99@75
|
1170 pBinaryComparison->setToolTip( i18n("Binary comparison of each file. (Default)") );
|
joachim99@75
|
1171 pBGLayout->addWidget( pBinaryComparison );
|
joachim99@75
|
1172
|
joachim99@75
|
1173 OptionRadioButton* pFullAnalysis = new OptionRadioButton( i18n("Full analysis"), false, "FullAnalysis", &m_bDmFullAnalysis, pBG, this );
|
joachim99@75
|
1174 pFullAnalysis->setToolTip( i18n("Do a full analysis and show statistics information in extra columns.\n"
|
joachim99@75
|
1175 "(Slower than a binary comparison, much slower for binary files.)") );
|
joachim99@75
|
1176 pBGLayout->addWidget( pFullAnalysis );
|
joachim99@75
|
1177
|
joachim99@77
|
1178 OptionRadioButton* pTrustDate = new OptionRadioButton( i18n("Trust the size and modification date (unsafe)"), false, "TrustDate", &m_bDmTrustDate, pBG, this );
|
joachim99@75
|
1179 pTrustDate->setToolTip( i18n("Assume that files are equal if the modification date and file length are equal.\n"
|
joachim99@77
|
1180 "Files with equal contents but different modification dates will appear as different.\n"
|
joachim99@75
|
1181 "Useful for big directories or slow networks.") );
|
joachim99@75
|
1182 pBGLayout->addWidget( pTrustDate );
|
joachim99@77
|
1183
|
joachim99@77
|
1184 OptionRadioButton* pTrustDateFallbackToBinary = new OptionRadioButton( i18n("Trust the size and date, but use binary comparison if date doesn't match (unsafe)"), false, "TrustDateFallbackToBinary", &m_bDmTrustDateFallbackToBinary, pBG, this );
|
joachim99@77
|
1185 pTrustDateFallbackToBinary->setToolTip( i18n("Assume that files are equal if the modification date and file length are equal.\n"
|
joachim99@77
|
1186 "If the date isn't equal but the sizes are, use binary comparison.\n"
|
joachim99@77
|
1187 "Useful for big directories or slow networks.") );
|
joachim99@77
|
1188 pBGLayout->addWidget( pTrustDateFallbackToBinary );
|
joachim99@75
|
1189
|
joachim99@75
|
1190 OptionRadioButton* pTrustSize = new OptionRadioButton( i18n("Trust the size (unsafe)"), false, "TrustSize", &m_bDmTrustSize, pBG, this );
|
joachim99@75
|
1191 pTrustSize->setToolTip( i18n("Assume that files are equal if their file lengths are equal.\n"
|
joachim99@75
|
1192 "Useful for big directories or slow networks when the date is modified during download.") );
|
joachim99@75
|
1193 pBGLayout->addWidget( pTrustSize );
|
joachim99@75
|
1194
|
joachim99@66
|
1195 ++line;
|
joachim99@66
|
1196
|
joachim99@51
|
1197
|
joachim99@8
|
1198 // Some two Dir-options: Affects only the default actions.
|
joachim99@51
|
1199 OptionCheckBox* pSyncMode = new OptionCheckBox( i18n("Synchronize directories"), false,"SyncMode", &m_bDmSyncMode, page, this );
|
joachim99@75
|
1200 gbox->addWidget( pSyncMode, line, 0, 1, 2 );
|
joachim99@75
|
1201 pSyncMode->setToolTip( i18n(
|
joachim99@8
|
1202 "Offers to store files in both directories so that\n"
|
joachim99@8
|
1203 "both directories are the same afterwards.\n"
|
joachim99@8
|
1204 "Works only when comparing two directories without specifying a destination." ) );
|
joachim99@8
|
1205 ++line;
|
joachim99@8
|
1206
|
joachim99@68
|
1207 // Allow white-space only differences to be considered equal
|
joachim99@77
|
1208 OptionCheckBox* pWhiteSpaceDiffsEqual = new OptionCheckBox( i18n("White space differences considered equal"), true,"WhiteSpaceEqual", &m_bDmWhiteSpaceEqual, page, this );
|
joachim99@75
|
1209 gbox->addWidget( pWhiteSpaceDiffsEqual, line, 0, 1, 2 );
|
joachim99@75
|
1210 pWhiteSpaceDiffsEqual->setToolTip( i18n(
|
joachim99@68
|
1211 "If files differ only by white space consider them equal.\n"
|
joachim99@68
|
1212 "This is only active when full analysis is chosen." ) );
|
joachim99@68
|
1213 connect(pFullAnalysis, SIGNAL(toggled(bool)), pWhiteSpaceDiffsEqual, SLOT(setEnabled(bool)));
|
joachim99@68
|
1214 pWhiteSpaceDiffsEqual->setEnabled(false);
|
joachim99@68
|
1215 ++line;
|
joachim99@68
|
1216
|
joachim99@51
|
1217 OptionCheckBox* pCopyNewer = new OptionCheckBox( i18n("Copy newer instead of merging (unsafe)"), false, "CopyNewer", &m_bDmCopyNewer, page, this );
|
joachim99@75
|
1218 gbox->addWidget( pCopyNewer, line, 0, 1, 2 );
|
joachim99@75
|
1219 pCopyNewer->setToolTip( i18n(
|
joachim99@8
|
1220 "Don't look inside, just take the newer file.\n"
|
joachim99@8
|
1221 "(Use this only if you know what you are doing!)\n"
|
joachim99@8
|
1222 "Only effective when comparing two directories." ) );
|
joachim99@8
|
1223 ++line;
|
joachim99@51
|
1224
|
joachim99@8
|
1225 OptionCheckBox* pCreateBakFiles = new OptionCheckBox( i18n("Backup files (.orig)"), true, "CreateBakFiles", &m_bDmCreateBakFiles, page, this );
|
joachim99@75
|
1226 gbox->addWidget( pCreateBakFiles, line, 0, 1, 2 );
|
joachim99@75
|
1227 pCreateBakFiles->setToolTip( i18n(
|
joachim99@8
|
1228 "When a file would be saved over an old file, then the old file\n"
|
joachim99@8
|
1229 "will be renamed with a '.orig'-extension instead of being deleted."));
|
joachim99@8
|
1230 ++line;
|
joachim99@8
|
1231
|
joachim99@8
|
1232 topLayout->addStretch(10);
|
joachim99@8
|
1233 }
|
joachim99@66
|
1234 /*
|
joachim99@58
|
1235 static void insertCodecs(OptionComboBox* p)
|
joachim99@58
|
1236 {
|
joachim99@58
|
1237 std::multimap<QString,QString> m; // Using the multimap for case-insensitive sorting.
|
joachim99@58
|
1238 int i;
|
joachim99@58
|
1239 for(i=0;;++i)
|
joachim99@58
|
1240 {
|
joachim99@58
|
1241 QTextCodec* pCodec = QTextCodec::codecForIndex ( i );
|
joachim99@80
|
1242 if ( pCodec != 0 ) m.insert( std::make_pair( QString(pCodec->mimeName()).toUpper(), pCodec->mimeName()) );
|
joachim99@58
|
1243 else break;
|
joachim99@58
|
1244 }
|
joachim99@58
|
1245
|
joachim99@58
|
1246 p->insertItem( i18n("Auto"), 0 );
|
joachim99@58
|
1247 std::multimap<QString,QString>::iterator mi;
|
joachim99@58
|
1248 for(mi=m.begin(), i=0; mi!=m.end(); ++mi, ++i)
|
joachim99@58
|
1249 p->insertItem(mi->second, i+1);
|
joachim99@58
|
1250 }
|
joachim99@66
|
1251 */
|
joachim99@58
|
1252
|
joachim99@75
|
1253 // UTF8-Codec that saves a BOM
|
joachim99@77
|
1254 // UTF8-Codec that saves a BOM
|
joachim99@75
|
1255 class Utf8BOMCodec : public QTextCodec
|
joachim99@75
|
1256 {
|
joachim99@100
|
1257 QTextCodec* m_pUtf8Codec;
|
joachim99@100
|
1258 class PublicTextCodec : public QTextCodec
|
joachim99@100
|
1259 {
|
joachim99@75
|
1260 public:
|
joachim99@100
|
1261 QString publicConvertToUnicode ( const char * p, int len, ConverterState* pState ) const
|
joachim99@100
|
1262 {
|
joachim99@100
|
1263 return convertToUnicode( p, len, pState );
|
joachim99@100
|
1264 }
|
joachim99@100
|
1265 QByteArray publicConvertFromUnicode ( const QChar * input, int number, ConverterState * pState ) const
|
joachim99@100
|
1266 {
|
joachim99@100
|
1267 return convertFromUnicode( input, number, pState );
|
joachim99@100
|
1268 }
|
joachim99@100
|
1269 };
|
joachim99@100
|
1270 public:
|
joachim99@100
|
1271 Utf8BOMCodec()
|
joachim99@100
|
1272 {
|
joachim99@100
|
1273 m_pUtf8Codec = QTextCodec::codecForName("UTF-8");
|
joachim99@100
|
1274 }
|
joachim99@75
|
1275 QByteArray name () const { return "UTF-8-BOM"; }
|
joachim99@77
|
1276 int mibEnum () const { return 2123; }
|
joachim99@75
|
1277 QByteArray convertFromUnicode ( const QChar * input, int number, ConverterState * pState ) const
|
joachim99@75
|
1278 {
|
joachim99@75
|
1279 QByteArray r;
|
joachim99@100
|
1280 if ( pState && pState->state_data[2]==0) // state_data[2] not used by QUtf8::convertFromUnicode (see qutfcodec.cpp)
|
joachim99@75
|
1281 {
|
joachim99@75
|
1282 r += "\xEF\xBB\xBF";
|
joachim99@100
|
1283 pState->state_data[2]=1;
|
joachim99@100
|
1284 pState->flags |= QTextCodec::IgnoreHeader;
|
joachim99@75
|
1285 }
|
joachim99@75
|
1286
|
joachim99@100
|
1287 r += ((PublicTextCodec*)m_pUtf8Codec)->publicConvertFromUnicode( input, number, pState );
|
joachim99@75
|
1288 return r;
|
joachim99@75
|
1289 }
|
joachim99@100
|
1290 QString convertToUnicode ( const char * p, int len, ConverterState* pState ) const
|
joachim99@75
|
1291 {
|
joachim99@100
|
1292 return ((PublicTextCodec*)m_pUtf8Codec)->publicConvertToUnicode( p, len, pState );
|
joachim99@77
|
1293 }
|
joachim99@75
|
1294 };
|
joachim99@75
|
1295
|
joachim99@58
|
1296 void OptionDialog::setupRegionalPage( void )
|
joachim99@58
|
1297 {
|
joachim99@75
|
1298 new Utf8BOMCodec();
|
joachim99@75
|
1299
|
joachim99@80
|
1300 QFrame* page = new QFrame();
|
joachim99@80
|
1301 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Regional Settings") );
|
joachim99@80
|
1302 pageItem->setHeader( i18n("Regional Settings") );
|
joachim99@80
|
1303 pageItem->setIcon( KIcon("locale" ) );
|
joachim99@80
|
1304 addPage( pageItem );
|
joachim99@80
|
1305
|
joachim99@75
|
1306 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
1307 topLayout->setMargin( 5 );
|
joachim99@75
|
1308 topLayout->setSpacing( spacingHint() );
|
joachim99@68
|
1309
|
joachim99@75
|
1310 QGridLayout *gbox = new QGridLayout();
|
joachim99@75
|
1311 gbox->setColumnStretch(1,5);
|
joachim99@68
|
1312 topLayout->addLayout( gbox );
|
joachim99@68
|
1313 int line=0;
|
joachim99@68
|
1314
|
joachim99@68
|
1315 QLabel* label;
|
joachim99@68
|
1316
|
joachim99@69
|
1317 #ifdef KREPLACEMENTS_H
|
joachim99@66
|
1318
|
joachim99@80
|
1319 static const char* countryMap[]={
|
joachim99@66
|
1320 "af Afrikaans",
|
joachim99@66
|
1321 "ar Arabic",
|
joachim99@66
|
1322 "az Azerbaijani",
|
joachim99@66
|
1323 "be Belarusian",
|
joachim99@66
|
1324 "bg Bulgarian",
|
joachim99@66
|
1325 "bn Bengali",
|
joachim99@66
|
1326 "bo Tibetan",
|
joachim99@66
|
1327 "br Breton",
|
joachim99@66
|
1328 "bs Bosnian",
|
joachim99@66
|
1329 "ca Catalan",
|
joachim99@66
|
1330 "cs Czech",
|
joachim99@66
|
1331 "cy Welsh",
|
joachim99@66
|
1332 "da Danish",
|
joachim99@66
|
1333 "de German",
|
joachim99@66
|
1334 "el Greek",
|
joachim99@66
|
1335 "en_GB British English",
|
joachim99@66
|
1336 "eo Esperanto",
|
joachim99@66
|
1337 "es Spanish",
|
joachim99@66
|
1338 "et Estonian",
|
joachim99@66
|
1339 "eu Basque",
|
joachim99@66
|
1340 "fa Farsi (Persian)",
|
joachim99@66
|
1341 "fi Finnish",
|
joachim99@66
|
1342 "fo Faroese",
|
joachim99@66
|
1343 "fr French",
|
joachim99@66
|
1344 "ga Irish Gaelic",
|
joachim99@66
|
1345 "gl Galician",
|
joachim99@66
|
1346 "gu Gujarati",
|
joachim99@66
|
1347 "he Hebrew",
|
joachim99@66
|
1348 "hi Hindi",
|
joachim99@66
|
1349 "hr Croatian",
|
joachim99@66
|
1350 "hsb Upper Sorbian",
|
joachim99@66
|
1351 "hu Hungarian",
|
joachim99@66
|
1352 "id Indonesian",
|
joachim99@66
|
1353 "is Icelandic",
|
joachim99@66
|
1354 "it Italian",
|
joachim99@66
|
1355 "ja Japanese",
|
joachim99@69
|
1356 "ka Georgian",
|
joachim99@66
|
1357 "ko Korean",
|
joachim99@66
|
1358 "ku Kurdish",
|
joachim99@66
|
1359 "lo Lao",
|
joachim99@66
|
1360 "lt Lithuanian",
|
joachim99@66
|
1361 "lv Latvian",
|
joachim99@66
|
1362 "mi Maori",
|
joachim99@66
|
1363 "mk Macedonian",
|
joachim99@66
|
1364 "mn Mongolian",
|
joachim99@66
|
1365 "ms Malay",
|
joachim99@66
|
1366 "mt Maltese",
|
joachim99@66
|
1367 "nb Norwegian Bookmal",
|
joachim99@66
|
1368 "nds Low Saxon",
|
joachim99@66
|
1369 "nl Dutch",
|
joachim99@66
|
1370 "nn Norwegian Nynorsk",
|
joachim99@66
|
1371 "nso Northern Sotho",
|
joachim99@66
|
1372 "oc Occitan",
|
joachim99@66
|
1373 "pl Polish",
|
joachim99@66
|
1374 "pt Portuguese",
|
joachim99@66
|
1375 "pt_BR Brazilian Portuguese",
|
joachim99@66
|
1376 "ro Romanian",
|
joachim99@66
|
1377 "ru Russian",
|
joachim99@69
|
1378 "rw Kinyarwanda",
|
joachim99@66
|
1379 "se Northern Sami",
|
joachim99@66
|
1380 "sk Slovak",
|
joachim99@66
|
1381 "sl Slovenian",
|
joachim99@66
|
1382 "sq Albanian",
|
joachim99@66
|
1383 "sr Serbian",
|
joachim99@69
|
1384 "sr@Latn Serbian",
|
joachim99@66
|
1385 "ss Swati",
|
joachim99@66
|
1386 "sv Swedish",
|
joachim99@66
|
1387 "ta Tamil",
|
joachim99@66
|
1388 "tg Tajik",
|
joachim99@66
|
1389 "th Thai",
|
joachim99@66
|
1390 "tr Turkish",
|
joachim99@66
|
1391 "uk Ukrainian",
|
joachim99@66
|
1392 "uz Uzbek",
|
joachim99@66
|
1393 "ven Venda",
|
joachim99@66
|
1394 "vi Vietnamese",
|
joachim99@66
|
1395 "wa Walloon",
|
joachim99@66
|
1396 "xh Xhosa",
|
joachim99@66
|
1397 "zh_CN Chinese Simplified",
|
joachim99@66
|
1398 "zh_TW Chinese Traditional",
|
joachim99@66
|
1399 "zu Zulu"
|
joachim99@66
|
1400 };
|
joachim99@66
|
1401
|
joachim99@58
|
1402 label = new QLabel( i18n("Language (restart required)"), page );
|
joachim99@58
|
1403 gbox->addWidget( label, line, 0 );
|
joachim99@58
|
1404 OptionComboBox* pLanguage = new OptionComboBox( 0, "Language", &m_language, page, this );
|
joachim99@58
|
1405 gbox->addWidget( pLanguage, line, 1 );
|
joachim99@75
|
1406 pLanguage->addItem( "Auto" ); // Must not translate, won't work otherwise!
|
joachim99@75
|
1407 pLanguage->addItem( "en_orig" );
|
joachim99@66
|
1408
|
joachim99@95
|
1409 #if !defined(_WIN32) && !defined(Q_OS_OS2)
|
joachim99@92
|
1410 // Read directory: Find all kdiff3_*.qm-files and insert the found files here
|
joachim99@92
|
1411 QDir localeDir( "/usr/share/locale" ); // See also kreplacements.cpp: getTranslationDir()
|
joachim99@92
|
1412 QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
joachim99@92
|
1413
|
joachim99@92
|
1414 for( int i = 0; i<dirList.size(); ++i )
|
joachim99@92
|
1415 {
|
joachim99@92
|
1416 QString languageId = dirList[i];
|
joachim99@92
|
1417 if ( ! QFile::exists( "/usr/share/locale/" + languageId + "/LC_MESSAGES/kdiff3.qm" ) )
|
joachim99@92
|
1418 continue;
|
joachim99@92
|
1419 #else
|
joachim99@92
|
1420 // Read directory: Find all kdiff3_*.qm-files and insert the found files here
|
joachim99@92
|
1421
|
joachim99@92
|
1422 QDir localeDir( getTranslationDir(QString()) );
|
joachim99@92
|
1423 QStringList fileList = localeDir.entryList( QStringList("kdiff3_*.qm") , QDir::Files, QDir::Name );
|
joachim99@92
|
1424 for( int i=0; i<fileList.size(); ++i )
|
joachim99@66
|
1425 {
|
joachim99@92
|
1426 QString fileName = fileList[i];
|
joachim99@66
|
1427 // Skip the "kdiff3_" and omit the .qm
|
joachim99@66
|
1428 QString languageId = fileName.mid(7, fileName.length()-10 );
|
joachim99@92
|
1429 #endif
|
joachim99@92
|
1430
|
joachim99@66
|
1431 unsigned int countryIdx=0;
|
joachim99@66
|
1432 for(countryIdx=0; countryIdx< sizeof(countryMap)/sizeof(countryMap[0]); ++countryIdx )
|
joachim99@66
|
1433 {
|
joachim99@66
|
1434 QString fullName = countryMap[countryIdx];
|
joachim99@66
|
1435 if ( languageId+" " == fullName.left(languageId.length()+1) )
|
joachim99@66
|
1436 {
|
joachim99@66
|
1437 languageId += " (" + fullName.mid(languageId.length()+1) + ")";
|
joachim99@66
|
1438 }
|
joachim99@66
|
1439 }
|
joachim99@66
|
1440
|
joachim99@75
|
1441 pLanguage->addItem( languageId );
|
joachim99@66
|
1442 }
|
joachim99@66
|
1443
|
joachim99@92
|
1444
|
joachim99@75
|
1445 label->setToolTip( i18n(
|
joachim99@58
|
1446 "Choose the language of the GUI-strings or \"Auto\".\n"
|
joachim99@58
|
1447 "For a change of language to take place, quit and restart KDiff3.")
|
joachim99@58
|
1448 );
|
joachim99@58
|
1449 ++line;
|
joachim99@66
|
1450 /*
|
joachim99@58
|
1451 label = new QLabel( i18n("Codec for file contents"), page );
|
joachim99@58
|
1452 gbox->addWidget( label, line, 0 );
|
joachim99@58
|
1453 OptionComboBox* pFileCodec = new OptionComboBox( 0, "FileCodec", &m_fileCodec, page, this );
|
joachim99@58
|
1454 gbox->addWidget( pFileCodec, line, 1 );
|
joachim99@58
|
1455 insertCodecs( pFileCodec );
|
joachim99@75
|
1456 label->setToolTip( i18n(
|
joachim99@58
|
1457 "Choose the codec that should be used for your input files\n"
|
joachim99@58
|
1458 "or \"Auto\" if unsure." )
|
joachim99@58
|
1459 );
|
joachim99@58
|
1460 ++line;
|
joachim99@66
|
1461 */
|
joachim99@68
|
1462 #endif
|
joachim99@68
|
1463
|
joachim99@68
|
1464 m_pSameEncoding = new OptionCheckBox( i18n("Use the same encoding for everything:"), true, "SameEncoding", &m_bSameEncoding, page, this );
|
joachim99@75
|
1465 gbox->addWidget( m_pSameEncoding, line, 0, 1, 2 );
|
joachim99@75
|
1466 m_pSameEncoding->setToolTip( i18n(
|
joachim99@68
|
1467 "Enable this allows to change all encodings by changing the first only.\n"
|
joachim99@68
|
1468 "Disable this if different individual settings are needed."
|
joachim99@68
|
1469 ) );
|
joachim99@68
|
1470 ++line;
|
joachim99@68
|
1471
|
joachim99@69
|
1472 label = new QLabel( i18n("Note: Local Encoding is ") + "\"" + QTextCodec::codecForLocale()->name() + "\"", page );
|
joachim99@68
|
1473 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1474 ++line;
|
joachim99@68
|
1475
|
joachim99@68
|
1476 label = new QLabel( i18n("File Encoding for A:"), page );
|
joachim99@68
|
1477 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1478 m_pEncodingAComboBox = new OptionEncodingComboBox( "EncodingForA", &m_pEncodingA, page, this );
|
joachim99@68
|
1479 gbox->addWidget( m_pEncodingAComboBox, line, 1 );
|
joachim99@75
|
1480
|
joachim99@75
|
1481 QString autoDetectToolTip = i18n(
|
joachim99@75
|
1482 "If enabled then Unicode (UTF-16 or UTF-8) encoding will be detected.\n"
|
joachim99@75
|
1483 "If the file is not Unicode then the selected encoding will be used as fallback.\n"
|
joachim99@75
|
1484 "(Unicode detection depends on the first bytes of a file.)"
|
joachim99@75
|
1485 );
|
joachim99@75
|
1486 m_pAutoDetectUnicodeA = new OptionCheckBox( i18n("Auto Detect Unicode"), true, "AutoDetectUnicodeA", &m_bAutoDetectUnicodeA, page, this );
|
joachim99@75
|
1487 gbox->addWidget( m_pAutoDetectUnicodeA, line, 2 );
|
joachim99@75
|
1488 m_pAutoDetectUnicodeA->setToolTip( autoDetectToolTip );
|
joachim99@68
|
1489 ++line;
|
joachim99@75
|
1490
|
joachim99@68
|
1491 label = new QLabel( i18n("File Encoding for B:"), page );
|
joachim99@68
|
1492 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1493 m_pEncodingBComboBox = new OptionEncodingComboBox( "EncodingForB", &m_pEncodingB, page, this );
|
joachim99@68
|
1494 gbox->addWidget( m_pEncodingBComboBox, line, 1 );
|
joachim99@75
|
1495 m_pAutoDetectUnicodeB = new OptionCheckBox( i18n("Auto Detect Unicode"), true, "AutoDetectUnicodeB", &m_bAutoDetectUnicodeB, page, this );
|
joachim99@75
|
1496 gbox->addWidget( m_pAutoDetectUnicodeB, line, 2 );
|
joachim99@75
|
1497 m_pAutoDetectUnicodeB->setToolTip( autoDetectToolTip );
|
joachim99@68
|
1498 ++line;
|
joachim99@75
|
1499
|
joachim99@68
|
1500 label = new QLabel( i18n("File Encoding for C:"), page );
|
joachim99@68
|
1501 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1502 m_pEncodingCComboBox = new OptionEncodingComboBox( "EncodingForC", &m_pEncodingC, page, this );
|
joachim99@68
|
1503 gbox->addWidget( m_pEncodingCComboBox, line, 1 );
|
joachim99@75
|
1504 m_pAutoDetectUnicodeC = new OptionCheckBox( i18n("Auto Detect Unicode"), true, "AutoDetectUnicodeC", &m_bAutoDetectUnicodeC, page, this );
|
joachim99@75
|
1505 gbox->addWidget( m_pAutoDetectUnicodeC, line, 2 );
|
joachim99@75
|
1506 m_pAutoDetectUnicodeC->setToolTip( autoDetectToolTip );
|
joachim99@68
|
1507 ++line;
|
joachim99@75
|
1508
|
joachim99@68
|
1509 label = new QLabel( i18n("File Encoding for Merge Output and Saving:"), page );
|
joachim99@68
|
1510 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1511 m_pEncodingOutComboBox = new OptionEncodingComboBox( "EncodingForOutput", &m_pEncodingOut, page, this );
|
joachim99@68
|
1512 gbox->addWidget( m_pEncodingOutComboBox, line, 1 );
|
joachim99@75
|
1513 m_pAutoSelectOutEncoding = new OptionCheckBox( i18n("Auto Select"), true, "AutoSelectOutEncoding", &m_bAutoSelectOutEncoding, page, this );
|
joachim99@75
|
1514 gbox->addWidget( m_pAutoSelectOutEncoding, line, 2 );
|
joachim99@75
|
1515 m_pAutoSelectOutEncoding->setToolTip( i18n(
|
joachim99@75
|
1516 "If enabled then the encoding from the input files is used.\n"
|
joachim99@75
|
1517 "In ambiguous cases a dialog will ask the user to choose the encoding for saving."
|
joachim99@75
|
1518 ) );
|
joachim99@68
|
1519 ++line;
|
joachim99@68
|
1520 label = new QLabel( i18n("File Encoding for Preprocessor Files:"), page );
|
joachim99@68
|
1521 gbox->addWidget( label, line, 0 );
|
joachim99@68
|
1522 m_pEncodingPPComboBox = new OptionEncodingComboBox( "EncodingForPP", &m_pEncodingPP, page, this );
|
joachim99@68
|
1523 gbox->addWidget( m_pEncodingPPComboBox, line, 1 );
|
joachim99@68
|
1524 ++line;
|
joachim99@68
|
1525
|
joachim99@68
|
1526 connect(m_pSameEncoding, SIGNAL(toggled(bool)), this, SLOT(slotEncodingChanged()));
|
joachim99@68
|
1527 connect(m_pEncodingAComboBox, SIGNAL(activated(int)), this, SLOT(slotEncodingChanged()));
|
joachim99@75
|
1528 connect(m_pAutoDetectUnicodeA, SIGNAL(toggled(bool)), this, SLOT(slotEncodingChanged()));
|
joachim99@75
|
1529 connect(m_pAutoSelectOutEncoding, SIGNAL(toggled(bool)), this, SLOT(slotEncodingChanged()));
|
joachim99@68
|
1530
|
joachim99@68
|
1531 OptionCheckBox* pRightToLeftLanguage = new OptionCheckBox( i18n("Right To Left Language"), false, "RightToLeftLanguage", &m_bRightToLeftLanguage, page, this );
|
joachim99@75
|
1532 gbox->addWidget( pRightToLeftLanguage, line, 0, 1, 2 );
|
joachim99@75
|
1533 pRightToLeftLanguage->setToolTip( i18n(
|
joachim99@68
|
1534 "Some languages are read from right to left.\n"
|
joachim99@68
|
1535 "This setting will change the viewer and editor accordingly."));
|
joachim99@68
|
1536 ++line;
|
joachim99@68
|
1537
|
joachim99@68
|
1538
|
joachim99@58
|
1539 topLayout->addStretch(10);
|
joachim99@58
|
1540 }
|
joachim99@58
|
1541
|
joachim99@77
|
1542 #ifdef _WIN32
|
joachim99@77
|
1543 #include "ccInstHelper.cpp"
|
joachim99@77
|
1544 #endif
|
joachim99@77
|
1545
|
joachim99@69
|
1546 void OptionDialog::setupIntegrationPage( void )
|
joachim99@69
|
1547 {
|
joachim99@80
|
1548 QFrame* page = new QFrame();
|
joachim99@80
|
1549 KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Integration") );
|
joachim99@80
|
1550 pageItem->setHeader( i18n("Integration Settings") );
|
joachim99@80
|
1551 pageItem->setIcon( KIcon( "preferences-desktop-launch-feedback" ) );
|
joachim99@80
|
1552 addPage( pageItem );
|
joachim99@80
|
1553
|
joachim99@75
|
1554 QVBoxLayout *topLayout = new QVBoxLayout( page );
|
joachim99@75
|
1555 topLayout->setMargin( 5 );
|
joachim99@75
|
1556 topLayout->setSpacing( spacingHint() );
|
joachim99@69
|
1557
|
joachim99@75
|
1558 QGridLayout *gbox = new QGridLayout();
|
joachim99@77
|
1559 gbox->setColumnStretch(2,5);
|
joachim99@69
|
1560 topLayout->addLayout( gbox );
|
joachim99@69
|
1561 int line=0;
|
joachim99@69
|
1562
|
joachim99@69
|
1563 QLabel* label;
|
joachim99@69
|
1564 label = new QLabel( i18n("Command line options to ignore:"), page );
|
joachim99@69
|
1565 gbox->addWidget( label, line, 0 );
|
joachim99@69
|
1566 OptionLineEdit* pIgnorableCmdLineOptions = new OptionLineEdit( "-u;-query;-html;-abort", "IgnorableCmdLineOptions", &m_ignorableCmdLineOptions, page, this );
|
joachim99@77
|
1567 gbox->addWidget( pIgnorableCmdLineOptions, line, 1, 1, 2 );
|
joachim99@75
|
1568 label->setToolTip( i18n(
|
joachim99@69
|
1569 "List of command line options that should be ignored when KDiff3 is used by other tools.\n"
|
joachim99@69
|
1570 "Several values can be specified if separated via ';'\n"
|
joachim99@69
|
1571 "This will suppress the \"Unknown option\"-error."
|
joachim99@69
|
1572 ));
|
joachim99@69
|
1573 ++line;
|
joachim99@69
|
1574
|
joachim99@80
|
1575
|
joachim99@80
|
1576 OptionCheckBox* pEscapeKeyQuits = new OptionCheckBox( i18n("Quit also via Escape key"), false, "EscapeKeyQuits", &m_bEscapeKeyQuits, page, this );
|
joachim99@80
|
1577 gbox->addWidget( pEscapeKeyQuits, line, 0, 1, 2 );
|
joachim99@80
|
1578 pEscapeKeyQuits->setToolTip( i18n(
|
joachim99@80
|
1579 "Fast method to exit.\n"
|
joachim99@80
|
1580 "For those who are used to using the Escape-key." ) );
|
joachim99@80
|
1581 ++line;
|
joachim99@80
|
1582
|
joachim99@77
|
1583 #ifdef _WIN32
|
joachim99@77
|
1584 QPushButton* pIntegrateWithClearCase = new QPushButton( i18n("Integrate with ClearCase"), page);
|
joachim99@77
|
1585 gbox->addWidget( pIntegrateWithClearCase, line, 0 );
|
joachim99@77
|
1586 pIntegrateWithClearCase->setToolTip( i18n(
|
joachim99@77
|
1587 "Integrate with Rational ClearCase from IBM.\n"
|
joachim99@77
|
1588 "Modifies the \"map\" file in ClearCase-subdir \"lib/mgrs\"\n"
|
joachim99@77
|
1589 "(Only enabled when ClearCase \"bin\" directory is in the path.)"));
|
joachim99@77
|
1590 connect(pIntegrateWithClearCase, SIGNAL(clicked()),this, SLOT(slotIntegrateWithClearCase()) );
|
joachim99@77
|
1591 pIntegrateWithClearCase->setEnabled( integrateWithClearCase( "existsClearCase", "" )!=0 );
|
joachim99@77
|
1592
|
joachim99@77
|
1593 QPushButton* pRemoveClearCaseIntegration = new QPushButton( i18n("Remove ClearCase Integration"), page);
|
joachim99@77
|
1594 gbox->addWidget( pRemoveClearCaseIntegration, line, 1 );
|
joachim99@77
|
1595 pRemoveClearCaseIntegration->setToolTip( i18n(
|
joachim99@77
|
1596 "Restore the old \"map\" file from before doing the Clearcase integration."));
|
joachim99@77
|
1597 connect(pRemoveClearCaseIntegration, SIGNAL(clicked()),this, SLOT(slotRemoveClearCaseIntegration()) );
|
joachim99@77
|
1598 pRemoveClearCaseIntegration->setEnabled( integrateWithClearCase( "existsClearCase", "" )!=0 );
|
joachim99@77
|
1599
|
joachim99@77
|
1600 ++line;
|
joachim99@77
|
1601 #endif
|
joachim99@77
|
1602
|
joachim99@69
|
1603 topLayout->addStretch(10);
|
joachim99@69
|
1604 }
|
joachim99@69
|
1605
|
joachim99@77
|
1606 void OptionDialog::slotIntegrateWithClearCase()
|
joachim99@77
|
1607 {
|
joachim99@77
|
1608 #ifdef _WIN32
|
joachim99@77
|
1609 char kdiff3CommandPath[1000];
|
joachim99@77
|
1610 GetModuleFileNameA( 0, kdiff3CommandPath, sizeof(kdiff3CommandPath)-1 );
|
joachim99@77
|
1611 integrateWithClearCase( "install", kdiff3CommandPath );
|
joachim99@77
|
1612 #endif
|
joachim99@77
|
1613 }
|
joachim99@77
|
1614
|
joachim99@77
|
1615 void OptionDialog::slotRemoveClearCaseIntegration()
|
joachim99@77
|
1616 {
|
joachim99@77
|
1617 #ifdef _WIN32
|
joachim99@77
|
1618 char kdiff3CommandPath[1000];
|
joachim99@77
|
1619 GetModuleFileNameA( 0, kdiff3CommandPath, sizeof(kdiff3CommandPath)-1 );
|
joachim99@77
|
1620 integrateWithClearCase( "uninstall", kdiff3CommandPath );
|
joachim99@77
|
1621 #endif
|
joachim99@77
|
1622 }
|
joachim99@69
|
1623
|
joachim99@68
|
1624 void OptionDialog::slotEncodingChanged()
|
joachim99@68
|
1625 {
|
joachim99@68
|
1626 if ( m_pSameEncoding->isChecked() )
|
joachim99@68
|
1627 {
|
joachim99@68
|
1628 m_pEncodingBComboBox->setEnabled( false );
|
joachim99@75
|
1629 m_pEncodingBComboBox->setCurrentIndex( m_pEncodingAComboBox->currentIndex() );
|
joachim99@68
|
1630 m_pEncodingCComboBox->setEnabled( false );
|
joachim99@75
|
1631 m_pEncodingCComboBox->setCurrentIndex( m_pEncodingAComboBox->currentIndex() );
|
joachim99@68
|
1632 m_pEncodingOutComboBox->setEnabled( false );
|
joachim99@75
|
1633 m_pEncodingOutComboBox->setCurrentIndex( m_pEncodingAComboBox->currentIndex() );
|
joachim99@68
|
1634 m_pEncodingPPComboBox->setEnabled( false );
|
joachim99@75
|
1635 m_pEncodingPPComboBox->setCurrentIndex( m_pEncodingAComboBox->currentIndex() );
|
joachim99@75
|
1636 m_pAutoDetectUnicodeB->setEnabled( false );
|
joachim99@75
|
1637 m_pAutoDetectUnicodeB->setCheckState( m_pAutoDetectUnicodeA->checkState() );
|
joachim99@75
|
1638 m_pAutoDetectUnicodeC->setEnabled( false );
|
joachim99@75
|
1639 m_pAutoDetectUnicodeC->setCheckState( m_pAutoDetectUnicodeA->checkState() );
|
joachim99@75
|
1640 m_pAutoSelectOutEncoding->setEnabled( false );
|
joachim99@75
|
1641 m_pAutoSelectOutEncoding->setCheckState( m_pAutoDetectUnicodeA->checkState() );
|
joachim99@68
|
1642 }
|
joachim99@68
|
1643 else
|
joachim99@68
|
1644 {
|
joachim99@68
|
1645 m_pEncodingBComboBox->setEnabled( true );
|
joachim99@68
|
1646 m_pEncodingCComboBox->setEnabled( true );
|
joachim99@68
|
1647 m_pEncodingOutComboBox->setEnabled( true );
|
joachim99@68
|
1648 m_pEncodingPPComboBox->setEnabled( true );
|
joachim99@75
|
1649 m_pAutoDetectUnicodeB->setEnabled( true );
|
joachim99@75
|
1650 m_pAutoDetectUnicodeC->setEnabled( true );
|
joachim99@75
|
1651 m_pAutoSelectOutEncoding->setEnabled( true );
|
joachim99@75
|
1652 m_pEncodingOutComboBox->setEnabled( m_pAutoSelectOutEncoding->checkState()==Qt::Unchecked );
|
joachim99@68
|
1653 }
|
joachim99@68
|
1654 }
|
joachim99@58
|
1655
|
joachim99@8
|
1656 void OptionDialog::setupKeysPage( void )
|
joachim99@8
|
1657 {
|
joachim99@8
|
1658 //QVBox *page = addVBoxPage( i18n("Keys"), i18n("KeyDialog" ),
|
joachim99@80
|
1659 // BarIcon("fonts", KIconLoader::SizeMedium ) );
|
joachim99@8
|
1660
|
joachim99@8
|
1661 //QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
|
joachim99@8
|
1662 // new KFontChooser( page,"font",false/*onlyFixed*/,QStringList(),false,6 );
|
joachim99@8
|
1663 //m_pKeyDialog=new KKeyDialog( false, 0 );
|
joachim99@8
|
1664 //topLayout->addWidget( m_pKeyDialog );
|
joachim99@8
|
1665 }
|
joachim99@8
|
1666
|
joachim99@8
|
1667 void OptionDialog::slotOk( void )
|
joachim99@8
|
1668 {
|
joachim99@8
|
1669 slotApply();
|
joachim99@8
|
1670
|
joachim99@8
|
1671 // My system returns variable width fonts even though I
|
joachim99@8
|
1672 // disabled this. Even QFont::fixedPitch() doesn't work.
|
joachim99@8
|
1673 QFontMetrics fm(m_font);
|
joachim99@8
|
1674 if ( fm.width('W')!=fm.width('i') )
|
joachim99@8
|
1675 {
|
joachim99@8
|
1676 int result = KMessageBox::warningYesNo(this, i18n(
|
joachim99@8
|
1677 "You selected a variable width font.\n\n"
|
joachim99@8
|
1678 "Because this program doesn't handle variable width fonts\n"
|
joachim99@8
|
1679 "correctly, you might experience problems while editing.\n\n"
|
joachim99@8
|
1680 "Do you want to continue or do you want to select another font."),
|
joachim99@51
|
1681 i18n("Incompatible Font"),
|
joachim99@80
|
1682 KGuiItem( i18n("Continue at Own Risk") ),
|
joachim99@80
|
1683 KGuiItem( i18n("Select Another Font")) );
|
joachim99@8
|
1684 if (result==KMessageBox::No)
|
joachim99@8
|
1685 return;
|
joachim99@8
|
1686 }
|
joachim99@8
|
1687
|
joachim99@8
|
1688 accept();
|
joachim99@8
|
1689 }
|
joachim99@8
|
1690
|
joachim99@8
|
1691
|
joachim99@8
|
1692 /** Copy the values from the widgets to the public variables.*/
|
joachim99@8
|
1693 void OptionDialog::slotApply( void )
|
joachim99@8
|
1694 {
|
joachim99@8
|
1695 std::list<OptionItem*>::iterator i;
|
joachim99@8
|
1696 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i)
|
joachim99@8
|
1697 {
|
joachim99@8
|
1698 (*i)->apply();
|
joachim99@8
|
1699 }
|
joachim99@8
|
1700
|
joachim99@80
|
1701 emit applyDone();
|
joachim99@75
|
1702
|
joachim99@75
|
1703 #ifdef _WIN32
|
joachim99@75
|
1704 QString locale = m_language;
|
joachim99@75
|
1705 if ( locale == "Auto" || locale.isEmpty() )
|
joachim99@75
|
1706 locale = QLocale::system().name().left(2);
|
joachim99@75
|
1707 int spacePos = locale.indexOf(' ');
|
joachim99@75
|
1708 if (spacePos>0) locale = locale.left(spacePos);
|
joachim99@75
|
1709 QSettings settings("HKEY_CURRENT_USER\\Software\\KDiff3\\diff-ext", QSettings::NativeFormat);
|
joachim99@75
|
1710 settings.setValue( "Language", locale );
|
joachim99@75
|
1711 #endif
|
joachim99@8
|
1712 }
|
joachim99@8
|
1713
|
joachim99@8
|
1714 /** Set the default values in the widgets only, while the
|
joachim99@8
|
1715 public variables remain unchanged. */
|
joachim99@8
|
1716 void OptionDialog::slotDefault()
|
joachim99@8
|
1717 {
|
joachim99@8
|
1718 int result = KMessageBox::warningContinueCancel(this, i18n("This resets all options. Not only those of the current topic.") );
|
joachim99@8
|
1719 if ( result==KMessageBox::Cancel ) return;
|
joachim99@8
|
1720 else resetToDefaults();
|
joachim99@8
|
1721 }
|
joachim99@8
|
1722
|
joachim99@8
|
1723 void OptionDialog::resetToDefaults()
|
joachim99@69
|
1724 {
|
joachim99@8
|
1725 std::list<OptionItem*>::iterator i;
|
joachim99@8
|
1726 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i)
|
joachim99@8
|
1727 {
|
joachim99@8
|
1728 (*i)->setToDefault();
|
joachim99@8
|
1729 }
|
joachim99@8
|
1730
|
joachim99@68
|
1731 slotEncodingChanged();
|
joachim99@8
|
1732 }
|
joachim99@8
|
1733
|
joachim99@8
|
1734 /** Initialise the widgets using the values in the public varibles. */
|
joachim99@8
|
1735 void OptionDialog::setState()
|
joachim99@8
|
1736 {
|
joachim99@8
|
1737 std::list<OptionItem*>::iterator i;
|
joachim99@8
|
1738 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i)
|
joachim99@8
|
1739 {
|
joachim99@8
|
1740 (*i)->setToCurrent();
|
joachim99@8
|
1741 }
|
joachim99@8
|
1742
|
joachim99@68
|
1743 slotEncodingChanged();
|
joachim99@8
|
1744 }
|
joachim99@8
|
1745
|
joachim99@69
|
1746 class ConfigValueMap : public ValueMap
|
joachim99@69
|
1747 {
|
joachim99@69
|
1748 private:
|
joachim99@80
|
1749 KConfigGroup m_config;
|
joachim99@69
|
1750 public:
|
joachim99@80
|
1751 ConfigValueMap( const KConfigGroup& config ) : m_config( config ){ }
|
joachim99@69
|
1752
|
joachim99@80
|
1753 void writeEntry(const QString& s, const QFont& v ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1754 void writeEntry(const QString& s, const QColor& v ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1755 void writeEntry(const QString& s, const QSize& v ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1756 void writeEntry(const QString& s, const QPoint& v ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1757 void writeEntry(const QString& s, int v ) { m_config.writeEntry(s,v); }
|
joachim99@80
|
1758 void writeEntry(const QString& s, bool v ) { m_config.writeEntry(s,v); }
|
joachim99@80
|
1759 void writeEntry(const QString& s, const QString& v ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1760 void writeEntry(const QString& s, const char* v ) { m_config.writeEntry(s,v); }
|
joachim99@69
|
1761
|
joachim99@80
|
1762 QFont readFontEntry (const QString& s, const QFont* defaultVal ) { return m_config.readEntry(s,*defaultVal); }
|
joachim99@80
|
1763 QColor readColorEntry(const QString& s, const QColor* defaultVal ){ return m_config.readEntry(s,*defaultVal); }
|
joachim99@80
|
1764 QSize readSizeEntry (const QString& s, const QSize* defaultVal ) { return m_config.readEntry(s,*defaultVal); }
|
joachim99@80
|
1765 QPoint readPointEntry(const QString& s, const QPoint* defaultVal) { return m_config.readEntry(s,*defaultVal); }
|
joachim99@80
|
1766 bool readBoolEntry (const QString& s, bool defaultVal ) { return m_config.readEntry(s,defaultVal); }
|
joachim99@80
|
1767 int readNumEntry (const QString& s, int defaultVal ) { return m_config.readEntry(s,defaultVal); }
|
joachim99@80
|
1768 QString readStringEntry(const QString& s, const QString& defaultVal){ return m_config.readEntry(s,defaultVal); }
|
joachim99@80
|
1769 #ifdef KREPLACEMENTS_H
|
joachim99@80
|
1770 void writeEntry(const QString& s, const QStringList& v, char separator ){ m_config.writeEntry(s,v,separator); }
|
joachim99@80
|
1771 QStringList readListEntry (const QString& s, const QStringList& def, char separator ) { return m_config.readEntry(s, def ,separator ); }
|
joachim99@80
|
1772 #else
|
joachim99@80
|
1773 void writeEntry(const QString& s, const QStringList& v, char separator ){ m_config.writeEntry(s,v); }
|
joachim99@80
|
1774 QStringList readListEntry (const QString& s, const QStringList& def, char separator ) { return m_config.readEntry(s, def ); }
|
joachim99@80
|
1775 #endif
|
joachim99@69
|
1776 };
|
joachim99@69
|
1777
|
joachim99@80
|
1778
|
joachim99@80
|
1779 void OptionDialog::saveOptions( KSharedConfigPtr config )
|
joachim99@8
|
1780 {
|
joachim99@8
|
1781 // No i18n()-Translations here!
|
joachim99@8
|
1782
|
joachim99@80
|
1783 ConfigValueMap cvm(config->group(KDIFF3_CONFIG_GROUP));
|
joachim99@8
|
1784 std::list<OptionItem*>::iterator i;
|
joachim99@8
|
1785 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i)
|
joachim99@8
|
1786 {
|
joachim99@69
|
1787 (*i)->write(&cvm);
|
joachim99@8
|
1788 }
|
joachim99@8
|
1789 }
|
joachim99@8
|
1790
|
joachim99@80
|
1791 void OptionDialog::readOptions( KSharedConfigPtr config )
|
joachim99@8
|
1792 {
|
joachim99@8
|
1793 // No i18n()-Translations here!
|
joachim99@8
|
1794
|
joachim99@80
|
1795 ConfigValueMap cvm(config->group(KDIFF3_CONFIG_GROUP));
|
joachim99@8
|
1796 std::list<OptionItem*>::iterator i;
|
joachim99@8
|
1797 for(i=m_optionItemList.begin(); i!=m_optionItemList.end(); ++i)
|
joachim99@8
|
1798 {
|
joachim99@69
|
1799 (*i)->read(&cvm);
|
joachim99@8
|
1800 }
|
joachim99@8
|
1801
|
joachim99@8
|
1802 setState();
|
joachim99@8
|
1803 }
|
joachim99@8
|
1804
|
joachim99@80
|
1805 QString OptionDialog::parseOptions( const QStringList& optionList )
|
joachim99@69
|
1806 {
|
joachim99@69
|
1807 QString result;
|
joachim99@80
|
1808 QStringList::const_iterator i;
|
joachim99@69
|
1809 for ( i=optionList.begin(); i!=optionList.end(); ++i )
|
joachim99@69
|
1810 {
|
joachim99@69
|
1811 QString s = *i;
|
joachim99@69
|
1812
|
joachim99@75
|
1813 int pos = s.indexOf('=');
|
joachim99@69
|
1814 if( pos > 0 ) // seems not to have a tag
|
joachim99@69
|
1815 {
|
joachim99@69
|
1816 QString key = s.left(pos);
|
joachim99@69
|
1817 QString val = s.mid(pos+1);
|
joachim99@69
|
1818 std::list<OptionItem*>::iterator j;
|
joachim99@69
|
1819 bool bFound = false;
|
joachim99@69
|
1820 for(j=m_optionItemList.begin(); j!=m_optionItemList.end(); ++j)
|
joachim99@69
|
1821 {
|
joachim99@69
|
1822 if ( (*j)->getSaveName()==key )
|
joachim99@69
|
1823 {
|
joachim99@69
|
1824 ValueMap config;
|
joachim99@69
|
1825 config.writeEntry( key, val ); // Write the value as a string and
|
joachim99@69
|
1826 (*j)->read(&config); // use the internal conversion from string to the needed value.
|
joachim99@69
|
1827 bFound = true;
|
joachim99@69
|
1828 break;
|
joachim99@69
|
1829 }
|
joachim99@69
|
1830 }
|
joachim99@69
|
1831 if ( ! bFound )
|
joachim99@69
|
1832 {
|
joachim99@69
|
1833 result += "No config item named \"" + key + "\"\n";
|
joachim99@69
|
1834 }
|
joachim99@69
|
1835 }
|
joachim99@69
|
1836 else
|
joachim99@69
|
1837 {
|
joachim99@69
|
1838 result += "No '=' found in \"" + s + "\"\n";
|
joachim99@69
|
1839 }
|
joachim99@69
|
1840 }
|
joachim99@69
|
1841 return result;
|
joachim99@69
|
1842 }
|
joachim99@69
|
1843
|
joachim99@69
|
1844 QString OptionDialog::calcOptionHelp()
|
joachim99@69
|
1845 {
|
joachim99@69
|
1846 ValueMap config;
|
joachim99@69
|
1847 std::list<OptionItem*>::iterator j;
|
joachim99@69
|
1848 for(j=m_optionItemList.begin(); j!=m_optionItemList.end(); ++j)
|
joachim99@69
|
1849 {
|
joachim99@69
|
1850 (*j)->write( &config );
|
joachim99@69
|
1851 }
|
joachim99@69
|
1852 return config.getAsString();
|
joachim99@69
|
1853 }
|
joachim99@69
|
1854
|
joachim99@69
|
1855 void OptionDialog::slotHistoryMergeRegExpTester()
|
joachim99@69
|
1856 {
|
joachim99@69
|
1857 RegExpTester dlg(this, s_autoMergeRegExpToolTip, s_historyStartRegExpToolTip,
|
joachim99@69
|
1858 s_historyEntryStartRegExpToolTip, s_historyEntryStartSortKeyOrderToolTip );
|
joachim99@69
|
1859 dlg.init(m_pAutoMergeRegExpLineEdit->currentText(), m_pHistoryStartRegExpLineEdit->currentText(),
|
joachim99@69
|
1860 m_pHistoryEntryStartRegExpLineEdit->currentText(), m_pHistorySortKeyOrderLineEdit->currentText());
|
joachim99@69
|
1861 if ( dlg.exec() )
|
joachim99@69
|
1862 {
|
joachim99@75
|
1863 m_pAutoMergeRegExpLineEdit->setEditText( dlg.autoMergeRegExp() );
|
joachim99@75
|
1864 m_pHistoryStartRegExpLineEdit->setEditText( dlg.historyStartRegExp() );
|
joachim99@75
|
1865 m_pHistoryEntryStartRegExpLineEdit->setEditText( dlg.historyEntryStartRegExp() );
|
joachim99@75
|
1866 m_pHistorySortKeyOrderLineEdit->setEditText( dlg.historySortKeyOrder() );
|
joachim99@69
|
1867 }
|
joachim99@69
|
1868 }
|
joachim99@69
|
1869
|
joachim99@69
|
1870
|
joachim99@70
|
1871 //#include "optiondialog.moc"
|