joachim99@8
|
1 /***************************************************************************
|
joachim99@8
|
2 kreplacements.cpp - description
|
joachim99@8
|
3 -------------------
|
joachim99@8
|
4 begin : Sat Aug 3 2002
|
joachim99@8
|
5 copyright : (C) 2002-2003 by Joachim Eibl
|
joachim99@8
|
6 email : joachim.eibl@gmx.de
|
joachim99@8
|
7 ***************************************************************************/
|
joachim99@8
|
8
|
joachim99@8
|
9 /***************************************************************************
|
joachim99@8
|
10 * *
|
joachim99@8
|
11 * This program is free software; you can redistribute it and/or modify *
|
joachim99@8
|
12 * it under the terms of the GNU General Public License as published by *
|
joachim99@8
|
13 * the Free Software Foundation; either version 2 of the License, or *
|
joachim99@8
|
14 * (at your option) any later version. *
|
joachim99@8
|
15 * *
|
joachim99@8
|
16 ***************************************************************************/
|
joachim99@8
|
17
|
joachim99@8
|
18
|
joachim99@8
|
19 #include "kreplacements.h"
|
joachim99@66
|
20 #include "common.h"
|
joachim99@8
|
21
|
joachim99@8
|
22 #include <assert.h>
|
joachim99@8
|
23
|
joachim99@8
|
24 #include <qnamespace.h>
|
joachim99@8
|
25 #include <qmessagebox.h>
|
joachim99@8
|
26 #include <qpopupmenu.h>
|
joachim99@8
|
27 #include <qmenubar.h>
|
joachim99@8
|
28 #include <qpainter.h>
|
joachim99@8
|
29 #include <qcolordialog.h>
|
joachim99@8
|
30 #include <qfontdialog.h>
|
joachim99@8
|
31 #include <qlabel.h>
|
joachim99@8
|
32 #include <qtextbrowser.h>
|
joachim99@8
|
33 #include <qtextstream.h>
|
joachim99@8
|
34 #include <qlayout.h>
|
joachim99@66
|
35 #include <qdockarea.h>
|
joachim99@8
|
36
|
joachim99@8
|
37 #include <vector>
|
joachim99@8
|
38 #include <iostream>
|
joachim99@8
|
39 #include <algorithm>
|
joachim99@8
|
40
|
joachim99@66
|
41
|
joachim99@8
|
42 static QString s_copyright;
|
joachim99@8
|
43 static QString s_email;
|
joachim99@8
|
44 static QString s_description;
|
joachim99@8
|
45 static QString s_appName;
|
joachim99@8
|
46 static QString s_version;
|
joachim99@8
|
47 static QString s_homepage;
|
joachim99@66
|
48 static KAboutData* s_pAboutData;
|
joachim99@66
|
49
|
joachim99@8
|
50
|
joachim99@8
|
51 #ifdef _WIN32
|
joachim99@8
|
52 #include <process.h>
|
joachim99@8
|
53 #include <windows.h>
|
joachim99@8
|
54 #endif
|
joachim99@8
|
55
|
joachim99@8
|
56 static void showHelp()
|
joachim99@8
|
57 {
|
joachim99@8
|
58 #ifdef _WIN32
|
joachim99@8
|
59 char buf[200];
|
joachim99@8
|
60 int r= SearchPathA( 0, ".", 0, sizeof(buf), buf, 0 );
|
joachim99@8
|
61
|
joachim99@8
|
62 QString exePath;
|
joachim99@8
|
63 if (r!=0) { exePath = buf; }
|
joachim99@8
|
64 else { exePath = "."; }
|
joachim99@8
|
65
|
joachim99@34
|
66 QFileInfo helpFile( exePath + "\\doc\\en\\index.html" );
|
joachim99@34
|
67 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\en\\index.html" ); }
|
joachim99@34
|
68 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\doc\\index.html" ); }
|
joachim99@34
|
69 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\index.html" ); }
|
joachim99@8
|
70 if ( ! helpFile.exists() )
|
joachim99@8
|
71 {
|
joachim99@34
|
72 QMessageBox::warning( 0, "KDiff3 documentation not found",
|
joachim99@34
|
73 "Couldn't find the documentation. \n\n"
|
joachim99@34
|
74 "The documentation can also be found at the homepage:\n\n "
|
joachim99@34
|
75 " http://kdiff3.sourceforge.net/");
|
joachim99@34
|
76 return;
|
joachim99@8
|
77 }
|
joachim99@8
|
78
|
joachim99@68
|
79 HINSTANCE hi = FindExecutableA( helpFile.fileName().ascii(), helpFile.dirPath(true).ascii(), buf );
|
joachim99@34
|
80 if ( int(hi)<=32 )
|
joachim99@8
|
81 {
|
joachim99@8
|
82 static QTextBrowser* pBrowser = 0;
|
joachim99@8
|
83 if (pBrowser==0)
|
joachim99@8
|
84 {
|
joachim99@8
|
85 pBrowser = new QTextBrowser( 0 );
|
joachim99@8
|
86 pBrowser->setMinimumSize( 600, 400 );
|
joachim99@8
|
87 }
|
joachim99@8
|
88 pBrowser->setSource(helpFile.filePath());
|
joachim99@8
|
89 pBrowser->show();
|
joachim99@8
|
90 }
|
joachim99@8
|
91 else
|
joachim99@8
|
92 {
|
joachim99@8
|
93 QFileInfo prog( buf );
|
joachim99@68
|
94 _spawnlp( _P_NOWAIT , prog.filePath().ascii(), prog.fileName().ascii(), ("file:///"+helpFile.absFilePath()).ascii(), NULL );
|
joachim99@8
|
95 }
|
joachim99@8
|
96
|
joachim99@8
|
97 #else
|
joachim99@8
|
98 static QTextBrowser* pBrowser = 0;
|
joachim99@8
|
99 if (pBrowser==0)
|
joachim99@8
|
100 {
|
joachim99@8
|
101 pBrowser = new QTextBrowser( 0 );
|
joachim99@8
|
102 pBrowser->setMinimumSize( 600, 400 );
|
joachim99@8
|
103 }
|
joachim99@8
|
104 pBrowser->setSource("/usr/local/share/doc/kdiff3/en/index.html");
|
joachim99@8
|
105 pBrowser->show();
|
joachim99@8
|
106 #endif
|
joachim99@8
|
107 }
|
joachim99@8
|
108
|
joachim99@53
|
109 QString getTranslationDir()
|
joachim99@53
|
110 {
|
joachim99@53
|
111 #ifdef _WIN32
|
joachim99@53
|
112 char buf[200];
|
joachim99@53
|
113 int r= SearchPathA( 0, ".", 0, sizeof(buf), buf, 0 );
|
joachim99@53
|
114
|
joachim99@53
|
115 QString exePath;
|
joachim99@53
|
116 if (r!=0) { exePath = buf; }
|
joachim99@53
|
117 else { exePath = "."; }
|
joachim99@53
|
118 return exePath;
|
joachim99@53
|
119 #else
|
joachim99@53
|
120 return ".";
|
joachim99@53
|
121 #endif
|
joachim99@53
|
122 }
|
joachim99@8
|
123
|
joachim99@8
|
124 // static
|
joachim99@8
|
125 void KMessageBox::error( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
126 {
|
joachim99@8
|
127 QMessageBox::critical( parent, caption, text );
|
joachim99@8
|
128 }
|
joachim99@8
|
129
|
joachim99@8
|
130 int KMessageBox::warningContinueCancel( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
131 const QString& button1 )
|
joachim99@8
|
132 {
|
joachim99@34
|
133 return 0 == QMessageBox::warning( parent, caption, text, button1, "Cancel" ) ? Continue : Cancel;
|
joachim99@8
|
134 }
|
joachim99@8
|
135
|
joachim99@8
|
136 void KMessageBox::sorry( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
137 {
|
joachim99@8
|
138 QMessageBox::information( parent, caption, text );
|
joachim99@8
|
139 }
|
joachim99@8
|
140
|
joachim99@8
|
141 void KMessageBox::information( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
142 {
|
joachim99@8
|
143 QMessageBox::information( parent, caption, text );
|
joachim99@8
|
144 }
|
joachim99@8
|
145
|
joachim99@8
|
146 int KMessageBox::warningYesNo( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
147 const QString& button1, const QString& button2 )
|
joachim99@8
|
148 {
|
joachim99@58
|
149 return 0 == QMessageBox::warning( parent, caption, text, button1, button2, QString::null, 1, 1 ) ? Yes : No;
|
joachim99@8
|
150 }
|
joachim99@8
|
151
|
joachim99@8
|
152 int KMessageBox::warningYesNoCancel( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
153 const QString& button1, const QString& button2 )
|
joachim99@8
|
154 {
|
joachim99@34
|
155 int val = QMessageBox::warning( parent, caption, text,
|
joachim99@53
|
156 button1, button2, i18n("Cancel") );
|
joachim99@8
|
157 if ( val==0 ) return Yes;
|
joachim99@8
|
158 if ( val==1 ) return No;
|
joachim99@8
|
159 else return Cancel;
|
joachim99@8
|
160 }
|
joachim99@8
|
161
|
joachim99@8
|
162
|
joachim99@68
|
163 KDialogBase::KDialogBase( int, const QString& caption, int, int, QWidget* parent, const char* name,
|
joachim99@8
|
164 bool /*modal*/, bool )
|
joachim99@8
|
165 : QTabDialog( parent, name, true /* modal */ )
|
joachim99@8
|
166 {
|
joachim99@8
|
167 setCaption( caption );
|
joachim99@8
|
168 setDefaultButton();
|
joachim99@8
|
169 setHelpButton();
|
joachim99@8
|
170 setCancelButton();
|
joachim99@8
|
171 //setApplyButton();
|
joachim99@8
|
172 setOkButton();
|
joachim99@8
|
173 setDefaultButton();
|
joachim99@8
|
174
|
joachim99@8
|
175 connect( this, SIGNAL( defaultButtonPressed() ), this, SLOT(slotDefault()) );
|
joachim99@8
|
176 connect( this, SIGNAL( helpButtonPressed() ), this, SLOT(slotHelp()));
|
joachim99@8
|
177 connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ));
|
joachim99@8
|
178 }
|
joachim99@8
|
179
|
joachim99@8
|
180 KDialogBase::~KDialogBase()
|
joachim99@8
|
181 {
|
joachim99@8
|
182 }
|
joachim99@8
|
183
|
joachim99@8
|
184 void KDialogBase::incInitialSize ( const QSize& )
|
joachim99@8
|
185 {
|
joachim99@8
|
186 }
|
joachim99@8
|
187
|
joachim99@8
|
188 void KDialogBase::setHelp(const QString&, const QString& )
|
joachim99@8
|
189 {
|
joachim99@8
|
190 }
|
joachim99@8
|
191
|
joachim99@8
|
192
|
joachim99@8
|
193 int KDialogBase::BarIcon(const QString& /*iconName*/, int )
|
joachim99@8
|
194 {
|
joachim99@8
|
195 return 0; // Not used for replacement.
|
joachim99@8
|
196 }
|
joachim99@8
|
197
|
joachim99@8
|
198
|
joachim99@8
|
199 QVBox* KDialogBase::addVBoxPage( const QString& name, const QString& /*info*/, int )
|
joachim99@8
|
200 {
|
joachim99@68
|
201 QVBox* p = new QVBox(this, name.ascii());
|
joachim99@8
|
202 addTab( p, name );
|
joachim99@8
|
203 return p;
|
joachim99@8
|
204 }
|
joachim99@8
|
205
|
joachim99@8
|
206 QFrame* KDialogBase::addPage( const QString& name, const QString& /*info*/, int )
|
joachim99@8
|
207 {
|
joachim99@68
|
208 QFrame* p = new QFrame( this, name.ascii() );
|
joachim99@8
|
209 addTab( p, name );
|
joachim99@8
|
210 return p;
|
joachim99@8
|
211 }
|
joachim99@8
|
212
|
joachim99@8
|
213 int KDialogBase::spacingHint()
|
joachim99@8
|
214 {
|
joachim99@8
|
215 return 5;
|
joachim99@8
|
216 }
|
joachim99@8
|
217
|
joachim99@8
|
218 static bool s_inAccept = false;
|
joachim99@8
|
219 static bool s_bAccepted = false;
|
joachim99@8
|
220 void KDialogBase::accept()
|
joachim99@8
|
221 {
|
joachim99@8
|
222 if( ! s_inAccept )
|
joachim99@8
|
223 {
|
joachim99@8
|
224 s_bAccepted = false;
|
joachim99@8
|
225 s_inAccept = true;
|
joachim99@8
|
226 slotOk();
|
joachim99@8
|
227 s_inAccept = false;
|
joachim99@8
|
228 if ( s_bAccepted )
|
joachim99@8
|
229 QTabDialog::accept();
|
joachim99@8
|
230 }
|
joachim99@8
|
231 else
|
joachim99@8
|
232 {
|
joachim99@8
|
233 s_bAccepted = true;
|
joachim99@8
|
234 }
|
joachim99@8
|
235 }
|
joachim99@8
|
236
|
joachim99@8
|
237 void KDialogBase::slotDefault( )
|
joachim99@8
|
238 {
|
joachim99@8
|
239 }
|
joachim99@8
|
240 void KDialogBase::slotOk()
|
joachim99@8
|
241 {
|
joachim99@8
|
242 }
|
joachim99@8
|
243 void KDialogBase::slotCancel( )
|
joachim99@8
|
244 {
|
joachim99@8
|
245 }
|
joachim99@8
|
246 void KDialogBase::slotApply( )
|
joachim99@8
|
247 {
|
joachim99@8
|
248 emit applyClicked();
|
joachim99@8
|
249 }
|
joachim99@8
|
250 void KDialogBase::slotHelp( )
|
joachim99@8
|
251 {
|
joachim99@8
|
252 showHelp();
|
joachim99@8
|
253 }
|
joachim99@8
|
254
|
joachim99@8
|
255 KURL KFileDialog::getSaveURL( const QString &startDir,
|
joachim99@68
|
256 const QString &filter,
|
joachim99@68
|
257 QWidget *parent, const QString &caption)
|
joachim99@8
|
258 {
|
joachim99@68
|
259 QString s = QFileDialog::getSaveFileName(startDir, filter, parent, 0, caption);
|
joachim99@8
|
260 return KURL(s);
|
joachim99@8
|
261 }
|
joachim99@8
|
262
|
joachim99@8
|
263 KURL KFileDialog::getOpenURL( const QString & startDir,
|
joachim99@8
|
264 const QString & filter,
|
joachim99@8
|
265 QWidget * parent,
|
joachim99@8
|
266 const QString & caption )
|
joachim99@8
|
267 {
|
joachim99@68
|
268 QString s = QFileDialog::getOpenFileName(startDir, filter, parent, 0, caption);
|
joachim99@8
|
269 return KURL(s);
|
joachim99@8
|
270 }
|
joachim99@8
|
271
|
joachim99@8
|
272 KURL KFileDialog::getExistingURL( const QString & startDir,
|
joachim99@8
|
273 QWidget * parent,
|
joachim99@8
|
274 const QString & caption)
|
joachim99@8
|
275 {
|
joachim99@68
|
276 QString s = QFileDialog::getExistingDirectory(startDir, parent, 0, caption);
|
joachim99@8
|
277 return KURL(s);
|
joachim99@8
|
278 }
|
joachim99@8
|
279
|
joachim99@8
|
280
|
joachim99@8
|
281 KToolBar::BarPosition KToolBar::barPos()
|
joachim99@8
|
282 {
|
joachim99@66
|
283 if ( m_pMainWindow->leftDock()->hasDockWindow(this) ) return Left;
|
joachim99@66
|
284 if ( m_pMainWindow->rightDock()->hasDockWindow(this) ) return Right;
|
joachim99@66
|
285 if ( m_pMainWindow->topDock()->hasDockWindow(this) ) return Top;
|
joachim99@66
|
286 if ( m_pMainWindow->bottomDock()->hasDockWindow(this) ) return Bottom;
|
joachim99@8
|
287 return Top;
|
joachim99@8
|
288 }
|
joachim99@8
|
289
|
joachim99@66
|
290 void KToolBar::setBarPos(BarPosition bp)
|
joachim99@8
|
291 {
|
joachim99@66
|
292 if ( bp == Left ) m_pMainWindow->moveDockWindow( this, DockLeft );
|
joachim99@66
|
293 else if ( bp == Right ) m_pMainWindow->moveDockWindow( this, DockRight );
|
joachim99@66
|
294 else if ( bp == Bottom ) m_pMainWindow->moveDockWindow( this, DockBottom );
|
joachim99@66
|
295 else if ( bp == Top ) m_pMainWindow->moveDockWindow( this, DockTop );
|
joachim99@8
|
296 }
|
joachim99@8
|
297
|
joachim99@8
|
298 KToolBar::KToolBar( QMainWindow* parent )
|
joachim99@8
|
299 : QToolBar( parent )
|
joachim99@8
|
300 {
|
joachim99@66
|
301 m_pMainWindow = parent;
|
joachim99@8
|
302 }
|
joachim99@8
|
303
|
joachim99@8
|
304
|
joachim99@68
|
305 KMainWindow::KMainWindow( QWidget* parent, const char* name )
|
joachim99@8
|
306 : QMainWindow( parent, name ), m_actionCollection(this)
|
joachim99@8
|
307 {
|
joachim99@8
|
308 fileMenu = new QPopupMenu();
|
joachim99@53
|
309 menuBar()->insertItem(i18n("&File"), fileMenu);
|
joachim99@8
|
310 editMenu = new QPopupMenu();
|
joachim99@53
|
311 menuBar()->insertItem(i18n("&Edit"), editMenu);
|
joachim99@8
|
312 directoryMenu = new QPopupMenu();
|
joachim99@53
|
313 menuBar()->insertItem(i18n("&Directory"), directoryMenu);
|
joachim99@51
|
314 dirCurrentItemMenu = 0;
|
joachim99@51
|
315 dirCurrentSyncItemMenu = 0;
|
joachim99@8
|
316 movementMenu = new QPopupMenu();
|
joachim99@53
|
317 menuBar()->insertItem(i18n("&Movement"), movementMenu);
|
joachim99@66
|
318 diffMenu = new QPopupMenu();
|
joachim99@66
|
319 menuBar()->insertItem(i18n("D&iffview"), diffMenu);
|
joachim99@8
|
320 mergeMenu = new QPopupMenu();
|
joachim99@53
|
321 menuBar()->insertItem(i18n("&Merge"), mergeMenu);
|
joachim99@8
|
322 windowsMenu = new QPopupMenu();
|
joachim99@53
|
323 menuBar()->insertItem(i18n("&Window"), windowsMenu);
|
joachim99@8
|
324 settingsMenu = new QPopupMenu();
|
joachim99@53
|
325 menuBar()->insertItem(i18n("&Settings"), settingsMenu);
|
joachim99@8
|
326 helpMenu = new QPopupMenu();
|
joachim99@53
|
327 menuBar()->insertItem(i18n("&Help"), helpMenu);
|
joachim99@8
|
328
|
joachim99@8
|
329 m_pToolBar = new KToolBar(this);
|
joachim99@8
|
330
|
joachim99@8
|
331 memberList = new QList<KMainWindow>;
|
joachim99@8
|
332 memberList->append(this);
|
joachim99@8
|
333 connect( qApp, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
|
joachim99@8
|
334 }
|
joachim99@8
|
335
|
joachim99@8
|
336 void KMainWindow::closeEvent(QCloseEvent*e)
|
joachim99@8
|
337 {
|
joachim99@8
|
338 if ( queryClose() )
|
joachim99@8
|
339 {
|
joachim99@8
|
340 e->accept();
|
joachim99@8
|
341 }
|
joachim99@8
|
342 else
|
joachim99@8
|
343 e->ignore();
|
joachim99@8
|
344 }
|
joachim99@8
|
345
|
joachim99@8
|
346 bool KMainWindow::event( QEvent* e )
|
joachim99@8
|
347 {
|
joachim99@8
|
348 return QMainWindow::event(e);
|
joachim99@8
|
349 }
|
joachim99@8
|
350
|
joachim99@8
|
351 KToolBar* KMainWindow::toolBar(const QString&)
|
joachim99@8
|
352 {
|
joachim99@8
|
353 return m_pToolBar;
|
joachim99@8
|
354 }
|
joachim99@8
|
355
|
joachim99@8
|
356 KActionCollection* KMainWindow::actionCollection()
|
joachim99@8
|
357 {
|
joachim99@8
|
358 return &m_actionCollection;
|
joachim99@8
|
359 }
|
joachim99@8
|
360
|
joachim99@8
|
361 void KMainWindow::createGUI()
|
joachim99@8
|
362 {
|
joachim99@8
|
363 KStdAction::help(this, SLOT(slotHelp()), actionCollection());
|
joachim99@8
|
364 KStdAction::about(this, SLOT(slotAbout()), actionCollection());
|
joachim99@8
|
365 }
|
joachim99@8
|
366
|
joachim99@8
|
367 void KMainWindow::quit()
|
joachim99@8
|
368 {
|
joachim99@8
|
369 if ( queryExit() )
|
joachim99@8
|
370 {
|
joachim99@8
|
371 qApp->quit();
|
joachim99@8
|
372 }
|
joachim99@8
|
373 }
|
joachim99@8
|
374
|
joachim99@8
|
375 void KMainWindow::slotAbout()
|
joachim99@8
|
376 {
|
joachim99@66
|
377 QTabDialog d;
|
joachim99@66
|
378 d.setCaption("About " + s_appName);
|
joachim99@66
|
379 QTextBrowser* tb1 = new QTextBrowser(&d);
|
joachim99@66
|
380 tb1->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
381 tb1->setText(
|
joachim99@66
|
382 s_appName + " Version " + s_version +
|
joachim99@66
|
383 "\n\n" + s_description +
|
joachim99@66
|
384 "\n\n" + s_copyright +
|
joachim99@66
|
385 "\n\nHomepage: " + s_homepage +
|
joachim99@66
|
386 "\n\nLicence: GNU GPL Version 2"
|
joachim99@66
|
387 );
|
joachim99@66
|
388 d.addTab(tb1,i18n("&About"));
|
joachim99@66
|
389
|
joachim99@66
|
390 std::list<KAboutData::AboutDataEntry>::iterator i;
|
joachim99@66
|
391
|
joachim99@66
|
392 QString s2;
|
joachim99@66
|
393 for( i=s_pAboutData->m_authorList.begin(); i!=s_pAboutData->m_authorList.end(); ++i )
|
joachim99@66
|
394 {
|
joachim99@66
|
395 if ( !i->m_name.isEmpty() ) s2 += i->m_name + "\n";
|
joachim99@66
|
396 if ( !i->m_task.isEmpty() ) s2 += " " + i->m_task + "\n";
|
joachim99@66
|
397 if ( !i->m_email.isEmpty() ) s2 += " " + i->m_email + "\n";
|
joachim99@66
|
398 if ( !i->m_weblink.isEmpty() ) s2 += " " + i->m_weblink + "\n";
|
joachim99@66
|
399 s2 += "\n";
|
joachim99@66
|
400 }
|
joachim99@66
|
401 QTextBrowser* tb2 = new QTextBrowser(&d);
|
joachim99@66
|
402 tb2->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
403 tb2->setText(s2);
|
joachim99@66
|
404 d.addTab(tb2,i18n("A&uthor"));
|
joachim99@66
|
405
|
joachim99@66
|
406 QString s3;
|
joachim99@66
|
407 for( i=s_pAboutData->m_creditList.begin(); i!=s_pAboutData->m_creditList.end(); ++i )
|
joachim99@66
|
408 {
|
joachim99@66
|
409 if ( !i->m_name.isEmpty() ) s3 += i->m_name + "\n";
|
joachim99@66
|
410 if ( !i->m_task.isEmpty() ) s3 += " " + i->m_task + "\n";
|
joachim99@66
|
411 if ( !i->m_email.isEmpty() ) s3 += " " + i->m_email + "\n";
|
joachim99@66
|
412 if ( !i->m_weblink.isEmpty() ) s3 += " " + i->m_weblink + "\n";
|
joachim99@66
|
413 s3 += "\n";
|
joachim99@66
|
414 }
|
joachim99@66
|
415 QTextBrowser* tb3 = new QTextBrowser(&d);
|
joachim99@66
|
416 tb3->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
417 tb3->setText(s3);
|
joachim99@66
|
418 d.addTab(tb3,i18n("&Thanks To"));
|
joachim99@66
|
419
|
joachim99@66
|
420 d.resize(400,300);
|
joachim99@66
|
421 d.exec();
|
joachim99@66
|
422 /*
|
joachim99@8
|
423 QMessageBox::information(
|
joachim99@8
|
424 this,
|
joachim99@8
|
425 "About " + s_appName,
|
joachim99@8
|
426 s_appName + " Version " + s_version +
|
joachim99@8
|
427 "\n\n" + s_description +
|
joachim99@8
|
428 "\n\n" + s_copyright +
|
joachim99@8
|
429 "\n\nHomepage: " + s_homepage +
|
joachim99@8
|
430 "\n\nLicence: GNU GPL Version 2"
|
joachim99@8
|
431 );
|
joachim99@66
|
432 */
|
joachim99@8
|
433 }
|
joachim99@8
|
434
|
joachim99@8
|
435 void KMainWindow::slotHelp()
|
joachim99@8
|
436 {
|
joachim99@8
|
437 showHelp();
|
joachim99@8
|
438 }
|
joachim99@8
|
439
|
joachim99@8
|
440 KConfig::KConfig()
|
joachim99@8
|
441 {
|
joachim99@8
|
442 QString home = QDir::homeDirPath();
|
joachim99@8
|
443 m_fileName = home + "/.kdiff3rc";
|
joachim99@8
|
444
|
joachim99@8
|
445 QFile f( m_fileName );
|
joachim99@8
|
446 if ( f.open(IO_ReadOnly) )
|
joachim99@8
|
447 { // file opened successfully
|
joachim99@8
|
448 QTextStream t( &f ); // use a text stream
|
joachim99@8
|
449 while ( !t.eof() )
|
joachim99@8
|
450 { // until end of file...
|
joachim99@8
|
451 QString s = t.readLine(); // line of text excluding '\n'
|
joachim99@8
|
452 int pos = s.find('=');
|
joachim99@8
|
453 if( pos > 0 ) // seems not to have a tag
|
joachim99@8
|
454 {
|
joachim99@8
|
455 QString key = s.left(pos);
|
joachim99@8
|
456 QString val = s.mid(pos+1);
|
joachim99@8
|
457 m_map[key] = val;
|
joachim99@8
|
458 }
|
joachim99@8
|
459 }
|
joachim99@8
|
460 f.close();
|
joachim99@8
|
461 }
|
joachim99@8
|
462 }
|
joachim99@8
|
463
|
joachim99@8
|
464 KConfig::~KConfig()
|
joachim99@8
|
465 {
|
joachim99@8
|
466 QFile f(m_fileName);
|
joachim99@8
|
467 if ( f.open( IO_WriteOnly | IO_Translate ) )
|
joachim99@8
|
468 { // file opened successfully
|
joachim99@8
|
469 QTextStream t( &f ); // use a text stream
|
joachim99@8
|
470 std::map<QString,QString>::iterator i;
|
joachim99@8
|
471 for( i=m_map.begin(); i!=m_map.end(); ++i)
|
joachim99@8
|
472 {
|
joachim99@8
|
473 QString key = i->first;
|
joachim99@8
|
474 QString val = i->second;
|
joachim99@8
|
475 t << key << "=" << val << "\n";
|
joachim99@8
|
476 }
|
joachim99@8
|
477 f.close();
|
joachim99@8
|
478 }
|
joachim99@8
|
479 }
|
joachim99@8
|
480
|
joachim99@8
|
481 void KConfig::setGroup(const QString&)
|
joachim99@8
|
482 {
|
joachim99@8
|
483 }
|
joachim99@8
|
484
|
joachim99@58
|
485 // safeStringJoin and safeStringSplit allow to convert a stringlist into a string and back
|
joachim99@58
|
486 // safely, even if the individual strings in the list contain the separator character.
|
joachim99@58
|
487 static QString safeStringJoin(const QStringList& sl, char sepChar=',', char metaChar='\\' )
|
joachim99@58
|
488 {
|
joachim99@58
|
489 // Join the strings in the list, using the separator ','
|
joachim99@58
|
490 // If a string contains the separator character, it will be replaced with "\,".
|
joachim99@58
|
491 // Any occurances of "\" (one backslash) will be replaced with "\\" (2 backslashes)
|
joachim99@58
|
492
|
joachim99@58
|
493 assert(sepChar!=metaChar);
|
joachim99@58
|
494
|
joachim99@58
|
495 QString sep;
|
joachim99@58
|
496 sep += sepChar;
|
joachim99@58
|
497 QString meta;
|
joachim99@58
|
498 meta += metaChar;
|
joachim99@58
|
499
|
joachim99@58
|
500 QString safeString;
|
joachim99@58
|
501
|
joachim99@58
|
502 QStringList::const_iterator i;
|
joachim99@58
|
503 for (i=sl.begin(); i!=sl.end(); ++i)
|
joachim99@58
|
504 {
|
joachim99@58
|
505 QString s = *i;
|
joachim99@58
|
506 s.replace(meta, meta+meta); // "\" -> "\\"
|
joachim99@58
|
507 s.replace(sep, meta+sep); // "," -> "\,"
|
joachim99@58
|
508 if ( i==sl.begin() )
|
joachim99@58
|
509 safeString = s;
|
joachim99@58
|
510 else
|
joachim99@58
|
511 safeString += sep + s;
|
joachim99@58
|
512 }
|
joachim99@58
|
513 return safeString;
|
joachim99@58
|
514 }
|
joachim99@58
|
515
|
joachim99@58
|
516 // Split a string that was joined with safeStringJoin
|
joachim99@58
|
517 static QStringList safeStringSplit(const QString& s, char sepChar=',', char metaChar='\\' )
|
joachim99@58
|
518 {
|
joachim99@58
|
519 assert(sepChar!=metaChar);
|
joachim99@58
|
520 QStringList sl;
|
joachim99@58
|
521 // Miniparser
|
joachim99@58
|
522 int i=0;
|
joachim99@58
|
523 int len=s.length();
|
joachim99@58
|
524 QString b;
|
joachim99@58
|
525 for(i=0;i<len;++i)
|
joachim99@58
|
526 {
|
joachim99@58
|
527 if ( i+1<len && s[i]==metaChar && s[i+1]==metaChar ){ b+=metaChar; ++i; }
|
joachim99@58
|
528 else if ( i+1<len && s[i]==metaChar && s[i+1]==sepChar ){ b+=sepChar; ++i; }
|
joachim99@58
|
529 else if ( s[i]==sepChar ) // real separator
|
joachim99@58
|
530 {
|
joachim99@58
|
531 sl.push_back(b);
|
joachim99@58
|
532 b="";
|
joachim99@58
|
533 }
|
joachim99@58
|
534 else { b+=s[i]; }
|
joachim99@58
|
535 }
|
joachim99@58
|
536 if ( !b.isEmpty() )
|
joachim99@58
|
537 sl.push_back(b);
|
joachim99@58
|
538
|
joachim99@58
|
539 return sl;
|
joachim99@58
|
540 }
|
joachim99@58
|
541
|
joachim99@58
|
542
|
joachim99@58
|
543
|
joachim99@8
|
544 static QString numStr(int n)
|
joachim99@8
|
545 {
|
joachim99@8
|
546 QString s;
|
joachim99@8
|
547 s.setNum( n );
|
joachim99@8
|
548 return s;
|
joachim99@8
|
549 }
|
joachim99@8
|
550
|
joachim99@8
|
551 static QString subSection( const QString& s, int idx, char sep )
|
joachim99@8
|
552 {
|
joachim99@8
|
553 int pos=0;
|
joachim99@8
|
554 while( idx>0 )
|
joachim99@8
|
555 {
|
joachim99@8
|
556 pos = s.find( sep, pos );
|
joachim99@8
|
557 --idx;
|
joachim99@8
|
558 if (pos<0) break;
|
joachim99@8
|
559 ++pos;
|
joachim99@8
|
560 }
|
joachim99@8
|
561 if ( pos>=0 )
|
joachim99@8
|
562 {
|
joachim99@8
|
563 int pos2 = s.find( sep, pos );
|
joachim99@8
|
564 if ( pos2>0 )
|
joachim99@8
|
565 return s.mid(pos, pos2-pos);
|
joachim99@8
|
566 else
|
joachim99@8
|
567 return s.mid(pos);
|
joachim99@8
|
568 }
|
joachim99@8
|
569
|
joachim99@8
|
570 return "";
|
joachim99@8
|
571 }
|
joachim99@8
|
572
|
joachim99@8
|
573 static int num( QString& s, int idx )
|
joachim99@8
|
574 {
|
joachim99@8
|
575 return subSection( s, idx, ',').toInt();
|
joachim99@8
|
576
|
joachim99@8
|
577 //return s.section(',', idx, idx).toInt();
|
joachim99@8
|
578 }
|
joachim99@8
|
579
|
joachim99@8
|
580 void KConfig::writeEntry(const QString& k, const QFont& v )
|
joachim99@8
|
581 {
|
joachim99@66
|
582 m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
|
joachim99@8
|
583 }
|
joachim99@8
|
584
|
joachim99@8
|
585 void KConfig::writeEntry(const QString& k, const QColor& v )
|
joachim99@8
|
586 {
|
joachim99@8
|
587 m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
|
joachim99@8
|
588 }
|
joachim99@8
|
589
|
joachim99@8
|
590 void KConfig::writeEntry(const QString& k, const QSize& v )
|
joachim99@8
|
591 {
|
joachim99@8
|
592 m_map[k] = numStr(v.width()) + "," + numStr(v.height());
|
joachim99@8
|
593 }
|
joachim99@8
|
594
|
joachim99@8
|
595 void KConfig::writeEntry(const QString& k, const QPoint& v )
|
joachim99@8
|
596 {
|
joachim99@8
|
597 m_map[k] = numStr(v.x()) + "," + numStr(v.y());
|
joachim99@8
|
598 }
|
joachim99@8
|
599
|
joachim99@8
|
600 void KConfig::writeEntry(const QString& k, int v )
|
joachim99@8
|
601 {
|
joachim99@8
|
602 m_map[k] = numStr(v);
|
joachim99@8
|
603 }
|
joachim99@8
|
604
|
joachim99@8
|
605 void KConfig::writeEntry(const QString& k, bool v )
|
joachim99@8
|
606 {
|
joachim99@8
|
607 m_map[k] = numStr(v);
|
joachim99@8
|
608 }
|
joachim99@8
|
609
|
joachim99@8
|
610 void KConfig::writeEntry(const QString& k, const QString& v )
|
joachim99@8
|
611 {
|
joachim99@8
|
612 m_map[k] = v;
|
joachim99@8
|
613 }
|
joachim99@8
|
614
|
joachim99@8
|
615 void KConfig::writeEntry(const QString& k, const QStringList& v, char separator )
|
joachim99@8
|
616 {
|
joachim99@58
|
617 m_map[k] = safeStringJoin(v, separator);
|
joachim99@8
|
618 }
|
joachim99@8
|
619
|
joachim99@8
|
620
|
joachim99@8
|
621 QFont KConfig::readFontEntry(const QString& k, QFont* defaultVal )
|
joachim99@8
|
622 {
|
joachim99@8
|
623 QFont f = *defaultVal;
|
joachim99@8
|
624 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
625 if ( i!=m_map.end() )
|
joachim99@8
|
626 {
|
joachim99@8
|
627 f.setFamily( subSection( i->second, 0, ',' ) );
|
joachim99@8
|
628 f.setPointSize( subSection( i->second, 1, ',' ).toInt() );
|
joachim99@66
|
629 f.setBold( subSection( i->second, 2, ',' )=="bold" );
|
joachim99@8
|
630 //f.fromString(i->second);
|
joachim99@8
|
631 }
|
joachim99@8
|
632
|
joachim99@8
|
633 return f;
|
joachim99@8
|
634 }
|
joachim99@8
|
635
|
joachim99@8
|
636 QColor KConfig::readColorEntry(const QString& k, QColor* defaultVal )
|
joachim99@8
|
637 {
|
joachim99@8
|
638 QColor c= *defaultVal;
|
joachim99@8
|
639 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
640 if ( i!=m_map.end() )
|
joachim99@8
|
641 {
|
joachim99@8
|
642 QString s = i->second;
|
joachim99@8
|
643 c = QColor( num(s,0),num(s,1),num(s,2) );
|
joachim99@8
|
644 }
|
joachim99@8
|
645
|
joachim99@8
|
646 return c;
|
joachim99@8
|
647 }
|
joachim99@8
|
648
|
joachim99@8
|
649 QSize KConfig::readSizeEntry(const QString& k)
|
joachim99@8
|
650 {
|
joachim99@8
|
651 QSize size(640,400);
|
joachim99@8
|
652 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
653 if ( i!=m_map.end() )
|
joachim99@8
|
654 {
|
joachim99@8
|
655
|
joachim99@8
|
656 QString s = i->second;
|
joachim99@8
|
657 size = QSize( num(s,0),num(s,1) );
|
joachim99@8
|
658 }
|
joachim99@8
|
659
|
joachim99@8
|
660 return size;
|
joachim99@8
|
661 }
|
joachim99@8
|
662
|
joachim99@8
|
663 QPoint KConfig::readPointEntry(const QString& k)
|
joachim99@8
|
664 {
|
joachim99@8
|
665 QPoint point(0,0);
|
joachim99@8
|
666 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
667 if ( i!=m_map.end() )
|
joachim99@8
|
668 {
|
joachim99@8
|
669 QString s = i->second;
|
joachim99@8
|
670 point = QPoint( num(s,0),num(s,1) );
|
joachim99@8
|
671 }
|
joachim99@8
|
672
|
joachim99@8
|
673 return point;
|
joachim99@8
|
674 }
|
joachim99@8
|
675
|
joachim99@8
|
676 bool KConfig::readBoolEntry(const QString& k, bool bDefault )
|
joachim99@8
|
677 {
|
joachim99@8
|
678 bool b = bDefault;
|
joachim99@8
|
679 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
680 if ( i!=m_map.end() )
|
joachim99@8
|
681 {
|
joachim99@8
|
682 QString s = i->second;
|
joachim99@8
|
683 b = (bool)num(s,0);
|
joachim99@8
|
684 }
|
joachim99@8
|
685
|
joachim99@8
|
686 return b;
|
joachim99@8
|
687 }
|
joachim99@8
|
688
|
joachim99@8
|
689 int KConfig::readNumEntry(const QString& k, int iDefault )
|
joachim99@8
|
690 {
|
joachim99@8
|
691 int ival = iDefault;
|
joachim99@8
|
692 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
693 if ( i!=m_map.end() )
|
joachim99@8
|
694 {
|
joachim99@8
|
695 QString s = i->second;
|
joachim99@8
|
696 ival = num(s,0);
|
joachim99@8
|
697 }
|
joachim99@8
|
698
|
joachim99@8
|
699 return ival;
|
joachim99@8
|
700 }
|
joachim99@8
|
701
|
joachim99@8
|
702 QString KConfig::readEntry(const QString& k, const QString& sDefault )
|
joachim99@8
|
703 {
|
joachim99@8
|
704 QString sval = sDefault;
|
joachim99@8
|
705 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
706 if ( i!=m_map.end() )
|
joachim99@8
|
707 {
|
joachim99@8
|
708 sval = i->second;
|
joachim99@8
|
709 }
|
joachim99@8
|
710
|
joachim99@8
|
711 return sval;
|
joachim99@8
|
712 }
|
joachim99@8
|
713
|
joachim99@58
|
714 QStringList KConfig::readListEntry(const QString& k, char separator )
|
joachim99@8
|
715 {
|
joachim99@8
|
716 QStringList strList;
|
joachim99@8
|
717
|
joachim99@8
|
718 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
719 if ( i!=m_map.end() )
|
joachim99@8
|
720 {
|
joachim99@58
|
721 strList = safeStringSplit( i->second, separator );
|
joachim99@8
|
722 }
|
joachim99@8
|
723 return strList;
|
joachim99@8
|
724 }
|
joachim99@8
|
725
|
joachim99@68
|
726 void KAction::init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
727 const char* name, bool bToggle, bool bMenu)
|
joachim99@8
|
728 {
|
joachim99@68
|
729 QString n(name);
|
joachim99@8
|
730 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
731 if( slot!=0 )
|
joachim99@8
|
732 {
|
joachim99@8
|
733 if (!bToggle)
|
joachim99@8
|
734 connect(this, SIGNAL(activated()), receiver, slot);
|
joachim99@8
|
735 else
|
joachim99@8
|
736 {
|
joachim99@8
|
737 connect(this, SIGNAL(toggled(bool)), receiver, slot);
|
joachim99@8
|
738 }
|
joachim99@8
|
739 }
|
joachim99@8
|
740
|
joachim99@8
|
741 if (bMenu)
|
joachim99@8
|
742 {
|
joachim99@68
|
743 if( n[0]=='g') addTo( p->movementMenu );
|
joachim99@68
|
744 else if( n.left(16)=="dir_current_sync")
|
joachim99@53
|
745 {
|
joachim99@53
|
746 if ( p->dirCurrentItemMenu==0 )
|
joachim99@53
|
747 {
|
joachim99@53
|
748 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@53
|
749 p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
750 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@53
|
751 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@53
|
752 }
|
joachim99@53
|
753 addTo( p->dirCurrentItemMenu );
|
joachim99@53
|
754 }
|
joachim99@68
|
755 else if( n.left(11)=="dir_current")
|
joachim99@53
|
756 {
|
joachim99@53
|
757 if ( p->dirCurrentItemMenu==0 )
|
joachim99@53
|
758 {
|
joachim99@53
|
759 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@53
|
760 p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
761 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@53
|
762 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@53
|
763 }
|
joachim99@53
|
764 addTo( p->dirCurrentSyncItemMenu );
|
joachim99@53
|
765 }
|
joachim99@68
|
766 else if( n.left(4)=="diff") addTo( p->diffMenu );
|
joachim99@8
|
767 else if( name[0]=='d') addTo( p->directoryMenu );
|
joachim99@8
|
768 else if( name[0]=='f') addTo( p->fileMenu );
|
joachim99@8
|
769 else if( name[0]=='w') addTo( p->windowsMenu );
|
joachim99@8
|
770 else addTo( p->mergeMenu );
|
joachim99@8
|
771 }
|
joachim99@8
|
772 }
|
joachim99@8
|
773
|
joachim99@68
|
774
|
joachim99@68
|
775 KAction::KAction(const QString& text, const QIconSet& icon, int accel,
|
joachim99@68
|
776 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
777 const char* name, bool bToggle, bool bMenu
|
joachim99@68
|
778 )
|
joachim99@68
|
779 : QAction ( text, icon, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@68
|
780 {
|
joachim99@68
|
781 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@68
|
782 if ( !icon.isNull() && p ) this->addTo( p->m_pToolBar );
|
joachim99@68
|
783
|
joachim99@68
|
784 init(receiver,slot,actionCollection,name,bToggle,bMenu);
|
joachim99@68
|
785 }
|
joachim99@68
|
786
|
joachim99@8
|
787 KAction::KAction(const QString& text, int accel,
|
joachim99@51
|
788 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
789 const char* name, bool bToggle, bool bMenu
|
joachim99@8
|
790 )
|
joachim99@8
|
791 : QAction ( text, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@8
|
792 {
|
joachim99@68
|
793 init(receiver,slot,actionCollection,name,bToggle,bMenu);
|
joachim99@8
|
794 }
|
joachim99@8
|
795
|
joachim99@8
|
796 void KAction::setStatusText(const QString&)
|
joachim99@8
|
797 {
|
joachim99@8
|
798 }
|
joachim99@8
|
799
|
joachim99@8
|
800 void KAction::plug(QPopupMenu* menu)
|
joachim99@8
|
801 {
|
joachim99@8
|
802 addTo(menu);
|
joachim99@8
|
803 }
|
joachim99@8
|
804
|
joachim99@8
|
805
|
joachim99@68
|
806 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@51
|
807 : KAction( text, icon, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
808 {
|
joachim99@8
|
809 }
|
joachim99@8
|
810
|
joachim99@68
|
811 KToggleAction::KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@51
|
812 : KAction( text, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
813 {
|
joachim99@8
|
814 }
|
joachim99@8
|
815
|
joachim99@68
|
816 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@8
|
817 : KAction( text, icon, accel, 0, 0, actionCollection, name, true, bMenu)
|
joachim99@8
|
818 {
|
joachim99@8
|
819 }
|
joachim99@8
|
820
|
joachim99@8
|
821 void KToggleAction::setChecked(bool bChecked)
|
joachim99@8
|
822 {
|
joachim99@8
|
823 blockSignals( true );
|
joachim99@8
|
824 setOn( bChecked );
|
joachim99@8
|
825 blockSignals( false );
|
joachim99@8
|
826 }
|
joachim99@8
|
827
|
joachim99@8
|
828 bool KToggleAction::isChecked()
|
joachim99@8
|
829 {
|
joachim99@8
|
830 return isOn();
|
joachim99@8
|
831 }
|
joachim99@8
|
832
|
joachim99@8
|
833
|
joachim99@8
|
834
|
joachim99@8
|
835 //static
|
joachim99@8
|
836 KAction* KStdAction::open( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
837 {
|
joachim99@8
|
838 #include "../xpm/fileopen.xpm"
|
joachim99@8
|
839 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
840 KAction* a = new KAction( i18n("Open"), QIconSet(QPixmap(fileopen)), Qt::CTRL+Qt::Key_O, parent, slot, actionCollection, "open", false, false);
|
joachim99@8
|
841 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
842 return a;
|
joachim99@8
|
843 }
|
joachim99@8
|
844
|
joachim99@8
|
845 KAction* KStdAction::save( QWidget* parent, const char* slot, KActionCollection* actionCollection )
|
joachim99@8
|
846 {
|
joachim99@8
|
847 #include "../xpm/filesave.xpm"
|
joachim99@8
|
848 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
849 KAction* a = new KAction( i18n("Save"), QIconSet(QPixmap(filesave)), Qt::CTRL+Qt::Key_S, parent, slot, actionCollection, "save", false, false);
|
joachim99@8
|
850 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
851 return a;
|
joachim99@8
|
852 }
|
joachim99@8
|
853
|
joachim99@8
|
854 KAction* KStdAction::saveAs( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
855 {
|
joachim99@8
|
856 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
857 KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false);
|
joachim99@8
|
858 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
859 return a;
|
joachim99@8
|
860 }
|
joachim99@8
|
861
|
joachim99@8
|
862 KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
863 {
|
joachim99@8
|
864 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
865 KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false);
|
joachim99@8
|
866 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
867 return a;
|
joachim99@8
|
868 }
|
joachim99@8
|
869
|
joachim99@8
|
870 KAction* KStdAction::cut( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
871 {
|
joachim99@8
|
872 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
873 KAction* a = new KAction( i18n("Cut"), Qt::CTRL+Qt::Key_X, parent, slot, actionCollection, "cut", false, false );
|
joachim99@8
|
874 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
875 return a;
|
joachim99@8
|
876 }
|
joachim99@8
|
877
|
joachim99@8
|
878 KAction* KStdAction::copy( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
879 {
|
joachim99@8
|
880 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
881 KAction* a = new KAction( i18n("Copy"), Qt::CTRL+Qt::Key_C, parent, slot, actionCollection, "copy", false, false );
|
joachim99@8
|
882 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
883 return a;
|
joachim99@8
|
884 }
|
joachim99@8
|
885
|
joachim99@8
|
886 KAction* KStdAction::paste( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
887 {
|
joachim99@8
|
888 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
889 KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false );
|
joachim99@8
|
890 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
891 return a;
|
joachim99@8
|
892 }
|
joachim99@8
|
893
|
joachim99@8
|
894 KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
895 {
|
joachim99@8
|
896 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
897 KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false );
|
joachim99@8
|
898 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
899 return a;
|
joachim99@8
|
900 }
|
joachim99@8
|
901
|
joachim99@8
|
902 KToggleAction* KStdAction::showStatusbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
903 {
|
joachim99@8
|
904 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
905 KToggleAction* a = new KToggleAction( i18n("Show &Statusbar"), 0, parent, slot, actionCollection, "showstatusbar", false );
|
joachim99@8
|
906 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
907 return a;
|
joachim99@8
|
908 }
|
joachim99@8
|
909
|
joachim99@8
|
910 KAction* KStdAction::preferences( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
911 {
|
joachim99@8
|
912 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
913 KAction* a = new KAction( i18n("&Configure %1...").arg("KDiff3"), 0, parent, slot, actionCollection, "settings", false, false );
|
joachim99@8
|
914 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
915 return a;
|
joachim99@8
|
916 }
|
joachim99@8
|
917 KAction* KStdAction::keyBindings( QWidget*, const char*, KActionCollection*)
|
joachim99@8
|
918 {
|
joachim99@8
|
919 return 0;
|
joachim99@8
|
920 }
|
joachim99@8
|
921
|
joachim99@8
|
922 KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
923 {
|
joachim99@8
|
924 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
925 KAction* a = new KAction( i18n("About"), 0, parent, slot, actionCollection, "about", false, false );
|
joachim99@8
|
926 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
927 return a;
|
joachim99@8
|
928 }
|
joachim99@8
|
929
|
joachim99@8
|
930 KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
931 {
|
joachim99@8
|
932 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
933 KAction* a = new KAction( i18n("Help"), Qt::Key_F1, parent, slot, actionCollection, "help", false, false );
|
joachim99@8
|
934 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
935 return a;
|
joachim99@8
|
936 }
|
joachim99@8
|
937 KAction* KStdAction::find( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
938 {
|
joachim99@8
|
939 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
940 KAction* a = new KAction( i18n("Find"), Qt::CTRL+Qt::Key_F, parent, slot, actionCollection, "find", false, false );
|
joachim99@8
|
941 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
942 return a;
|
joachim99@8
|
943 }
|
joachim99@8
|
944
|
joachim99@8
|
945 KAction* KStdAction::findNext( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
946 {
|
joachim99@8
|
947 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
948 KAction* a = new KAction( i18n("Find Next"), Qt::Key_F3, parent, slot, actionCollection, "findNext", false, false );
|
joachim99@8
|
949 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
950 return a;
|
joachim99@8
|
951 }
|
joachim99@8
|
952
|
joachim99@8
|
953
|
joachim99@8
|
954
|
joachim99@8
|
955
|
joachim99@8
|
956 KFontChooser::KFontChooser( QWidget* pParent, const QString& /*name*/, bool, const QStringList&, bool, int )
|
joachim99@8
|
957 : QWidget(pParent)
|
joachim99@8
|
958 {
|
joachim99@8
|
959 m_pParent = pParent;
|
joachim99@8
|
960 QVBoxLayout* pLayout = new QVBoxLayout( this );
|
joachim99@53
|
961 m_pSelectFont = new QPushButton(i18n("Select Font"), this );
|
joachim99@8
|
962 connect(m_pSelectFont, SIGNAL(clicked()), this, SLOT(slotSelectFont()));
|
joachim99@8
|
963 pLayout->addWidget(m_pSelectFont);
|
joachim99@8
|
964
|
joachim99@8
|
965 m_pLabel = new QLabel( "", this );
|
joachim99@8
|
966 m_pLabel->setFont( m_font );
|
joachim99@8
|
967 m_pLabel->setMinimumWidth(200);
|
joachim99@8
|
968 m_pLabel->setText( "The quick brown fox jumps over the river\n"
|
joachim99@8
|
969 "but the little red hen escapes with a shiver.\n"
|
joachim99@8
|
970 ":-)");
|
joachim99@8
|
971 pLayout->addWidget(m_pLabel);
|
joachim99@8
|
972 }
|
joachim99@8
|
973
|
joachim99@8
|
974 QFont KFontChooser::font()
|
joachim99@8
|
975 {
|
joachim99@8
|
976 return m_font;//QFont("courier",10);
|
joachim99@8
|
977 }
|
joachim99@8
|
978
|
joachim99@8
|
979 void KFontChooser::setFont( const QFont& font, bool )
|
joachim99@8
|
980 {
|
joachim99@8
|
981 m_font = font;
|
joachim99@8
|
982 m_pLabel->setFont( m_font );
|
joachim99@8
|
983 //update();
|
joachim99@8
|
984 }
|
joachim99@8
|
985
|
joachim99@8
|
986 void KFontChooser::slotSelectFont()
|
joachim99@8
|
987 {
|
joachim99@8
|
988 for(;;)
|
joachim99@8
|
989 {
|
joachim99@8
|
990 bool bOk;
|
joachim99@8
|
991 m_font = QFontDialog::getFont(&bOk, m_font );
|
joachim99@8
|
992 m_pLabel->setFont( m_font );
|
joachim99@8
|
993 QFontMetrics fm(m_font);
|
joachim99@8
|
994
|
joachim99@8
|
995 // Variable width font.
|
joachim99@8
|
996 if ( fm.width('W')!=fm.width('i') )
|
joachim99@8
|
997 {
|
joachim99@8
|
998 int result = KMessageBox::warningYesNo(m_pParent, i18n(
|
joachim99@8
|
999 "You selected a variable width font.\n\n"
|
joachim99@8
|
1000 "Because this program doesn't handle variable width fonts\n"
|
joachim99@8
|
1001 "correctly, you might experience problems while editing.\n\n"
|
joachim99@8
|
1002 "Do you want to continue or do you want to select another font."),
|
joachim99@8
|
1003 i18n("Incompatible font."),
|
joachim99@8
|
1004 i18n("Continue at my own risk"), i18n("Select another font"));
|
joachim99@8
|
1005 if (result==KMessageBox::Yes)
|
joachim99@8
|
1006 return;
|
joachim99@8
|
1007 }
|
joachim99@8
|
1008 else
|
joachim99@8
|
1009 return;
|
joachim99@8
|
1010 }
|
joachim99@8
|
1011 }
|
joachim99@8
|
1012
|
joachim99@8
|
1013
|
joachim99@8
|
1014 KColorButton::KColorButton(QWidget* parent)
|
joachim99@8
|
1015 : QPushButton(parent)
|
joachim99@8
|
1016 {
|
joachim99@8
|
1017 connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()));
|
joachim99@8
|
1018 }
|
joachim99@8
|
1019
|
joachim99@8
|
1020 QColor KColorButton::color()
|
joachim99@8
|
1021 {
|
joachim99@8
|
1022 return m_color;
|
joachim99@8
|
1023 }
|
joachim99@8
|
1024
|
joachim99@8
|
1025 void KColorButton::setColor( const QColor& color )
|
joachim99@8
|
1026 {
|
joachim99@8
|
1027 m_color = color;
|
joachim99@8
|
1028 update();
|
joachim99@8
|
1029 }
|
joachim99@8
|
1030
|
joachim99@8
|
1031 void KColorButton::paintEvent( QPaintEvent* e )
|
joachim99@8
|
1032 {
|
joachim99@8
|
1033 QPushButton::paintEvent(e);
|
joachim99@8
|
1034 QPainter p(this);
|
joachim99@8
|
1035
|
joachim99@8
|
1036 int w = width();
|
joachim99@8
|
1037 int h = height();
|
joachim99@8
|
1038 p.fillRect( 10, 5, w-20, h-10, m_color );
|
joachim99@8
|
1039 p.drawRect( 10, 5, w-20, h-10 );
|
joachim99@8
|
1040 }
|
joachim99@8
|
1041
|
joachim99@8
|
1042 void KColorButton::slotClicked()
|
joachim99@8
|
1043 {
|
joachim99@8
|
1044 // Under Windows ChooseColor() should be used. (Nicer if few colors exist.)
|
joachim99@8
|
1045 QColor c = QColorDialog::getColor ( m_color, this );
|
joachim99@8
|
1046 if ( c.isValid() ) m_color = c;
|
joachim99@8
|
1047 update();
|
joachim99@8
|
1048 }
|
joachim99@8
|
1049
|
joachim99@8
|
1050 QPixmap KIconLoader::loadIcon( const QString&, int )
|
joachim99@8
|
1051 {
|
joachim99@8
|
1052 return QPixmap();
|
joachim99@8
|
1053 }
|
joachim99@8
|
1054
|
joachim99@8
|
1055 KAboutData::KAboutData( const QString& /*name*/, const QString& appName, const QString& version,
|
joachim99@8
|
1056 const QString& description, int,
|
joachim99@8
|
1057 const QString& copyright, int, const QString& homepage, const QString& email)
|
joachim99@8
|
1058 {
|
joachim99@8
|
1059 s_copyright = copyright;
|
joachim99@8
|
1060 s_email = email;
|
joachim99@8
|
1061 s_appName = appName;
|
joachim99@8
|
1062 s_description = description;
|
joachim99@8
|
1063 s_version = version;
|
joachim99@8
|
1064 s_homepage = homepage;
|
joachim99@8
|
1065 }
|
joachim99@8
|
1066
|
joachim99@51
|
1067 KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ )
|
joachim99@8
|
1068 {
|
joachim99@8
|
1069 }
|
joachim99@8
|
1070
|
joachim99@66
|
1071 void KAboutData::addAuthor(const char* name, const char* task, const char* email, const char* weblink)
|
joachim99@8
|
1072 {
|
joachim99@66
|
1073 m_authorList.push_back( AboutDataEntry( name, task, email, weblink) );
|
joachim99@66
|
1074 }
|
joachim99@66
|
1075
|
joachim99@66
|
1076 void KAboutData::addCredit(const char* name, const char* task, const char* email, const char* weblink)
|
joachim99@66
|
1077 {
|
joachim99@66
|
1078 m_creditList.push_back( AboutDataEntry( name, task, email, weblink) );
|
joachim99@8
|
1079 }
|
joachim99@8
|
1080
|
joachim99@8
|
1081 /* Option structure: e.g.:
|
joachim99@8
|
1082 { "m", 0, 0 },
|
joachim99@8
|
1083 { "merge", I18N_NOOP("Automatically merge the input."), 0 },
|
joachim99@8
|
1084 { "o", 0, 0 },
|
joachim99@8
|
1085 { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 },
|
joachim99@8
|
1086 { "+[File1]", I18N_NOOP("file1 to open (base)"), 0 },
|
joachim99@8
|
1087 { "+[File2]", I18N_NOOP("file2 to open"), 0 },
|
joachim99@8
|
1088 { "+[File3]", I18N_NOOP("file3 to open"), 0 },
|
joachim99@8
|
1089 */
|
joachim99@8
|
1090 ////////////////
|
joachim99@8
|
1091 static KCmdLineArgs s_cmdLineArgs;
|
joachim99@8
|
1092 static int s_argc;
|
joachim99@8
|
1093 static char** s_argv;
|
joachim99@8
|
1094 static KCmdLineOptions* s_pOptions;
|
joachim99@8
|
1095
|
joachim99@8
|
1096 static std::vector<QCStringList> s_vOption;
|
joachim99@8
|
1097 static std::vector<const char*> s_vArg;
|
joachim99@8
|
1098
|
joachim99@8
|
1099 KCmdLineArgs* KCmdLineArgs::parsedArgs() // static
|
joachim99@8
|
1100 {
|
joachim99@51
|
1101 return &s_cmdLineArgs;
|
joachim99@8
|
1102 }
|
joachim99@8
|
1103
|
joachim99@66
|
1104 void KCmdLineArgs::init( int argc, char**argv, KAboutData* pAboutData ) // static
|
joachim99@8
|
1105 {
|
joachim99@8
|
1106 s_argc = argc;
|
joachim99@8
|
1107 s_argv = argv;
|
joachim99@66
|
1108 s_pAboutData = pAboutData;
|
joachim99@8
|
1109 }
|
joachim99@8
|
1110
|
joachim99@8
|
1111 void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static
|
joachim99@8
|
1112 {
|
joachim99@8
|
1113 s_pOptions = options;
|
joachim99@8
|
1114 }
|
joachim99@8
|
1115
|
joachim99@8
|
1116 int KCmdLineArgs::count()
|
joachim99@8
|
1117 {
|
joachim99@8
|
1118 return s_vArg.size();
|
joachim99@8
|
1119 }
|
joachim99@8
|
1120
|
joachim99@8
|
1121 QString KCmdLineArgs::arg(int idx)
|
joachim99@8
|
1122 {
|
joachim99@58
|
1123 return QString::fromLocal8Bit( s_vArg[idx] );
|
joachim99@8
|
1124 }
|
joachim99@8
|
1125
|
joachim99@8
|
1126 void KCmdLineArgs::clear()
|
joachim99@8
|
1127 {
|
joachim99@8
|
1128 }
|
joachim99@8
|
1129
|
joachim99@8
|
1130 QString KCmdLineArgs::getOption( const QString& s )
|
joachim99@8
|
1131 {
|
joachim99@8
|
1132 // Find the option
|
joachim99@8
|
1133 int j=0;
|
joachim99@8
|
1134 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1135 {
|
joachim99@8
|
1136 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1137 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1138 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1139
|
joachim99@8
|
1140 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
1141 {
|
joachim99@8
|
1142 return s_vOption[j].isEmpty() ? QString() : s_vOption[j].last();
|
joachim99@8
|
1143 }
|
joachim99@8
|
1144 }
|
joachim99@8
|
1145 assert(false);
|
joachim99@8
|
1146 return QString();
|
joachim99@8
|
1147 }
|
joachim99@8
|
1148
|
joachim99@8
|
1149 QCStringList KCmdLineArgs::getOptionList( const QString& s )
|
joachim99@8
|
1150 {
|
joachim99@8
|
1151 // Find the option
|
joachim99@8
|
1152 int j=0;
|
joachim99@8
|
1153 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1154 {
|
joachim99@8
|
1155 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1156 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1157 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1158
|
joachim99@8
|
1159 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
1160 {
|
joachim99@8
|
1161 return s_vOption[j];
|
joachim99@8
|
1162 }
|
joachim99@8
|
1163 }
|
joachim99@8
|
1164
|
joachim99@8
|
1165 assert(false);
|
joachim99@8
|
1166 return QCStringList();
|
joachim99@8
|
1167 }
|
joachim99@8
|
1168
|
joachim99@8
|
1169 bool KCmdLineArgs::isSet(const QString& s)
|
joachim99@8
|
1170 {
|
joachim99@8
|
1171 // Find the option
|
joachim99@8
|
1172 int j=0;
|
joachim99@8
|
1173 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1174 {
|
joachim99@8
|
1175 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1176 if( s == QString( optName ) )
|
joachim99@8
|
1177 {
|
joachim99@8
|
1178 return ! s_vOption[j].isEmpty();
|
joachim99@8
|
1179 }
|
joachim99@8
|
1180 }
|
joachim99@8
|
1181 assert(false);
|
joachim99@8
|
1182 return false;
|
joachim99@8
|
1183 }
|
joachim99@8
|
1184
|
joachim99@8
|
1185 ///////////////////
|
joachim99@8
|
1186 KApplication* kapp;
|
joachim99@8
|
1187
|
joachim99@8
|
1188 KApplication::KApplication()
|
joachim99@8
|
1189 : QApplication( s_argc,s_argv )
|
joachim99@8
|
1190 {
|
joachim99@8
|
1191 kapp = this;
|
joachim99@8
|
1192
|
joachim99@8
|
1193 int nofOptions=0;
|
joachim99@8
|
1194 int nofArgs=0;
|
joachim99@8
|
1195 int i=0;
|
joachim99@8
|
1196 while( s_pOptions[i].shortName != 0 )
|
joachim99@8
|
1197 {
|
joachim99@8
|
1198 if ( s_pOptions[i].shortName[0]=='[' )
|
joachim99@8
|
1199 nofArgs++;
|
joachim99@8
|
1200 else
|
joachim99@8
|
1201 nofOptions++;
|
joachim99@8
|
1202
|
joachim99@8
|
1203 ++i;
|
joachim99@8
|
1204 }
|
joachim99@8
|
1205
|
joachim99@8
|
1206 s_vOption.resize(nofOptions);
|
joachim99@8
|
1207
|
joachim99@8
|
1208 for( i=1; i<s_argc; ++i )
|
joachim99@8
|
1209 {
|
joachim99@8
|
1210 if ( s_argv[i][0]=='-' ) // An option
|
joachim99@8
|
1211 {
|
joachim99@8
|
1212 // Find the option
|
joachim99@8
|
1213 int j=0;
|
joachim99@8
|
1214 for( j=0; j<nofOptions; ++j )
|
joachim99@8
|
1215 {
|
joachim99@8
|
1216 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1217 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1218 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1219
|
joachim99@8
|
1220 if( len>0 && ( s_argv[i][1]=='-' && memcmp( &s_argv[i][2], optName, len )==0 ||
|
joachim99@8
|
1221 memcmp( &s_argv[i][1], optName, len )==0 ))
|
joachim99@8
|
1222 {
|
joachim99@8
|
1223 if (s_pOptions[j].longName == 0) // alias, because without description.
|
joachim99@8
|
1224 {
|
joachim99@8
|
1225 ++j;
|
joachim99@8
|
1226 optName = s_pOptions[j].shortName;
|
joachim99@8
|
1227 pos = strchr( optName,' ' );
|
joachim99@8
|
1228 }
|
joachim99@8
|
1229 if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param
|
joachim99@8
|
1230 else { s_vOption[j].append("1"); } //set state
|
joachim99@8
|
1231 break;
|
joachim99@8
|
1232 }
|
joachim99@8
|
1233 }
|
joachim99@8
|
1234 if (j==nofOptions)
|
joachim99@8
|
1235 {
|
joachim99@58
|
1236 QString s;
|
joachim99@58
|
1237 s = QString("Unknown option: ") + s_argv[i] + "\n";
|
joachim99@8
|
1238
|
joachim99@58
|
1239 s += "KDiff3-Usage when starting via commandline: \n";
|
joachim99@58
|
1240 s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n";
|
joachim99@58
|
1241 s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n";
|
joachim99@58
|
1242 s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n";
|
joachim99@58
|
1243 s += "- Merging 3 files: \t\tkdiff3 file1 file2 file3 -o outputfile\n";
|
joachim99@58
|
1244 s += " Note that file1 will be treated as base of file2 and file3.\n";
|
joachim99@58
|
1245 s += "\n";
|
joachim99@58
|
1246 s += "If you start without arguments, then a dialog will appear\n";
|
joachim99@58
|
1247 s += "where you can select your files via a filebrowser.\n";
|
joachim99@58
|
1248 s += "\n";
|
joachim99@66
|
1249
|
joachim99@66
|
1250 s += "Options:\n";
|
joachim99@66
|
1251
|
joachim99@66
|
1252 j=0;
|
joachim99@66
|
1253 int pos=s.length();
|
joachim99@66
|
1254 for( j=0; j<nofOptions; ++j )
|
joachim99@66
|
1255 {
|
joachim99@66
|
1256 if ( s_pOptions[j].longName!=0 )
|
joachim99@66
|
1257 {
|
joachim99@66
|
1258 if (s_pOptions[j].shortName[0]!='+')
|
joachim99@66
|
1259 {
|
joachim99@66
|
1260 s += "-";
|
joachim99@66
|
1261 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-";
|
joachim99@66
|
1262 }
|
joachim99@66
|
1263 s += s_pOptions[j].shortName;
|
joachim99@66
|
1264 s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) );
|
joachim99@66
|
1265 s += s_pOptions[j].longName;
|
joachim99@66
|
1266 s +="\n";
|
joachim99@66
|
1267 pos=s.length();
|
joachim99@66
|
1268 }
|
joachim99@66
|
1269 else
|
joachim99@66
|
1270 {
|
joachim99@66
|
1271 s += "-";
|
joachim99@66
|
1272 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-";
|
joachim99@66
|
1273 s += s_pOptions[j].shortName;
|
joachim99@66
|
1274 s += ", ";
|
joachim99@66
|
1275 }
|
joachim99@66
|
1276 }
|
joachim99@66
|
1277
|
joachim99@66
|
1278 s += "\nFor more documentation, see the help-menu or the subdirectory doc.\n";
|
joachim99@58
|
1279 #ifdef _WIN32
|
joachim99@58
|
1280 // A windows program has no console
|
joachim99@58
|
1281 KMessageBox::information(0, s,i18n("KDiff3-Usage"));
|
joachim99@58
|
1282 #else
|
joachim99@58
|
1283 std::cerr << s.latin1() << std::endl;
|
joachim99@58
|
1284 #endif
|
joachim99@58
|
1285
|
joachim99@8
|
1286 ::exit(-1);
|
joachim99@8
|
1287 }
|
joachim99@8
|
1288 }
|
joachim99@8
|
1289 else
|
joachim99@8
|
1290 s_vArg.push_back( s_argv[i] );
|
joachim99@8
|
1291 }
|
joachim99@8
|
1292 }
|
joachim99@8
|
1293
|
joachim99@8
|
1294 KConfig* KApplication::config()
|
joachim99@8
|
1295 {
|
joachim99@8
|
1296 return &m_config;
|
joachim99@8
|
1297 }
|
joachim99@8
|
1298
|
joachim99@8
|
1299 bool KApplication::isRestored()
|
joachim99@8
|
1300 {
|
joachim99@8
|
1301 return false;
|
joachim99@8
|
1302 }
|
joachim99@8
|
1303
|
joachim99@8
|
1304 KApplication* KApplication::kApplication()
|
joachim99@8
|
1305 {
|
joachim99@8
|
1306 return kapp;
|
joachim99@8
|
1307 }
|
joachim99@8
|
1308
|
joachim99@8
|
1309 KIconLoader* KApplication::iconLoader()
|
joachim99@8
|
1310 {
|
joachim99@8
|
1311 return &m_iconLoader;
|
joachim99@8
|
1312 }
|
joachim99@8
|
1313
|
joachim99@8
|
1314
|
joachim99@8
|
1315 namespace KIO
|
joachim99@8
|
1316 {
|
joachim99@8
|
1317 SimpleJob* mkdir( KURL ){return 0;}
|
joachim99@8
|
1318 SimpleJob* rmdir( KURL ){return 0;}
|
joachim99@8
|
1319 SimpleJob* file_delete( KURL, bool ){return 0;}
|
joachim99@8
|
1320 FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1321 FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1322 CopyJob* link( KURL, KURL, bool ) {return 0;}
|
joachim99@8
|
1323 ListJob* listRecursive( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1324 ListJob* listDir( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1325 StatJob* stat( KURL, bool, int, bool ){return 0;}
|
joachim99@8
|
1326 TransferJob* get( KURL, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1327 TransferJob* put( KURL, int, bool, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1328 };
|
joachim99@8
|
1329
|
joachim99@8
|
1330 KActionCollection* KParts::Part::actionCollection()
|
joachim99@8
|
1331 {
|
joachim99@8
|
1332 return 0;
|
joachim99@8
|
1333 }
|
joachim99@8
|
1334
|
joachim99@8
|
1335 KApplication* KParts::Part::instance()
|
joachim99@8
|
1336 {
|
joachim99@8
|
1337 return kapp;
|
joachim99@8
|
1338 }
|
joachim99@8
|
1339
|
joachim99@8
|
1340
|
joachim99@8
|
1341 KLibLoader* KLibLoader::self()
|
joachim99@8
|
1342 {
|
joachim99@8
|
1343 static KLibLoader ll;
|
joachim99@8
|
1344 return ≪
|
joachim99@8
|
1345 }
|
joachim99@8
|
1346
|
joachim99@8
|
1347 extern "C" void* init_libkdiff3part();
|
joachim99@8
|
1348 KLibFactory* KLibLoader::factory(QString const&)
|
joachim99@8
|
1349 {
|
joachim99@8
|
1350 return (KLibFactory*) init_libkdiff3part();
|
joachim99@8
|
1351 }
|
joachim99@8
|
1352
|
joachim99@68
|
1353 QObject* KLibFactory::create(QObject* pParent, const QString& name, const QString& classname )
|
joachim99@8
|
1354 {
|
joachim99@8
|
1355 KParts::Factory* f = dynamic_cast<KParts::Factory*>(this);
|
joachim99@8
|
1356 if (f!=0)
|
joachim99@68
|
1357 return f->createPartObject( (QWidget*)pParent, name.ascii(),
|
joachim99@68
|
1358 pParent, name.ascii(),
|
joachim99@68
|
1359 classname.ascii(), QStringList() );
|
joachim99@8
|
1360 else
|
joachim99@8
|
1361 return 0;
|
joachim99@8
|
1362 }
|
joachim99@8
|
1363
|
joachim99@8
|
1364
|
joachim99@8
|
1365
|
joachim99@58
|
1366
|
joachim99@8
|
1367 #include "kreplacements.moc"
|