comparison mainwindow.cpp @ 112:4bd17f36d059

* Make diff binary a settings property; some tidying
author Chris Cannam
date Fri, 26 Nov 2010 17:02:55 +0000
parents 1721c580c10e
children 5fc7b4fc77a8
comparison
equal deleted inserted replaced
111:151209bc5bd6 112:4bd17f36d059
29 #include <QToolButton> 29 #include <QToolButton>
30 #include <QSettings> 30 #include <QSettings>
31 #include <QInputDialog> 31 #include <QInputDialog>
32 32
33 #include "mainwindow.h" 33 #include "mainwindow.h"
34 #include "settingsdialog.h"
35 #include "multichoicedialog.h" 34 #include "multichoicedialog.h"
36 #include "startupdialog.h" 35 #include "startupdialog.h"
37 #include "colourset.h" 36 #include "colourset.h"
38 #include "debug.h" 37 #include "debug.h"
39 #include "logparser.h" 38 #include "logparser.h"
78 enableDisableActions(); 77 enableDisableActions();
79 78
80 if (firstStart) { 79 if (firstStart) {
81 startupDialog(); 80 startupDialog();
82 } 81 }
82
83 findDiffBinaryName();
83 84
84 ColourSet *cs = ColourSet::instance(); 85 ColourSet *cs = ColourSet::instance();
85 cs->clearDefaultNames(); 86 cs->clearDefaultNames();
86 cs->addDefaultName(""); 87 cs->addDefaultName("");
87 cs->addDefaultName(getUserInfo()); 88 cs->addDefaultName(getUserInfo());
283 if (files.empty()) files = hgTabs->getAllCommittableFiles(); 284 if (files.empty()) files = hgTabs->getAllCommittableFiles();
284 285
285 if (ConfirmCommentDialog::confirmAndGetLongComment 286 if (ConfirmCommentDialog::confirmAndGetLongComment
286 (this, 287 (this,
287 tr("Commit files"), 288 tr("Commit files"),
288 tr("<h2>Commit files</h2><p>About to commit the following files:"), 289 tr("<h3>Commit files</h3><p>You are about to commit the following files:"),
289 tr("<h2>Commit files</h2><p>About to commit %1 files."), 290 tr("<h3>Commit files</h3><p>You are about to commit %1 files."),
290 files, 291 files,
291 comment)) { 292 comment)) {
292 293
293 if ((justMerged == false) && //!!! review usage of justMerged, and how it interacts with asynchronous request queue 294 if ((justMerged == false) && //!!! review usage of justMerged, and how it interacts with asynchronous request queue
294 !files.empty()) { 295 !files.empty()) {
348 349
349 hgIgnorePath = workFolderPath; 350 hgIgnorePath = workFolderPath;
350 hgIgnorePath += ".hgignore"; 351 hgIgnorePath += ".hgignore";
351 352
352 params << hgIgnorePath; 353 params << hgIgnorePath;
353 354
354 if ((getSystem() == "Linux")) 355 //!!!
355 { 356 #ifdef Q_OS_LINUX
357
356 editorName = "gedit"; 358 editorName = "gedit";
357 } 359
358 else 360 #else
359 { 361
360 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"""; 362 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe""";
361 } 363
364 #endif
362 365
363 HgAction action(ACT_HG_IGNORE, workFolderPath, params); 366 HgAction action(ACT_HG_IGNORE, workFolderPath, params);
364 action.executable = editorName; 367 action.executable = editorName;
365 368
366 runner->requestAction(action); 369 runner->requestAction(action);
367 } 370 }
368 371
369 372 void MainWindow::findDiffBinaryName()
373 {
374 QSettings settings;
375 QString diff = settings.value("extdiffbinary", "").toString();
376 if (diff == "") {
377 QStringList bases;
378 bases << "opendiff" << "kompare" << "kdiff3" << "meld";
379 bool found = false;
380 foreach (QString base, bases) {
381 diff = findExecutable(base);
382 if (diff != base) {
383 found = true;
384 break;
385 }
386 }
387 if (found) {
388 settings.setValue("extdiffbinary", diff);
389 } else {
390 diff = "";
391 }
392 }
393 diffBinaryName = diff;
394 }
370 395
371 void MainWindow::hgFileDiff() 396 void MainWindow::hgFileDiff()
372 { 397 {
373 QStringList params; 398 QStringList params;
374 /*!!! 399 /*!!!
385 } 410 }
386 411
387 412
388 void MainWindow::hgFolderDiff() 413 void MainWindow::hgFolderDiff()
389 { 414 {
390 QStringList params; 415 if (diffBinaryName == "") return;
391 416
392 //Diff parent against working folder (folder diff) 417 QStringList params;
418
419 // Diff parent against working folder (folder diff)
420
393 params << "--config" << "extensions.extdiff=" << "extdiff" << "-p"; 421 params << "--config" << "extensions.extdiff=" << "extdiff" << "-p";
394 422 params << diffBinaryName;
395 params << "kompare"; 423
396
397 // params << "kdiff3";
398 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params)); 424 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
399 } 425 }
400 426
401 427
402 void MainWindow::hgChgSetDiff() 428 void MainWindow::hgChgSetDiff()
463 if (files.empty()) files = hgTabs->getAllRevertableFiles(); 489 if (files.empty()) files = hgTabs->getAllRevertableFiles();
464 490
465 if (ConfirmCommentDialog::confirmDangerousFilesAction 491 if (ConfirmCommentDialog::confirmDangerousFilesAction
466 (this, 492 (this,
467 tr("Revert files"), 493 tr("Revert files"),
468 tr("<h2>Revert files</h2><p>About to revert the following files to their previous committed state. This will <b>throw away any changes</b> that you have made to these files but have not committed."), 494 tr("<h3>Revert files</h3><p>You are about to <b>revert</b> the following files to their previous committed state.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed."),
469 tr("<h2>Revert files</h2><p>About to revert %1 files. This will <b>throw away any changes</b> that you have made to these files but have not committed."), 495 tr("<h3>Revert files</h3><p>You are about to <b>revert</b> %1 files.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed."),
470 files)) { 496 files)) {
471 497
472 if (files.empty()) { 498 if (files.empty()) {
473 params << "revert" << "--no-backup"; 499 params << "revert" << "--no-backup";
474 } else { 500 } else {
1215 workFolderExist = false; 1241 workFolderExist = false;
1216 } else { 1242 } else {
1217 workFolderExist = true; 1243 workFolderExist = true;
1218 } 1244 }
1219 1245
1220 if (!localRepoDir.exists(workFolderPath + "/" + getHgDirName())) { 1246 if (!localRepoDir.exists(workFolderPath + "/.hg")) {
1221 localRepoActionsEnabled = false; 1247 localRepoActionsEnabled = false;
1222 localRepoExist = false; 1248 localRepoExist = false;
1223 } 1249 }
1224 1250
1225 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled); 1251 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
1230 if (tabPage != WORKTAB) 1256 if (tabPage != WORKTAB)
1231 { 1257 {
1232 localRepoActionsEnabled = false; 1258 localRepoActionsEnabled = false;
1233 } 1259 }
1234 */ 1260 */
1261 bool haveDiff = (diffBinaryName != "");
1262
1235 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true)); 1263 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
1236 hgStatAct -> setEnabled(localRepoActionsEnabled); 1264 hgStatAct -> setEnabled(localRepoActionsEnabled);
1237 hgFileDiffAct -> setEnabled(localRepoActionsEnabled); 1265 hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
1238 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled); 1266 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
1239 hgRevertAct -> setEnabled(localRepoActionsEnabled); 1267 hgRevertAct -> setEnabled(localRepoActionsEnabled);
1240 hgAddAct -> setEnabled(localRepoActionsEnabled); 1268 hgAddAct -> setEnabled(localRepoActionsEnabled);
1241 hgRemoveAct -> setEnabled(localRepoActionsEnabled); 1269 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
1242 hgUpdateAct -> setEnabled(localRepoActionsEnabled); 1270 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
1243 hgCommitAct -> setEnabled(localRepoActionsEnabled); 1271 hgCommitAct -> setEnabled(localRepoActionsEnabled);