Mercurial > hg > easyhg
comparison confirmcommentdialog.cpp @ 104:af314dd436d5
* Slightly more useful commit dialog
author | Chris Cannam |
---|---|
date | Thu, 25 Nov 2010 14:30:40 +0000 |
parents | 0bd32aedc6f6 |
children | 1928f9b408e6 |
comparison
equal
deleted
inserted
replaced
103:0bd32aedc6f6 | 104:af314dd436d5 |
---|---|
17 | 17 |
18 #include "confirmcommentdialog.h" | 18 #include "confirmcommentdialog.h" |
19 | 19 |
20 #include <QMessageBox> | 20 #include <QMessageBox> |
21 #include <QInputDialog> | 21 #include <QInputDialog> |
22 #include <QGridLayout> | |
23 #include <QLabel> | |
24 #include <QTextEdit> | |
25 #include <QDialogButtonBox> | |
22 | 26 |
23 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, | 27 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, |
24 QString title, | 28 QString title, |
25 QString introText, | 29 QString introText, |
26 QString introTextWithCount, | 30 QString introTextWithCount, |
48 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, | 52 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, |
49 QString title, | 53 QString title, |
50 QString introText, | 54 QString introText, |
51 QString introTextWithCount, | 55 QString introTextWithCount, |
52 QStringList files, | 56 QStringList files, |
53 QString &comment) | 57 QString &comment, |
58 bool longComment) | |
54 { | 59 { |
55 QString text; | 60 QString text; |
56 if (files.size() <= 10) { | 61 if (files.size() <= 10) { |
57 text = "<qt>" + introText; | 62 text = "<qt>" + introText; |
58 text += "<p><ul>"; | 63 text += "<p><ul>"; |
61 } | 66 } |
62 text += "</ul><p>Please enter your comment:</qt>"; | 67 text += "</ul><p>Please enter your comment:</qt>"; |
63 } else { | 68 } else { |
64 text = "<qt>" + introText.arg(files.size()); | 69 text = "<qt>" + introText.arg(files.size()); |
65 } | 70 } |
66 return confirmAndComment(parent, title, text, comment); | 71 return confirmAndComment(parent, title, text, comment, longComment); |
67 } | 72 } |
68 | 73 |
69 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, | 74 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent, |
70 QString title, | 75 QString title, |
71 QString introText, | 76 QString introText, |
72 QString &comment) | 77 QString &comment, |
78 bool longComment) | |
73 { | 79 { |
74 bool ok = false; | 80 bool ok = false; |
75 //!!! ok, for comments need more than one line | 81 if (!longComment) { |
76 comment = QInputDialog::getText(parent, title, introText, | 82 comment = QInputDialog::getText(parent, title, introText, |
77 QLineEdit::Normal, comment, &ok); | 83 QLineEdit::Normal, comment, &ok); |
84 } else { | |
85 QDialog *d = new QDialog(parent); | |
86 d->setWindowTitle(title); | |
87 QGridLayout *layout = new QGridLayout; | |
88 d->setLayout(layout); | |
89 QLabel *label = new QLabel(introText); | |
90 layout->addWidget(label, 0, 0); | |
91 QTextEdit *textEdit = new QTextEdit; | |
92 textEdit->setAcceptRichText(false); | |
93 layout->addWidget(textEdit, 1, 0); | |
94 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | | |
95 QDialogButtonBox::Cancel); | |
96 layout->addWidget(bbox, 2, 0); | |
97 QObject::connect(bbox, SIGNAL(accepted()), d, SLOT(accept())); | |
98 QObject::connect(bbox, SIGNAL(rejected()), d, SLOT(reject())); | |
99 if (d->exec() == QDialog::Accepted) { | |
100 comment = textEdit->document()->toPlainText(); | |
101 ok = true; | |
102 } | |
103 } | |
78 return ok; | 104 return ok; |
79 } | 105 } |