Mercurial > hg > easyhg
diff confirmcommentdialog.cpp @ 109:1721c580c10e
* Add a queueing mechanism for Hg actions, instead of refusing to start an action if something else is already happening. This is essential now that actions can be prompted by asynchronous events (e.g. filesystem watcher).
* Make Revert behave sensibly
author | Chris Cannam |
---|---|
date | Fri, 26 Nov 2010 12:48:29 +0000 |
parents | 1928f9b408e6 |
children | edab92f3ea0b |
line wrap: on
line diff
--- a/confirmcommentdialog.cpp Thu Nov 25 21:08:17 2010 +0000 +++ b/confirmcommentdialog.cpp Fri Nov 26 12:48:29 2010 +0000 @@ -16,6 +16,7 @@ */ #include "confirmcommentdialog.h" +#include "common.h" #include <QMessageBox> #include <QInputDialog> @@ -64,6 +65,18 @@ return m_textEdit->document()->toPlainText(); } +QString ConfirmCommentDialog::buildFilesText(QString intro, QStringList files) +{ + QString text; + text = "<qt>" + intro; + text += "<p><code>"; + foreach (QString file, files) { + text += " " + xmlEncode(file) + "<br>"; + } + text += "</code></qt>"; + return text; +} + bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, QString title, QString introText, @@ -72,14 +85,9 @@ { QString text; if (files.size() <= 10) { - text = "<qt>" + introText; - text += "<code>"; - foreach (QString file, files) { - text += file + "<br>"; - } - text += "</code></qt>"; + text = buildFilesText(introText, files); } else { - text = "<qt>" + introText.arg(files.size()); + text = "<qt>" + introTextWithCount.arg(files.size()) + "</qt>"; } return (QMessageBox::information(parent, title, @@ -89,6 +97,48 @@ == QMessageBox::Ok); } +bool ConfirmCommentDialog::confirmDangerousFilesAction(QWidget *parent, + QString title, + QString introText, + QString introTextWithCount, + QStringList files) +{ + QString text; + if (files.size() <= 10) { + text = buildFilesText(introText, files); + } else { + text = "<qt>" + introTextWithCount.arg(files.size()) + "</qt>"; + } + return (QMessageBox::warning(parent, + title, + text, + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Cancel) + == QMessageBox::Ok); +} + +bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, + QString title, + QString introText, + QString introTextWithCount, + QStringList files, + QString &comment) +{ + return confirmAndComment(parent, title, introText, + introTextWithCount, files, comment, false); +} + +bool ConfirmCommentDialog::confirmAndGetLongComment(QWidget *parent, + QString title, + QString introText, + QString introTextWithCount, + QStringList files, + QString &comment) +{ + return confirmAndComment(parent, title, introText, + introTextWithCount, files, comment, true); +} + bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, QString title, QString introText, @@ -99,18 +149,30 @@ { QString text; if (files.size() <= 10) { - text = "<qt>" + introText; - text += "<p><ul>"; - foreach (QString file, files) { - text += "<li>" + file + "</li>"; - } - text += "</ul><p>Please enter your comment:</qt>"; + text = buildFilesText(introText, files); } else { - text = "<qt>" + introText.arg(files.size()); + text = "<qt>" + introTextWithCount.arg(files.size()); } + text += tr("<p>Please enter your comment:</qt>"); return confirmAndComment(parent, title, text, comment, longComment); } +bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, + QString title, + QString introText, + QString &comment) +{ + return confirmAndComment(parent, title, introText, comment, false); +} + +bool ConfirmCommentDialog::confirmAndGetLongComment(QWidget *parent, + QString title, + QString introText, + QString &comment) +{ + return confirmAndComment(parent, title, introText, comment, true); +} + bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, QString title, QString introText,