Mercurial > hg > easyhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
108:8ae3b44c0073 | 109:1721c580c10e |
---|---|
14 License, or (at your option) any later version. See the file | 14 License, or (at your option) any later version. See the file |
15 COPYING included with this distribution for more information. | 15 COPYING included with this distribution for more information. |
16 */ | 16 */ |
17 | 17 |
18 #include "confirmcommentdialog.h" | 18 #include "confirmcommentdialog.h" |
19 #include "common.h" | |
19 | 20 |
20 #include <QMessageBox> | 21 #include <QMessageBox> |
21 #include <QInputDialog> | 22 #include <QInputDialog> |
22 #include <QGridLayout> | 23 #include <QGridLayout> |
23 #include <QLabel> | 24 #include <QLabel> |
62 QString ConfirmCommentDialog::getComment() const | 63 QString ConfirmCommentDialog::getComment() const |
63 { | 64 { |
64 return m_textEdit->document()->toPlainText(); | 65 return m_textEdit->document()->toPlainText(); |
65 } | 66 } |
66 | 67 |
68 QString ConfirmCommentDialog::buildFilesText(QString intro, QStringList files) | |
69 { | |
70 QString text; | |
71 text = "<qt>" + intro; | |
72 text += "<p><code>"; | |
73 foreach (QString file, files) { | |
74 text += " " + xmlEncode(file) + "<br>"; | |
75 } | |
76 text += "</code></qt>"; | |
77 return text; | |
78 } | |
79 | |
67 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, | 80 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, |
68 QString title, | 81 QString title, |
69 QString introText, | 82 QString introText, |
70 QString introTextWithCount, | 83 QString introTextWithCount, |
71 QStringList files) | 84 QStringList files) |
72 { | 85 { |
73 QString text; | 86 QString text; |
74 if (files.size() <= 10) { | 87 if (files.size() <= 10) { |
75 text = "<qt>" + introText; | 88 text = buildFilesText(introText, files); |
76 text += "<code>"; | |
77 foreach (QString file, files) { | |
78 text += file + "<br>"; | |
79 } | |
80 text += "</code></qt>"; | |
81 } else { | 89 } else { |
82 text = "<qt>" + introText.arg(files.size()); | 90 text = "<qt>" + introTextWithCount.arg(files.size()) + "</qt>"; |
83 } | 91 } |
84 return (QMessageBox::information(parent, | 92 return (QMessageBox::information(parent, |
85 title, | 93 title, |
86 text, | 94 text, |
87 QMessageBox::Ok | QMessageBox::Cancel, | 95 QMessageBox::Ok | QMessageBox::Cancel, |
88 QMessageBox::Ok) | 96 QMessageBox::Ok) |
89 == QMessageBox::Ok); | 97 == QMessageBox::Ok); |
98 } | |
99 | |
100 bool ConfirmCommentDialog::confirmDangerousFilesAction(QWidget *parent, | |
101 QString title, | |
102 QString introText, | |
103 QString introTextWithCount, | |
104 QStringList files) | |
105 { | |
106 QString text; | |
107 if (files.size() <= 10) { | |
108 text = buildFilesText(introText, files); | |
109 } else { | |
110 text = "<qt>" + introTextWithCount.arg(files.size()) + "</qt>"; | |
111 } | |
112 return (QMessageBox::warning(parent, | |
113 title, | |
114 text, | |
115 QMessageBox::Ok | QMessageBox::Cancel, | |
116 QMessageBox::Cancel) | |
117 == QMessageBox::Ok); | |
118 } | |
119 | |
120 bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, | |
121 QString title, | |
122 QString introText, | |
123 QString introTextWithCount, | |
124 QStringList files, | |
125 QString &comment) | |
126 { | |
127 return confirmAndComment(parent, title, introText, | |
128 introTextWithCount, files, comment, false); | |
129 } | |
130 | |
131 bool ConfirmCommentDialog::confirmAndGetLongComment(QWidget *parent, | |
132 QString title, | |
133 QString introText, | |
134 QString introTextWithCount, | |
135 QStringList files, | |
136 QString &comment) | |
137 { | |
138 return confirmAndComment(parent, title, introText, | |
139 introTextWithCount, files, comment, true); | |
90 } | 140 } |
91 | 141 |
92 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, | 142 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, |
93 QString title, | 143 QString title, |
94 QString introText, | 144 QString introText, |
97 QString &comment, | 147 QString &comment, |
98 bool longComment) | 148 bool longComment) |
99 { | 149 { |
100 QString text; | 150 QString text; |
101 if (files.size() <= 10) { | 151 if (files.size() <= 10) { |
102 text = "<qt>" + introText; | 152 text = buildFilesText(introText, files); |
103 text += "<p><ul>"; | |
104 foreach (QString file, files) { | |
105 text += "<li>" + file + "</li>"; | |
106 } | |
107 text += "</ul><p>Please enter your comment:</qt>"; | |
108 } else { | 153 } else { |
109 text = "<qt>" + introText.arg(files.size()); | 154 text = "<qt>" + introTextWithCount.arg(files.size()); |
110 } | 155 } |
156 text += tr("<p>Please enter your comment:</qt>"); | |
111 return confirmAndComment(parent, title, text, comment, longComment); | 157 return confirmAndComment(parent, title, text, comment, longComment); |
158 } | |
159 | |
160 bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, | |
161 QString title, | |
162 QString introText, | |
163 QString &comment) | |
164 { | |
165 return confirmAndComment(parent, title, introText, comment, false); | |
166 } | |
167 | |
168 bool ConfirmCommentDialog::confirmAndGetLongComment(QWidget *parent, | |
169 QString title, | |
170 QString introText, | |
171 QString &comment) | |
172 { | |
173 return confirmAndComment(parent, title, introText, comment, true); | |
112 } | 174 } |
113 | 175 |
114 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, | 176 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, |
115 QString title, | 177 QString title, |
116 QString introText, | 178 QString introText, |