Mercurial > hg > easyhg
comparison confirmcommentdialog.cpp @ 307:5b4aa1c24407 new-branches-with-status-outside-tabs
Merge branch status_outside_tabs into branch new-branches, and make a new branch
author | Chris Cannam |
---|---|
date | Mon, 28 Feb 2011 13:09:37 +0000 |
parents | fd9dc5a457d8 |
children |
comparison
equal
deleted
inserted
replaced
278:f7cdd5b31aed | 307:5b4aa1c24407 |
---|---|
49 | 49 |
50 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | | 50 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | |
51 QDialogButtonBox::Cancel); | 51 QDialogButtonBox::Cancel); |
52 layout->addWidget(bbox, 2, 0); | 52 layout->addWidget(bbox, 2, 0); |
53 m_ok = bbox->button(QDialogButtonBox::Ok); | 53 m_ok = bbox->button(QDialogButtonBox::Ok); |
54 m_ok->setDefault(true); | |
54 m_ok->setEnabled(initialComment != ""); | 55 m_ok->setEnabled(initialComment != ""); |
55 m_ok->setText(okButtonText); | 56 m_ok->setText(okButtonText); |
57 bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false); | |
56 | 58 |
57 connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); | 59 connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); |
58 connect(bbox, SIGNAL(rejected()), this, SLOT(reject())); | 60 connect(bbox, SIGNAL(rejected()), this, SLOT(reject())); |
59 } | 61 } |
60 | 62 |
69 } | 71 } |
70 | 72 |
71 QString ConfirmCommentDialog::buildFilesText(QString intro, QStringList files) | 73 QString ConfirmCommentDialog::buildFilesText(QString intro, QStringList files) |
72 { | 74 { |
73 QString text; | 75 QString text; |
74 text = "<qt>" + intro; | 76 |
75 text += "<p><code>"; | 77 if (intro == "") text = "<qt>"; |
78 else text = "<qt>" + intro + "<p>"; | |
79 | |
80 text += "<code>"; | |
76 foreach (QString file, files) { | 81 foreach (QString file, files) { |
77 text += " " + xmlEncode(file) + "<br>"; | 82 text += " " + xmlEncode(file) + "<br>"; |
78 } | 83 } |
79 text += "</code></qt>"; | 84 text += "</code></qt>"; |
85 | |
80 return text; | 86 return text; |
81 } | 87 } |
82 | 88 |
83 bool ConfirmCommentDialog::confirm(QWidget *parent, | 89 bool ConfirmCommentDialog::confirm(QWidget *parent, |
84 QString title, | 90 QString title, |
91 QString head, | |
85 QString text, | 92 QString text, |
86 QString okButtonText) | 93 QString okButtonText) |
87 { | 94 { |
88 QMessageBox box(QMessageBox::Question, | 95 QMessageBox box(QMessageBox::Question, |
89 title, | 96 title, |
90 text, | 97 head, |
91 QMessageBox::Cancel, | 98 QMessageBox::Cancel, |
92 parent); | 99 parent); |
93 | 100 |
101 box.setInformativeText(text); | |
102 | |
94 QPushButton *ok = box.addButton(QMessageBox::Ok); | 103 QPushButton *ok = box.addButton(QMessageBox::Ok); |
95 ok->setText(okButtonText); | 104 ok->setText(okButtonText); |
105 box.setDefaultButton(QMessageBox::Ok); | |
96 if (box.exec() == -1) return false; | 106 if (box.exec() == -1) return false; |
97 return box.standardButton(box.clickedButton()) == QMessageBox::Ok; | 107 return box.standardButton(box.clickedButton()) == QMessageBox::Ok; |
98 } | 108 } |
99 | 109 |
100 bool ConfirmCommentDialog::confirmDangerous(QWidget *parent, | 110 bool ConfirmCommentDialog::confirmDangerous(QWidget *parent, |
101 QString title, | 111 QString title, |
112 QString head, | |
102 QString text, | 113 QString text, |
103 QString okButtonText) | 114 QString okButtonText) |
104 { | 115 { |
105 QMessageBox box(QMessageBox::Warning, | 116 QMessageBox box(QMessageBox::Warning, |
106 title, | 117 title, |
107 text, | 118 head, |
108 QMessageBox::Cancel, | 119 QMessageBox::Cancel, |
109 parent); | 120 parent); |
110 | 121 |
122 box.setInformativeText(text); | |
123 | |
111 QPushButton *ok = box.addButton(QMessageBox::Ok); | 124 QPushButton *ok = box.addButton(QMessageBox::Ok); |
112 ok->setText(okButtonText); | 125 ok->setText(okButtonText); |
126 box.setDefaultButton(QMessageBox::Cancel); | |
113 if (box.exec() == -1) return false; | 127 if (box.exec() == -1) return false; |
114 return box.standardButton(box.clickedButton()) == QMessageBox::Ok; | 128 return box.standardButton(box.clickedButton()) == QMessageBox::Ok; |
115 } | 129 } |
116 | 130 |
117 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, | 131 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent, |
125 if (files.size() <= 10) { | 139 if (files.size() <= 10) { |
126 text = buildFilesText(introText, files); | 140 text = buildFilesText(introText, files); |
127 } else { | 141 } else { |
128 text = "<qt>" + introTextWithCount + "</qt>"; | 142 text = "<qt>" + introTextWithCount + "</qt>"; |
129 } | 143 } |
130 return confirm(parent, title, text, okButtonText); | 144 return confirm(parent, title, text, "", okButtonText); |
131 } | 145 } |
132 | 146 |
133 bool ConfirmCommentDialog::confirmDangerousFilesAction(QWidget *parent, | 147 bool ConfirmCommentDialog::confirmDangerousFilesAction(QWidget *parent, |
134 QString title, | 148 QString title, |
135 QString introText, | 149 QString introText, |
141 if (files.size() <= 10) { | 155 if (files.size() <= 10) { |
142 text = buildFilesText(introText, files); | 156 text = buildFilesText(introText, files); |
143 } else { | 157 } else { |
144 text = "<qt>" + introTextWithCount + "</qt>"; | 158 text = "<qt>" + introTextWithCount + "</qt>"; |
145 } | 159 } |
146 return confirmDangerous(parent, title, text, okButtonText); | 160 return confirmDangerous(parent, title, text, "", okButtonText); |
147 } | 161 } |
148 | 162 |
149 bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, | 163 bool ConfirmCommentDialog::confirmAndGetShortComment(QWidget *parent, |
150 QString title, | 164 QString title, |
151 QString introText, | 165 QString introText, |