comparison mainwindow.cpp @ 293:7b4f42cfc596

Merge from branch "more_information_dialog"
author Chris Cannam
date Mon, 21 Feb 2011 18:17:18 +0000
parents 37f67999b661 2e34e7ee7baf
children fc9d411ff6e7
comparison
equal deleted inserted replaced
292:a1c8630a0057 293:7b4f42cfc596
41 #include "debug.h" 41 #include "debug.h"
42 #include "logparser.h" 42 #include "logparser.h"
43 #include "confirmcommentdialog.h" 43 #include "confirmcommentdialog.h"
44 #include "incomingdialog.h" 44 #include "incomingdialog.h"
45 #include "settingsdialog.h" 45 #include "settingsdialog.h"
46 #include "moreinformationdialog.h"
46 #include "version.h" 47 #include "version.h"
47 48
48 49
49 MainWindow::MainWindow(QString myDirPath) : 50 MainWindow::MainWindow(QString myDirPath) :
50 m_myDirPath(myDirPath), 51 m_myDirPath(myDirPath),
857 858
858 void MainWindow::hgPull() 859 void MainWindow::hgPull()
859 { 860 {
860 if (ConfirmCommentDialog::confirm 861 if (ConfirmCommentDialog::confirm
861 (this, tr("Confirm pull"), 862 (this, tr("Confirm pull"),
862 format3(tr("Confirm pull from remote repository"), 863 format3(tr("Pull from remote repository?"),
863 tr("You are about to pull changes from the following remote repository:"), 864 tr("You are about to pull changes from the following remote repository:"),
864 m_remoteRepoPath), 865 m_remoteRepoPath),
865 tr("Pull"))) { 866 tr("Pull"))) {
866 867
867 QStringList params; 868 QStringList params;
872 873
873 void MainWindow::hgPush() 874 void MainWindow::hgPush()
874 { 875 {
875 if (ConfirmCommentDialog::confirm 876 if (ConfirmCommentDialog::confirm
876 (this, tr("Confirm push"), 877 (this, tr("Confirm push"),
877 format3(tr("Confirm push to remote repository"), 878 format3(tr("Push to remote repository?"),
878 tr("You are about to push your changes to the following remote repository:"), 879 tr("You are about to push your changes to the following remote repository:"),
879 m_remoteRepoPath), 880 m_remoteRepoPath),
880 tr("Push"))) { 881 tr("Push"))) {
881 882
882 QStringList params; 883 QStringList params;
1541 if (!m_fsWatcherSuspended) { 1542 if (!m_fsWatcherSuspended) {
1542 hgStat(); 1543 hgStat();
1543 } 1544 }
1544 } 1545 }
1545 1546
1547 QString MainWindow::format1(QString head)
1548 {
1549 return QString("<qt><h3>%1</h3></qt>").arg(head);
1550 }
1551
1546 QString MainWindow::format3(QString head, QString intro, QString code) 1552 QString MainWindow::format3(QString head, QString intro, QString code)
1547 { 1553 {
1548 code = xmlEncode(code).replace("\n", "<br>") 1554 code = xmlEncode(code).replace("\n", "<br>")
1549 #ifndef Q_OS_WIN32 1555 #ifndef Q_OS_WIN32
1550 // The hard hyphen comes out funny on Windows 1556 // The hard hyphen comes out funny on Windows
1583 } 1589 }
1584 } 1590 }
1585 1591
1586 void MainWindow::showPushResult(QString output) 1592 void MainWindow::showPushResult(QString output)
1587 { 1593 {
1594 QString head;
1588 QString report; 1595 QString report;
1589 int n = extractChangeCount(output); 1596 int n = extractChangeCount(output);
1590 if (n > 0) { 1597 if (n > 0) {
1591 report = tr("Pushed %n changeset(s)", "", n); 1598 head = tr("Pushed %n changeset(s)", "", n);
1592 } else if (n == 0) { 1599 } else if (n == 0) {
1593 report = tr("No changes to push"); 1600 head = tr("No changes to push");
1601 report = tr("The remote repository already contains all changes that have been committed locally.");
1602 if (hgTabs->canCommit()) {
1603 report = tr("%1<p>You do have some uncommitted changes. If you wish to push those to the remote repository, commit them locally first.").arg(report);
1604 }
1594 } else { 1605 } else {
1595 report = tr("Push complete"); 1606 head = tr("Push complete");
1596 } 1607 }
1597 report = format3(report, tr("The push command output was:"), output);
1598 m_runner->hide(); 1608 m_runner->hide();
1599 QMessageBox::information(this, "Push complete", report); 1609
1610 MoreInformationDialog::information(this, tr("Push complete"),
1611 head, report, output);
1600 } 1612 }
1601 1613
1602 void MainWindow::showPullResult(QString output) 1614 void MainWindow::showPullResult(QString output)
1603 { 1615 {
1616 QString head;
1604 QString report; 1617 QString report;
1605 int n = extractChangeCount(output); 1618 int n = extractChangeCount(output);
1606 if (n > 0) { 1619 if (n > 0) {
1607 report = tr("Pulled %n changeset(s)", "", n); 1620 head = tr("Pulled %n changeset(s)", "", n);
1621 report = tr("New changes will be highlighted in the history. Update to bring these changes into your working copy.");
1608 } else if (n == 0) { 1622 } else if (n == 0) {
1609 report = tr("No changes to pull"); 1623 head = tr("No changes to pull");
1624 report = tr("Your local repository already contains all changes found in the remote repository.");
1610 } else { 1625 } else {
1611 report = tr("Pull complete"); 1626 head = tr("Pull complete");
1612 } 1627 }
1613 report = format3(report, tr("The pull command output was:"), output);
1614 m_runner->hide(); 1628 m_runner->hide();
1615 1629
1616 //!!! and something about updating 1630 runner->hide();
1617 1631
1618 QMessageBox::information(this, "Pull complete", report); 1632 MoreInformationDialog::information(this, tr("Pull complete"),
1633 head, report, output);
1619 } 1634 }
1620 1635
1621 void MainWindow::reportNewRemoteHeads(QString output) 1636 void MainWindow::reportNewRemoteHeads(QString output)
1622 { 1637 {
1623 bool headsAreLocal = false; 1638 bool headsAreLocal = false;
1638 headsAreLocal = true; 1653 headsAreLocal = true;
1639 } 1654 }
1640 } 1655 }
1641 1656
1642 if (headsAreLocal) { 1657 if (headsAreLocal) {
1643 QMessageBox::warning 1658 MoreInformationDialog::warning
1644 (this, tr("Push failed"), 1659 (this,
1645 format3(tr("Push failed"), 1660 tr("Push failed"),
1646 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first.<br><br>The output of the push command was:"), 1661 tr("Push failed"),
1647 output)); 1662 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first."),
1663 output);
1648 } else { 1664 } else {
1649 QMessageBox::warning 1665 MoreInformationDialog::warning
1650 (this, tr("Push failed"), 1666 (this,
1651 format3(tr("Push failed"), 1667 tr("Push failed"),
1652 tr("Your local repository could not be pushed to the remote repository.<br><br>The remote repository may have been changed by someone else since you last pushed. Try pulling and merging their changes into your local repository first.<br><br>The output of the push command was:"), 1668 tr("Push failed"),
1653 output)); 1669 tr("Your local repository could not be pushed to the remote repository.<br><br>The remote repository may have been changed by someone else since you last pushed. Try pulling and merging their changes into your local repository first."),
1670 output);
1654 } 1671 }
1655 } 1672 }
1656 1673
1657 void MainWindow::commandStarting(HgAction action) 1674 void MainWindow::commandStarting(HgAction action)
1658 { 1675 {
1684 switch(action.action) { 1701 switch(action.action) {
1685 case ACT_NONE: 1702 case ACT_NONE:
1686 // uh huh 1703 // uh huh
1687 return; 1704 return;
1688 case ACT_TEST_HG: 1705 case ACT_TEST_HG:
1689 QMessageBox::warning 1706 MoreInformationDialog::warning
1690 (this, tr("Failed to run Mercurial"), 1707 (this,
1691 format3(tr("Failed to run Mercurial"), 1708 tr("Failed to run Mercurial"),
1692 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")), 1709 tr("Failed to run Mercurial"),
1693 output)); 1710 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.").arg(setstr),
1711 output);
1694 settings(); 1712 settings();
1695 return; 1713 return;
1696 case ACT_TEST_HG_EXT: 1714 case ACT_TEST_HG_EXT:
1697 QMessageBox::warning 1715 QMessageBox::warning
1698 (this, tr("Failed to run Mercurial"), 1716 (this,
1699 format3(tr("Failed to run Mercurial with extension enabled"), 1717 tr("Failed to run Mercurial"),
1700 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem with EasyMercurial.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1. Note that remote repositories that require authentication may not work if you do this.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")), 1718 tr("Failed to run Mercurial with extension enabled"),
1701 output)); 1719 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem with EasyMercurial.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1. Note that remote repositories that require authentication may not work if you do this.").arg(setstr),
1720 output);
1702 settings(); 1721 settings();
1703 return; 1722 return;
1704 case ACT_CLONEFROMREMOTE: 1723 case ACT_CLONEFROMREMOTE:
1705 // if clone fails, we have no repo 1724 // if clone fails, we have no repo
1706 m_workFolderPath = ""; 1725 m_workFolderPath = "";
1742 if (command == "") command = "hg"; 1761 if (command == "") command = "hg";
1743 foreach (QString arg, action.params) { 1762 foreach (QString arg, action.params) {
1744 command += " " + arg; 1763 command += " " + arg;
1745 } 1764 }
1746 1765
1766 //!!!
1767
1747 QString message = tr("<qt><h3>Command failed</h3>" 1768 QString message = tr("<qt><h3>Command failed</h3>"
1748 "<p>The following command failed:</p>" 1769 "<p>The following command failed:</p>"
1749 "<code>%1</code>" 1770 "<code>%1</code>"
1750 "%2</qt>") 1771 "%2</qt>")
1751 .arg(command) 1772 .arg(command)
1850 1871
1851 case ACT_CLONEFROMREMOTE: 1872 case ACT_CLONEFROMREMOTE:
1852 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); 1873 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
1853 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); 1874 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
1854 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true); 1875 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true);
1855 QMessageBox::information(this, tr("Clone"), tr("<qt><h3>Clone successful</h3><pre>%1</pre>").arg(xmlEncode(output))); 1876 MoreInformationDialog::information
1877 (this,
1878 tr("Clone"),
1879 tr("Clone successful"),
1880 tr("The remote repository <pre>%1</pre> was successfully cloned to the local folder <pre>%2</pre>.").arg(remoteRepoPath).arg(workFolderPath),
1881 output);
1856 enableDisableActions(); 1882 enableDisableActions();
1857 m_shouldHgStat = true; 1883 m_shouldHgStat = true;
1858 break; 1884 break;
1859 1885
1860 case ACT_LOG: 1886 case ACT_LOG: