diff mainwindow.cpp @ 126:f41bbd0c7c27

* Add confirm dialogs for pull and push
author Chris Cannam
date Mon, 29 Nov 2010 17:11:29 +0000
parents 63c2f3f61c79
children 758471b71721
line wrap: on
line diff
--- a/mainwindow.cpp	Mon Nov 29 17:03:17 2010 +0000
+++ b/mainwindow.cpp	Mon Nov 29 17:11:29 2010 +0000
@@ -587,24 +587,34 @@
     runner->requestAction(HgAction(ACT_INCOMING, workFolderPath, params));
 }
 
-
 void MainWindow::hgPull()
 {
-    QStringList params;
+    if (QMessageBox::question
+        (this, tr("Confirm pull"),
+         format3(tr("Confirm pull from remote repository"),
+                 tr("You are about to pull from the following remote repository:"),
+                 remoteRepoPath),
+         QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
 
-    params << "pull" << remoteRepoPath;
-
-    runner->requestAction(HgAction(ACT_PULL, workFolderPath, params));
+        QStringList params;
+        params << "pull" << remoteRepoPath;
+        runner->requestAction(HgAction(ACT_PULL, workFolderPath, params));
+    }
 }
 
-
 void MainWindow::hgPush()
 {
-    QStringList params;
+    if (QMessageBox::question
+        (this, tr("Confirm push"),
+         format3(tr("Confirm push to remote repository"),
+                 tr("You are about to push to the following remote repository:"),
+                 remoteRepoPath),
+         QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
 
-    params << "push" << remoteRepoPath;
-
-    runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
+        QStringList params;
+        params << "push" << remoteRepoPath;
+        runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
+    }
 }
 
 QString MainWindow::listAllUpIpV4Addresses()
@@ -1043,6 +1053,9 @@
     if (intro == "") {
         return QString("<qt><h3>%1</h3><code>%2</code>")
             .arg(head).arg(xmlEncode(code).replace("\n", "<br>"));
+    } else if (code == "") {
+        return QString("<qt><h3>%1</h3><p>%2</p>")
+            .arg(head).arg(intro);
     } else {
         return QString("<qt><h3>%1</h3><p>%2</p><code>%3</code>")
             .arg(head).arg(intro).arg(xmlEncode(code).replace("\n", "<br>"));