changeset 104:af314dd436d5

* Slightly more useful commit dialog
author Chris Cannam
date Thu, 25 Nov 2010 14:30:40 +0000
parents 0bd32aedc6f6
children 1928f9b408e6
files confirmcommentdialog.cpp confirmcommentdialog.h hgrunner.cpp mainwindow.cpp
diffstat 4 files changed, 64 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/confirmcommentdialog.cpp	Wed Nov 24 22:44:40 2010 +0000
+++ b/confirmcommentdialog.cpp	Thu Nov 25 14:30:40 2010 +0000
@@ -19,6 +19,10 @@
 
 #include <QMessageBox>
 #include <QInputDialog>
+#include <QGridLayout>
+#include <QLabel>
+#include <QTextEdit>
+#include <QDialogButtonBox>
 
 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent,
                                               QString title,
@@ -50,7 +54,8 @@
                                              QString introText,
                                              QString introTextWithCount,
                                              QStringList files,
-                                             QString &comment)
+                                             QString &comment,
+                                             bool longComment)
 {
     QString text;
     if (files.size() <= 10) {
@@ -63,17 +68,38 @@
     } else {
         text = "<qt>" + introText.arg(files.size());
     }
-    return confirmAndComment(parent, title, text, comment);
+    return confirmAndComment(parent, title, text, comment, longComment);
 }
 
 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent,
                                              QString title,
                                              QString introText,
-                                             QString &comment)
+                                             QString &comment,
+                                             bool longComment)
 {
     bool ok = false;
-    //!!! ok, for comments need more than one line
-    comment = QInputDialog::getText(parent, title, introText,
-                                    QLineEdit::Normal, comment, &ok);
+    if (!longComment) {
+        comment = QInputDialog::getText(parent, title, introText,
+                                        QLineEdit::Normal, comment, &ok);
+    } else {
+        QDialog *d = new QDialog(parent);
+        d->setWindowTitle(title);
+        QGridLayout *layout = new QGridLayout;
+        d->setLayout(layout);
+        QLabel *label = new QLabel(introText);
+        layout->addWidget(label, 0, 0);
+        QTextEdit *textEdit = new QTextEdit;
+        textEdit->setAcceptRichText(false);
+        layout->addWidget(textEdit, 1, 0);
+        QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
+                                                      QDialogButtonBox::Cancel);
+        layout->addWidget(bbox, 2, 0);
+        QObject::connect(bbox, SIGNAL(accepted()), d, SLOT(accept()));
+        QObject::connect(bbox, SIGNAL(rejected()), d, SLOT(reject()));
+        if (d->exec() == QDialog::Accepted) {
+            comment = textEdit->document()->toPlainText();
+            ok = true;
+        }
+    }
     return ok;
 }
--- a/confirmcommentdialog.h	Wed Nov 24 22:44:40 2010 +0000
+++ b/confirmcommentdialog.h	Thu Nov 25 14:30:40 2010 +0000
@@ -36,12 +36,14 @@
                                   QString introText,
                                   QString introTextWithCount,
                                   QStringList files,
-                                  QString &comment);
+                                  QString &comment,
+                                  bool longComment);
 
     static bool confirmAndComment(QWidget *parent,
                                   QString title,
                                   QString introText,
-                                  QString &comment);
+                                  QString &comment,
+                                  bool longComment);
 
 };
 
--- a/hgrunner.cpp	Wed Nov 24 22:44:40 2010 +0000
+++ b/hgrunner.cpp	Thu Nov 25 14:30:40 2010 +0000
@@ -47,6 +47,7 @@
     QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
     env.insert("LANG", "en_US.utf8");
     env.insert("LC_ALL", "en_US.utf8");
+    env.insert("HGPLAIN", "1");
     m_proc->setProcessEnvironment(env);
 
     m_proc->setProcessChannelMode(QProcess::MergedChannels);
@@ -86,14 +87,11 @@
 
 void HgRunner::started()
 {
+    DEBUG << "started" << endl;
     /*
-    if (procInput) procInput->write("blah\n");
-    if (procInput) procInput->write("blah\n");
-    if (procInput) {
-        procInput->close();
-//        ::close(ptyMasterFd);
-    }
-    proc -> closeWriteChannel();
+    m_proc->write("blah\n");
+    m_proc->write("blah\n");
+    m_proc -> closeWriteChannel();
     */
 }
 
@@ -230,6 +228,14 @@
 
 void HgRunner::startHgCommand(QString workingDir, QStringList params)
 {
+#ifdef Q_OS_WIN32
+    // This at least means we won't block on the non-working password prompt
+    params.push_front("ui.interactive=false");
+#else
+    // password prompt should work here
+    params.push_front("ui.interactive=true");
+#endif
+    params.push_front("--config");
     startCommand(getHgBinaryName(), workingDir, params);
 }
 
--- a/mainwindow.cpp	Wed Nov 24 22:44:40 2010 +0000
+++ b/mainwindow.cpp	Thu Nov 25 14:30:40 2010 +0000
@@ -336,7 +336,8 @@
                                                     tr("About to commit the following files:"),
                                                     tr("About to commit %1 files."),
                                                     files,
-                                                    comment)) {
+                                                    comment,
+                                                    true)) {
 
             //!!! do something more sensible when the comment is empty
             // (i.e. tell the user about it?)
@@ -383,7 +384,8 @@
         if (ConfirmCommentDialog::confirmAndComment(this,
                                                     tr("Tag"),
                                                     tr("Enter tag:"),
-                                                    tag)) {
+                                                    tag,
+                                                    false)) {
             if (!tag.isEmpty()) //!!! do something better if it is empty
             {
                 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
@@ -577,8 +579,19 @@
     {
         QStringList params;
 
+        if (!QDir(workFolderPath).exists()) {
+            if (!QDir().mkpath(workFolderPath)) {
+                DEBUG << "hgCloneFromRemote: Failed to create target path "
+                        << workFolderPath << endl;
+                //!!! report error
+                return;
+            }
+        }
+
         params << "clone" << remoteRepoPath << workFolderPath;
 
+        hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
+
         runner -> startHgCommand(workFolderPath, params);
         runningAction = ACT_CLONEFROMREMOTE;
     }