joachim99@8
|
1 /***************************************************************************
|
joachim99@8
|
2 kreplacements.cpp - description
|
joachim99@8
|
3 -------------------
|
joachim99@8
|
4 begin : Sat Aug 3 2002
|
joachim99@69
|
5 copyright : (C) 2002-2006 by Joachim Eibl
|
joachim99@69
|
6 email : joachim.eibl at 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@69
|
280 QString KFileDialog::getSaveFileName (const QString &startDir,
|
joachim99@69
|
281 const QString &filter,
|
joachim99@69
|
282 QWidget *parent,
|
joachim99@69
|
283 const QString &caption)
|
joachim99@69
|
284 {
|
joachim99@69
|
285 return QFileDialog::getSaveFileName( startDir, filter, parent, 0, caption );
|
joachim99@69
|
286 }
|
joachim99@69
|
287
|
joachim99@8
|
288
|
joachim99@8
|
289 KToolBar::BarPosition KToolBar::barPos()
|
joachim99@8
|
290 {
|
joachim99@66
|
291 if ( m_pMainWindow->leftDock()->hasDockWindow(this) ) return Left;
|
joachim99@66
|
292 if ( m_pMainWindow->rightDock()->hasDockWindow(this) ) return Right;
|
joachim99@66
|
293 if ( m_pMainWindow->topDock()->hasDockWindow(this) ) return Top;
|
joachim99@66
|
294 if ( m_pMainWindow->bottomDock()->hasDockWindow(this) ) return Bottom;
|
joachim99@8
|
295 return Top;
|
joachim99@8
|
296 }
|
joachim99@8
|
297
|
joachim99@66
|
298 void KToolBar::setBarPos(BarPosition bp)
|
joachim99@8
|
299 {
|
joachim99@66
|
300 if ( bp == Left ) m_pMainWindow->moveDockWindow( this, DockLeft );
|
joachim99@66
|
301 else if ( bp == Right ) m_pMainWindow->moveDockWindow( this, DockRight );
|
joachim99@66
|
302 else if ( bp == Bottom ) m_pMainWindow->moveDockWindow( this, DockBottom );
|
joachim99@66
|
303 else if ( bp == Top ) m_pMainWindow->moveDockWindow( this, DockTop );
|
joachim99@8
|
304 }
|
joachim99@8
|
305
|
joachim99@8
|
306 KToolBar::KToolBar( QMainWindow* parent )
|
joachim99@8
|
307 : QToolBar( parent )
|
joachim99@8
|
308 {
|
joachim99@66
|
309 m_pMainWindow = parent;
|
joachim99@8
|
310 }
|
joachim99@8
|
311
|
joachim99@8
|
312
|
joachim99@68
|
313 KMainWindow::KMainWindow( QWidget* parent, const char* name )
|
joachim99@8
|
314 : QMainWindow( parent, name ), m_actionCollection(this)
|
joachim99@8
|
315 {
|
joachim99@8
|
316 fileMenu = new QPopupMenu();
|
joachim99@53
|
317 menuBar()->insertItem(i18n("&File"), fileMenu);
|
joachim99@8
|
318 editMenu = new QPopupMenu();
|
joachim99@53
|
319 menuBar()->insertItem(i18n("&Edit"), editMenu);
|
joachim99@8
|
320 directoryMenu = new QPopupMenu();
|
joachim99@53
|
321 menuBar()->insertItem(i18n("&Directory"), directoryMenu);
|
joachim99@51
|
322 dirCurrentItemMenu = 0;
|
joachim99@51
|
323 dirCurrentSyncItemMenu = 0;
|
joachim99@8
|
324 movementMenu = new QPopupMenu();
|
joachim99@53
|
325 menuBar()->insertItem(i18n("&Movement"), movementMenu);
|
joachim99@66
|
326 diffMenu = new QPopupMenu();
|
joachim99@66
|
327 menuBar()->insertItem(i18n("D&iffview"), diffMenu);
|
joachim99@8
|
328 mergeMenu = new QPopupMenu();
|
joachim99@53
|
329 menuBar()->insertItem(i18n("&Merge"), mergeMenu);
|
joachim99@8
|
330 windowsMenu = new QPopupMenu();
|
joachim99@53
|
331 menuBar()->insertItem(i18n("&Window"), windowsMenu);
|
joachim99@8
|
332 settingsMenu = new QPopupMenu();
|
joachim99@53
|
333 menuBar()->insertItem(i18n("&Settings"), settingsMenu);
|
joachim99@8
|
334 helpMenu = new QPopupMenu();
|
joachim99@53
|
335 menuBar()->insertItem(i18n("&Help"), helpMenu);
|
joachim99@8
|
336
|
joachim99@8
|
337 m_pToolBar = new KToolBar(this);
|
joachim99@8
|
338
|
joachim99@8
|
339 memberList = new QList<KMainWindow>;
|
joachim99@8
|
340 memberList->append(this);
|
joachim99@8
|
341 }
|
joachim99@8
|
342
|
joachim99@8
|
343 KToolBar* KMainWindow::toolBar(const QString&)
|
joachim99@8
|
344 {
|
joachim99@8
|
345 return m_pToolBar;
|
joachim99@8
|
346 }
|
joachim99@8
|
347
|
joachim99@8
|
348 KActionCollection* KMainWindow::actionCollection()
|
joachim99@8
|
349 {
|
joachim99@8
|
350 return &m_actionCollection;
|
joachim99@8
|
351 }
|
joachim99@8
|
352
|
joachim99@8
|
353 void KMainWindow::createGUI()
|
joachim99@8
|
354 {
|
joachim99@8
|
355 KStdAction::help(this, SLOT(slotHelp()), actionCollection());
|
joachim99@8
|
356 KStdAction::about(this, SLOT(slotAbout()), actionCollection());
|
joachim99@69
|
357 KStdAction::aboutQt(actionCollection());
|
joachim99@8
|
358 }
|
joachim99@8
|
359
|
joachim99@8
|
360 void KMainWindow::slotAbout()
|
joachim99@8
|
361 {
|
joachim99@66
|
362 QTabDialog d;
|
joachim99@66
|
363 d.setCaption("About " + s_appName);
|
joachim99@66
|
364 QTextBrowser* tb1 = new QTextBrowser(&d);
|
joachim99@66
|
365 tb1->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
366 tb1->setText(
|
joachim99@66
|
367 s_appName + " Version " + s_version +
|
joachim99@66
|
368 "\n\n" + s_description +
|
joachim99@66
|
369 "\n\n" + s_copyright +
|
joachim99@66
|
370 "\n\nHomepage: " + s_homepage +
|
joachim99@66
|
371 "\n\nLicence: GNU GPL Version 2"
|
joachim99@66
|
372 );
|
joachim99@66
|
373 d.addTab(tb1,i18n("&About"));
|
joachim99@66
|
374
|
joachim99@66
|
375 std::list<KAboutData::AboutDataEntry>::iterator i;
|
joachim99@66
|
376
|
joachim99@66
|
377 QString s2;
|
joachim99@66
|
378 for( i=s_pAboutData->m_authorList.begin(); i!=s_pAboutData->m_authorList.end(); ++i )
|
joachim99@66
|
379 {
|
joachim99@66
|
380 if ( !i->m_name.isEmpty() ) s2 += i->m_name + "\n";
|
joachim99@66
|
381 if ( !i->m_task.isEmpty() ) s2 += " " + i->m_task + "\n";
|
joachim99@66
|
382 if ( !i->m_email.isEmpty() ) s2 += " " + i->m_email + "\n";
|
joachim99@66
|
383 if ( !i->m_weblink.isEmpty() ) s2 += " " + i->m_weblink + "\n";
|
joachim99@66
|
384 s2 += "\n";
|
joachim99@66
|
385 }
|
joachim99@66
|
386 QTextBrowser* tb2 = new QTextBrowser(&d);
|
joachim99@66
|
387 tb2->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
388 tb2->setText(s2);
|
joachim99@66
|
389 d.addTab(tb2,i18n("A&uthor"));
|
joachim99@66
|
390
|
joachim99@66
|
391 QString s3;
|
joachim99@66
|
392 for( i=s_pAboutData->m_creditList.begin(); i!=s_pAboutData->m_creditList.end(); ++i )
|
joachim99@66
|
393 {
|
joachim99@66
|
394 if ( !i->m_name.isEmpty() ) s3 += i->m_name + "\n";
|
joachim99@66
|
395 if ( !i->m_task.isEmpty() ) s3 += " " + i->m_task + "\n";
|
joachim99@66
|
396 if ( !i->m_email.isEmpty() ) s3 += " " + i->m_email + "\n";
|
joachim99@66
|
397 if ( !i->m_weblink.isEmpty() ) s3 += " " + i->m_weblink + "\n";
|
joachim99@66
|
398 s3 += "\n";
|
joachim99@66
|
399 }
|
joachim99@66
|
400 QTextBrowser* tb3 = new QTextBrowser(&d);
|
joachim99@66
|
401 tb3->setWordWrap( QTextEdit::NoWrap );
|
joachim99@66
|
402 tb3->setText(s3);
|
joachim99@66
|
403 d.addTab(tb3,i18n("&Thanks To"));
|
joachim99@66
|
404
|
joachim99@66
|
405 d.resize(400,300);
|
joachim99@66
|
406 d.exec();
|
joachim99@66
|
407 /*
|
joachim99@8
|
408 QMessageBox::information(
|
joachim99@8
|
409 this,
|
joachim99@8
|
410 "About " + s_appName,
|
joachim99@8
|
411 s_appName + " Version " + s_version +
|
joachim99@8
|
412 "\n\n" + s_description +
|
joachim99@8
|
413 "\n\n" + s_copyright +
|
joachim99@8
|
414 "\n\nHomepage: " + s_homepage +
|
joachim99@8
|
415 "\n\nLicence: GNU GPL Version 2"
|
joachim99@8
|
416 );
|
joachim99@66
|
417 */
|
joachim99@8
|
418 }
|
joachim99@8
|
419
|
joachim99@8
|
420 void KMainWindow::slotHelp()
|
joachim99@8
|
421 {
|
joachim99@8
|
422 showHelp();
|
joachim99@8
|
423 }
|
joachim99@8
|
424
|
joachim99@69
|
425
|
joachim99@69
|
426 QString KStandardDirs::findResource(const QString& resource, const QString& /*appName*/)
|
joachim99@69
|
427 {
|
joachim99@69
|
428 if (resource=="config")
|
joachim99@69
|
429 {
|
joachim99@69
|
430 QString home = QDir::homeDirPath();
|
joachim99@69
|
431 return home + "/.kdiff3rc";
|
joachim99@69
|
432 }
|
joachim99@69
|
433 return QString();
|
joachim99@69
|
434 }
|
joachim99@69
|
435
|
joachim99@8
|
436 KConfig::KConfig()
|
joachim99@8
|
437 {
|
joachim99@69
|
438 }
|
joachim99@69
|
439
|
joachim99@69
|
440 void KConfig::readConfigFile( const QString& configFileName )
|
joachim99@69
|
441 {
|
joachim99@69
|
442 if ( !configFileName.isEmpty() )
|
joachim99@69
|
443 {
|
joachim99@69
|
444 m_fileName = configFileName;
|
joachim99@69
|
445 }
|
joachim99@69
|
446 else
|
joachim99@69
|
447 {
|
joachim99@69
|
448 m_fileName = KStandardDirs().findResource("config","kdiff3rc");
|
joachim99@69
|
449 }
|
joachim99@8
|
450
|
joachim99@8
|
451 QFile f( m_fileName );
|
joachim99@8
|
452 if ( f.open(IO_ReadOnly) )
|
joachim99@8
|
453 { // file opened successfully
|
joachim99@69
|
454 QTextStream t( &f ); // use a text stream
|
joachim99@69
|
455 load(t);
|
joachim99@8
|
456 f.close();
|
joachim99@8
|
457 }
|
joachim99@8
|
458 }
|
joachim99@8
|
459
|
joachim99@8
|
460 KConfig::~KConfig()
|
joachim99@8
|
461 {
|
joachim99@8
|
462 QFile f(m_fileName);
|
joachim99@8
|
463 if ( f.open( IO_WriteOnly | IO_Translate ) )
|
joachim99@8
|
464 { // file opened successfully
|
joachim99@8
|
465 QTextStream t( &f ); // use a text stream
|
joachim99@69
|
466 save(t);
|
joachim99@8
|
467 f.close();
|
joachim99@8
|
468 }
|
joachim99@8
|
469 }
|
joachim99@8
|
470
|
joachim99@8
|
471 void KConfig::setGroup(const QString&)
|
joachim99@8
|
472 {
|
joachim99@8
|
473 }
|
joachim99@8
|
474
|
joachim99@68
|
475 void KAction::init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
476 const char* name, bool bToggle, bool bMenu)
|
joachim99@8
|
477 {
|
joachim99@68
|
478 QString n(name);
|
joachim99@8
|
479 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
480 if( slot!=0 )
|
joachim99@8
|
481 {
|
joachim99@8
|
482 if (!bToggle)
|
joachim99@8
|
483 connect(this, SIGNAL(activated()), receiver, slot);
|
joachim99@8
|
484 else
|
joachim99@8
|
485 {
|
joachim99@8
|
486 connect(this, SIGNAL(toggled(bool)), receiver, slot);
|
joachim99@8
|
487 }
|
joachim99@8
|
488 }
|
joachim99@8
|
489
|
joachim99@8
|
490 if (bMenu)
|
joachim99@8
|
491 {
|
joachim99@68
|
492 if( n[0]=='g') addTo( p->movementMenu );
|
joachim99@68
|
493 else if( n.left(16)=="dir_current_sync")
|
joachim99@53
|
494 {
|
joachim99@53
|
495 if ( p->dirCurrentItemMenu==0 )
|
joachim99@53
|
496 {
|
joachim99@53
|
497 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@53
|
498 p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
499 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@53
|
500 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@53
|
501 }
|
joachim99@53
|
502 addTo( p->dirCurrentItemMenu );
|
joachim99@53
|
503 }
|
joachim99@68
|
504 else if( n.left(11)=="dir_current")
|
joachim99@53
|
505 {
|
joachim99@53
|
506 if ( p->dirCurrentItemMenu==0 )
|
joachim99@53
|
507 {
|
joachim99@53
|
508 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@53
|
509 p->directoryMenu->insertItem(i18n("Current Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
510 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@53
|
511 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@53
|
512 }
|
joachim99@53
|
513 addTo( p->dirCurrentSyncItemMenu );
|
joachim99@53
|
514 }
|
joachim99@68
|
515 else if( n.left(4)=="diff") addTo( p->diffMenu );
|
joachim99@8
|
516 else if( name[0]=='d') addTo( p->directoryMenu );
|
joachim99@8
|
517 else if( name[0]=='f') addTo( p->fileMenu );
|
joachim99@8
|
518 else if( name[0]=='w') addTo( p->windowsMenu );
|
joachim99@8
|
519 else addTo( p->mergeMenu );
|
joachim99@8
|
520 }
|
joachim99@8
|
521 }
|
joachim99@8
|
522
|
joachim99@68
|
523
|
joachim99@68
|
524 KAction::KAction(const QString& text, const QIconSet& icon, int accel,
|
joachim99@68
|
525 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
526 const char* name, bool bToggle, bool bMenu
|
joachim99@68
|
527 )
|
joachim99@68
|
528 : QAction ( text, icon, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@68
|
529 {
|
joachim99@68
|
530 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@68
|
531 if ( !icon.isNull() && p ) this->addTo( p->m_pToolBar );
|
joachim99@68
|
532
|
joachim99@68
|
533 init(receiver,slot,actionCollection,name,bToggle,bMenu);
|
joachim99@68
|
534 }
|
joachim99@68
|
535
|
joachim99@8
|
536 KAction::KAction(const QString& text, int accel,
|
joachim99@51
|
537 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@68
|
538 const char* name, bool bToggle, bool bMenu
|
joachim99@8
|
539 )
|
joachim99@8
|
540 : QAction ( text, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@8
|
541 {
|
joachim99@68
|
542 init(receiver,slot,actionCollection,name,bToggle,bMenu);
|
joachim99@8
|
543 }
|
joachim99@8
|
544
|
joachim99@8
|
545 void KAction::setStatusText(const QString&)
|
joachim99@8
|
546 {
|
joachim99@8
|
547 }
|
joachim99@8
|
548
|
joachim99@8
|
549 void KAction::plug(QPopupMenu* menu)
|
joachim99@8
|
550 {
|
joachim99@8
|
551 addTo(menu);
|
joachim99@8
|
552 }
|
joachim99@8
|
553
|
joachim99@8
|
554
|
joachim99@68
|
555 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@51
|
556 : KAction( text, icon, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
557 {
|
joachim99@8
|
558 }
|
joachim99@8
|
559
|
joachim99@68
|
560 KToggleAction::KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@51
|
561 : KAction( text, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
562 {
|
joachim99@8
|
563 }
|
joachim99@8
|
564
|
joachim99@68
|
565 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu)
|
joachim99@8
|
566 : KAction( text, icon, accel, 0, 0, actionCollection, name, true, bMenu)
|
joachim99@8
|
567 {
|
joachim99@8
|
568 }
|
joachim99@8
|
569
|
joachim99@8
|
570 void KToggleAction::setChecked(bool bChecked)
|
joachim99@8
|
571 {
|
joachim99@8
|
572 blockSignals( true );
|
joachim99@8
|
573 setOn( bChecked );
|
joachim99@8
|
574 blockSignals( false );
|
joachim99@8
|
575 }
|
joachim99@8
|
576
|
joachim99@8
|
577 bool KToggleAction::isChecked()
|
joachim99@8
|
578 {
|
joachim99@8
|
579 return isOn();
|
joachim99@8
|
580 }
|
joachim99@8
|
581
|
joachim99@8
|
582
|
joachim99@8
|
583
|
joachim99@8
|
584 //static
|
joachim99@8
|
585 KAction* KStdAction::open( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
586 {
|
joachim99@8
|
587 #include "../xpm/fileopen.xpm"
|
joachim99@8
|
588 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
589 KAction* a = new KAction( i18n("Open"), QIconSet(QPixmap(fileopen)), Qt::CTRL+Qt::Key_O, parent, slot, actionCollection, "open", false, false);
|
joachim99@8
|
590 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
591 return a;
|
joachim99@8
|
592 }
|
joachim99@8
|
593
|
joachim99@8
|
594 KAction* KStdAction::save( QWidget* parent, const char* slot, KActionCollection* actionCollection )
|
joachim99@8
|
595 {
|
joachim99@8
|
596 #include "../xpm/filesave.xpm"
|
joachim99@8
|
597 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
598 KAction* a = new KAction( i18n("Save"), QIconSet(QPixmap(filesave)), Qt::CTRL+Qt::Key_S, parent, slot, actionCollection, "save", false, false);
|
joachim99@8
|
599 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
600 return a;
|
joachim99@8
|
601 }
|
joachim99@8
|
602
|
joachim99@8
|
603 KAction* KStdAction::saveAs( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
604 {
|
joachim99@8
|
605 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
606 KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false);
|
joachim99@8
|
607 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
608 return a;
|
joachim99@8
|
609 }
|
joachim99@8
|
610
|
joachim99@69
|
611 KAction* KStdAction::print( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@69
|
612 {
|
joachim99@69
|
613 #include "../xpm/fileprint.xpm"
|
joachim99@69
|
614 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@69
|
615 KAction* a = new KAction( i18n("Print..."), QIconSet(QPixmap(fileprint)),Qt::CTRL+Qt::Key_P, parent, slot, actionCollection, "print", false, false);
|
joachim99@69
|
616 if(p) a->addTo( p->fileMenu );
|
joachim99@69
|
617 return a;
|
joachim99@69
|
618 }
|
joachim99@69
|
619
|
joachim99@8
|
620 KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
621 {
|
joachim99@8
|
622 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
623 KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false);
|
joachim99@8
|
624 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
625 return a;
|
joachim99@8
|
626 }
|
joachim99@8
|
627
|
joachim99@8
|
628 KAction* KStdAction::cut( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
629 {
|
joachim99@8
|
630 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
631 KAction* a = new KAction( i18n("Cut"), Qt::CTRL+Qt::Key_X, parent, slot, actionCollection, "cut", false, false );
|
joachim99@8
|
632 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
633 return a;
|
joachim99@8
|
634 }
|
joachim99@8
|
635
|
joachim99@8
|
636 KAction* KStdAction::copy( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
637 {
|
joachim99@8
|
638 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
639 KAction* a = new KAction( i18n("Copy"), Qt::CTRL+Qt::Key_C, parent, slot, actionCollection, "copy", false, false );
|
joachim99@8
|
640 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
641 return a;
|
joachim99@8
|
642 }
|
joachim99@8
|
643
|
joachim99@8
|
644 KAction* KStdAction::paste( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
645 {
|
joachim99@8
|
646 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
647 KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false );
|
joachim99@8
|
648 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
649 return a;
|
joachim99@8
|
650 }
|
joachim99@8
|
651
|
joachim99@69
|
652 KAction* KStdAction::selectAll( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@69
|
653 {
|
joachim99@69
|
654 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@69
|
655 KAction* a = new KAction( i18n("Select All"), Qt::CTRL+Qt::Key_A, parent, slot, actionCollection, "selectall", false, false );
|
joachim99@69
|
656 if(p) a->addTo( p->editMenu );
|
joachim99@69
|
657 return a;
|
joachim99@69
|
658 }
|
joachim99@69
|
659
|
joachim99@8
|
660 KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
661 {
|
joachim99@8
|
662 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
663 KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false );
|
joachim99@8
|
664 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
665 return a;
|
joachim99@8
|
666 }
|
joachim99@8
|
667
|
joachim99@8
|
668 KToggleAction* KStdAction::showStatusbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
669 {
|
joachim99@8
|
670 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
671 KToggleAction* a = new KToggleAction( i18n("Show &Statusbar"), 0, parent, slot, actionCollection, "showstatusbar", false );
|
joachim99@8
|
672 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
673 return a;
|
joachim99@8
|
674 }
|
joachim99@8
|
675
|
joachim99@8
|
676 KAction* KStdAction::preferences( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
677 {
|
joachim99@8
|
678 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
679 KAction* a = new KAction( i18n("&Configure %1...").arg("KDiff3"), 0, parent, slot, actionCollection, "settings", false, false );
|
joachim99@8
|
680 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
681 return a;
|
joachim99@8
|
682 }
|
joachim99@8
|
683 KAction* KStdAction::keyBindings( QWidget*, const char*, KActionCollection*)
|
joachim99@8
|
684 {
|
joachim99@8
|
685 return 0;
|
joachim99@8
|
686 }
|
joachim99@8
|
687
|
joachim99@8
|
688 KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
689 {
|
joachim99@8
|
690 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@69
|
691 KAction* a = new KAction( i18n("About")+" KDiff3", 0, parent, slot, actionCollection, "about_kdiff3", false, false );
|
joachim99@69
|
692 if(p) a->addTo( p->helpMenu );
|
joachim99@69
|
693 return a;
|
joachim99@69
|
694 }
|
joachim99@69
|
695
|
joachim99@69
|
696 KAction* KStdAction::aboutQt( KActionCollection* actionCollection )
|
joachim99@69
|
697 {
|
joachim99@69
|
698 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@69
|
699 KAction* a = new KAction( i18n("About")+" Qt", 0, qApp, SLOT(aboutQt()), actionCollection, "about_qt", false, false );
|
joachim99@8
|
700 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
701 return a;
|
joachim99@8
|
702 }
|
joachim99@8
|
703
|
joachim99@8
|
704 KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
705 {
|
joachim99@8
|
706 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
707 KAction* a = new KAction( i18n("Help"), Qt::Key_F1, parent, slot, actionCollection, "help", false, false );
|
joachim99@8
|
708 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
709 return a;
|
joachim99@8
|
710 }
|
joachim99@8
|
711 KAction* KStdAction::find( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
712 {
|
joachim99@8
|
713 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
714 KAction* a = new KAction( i18n("Find"), Qt::CTRL+Qt::Key_F, parent, slot, actionCollection, "find", false, false );
|
joachim99@8
|
715 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
716 return a;
|
joachim99@8
|
717 }
|
joachim99@8
|
718
|
joachim99@8
|
719 KAction* KStdAction::findNext( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
720 {
|
joachim99@8
|
721 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@53
|
722 KAction* a = new KAction( i18n("Find Next"), Qt::Key_F3, parent, slot, actionCollection, "findNext", false, false );
|
joachim99@8
|
723 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
724 return a;
|
joachim99@8
|
725 }
|
joachim99@8
|
726
|
joachim99@8
|
727
|
joachim99@8
|
728
|
joachim99@8
|
729
|
joachim99@8
|
730 KFontChooser::KFontChooser( QWidget* pParent, const QString& /*name*/, bool, const QStringList&, bool, int )
|
joachim99@8
|
731 : QWidget(pParent)
|
joachim99@8
|
732 {
|
joachim99@8
|
733 m_pParent = pParent;
|
joachim99@8
|
734 QVBoxLayout* pLayout = new QVBoxLayout( this );
|
joachim99@53
|
735 m_pSelectFont = new QPushButton(i18n("Select Font"), this );
|
joachim99@8
|
736 connect(m_pSelectFont, SIGNAL(clicked()), this, SLOT(slotSelectFont()));
|
joachim99@8
|
737 pLayout->addWidget(m_pSelectFont);
|
joachim99@8
|
738
|
joachim99@8
|
739 m_pLabel = new QLabel( "", this );
|
joachim99@8
|
740 m_pLabel->setFont( m_font );
|
joachim99@8
|
741 m_pLabel->setMinimumWidth(200);
|
joachim99@8
|
742 m_pLabel->setText( "The quick brown fox jumps over the river\n"
|
joachim99@8
|
743 "but the little red hen escapes with a shiver.\n"
|
joachim99@8
|
744 ":-)");
|
joachim99@8
|
745 pLayout->addWidget(m_pLabel);
|
joachim99@8
|
746 }
|
joachim99@8
|
747
|
joachim99@8
|
748 QFont KFontChooser::font()
|
joachim99@8
|
749 {
|
joachim99@8
|
750 return m_font;//QFont("courier",10);
|
joachim99@8
|
751 }
|
joachim99@8
|
752
|
joachim99@8
|
753 void KFontChooser::setFont( const QFont& font, bool )
|
joachim99@8
|
754 {
|
joachim99@8
|
755 m_font = font;
|
joachim99@8
|
756 m_pLabel->setFont( m_font );
|
joachim99@8
|
757 //update();
|
joachim99@8
|
758 }
|
joachim99@8
|
759
|
joachim99@8
|
760 void KFontChooser::slotSelectFont()
|
joachim99@8
|
761 {
|
joachim99@8
|
762 for(;;)
|
joachim99@8
|
763 {
|
joachim99@8
|
764 bool bOk;
|
joachim99@8
|
765 m_font = QFontDialog::getFont(&bOk, m_font );
|
joachim99@8
|
766 m_pLabel->setFont( m_font );
|
joachim99@8
|
767 QFontMetrics fm(m_font);
|
joachim99@8
|
768
|
joachim99@8
|
769 // Variable width font.
|
joachim99@8
|
770 if ( fm.width('W')!=fm.width('i') )
|
joachim99@8
|
771 {
|
joachim99@8
|
772 int result = KMessageBox::warningYesNo(m_pParent, i18n(
|
joachim99@8
|
773 "You selected a variable width font.\n\n"
|
joachim99@8
|
774 "Because this program doesn't handle variable width fonts\n"
|
joachim99@8
|
775 "correctly, you might experience problems while editing.\n\n"
|
joachim99@8
|
776 "Do you want to continue or do you want to select another font."),
|
joachim99@8
|
777 i18n("Incompatible font."),
|
joachim99@8
|
778 i18n("Continue at my own risk"), i18n("Select another font"));
|
joachim99@8
|
779 if (result==KMessageBox::Yes)
|
joachim99@8
|
780 return;
|
joachim99@8
|
781 }
|
joachim99@8
|
782 else
|
joachim99@8
|
783 return;
|
joachim99@8
|
784 }
|
joachim99@8
|
785 }
|
joachim99@8
|
786
|
joachim99@8
|
787
|
joachim99@8
|
788 KColorButton::KColorButton(QWidget* parent)
|
joachim99@8
|
789 : QPushButton(parent)
|
joachim99@8
|
790 {
|
joachim99@8
|
791 connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()));
|
joachim99@8
|
792 }
|
joachim99@8
|
793
|
joachim99@8
|
794 QColor KColorButton::color()
|
joachim99@8
|
795 {
|
joachim99@8
|
796 return m_color;
|
joachim99@8
|
797 }
|
joachim99@8
|
798
|
joachim99@8
|
799 void KColorButton::setColor( const QColor& color )
|
joachim99@8
|
800 {
|
joachim99@8
|
801 m_color = color;
|
joachim99@8
|
802 update();
|
joachim99@8
|
803 }
|
joachim99@8
|
804
|
joachim99@8
|
805 void KColorButton::paintEvent( QPaintEvent* e )
|
joachim99@8
|
806 {
|
joachim99@8
|
807 QPushButton::paintEvent(e);
|
joachim99@8
|
808 QPainter p(this);
|
joachim99@8
|
809
|
joachim99@8
|
810 int w = width();
|
joachim99@8
|
811 int h = height();
|
joachim99@8
|
812 p.fillRect( 10, 5, w-20, h-10, m_color );
|
joachim99@8
|
813 p.drawRect( 10, 5, w-20, h-10 );
|
joachim99@8
|
814 }
|
joachim99@8
|
815
|
joachim99@8
|
816 void KColorButton::slotClicked()
|
joachim99@8
|
817 {
|
joachim99@8
|
818 // Under Windows ChooseColor() should be used. (Nicer if few colors exist.)
|
joachim99@8
|
819 QColor c = QColorDialog::getColor ( m_color, this );
|
joachim99@8
|
820 if ( c.isValid() ) m_color = c;
|
joachim99@8
|
821 update();
|
joachim99@8
|
822 }
|
joachim99@8
|
823
|
joachim99@69
|
824 KPrinter::KPrinter()
|
joachim99@69
|
825 {
|
joachim99@69
|
826 }
|
joachim99@69
|
827 QValueList<int> KPrinter::pageList()
|
joachim99@69
|
828 {
|
joachim99@69
|
829 QValueList<int> vl;
|
joachim99@69
|
830 int to = toPage();
|
joachim99@69
|
831 for(int i=fromPage(); i<=to; ++i)
|
joachim99@69
|
832 {
|
joachim99@69
|
833 vl.push_back(i);
|
joachim99@69
|
834 }
|
joachim99@69
|
835 return vl;
|
joachim99@69
|
836 }
|
joachim99@69
|
837 void KPrinter::setCurrentPage(int)
|
joachim99@69
|
838 {
|
joachim99@69
|
839 }
|
joachim99@69
|
840 void KPrinter::setPageSelection(e_PageSelection)
|
joachim99@69
|
841 {
|
joachim99@69
|
842 }
|
joachim99@69
|
843
|
joachim99@69
|
844
|
joachim99@8
|
845 QPixmap KIconLoader::loadIcon( const QString&, int )
|
joachim99@8
|
846 {
|
joachim99@8
|
847 return QPixmap();
|
joachim99@8
|
848 }
|
joachim99@8
|
849
|
joachim99@8
|
850 KAboutData::KAboutData( const QString& /*name*/, const QString& appName, const QString& version,
|
joachim99@8
|
851 const QString& description, int,
|
joachim99@8
|
852 const QString& copyright, int, const QString& homepage, const QString& email)
|
joachim99@8
|
853 {
|
joachim99@8
|
854 s_copyright = copyright;
|
joachim99@8
|
855 s_email = email;
|
joachim99@8
|
856 s_appName = appName;
|
joachim99@8
|
857 s_description = description;
|
joachim99@8
|
858 s_version = version;
|
joachim99@8
|
859 s_homepage = homepage;
|
joachim99@8
|
860 }
|
joachim99@8
|
861
|
joachim99@51
|
862 KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ )
|
joachim99@8
|
863 {
|
joachim99@8
|
864 }
|
joachim99@8
|
865
|
joachim99@66
|
866 void KAboutData::addAuthor(const char* name, const char* task, const char* email, const char* weblink)
|
joachim99@8
|
867 {
|
joachim99@66
|
868 m_authorList.push_back( AboutDataEntry( name, task, email, weblink) );
|
joachim99@66
|
869 }
|
joachim99@66
|
870
|
joachim99@66
|
871 void KAboutData::addCredit(const char* name, const char* task, const char* email, const char* weblink)
|
joachim99@66
|
872 {
|
joachim99@66
|
873 m_creditList.push_back( AboutDataEntry( name, task, email, weblink) );
|
joachim99@8
|
874 }
|
joachim99@8
|
875
|
joachim99@8
|
876 /* Option structure: e.g.:
|
joachim99@8
|
877 { "m", 0, 0 },
|
joachim99@8
|
878 { "merge", I18N_NOOP("Automatically merge the input."), 0 },
|
joachim99@8
|
879 { "o", 0, 0 },
|
joachim99@8
|
880 { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 },
|
joachim99@8
|
881 { "+[File1]", I18N_NOOP("file1 to open (base)"), 0 },
|
joachim99@8
|
882 { "+[File2]", I18N_NOOP("file2 to open"), 0 },
|
joachim99@8
|
883 { "+[File3]", I18N_NOOP("file3 to open"), 0 },
|
joachim99@8
|
884 */
|
joachim99@8
|
885 ////////////////
|
joachim99@8
|
886 static KCmdLineArgs s_cmdLineArgs;
|
joachim99@8
|
887 static int s_argc;
|
joachim99@8
|
888 static char** s_argv;
|
joachim99@8
|
889 static KCmdLineOptions* s_pOptions;
|
joachim99@8
|
890
|
joachim99@8
|
891 static std::vector<QCStringList> s_vOption;
|
joachim99@8
|
892 static std::vector<const char*> s_vArg;
|
joachim99@8
|
893
|
joachim99@8
|
894 KCmdLineArgs* KCmdLineArgs::parsedArgs() // static
|
joachim99@8
|
895 {
|
joachim99@51
|
896 return &s_cmdLineArgs;
|
joachim99@8
|
897 }
|
joachim99@8
|
898
|
joachim99@66
|
899 void KCmdLineArgs::init( int argc, char**argv, KAboutData* pAboutData ) // static
|
joachim99@8
|
900 {
|
joachim99@8
|
901 s_argc = argc;
|
joachim99@8
|
902 s_argv = argv;
|
joachim99@66
|
903 s_pAboutData = pAboutData;
|
joachim99@8
|
904 }
|
joachim99@8
|
905
|
joachim99@8
|
906 void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static
|
joachim99@8
|
907 {
|
joachim99@8
|
908 s_pOptions = options;
|
joachim99@8
|
909 }
|
joachim99@8
|
910
|
joachim99@8
|
911 int KCmdLineArgs::count()
|
joachim99@8
|
912 {
|
joachim99@8
|
913 return s_vArg.size();
|
joachim99@8
|
914 }
|
joachim99@8
|
915
|
joachim99@8
|
916 QString KCmdLineArgs::arg(int idx)
|
joachim99@8
|
917 {
|
joachim99@58
|
918 return QString::fromLocal8Bit( s_vArg[idx] );
|
joachim99@8
|
919 }
|
joachim99@8
|
920
|
joachim99@8
|
921 void KCmdLineArgs::clear()
|
joachim99@8
|
922 {
|
joachim99@8
|
923 }
|
joachim99@8
|
924
|
joachim99@8
|
925 QString KCmdLineArgs::getOption( const QString& s )
|
joachim99@8
|
926 {
|
joachim99@8
|
927 // Find the option
|
joachim99@8
|
928 int j=0;
|
joachim99@8
|
929 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
930 {
|
joachim99@69
|
931 const char* optName = s_pOptions[j].name;
|
joachim99@8
|
932 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
933 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
934
|
joachim99@8
|
935 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
936 {
|
joachim99@8
|
937 return s_vOption[j].isEmpty() ? QString() : s_vOption[j].last();
|
joachim99@8
|
938 }
|
joachim99@8
|
939 }
|
joachim99@8
|
940 assert(false);
|
joachim99@8
|
941 return QString();
|
joachim99@8
|
942 }
|
joachim99@8
|
943
|
joachim99@8
|
944 QCStringList KCmdLineArgs::getOptionList( const QString& s )
|
joachim99@8
|
945 {
|
joachim99@8
|
946 // Find the option
|
joachim99@8
|
947 int j=0;
|
joachim99@8
|
948 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
949 {
|
joachim99@69
|
950 const char* optName = s_pOptions[j].name;
|
joachim99@8
|
951 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
952 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
953
|
joachim99@8
|
954 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
955 {
|
joachim99@8
|
956 return s_vOption[j];
|
joachim99@8
|
957 }
|
joachim99@8
|
958 }
|
joachim99@8
|
959
|
joachim99@8
|
960 assert(false);
|
joachim99@8
|
961 return QCStringList();
|
joachim99@8
|
962 }
|
joachim99@8
|
963
|
joachim99@8
|
964 bool KCmdLineArgs::isSet(const QString& s)
|
joachim99@8
|
965 {
|
joachim99@8
|
966 // Find the option
|
joachim99@8
|
967 int j=0;
|
joachim99@8
|
968 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
969 {
|
joachim99@69
|
970 const char* optName = s_pOptions[j].name;
|
joachim99@8
|
971 if( s == QString( optName ) )
|
joachim99@8
|
972 {
|
joachim99@8
|
973 return ! s_vOption[j].isEmpty();
|
joachim99@8
|
974 }
|
joachim99@8
|
975 }
|
joachim99@8
|
976 assert(false);
|
joachim99@8
|
977 return false;
|
joachim99@8
|
978 }
|
joachim99@8
|
979
|
joachim99@8
|
980 ///////////////////
|
joachim99@8
|
981 KApplication* kapp;
|
joachim99@8
|
982
|
joachim99@8
|
983 KApplication::KApplication()
|
joachim99@8
|
984 : QApplication( s_argc,s_argv )
|
joachim99@8
|
985 {
|
joachim99@8
|
986 kapp = this;
|
joachim99@8
|
987
|
joachim99@8
|
988 int nofOptions=0;
|
joachim99@8
|
989 int nofArgs=0;
|
joachim99@8
|
990 int i=0;
|
joachim99@69
|
991 while( s_pOptions[i].name != 0 )
|
joachim99@8
|
992 {
|
joachim99@69
|
993 if ( s_pOptions[i].name[0]=='[' )
|
joachim99@8
|
994 nofArgs++;
|
joachim99@8
|
995 else
|
joachim99@8
|
996 nofOptions++;
|
joachim99@8
|
997
|
joachim99@8
|
998 ++i;
|
joachim99@8
|
999 }
|
joachim99@8
|
1000
|
joachim99@69
|
1001 // First find the option "-config" or "--config" to allow loading of options
|
joachim99@69
|
1002 QString configFileName;
|
joachim99@69
|
1003 for( i=1; i<s_argc-1; ++i )
|
joachim99@69
|
1004 {
|
joachim99@69
|
1005 QString arg = s_argv[i];
|
joachim99@69
|
1006 if ( arg == "-config" || arg == "--config" )
|
joachim99@69
|
1007 {
|
joachim99@69
|
1008 configFileName = s_argv[i+1];
|
joachim99@69
|
1009 }
|
joachim99@69
|
1010 }
|
joachim99@69
|
1011 m_config.readConfigFile(configFileName);
|
joachim99@69
|
1012
|
joachim99@69
|
1013 QStringList ignorableCmdLineOptionsList = m_config.readListEntry("IgnorableCmdLineOptions", QString("-u;-query;-html;-abort"), '|');
|
joachim99@69
|
1014 QString ignorableCmdLineOptions;
|
joachim99@69
|
1015 if ( !ignorableCmdLineOptionsList.isEmpty() )
|
joachim99@69
|
1016 ignorableCmdLineOptions = ignorableCmdLineOptionsList.front() + ";";
|
joachim99@69
|
1017
|
joachim99@8
|
1018 s_vOption.resize(nofOptions);
|
joachim99@8
|
1019
|
joachim99@8
|
1020 for( i=1; i<s_argc; ++i )
|
joachim99@8
|
1021 {
|
joachim99@8
|
1022 if ( s_argv[i][0]=='-' ) // An option
|
joachim99@8
|
1023 {
|
joachim99@69
|
1024 if ( ignorableCmdLineOptions.contains(QString(s_argv[i])+";") )
|
joachim99@69
|
1025 continue;
|
joachim99@8
|
1026 // Find the option
|
joachim99@8
|
1027 int j=0;
|
joachim99@8
|
1028 for( j=0; j<nofOptions; ++j )
|
joachim99@8
|
1029 {
|
joachim99@69
|
1030 const char* optName = s_pOptions[j].name;
|
joachim99@8
|
1031 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1032 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@69
|
1033 int len2 = strlen(s_argv[i]);
|
joachim99@8
|
1034
|
joachim99@69
|
1035 if( len>0 && ( s_argv[i][1]=='-' && len2-2==len && memcmp( &s_argv[i][2], optName, len )==0 ||
|
joachim99@69
|
1036 len2-1==len && memcmp( &s_argv[i][1], optName, len )==0 ))
|
joachim99@8
|
1037 {
|
joachim99@69
|
1038 if (s_pOptions[j].description == 0) // alias, because without description.
|
joachim99@8
|
1039 {
|
joachim99@8
|
1040 ++j;
|
joachim99@69
|
1041 optName = s_pOptions[j].name;
|
joachim99@8
|
1042 pos = strchr( optName,' ' );
|
joachim99@8
|
1043 }
|
joachim99@8
|
1044 if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param
|
joachim99@8
|
1045 else { s_vOption[j].append("1"); } //set state
|
joachim99@8
|
1046 break;
|
joachim99@8
|
1047 }
|
joachim99@8
|
1048 }
|
joachim99@8
|
1049 if (j==nofOptions)
|
joachim99@8
|
1050 {
|
joachim99@58
|
1051 QString s;
|
joachim99@58
|
1052 s = QString("Unknown option: ") + s_argv[i] + "\n";
|
joachim99@69
|
1053 s += "If KDiff3 should ignore this option, run KDiff3 normally and edit\n"
|
joachim99@69
|
1054 "the \"Command line options to ignore\" in the \"Integration Settings\".\n\n";
|
joachim99@8
|
1055
|
joachim99@58
|
1056 s += "KDiff3-Usage when starting via commandline: \n";
|
joachim99@58
|
1057 s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n";
|
joachim99@58
|
1058 s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n";
|
joachim99@58
|
1059 s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n";
|
joachim99@58
|
1060 s += "- Merging 3 files: \t\tkdiff3 file1 file2 file3 -o outputfile\n";
|
joachim99@58
|
1061 s += " Note that file1 will be treated as base of file2 and file3.\n";
|
joachim99@58
|
1062 s += "\n";
|
joachim99@58
|
1063 s += "If you start without arguments, then a dialog will appear\n";
|
joachim99@58
|
1064 s += "where you can select your files via a filebrowser.\n";
|
joachim99@58
|
1065 s += "\n";
|
joachim99@66
|
1066
|
joachim99@66
|
1067 s += "Options:\n";
|
joachim99@66
|
1068
|
joachim99@66
|
1069 j=0;
|
joachim99@66
|
1070 int pos=s.length();
|
joachim99@66
|
1071 for( j=0; j<nofOptions; ++j )
|
joachim99@66
|
1072 {
|
joachim99@69
|
1073 if ( s_pOptions[j].description!=0 )
|
joachim99@66
|
1074 {
|
joachim99@69
|
1075 if (s_pOptions[j].name[0]!='+')
|
joachim99@66
|
1076 {
|
joachim99@66
|
1077 s += "-";
|
joachim99@69
|
1078 if ( strlen(s_pOptions[j].name)>1 ) s += "-";
|
joachim99@66
|
1079 }
|
joachim99@69
|
1080 s += s_pOptions[j].name;
|
joachim99@66
|
1081 s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) );
|
joachim99@69
|
1082 s += s_pOptions[j].description;
|
joachim99@66
|
1083 s +="\n";
|
joachim99@66
|
1084 pos=s.length();
|
joachim99@66
|
1085 }
|
joachim99@66
|
1086 else
|
joachim99@66
|
1087 {
|
joachim99@66
|
1088 s += "-";
|
joachim99@69
|
1089 if ( strlen(s_pOptions[j].name)>1 ) s += "-";
|
joachim99@69
|
1090 s += s_pOptions[j].name;
|
joachim99@66
|
1091 s += ", ";
|
joachim99@66
|
1092 }
|
joachim99@66
|
1093 }
|
joachim99@69
|
1094
|
joachim99@69
|
1095 s += "\n"+i18n("For more documentation, see the help-menu or the subdirectory doc.")+"\n";
|
joachim99@69
|
1096 #ifdef _WIN32
|
joachim99@58
|
1097 // A windows program has no console
|
joachim99@69
|
1098 if ( 0==QMessageBox::information(0, i18n("KDiff3-Usage"), s, i18n("Ignore"),i18n("Exit") ) )
|
joachim99@69
|
1099 continue;
|
joachim99@58
|
1100 #else
|
joachim99@58
|
1101 std::cerr << s.latin1() << std::endl;
|
joachim99@58
|
1102 #endif
|
joachim99@69
|
1103
|
joachim99@8
|
1104 ::exit(-1);
|
joachim99@8
|
1105 }
|
joachim99@8
|
1106 }
|
joachim99@8
|
1107 else
|
joachim99@8
|
1108 s_vArg.push_back( s_argv[i] );
|
joachim99@8
|
1109 }
|
joachim99@8
|
1110 }
|
joachim99@8
|
1111
|
joachim99@8
|
1112 KConfig* KApplication::config()
|
joachim99@8
|
1113 {
|
joachim99@8
|
1114 return &m_config;
|
joachim99@8
|
1115 }
|
joachim99@8
|
1116
|
joachim99@8
|
1117 bool KApplication::isRestored()
|
joachim99@8
|
1118 {
|
joachim99@8
|
1119 return false;
|
joachim99@8
|
1120 }
|
joachim99@8
|
1121
|
joachim99@8
|
1122 KApplication* KApplication::kApplication()
|
joachim99@8
|
1123 {
|
joachim99@8
|
1124 return kapp;
|
joachim99@8
|
1125 }
|
joachim99@8
|
1126
|
joachim99@8
|
1127 KIconLoader* KApplication::iconLoader()
|
joachim99@8
|
1128 {
|
joachim99@8
|
1129 return &m_iconLoader;
|
joachim99@8
|
1130 }
|
joachim99@8
|
1131
|
joachim99@8
|
1132
|
joachim99@8
|
1133 namespace KIO
|
joachim99@8
|
1134 {
|
joachim99@8
|
1135 SimpleJob* mkdir( KURL ){return 0;}
|
joachim99@8
|
1136 SimpleJob* rmdir( KURL ){return 0;}
|
joachim99@8
|
1137 SimpleJob* file_delete( KURL, bool ){return 0;}
|
joachim99@8
|
1138 FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1139 FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1140 CopyJob* link( KURL, KURL, bool ) {return 0;}
|
joachim99@8
|
1141 ListJob* listRecursive( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1142 ListJob* listDir( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1143 StatJob* stat( KURL, bool, int, bool ){return 0;}
|
joachim99@8
|
1144 TransferJob* get( KURL, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1145 TransferJob* put( KURL, int, bool, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1146 };
|
joachim99@8
|
1147
|
joachim99@8
|
1148 KActionCollection* KParts::Part::actionCollection()
|
joachim99@8
|
1149 {
|
joachim99@8
|
1150 return 0;
|
joachim99@8
|
1151 }
|
joachim99@8
|
1152
|
joachim99@8
|
1153 KApplication* KParts::Part::instance()
|
joachim99@8
|
1154 {
|
joachim99@8
|
1155 return kapp;
|
joachim99@8
|
1156 }
|
joachim99@8
|
1157
|
joachim99@8
|
1158
|
joachim99@8
|
1159 KLibLoader* KLibLoader::self()
|
joachim99@8
|
1160 {
|
joachim99@8
|
1161 static KLibLoader ll;
|
joachim99@8
|
1162 return ≪
|
joachim99@8
|
1163 }
|
joachim99@8
|
1164
|
joachim99@8
|
1165 extern "C" void* init_libkdiff3part();
|
joachim99@8
|
1166 KLibFactory* KLibLoader::factory(QString const&)
|
joachim99@8
|
1167 {
|
joachim99@8
|
1168 return (KLibFactory*) init_libkdiff3part();
|
joachim99@8
|
1169 }
|
joachim99@8
|
1170
|
joachim99@68
|
1171 QObject* KLibFactory::create(QObject* pParent, const QString& name, const QString& classname )
|
joachim99@8
|
1172 {
|
joachim99@8
|
1173 KParts::Factory* f = dynamic_cast<KParts::Factory*>(this);
|
joachim99@8
|
1174 if (f!=0)
|
joachim99@68
|
1175 return f->createPartObject( (QWidget*)pParent, name.ascii(),
|
joachim99@68
|
1176 pParent, name.ascii(),
|
joachim99@68
|
1177 classname.ascii(), QStringList() );
|
joachim99@8
|
1178 else
|
joachim99@8
|
1179 return 0;
|
joachim99@8
|
1180 }
|
joachim99@8
|
1181
|
joachim99@8
|
1182
|
joachim99@8
|
1183
|
joachim99@58
|
1184
|
joachim99@8
|
1185 #include "kreplacements.moc"
|