Mercurial > hg > easyhg
comparison mainwindow.cpp @ 175:6def8bf3be44
* Start implementing Settings dialog; add Test function to run on startup to make sure hg works
| author | Chris Cannam |
|---|---|
| date | Thu, 16 Dec 2010 17:32:25 +0000 |
| parents | 4dc802a4d5ae |
| children | bb89bcd8986b |
comparison
equal
deleted
inserted
replaced
| 174:4dc802a4d5ae | 175:6def8bf3be44 |
|---|---|
| 37 #include "colourset.h" | 37 #include "colourset.h" |
| 38 #include "debug.h" | 38 #include "debug.h" |
| 39 #include "logparser.h" | 39 #include "logparser.h" |
| 40 #include "confirmcommentdialog.h" | 40 #include "confirmcommentdialog.h" |
| 41 #include "incomingdialog.h" | 41 #include "incomingdialog.h" |
| 42 #include "settingsdialog.h" | |
| 42 | 43 |
| 43 | 44 |
| 44 MainWindow::MainWindow(QString myDirPath) : | 45 MainWindow::MainWindow(QString myDirPath) : |
| 45 m_myDirPath(myDirPath) | 46 m_myDirPath(myDirPath) |
| 46 { | 47 { |
| 97 | 98 |
| 98 if (workFolderPath == "") { | 99 if (workFolderPath == "") { |
| 99 open(); | 100 open(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 hgQueryPaths(); | 103 hgTest(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 | 106 |
| 106 void MainWindow::closeEvent(QCloseEvent *) | 107 void MainWindow::closeEvent(QCloseEvent *) |
| 107 { | 108 { |
| 157 { | 158 { |
| 158 clearState(); | 159 clearState(); |
| 159 hgQueryPaths(); | 160 hgQueryPaths(); |
| 160 } | 161 } |
| 161 | 162 |
| 163 void MainWindow::hgTest() | |
| 164 { | |
| 165 QStringList params; | |
| 166 params << "--version"; | |
| 167 runner->requestAction(HgAction(ACT_TEST_HG, m_myDirPath, params)); | |
| 168 } | |
| 169 | |
| 162 void MainWindow::hgStat() | 170 void MainWindow::hgStat() |
| 163 { | 171 { |
| 164 QStringList params; | 172 QStringList params; |
| 165 params << "stat" << "-ardum"; | 173 params << "stat" << "-ardum"; |
| 166 | 174 |
| 393 } | 401 } |
| 394 | 402 |
| 395 void MainWindow::findDiffBinaryName() | 403 void MainWindow::findDiffBinaryName() |
| 396 { | 404 { |
| 397 QSettings settings; | 405 QSettings settings; |
| 406 settings.beginGroup("Locations"); | |
| 398 QString diff = settings.value("extdiffbinary", "").toString(); | 407 QString diff = settings.value("extdiffbinary", "").toString(); |
| 399 if (diff == "") { | 408 if (diff == "") { |
| 400 QStringList bases; | 409 QStringList bases; |
| 401 bases << "opendiff" << "kompare" << "kdiff3" << "meld"; | 410 bases << "opendiff" << "kompare" << "kdiff3" << "meld"; |
| 402 bool found = false; | 411 bool found = false; |
| 417 } | 426 } |
| 418 | 427 |
| 419 void MainWindow::findMergeBinaryName() | 428 void MainWindow::findMergeBinaryName() |
| 420 { | 429 { |
| 421 QSettings settings; | 430 QSettings settings; |
| 431 settings.beginGroup("Locations"); | |
| 422 QString merge = settings.value("mergebinary", "").toString(); | 432 QString merge = settings.value("mergebinary", "").toString(); |
| 423 if (merge == "") { | 433 if (merge == "") { |
| 424 QStringList bases; | 434 QStringList bases; |
| 425 bases << "fmdiff3" << "meld" << "diffuse" << "kdiff3"; | 435 bases << "fmdiff3" << "meld" << "diffuse" << "kdiff3"; |
| 426 bool found = false; | 436 bool found = false; |
| 1082 return true; | 1092 return true; |
| 1083 } | 1093 } |
| 1084 | 1094 |
| 1085 void MainWindow::settings() | 1095 void MainWindow::settings() |
| 1086 { | 1096 { |
| 1087 /*!!! | |
| 1088 SettingsDialog *settingsDlg = new SettingsDialog(this); | 1097 SettingsDialog *settingsDlg = new SettingsDialog(this); |
| 1089 settingsDlg->setModal(true); | |
| 1090 settingsDlg->exec(); | 1098 settingsDlg->exec(); |
| 1091 hgTabs -> clearLists(); | |
| 1092 enableDisableActions(); | |
| 1093 hgStat(); | |
| 1094 */ | |
| 1095 } | 1099 } |
| 1096 | 1100 |
| 1097 #define STDOUT_NEEDS_BIG_WINDOW 512 | 1101 #define STDOUT_NEEDS_BIG_WINDOW 512 |
| 1098 #define SMALL_WND_W 500 | 1102 #define SMALL_WND_W 500 |
| 1099 #define SMALL_WND_H 300 | 1103 #define SMALL_WND_H 300 |
| 1176 hgStat(); | 1180 hgStat(); |
| 1177 } | 1181 } |
| 1178 | 1182 |
| 1179 QString MainWindow::format3(QString head, QString intro, QString code) | 1183 QString MainWindow::format3(QString head, QString intro, QString code) |
| 1180 { | 1184 { |
| 1181 code = xmlEncode(code).replace("\n", "<br>").replace(" ", " "); | 1185 code = xmlEncode(code).replace("\n", "<br>").replace("-", "‑").replace(" ", " "); |
| 1182 if (intro == "") { | 1186 if (intro == "") { |
| 1183 return QString("<qt><h3>%1</h3><p><code>%2</code></p>") | 1187 return QString("<qt><h3>%1</h3><p><code>%2</code></p>") |
| 1184 .arg(head).arg(code); | 1188 .arg(head).arg(code); |
| 1185 } else if (code == "") { | 1189 } else if (code == "") { |
| 1186 return QString("<qt><h3>%1</h3><p>%2</p>") | 1190 return QString("<qt><h3>%1</h3><p>%2</p>") |
| 1289 // Some commands we just have to ignore bad return values from: | 1293 // Some commands we just have to ignore bad return values from: |
| 1290 | 1294 |
| 1291 switch(action.action) { | 1295 switch(action.action) { |
| 1292 case ACT_NONE: | 1296 case ACT_NONE: |
| 1293 // uh huh | 1297 // uh huh |
| 1298 return; | |
| 1299 case ACT_TEST_HG: | |
| 1300 QMessageBox::warning | |
| 1301 (this, tr("Failed to run Mercurial"), | |
| 1302 format3(tr("Failed to run Mercurial"), | |
| 1303 tr("The Mercurial program either could not be found or failed to run.<br>This may indicate a problem with the Mercurial installation, or with the EasyHg interaction extension.<br><br>The test command said:"), | |
| 1304 output)); | |
| 1305 settings(); | |
| 1294 return; | 1306 return; |
| 1295 case ACT_INCOMING: | 1307 case ACT_INCOMING: |
| 1296 // returns non-zero code if the check was successful but there | 1308 // returns non-zero code if the check was successful but there |
| 1297 // are no changes pending | 1309 // are no changes pending |
| 1298 if (output.trimmed() == "") showIncoming(""); | 1310 if (output.trimmed() == "") showIncoming(""); |
| 1348 bool headsChanged = false; | 1360 bool headsChanged = false; |
| 1349 QStringList oldHeadIds; | 1361 QStringList oldHeadIds; |
| 1350 | 1362 |
| 1351 switch (action) { | 1363 switch (action) { |
| 1352 | 1364 |
| 1365 case ACT_TEST_HG: | |
| 1366 break; | |
| 1367 | |
| 1353 case ACT_QUERY_PATHS: | 1368 case ACT_QUERY_PATHS: |
| 1354 { | 1369 { |
| 1355 DEBUG << "stdout is " << output << endl; | 1370 DEBUG << "stdout is " << output << endl; |
| 1356 LogParser lp(output, "="); | 1371 LogParser lp(output, "="); |
| 1357 LogList ll = lp.parse(); | 1372 LogList ll = lp.parse(); |
| 1531 // of whichever sequence is in use. | 1546 // of whichever sequence is in use. |
| 1532 | 1547 |
| 1533 bool noMore = false; | 1548 bool noMore = false; |
| 1534 | 1549 |
| 1535 switch (action) { | 1550 switch (action) { |
| 1551 | |
| 1552 case ACT_TEST_HG: | |
| 1553 hgQueryPaths(); | |
| 1554 break; | |
| 1536 | 1555 |
| 1537 case ACT_QUERY_PATHS: | 1556 case ACT_QUERY_PATHS: |
| 1538 hgQueryBranch(); | 1557 hgQueryBranch(); |
| 1539 break; | 1558 break; |
| 1540 | 1559 |
