Changeset 38185 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 26, 2011 1:46:39 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp
r31319 r38185 38 38 #include <QToolButton> 39 39 #include <QKeyEvent> 40 #include <QClipboard> 40 41 41 42 #ifdef Q_WS_MAC … … 164 165 connect (mButton2PB, SIGNAL (clicked()), SLOT (done2())); 165 166 167 /* If this is an error message add an "Copy to clipboard" button for easier 168 * bug reports. */ 169 if (aIcon == QIMessageBox::Critical) 170 { 171 QPushButton *pCopyButton = createButton(Copy); 172 pCopyButton->setToolTip(tr("Copy all errors to the clipboard")); 173 connect(pCopyButton, SIGNAL(clicked()), SLOT(copy())); 174 } 175 166 176 /* this call is a must -- it initializes mFlagCB and mSpacer */ 167 177 setDetailsShown (false); … … 258 268 switch (aButton & ButtonMask) 259 269 { 260 case Ok: text = tr ("OK"); role = QDialogButtonBox::AcceptRole; break; 261 case Yes: text = tr ("Yes"); role = QDialogButtonBox::YesRole; break; 262 case No: text = tr ("No"); role = QDialogButtonBox::NoRole; break; 263 case Cancel: text = tr ("Cancel"); role = QDialogButtonBox::RejectRole; break; 264 case Ignore: text = tr ("Ignore"); role = QDialogButtonBox::AcceptRole; break; 270 case Ok: text = tr("OK"); role = QDialogButtonBox::AcceptRole; break; 271 case Yes: text = tr("Yes"); role = QDialogButtonBox::YesRole; break; 272 case No: text = tr("No"); role = QDialogButtonBox::NoRole; break; 273 case Cancel: text = tr("Cancel"); role = QDialogButtonBox::RejectRole; break; 274 case Ignore: text = tr("Ignore"); role = QDialogButtonBox::AcceptRole; break; 275 case Copy: text = tr("Copy"); role = QDialogButtonBox::ActionRole; break; 265 276 default: 266 AssertMsgFailed 277 AssertMsgFailed(("Type %d is not implemented", aButton)); 267 278 return NULL; 268 279 } … … 455 466 } 456 467 468 void QIMessageBox::copy() const 469 { 470 /* Create the error string with all errors. First the html version. */ 471 QString strError = "<html><body><p>" + mText + "</p>"; 472 for (size_t i = 0; i < mDetailsList.size(); ++i) 473 strError += mDetailsList.at(i).first + mDetailsList.at(i).second + "<br>"; 474 strError += "</body></html>"; 475 strError.remove(QRegExp("</+qt>")); 476 strError = strError.replace(QRegExp(" "), " "); 477 /* Create a new mime data object holding both the html and the plain text version. */ 478 QMimeData *pMd = new QMimeData(); 479 pMd->setHtml(strError); 480 /* Replace all the html entities. */ 481 strError = strError.replace(QRegExp("<br>|</tr>"), "\n"); 482 strError = strError.replace(QRegExp("</p>"), "\n\n"); 483 strError = strError.remove(QRegExp("<[^>]*>")); 484 pMd->setText(strError); 485 /* Add the mime data to the global clipboard. */ 486 QClipboard *pClipboard = QApplication::clipboard(); 487 pClipboard->setMimeData(pMd); 488 } 489 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h
r36011 r38185 66 66 { 67 67 NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5, 68 Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, 68 Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, Copy = 10, 69 69 ButtonMask = 0xFF, 70 70 … … 114 114 void reject(); 115 115 116 void copy() const; 117 116 118 private: 117 119
Note:
See TracChangeset
for help on using the changeset viewer.