Changeset 5763 in vbox
- Timestamp:
- Nov 15, 2007 6:14:21 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26148
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r5656 r5763 51 51 // helpers 52 52 53 int message (QWidget *parent, Type type, const QString &msg, 54 const QString &details = QString::null, 55 const char *autoConfirmId = NULL, 56 int b1 = 0, int b2 = 0, int b3 = 0, 57 const char *name = 0); 58 59 int message (QWidget *parent, Type type, const QString &msg, 60 const char *autoConfirmId, 61 int b1 = 0, int b2 = 0, int b3 = 0, 62 const char *name = 0) 63 { 64 return message (parent, type, msg, QString::null, autoConfirmId, 65 b1, b2, b3, name); 66 } 67 68 bool messageYesNo (QWidget *parent, Type type, const QString &msg, 69 const QString &details = QString::null, 70 const char *autoConfirmId = 0, 71 const char *name = 0); 72 73 bool messageYesNo (QWidget *parent, Type type, const QString &msg, 74 const char *autoConfirmId, 75 const char *name = 0) 76 { 77 return messageYesNo (parent, type, msg, QString::null, autoConfirmId, name); 53 int message (QWidget *aParent, Type aType, const QString &aMessage, 54 const QString &aDetails = QString::null, 55 const char *aAutoConfirmId = 0, 56 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0, 57 const QString &aText1 = QString::null, 58 const QString &aText2 = QString::null, 59 const QString &aText3 = QString::null); 60 61 int message (QWidget *aParent, Type aType, const QString &aMessage, 62 const char *aAutoConfirmId, 63 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0, 64 const QString &aText1 = QString::null, 65 const QString &aText2 = QString::null, 66 const QString &aText3 = QString::null) 67 { 68 return message (aParent, aType, aMessage, QString::null, aAutoConfirmId, 69 aButton1, aButton2, aButton3, aText1, aText2, aText3); 70 } 71 72 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage, 73 const QString &aDetails = QString::null, 74 const char *aAutoConfirmId = 0, 75 const QString &aYesText = QString::null, 76 const QString &aNoText = QString::null) 77 { 78 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId, 79 QIMessageBox::Yes | QIMessageBox::Default, 80 QIMessageBox::No | QIMessageBox::Escape, 81 0, 82 aYesText, aNoText, QString::null) & 83 QIMessageBox::ButtonMask) == QIMessageBox::Yes; 84 } 85 86 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage, 87 const char *aAutoConfirmId, 88 const QString &aYesText = QString::null, 89 const QString &aNoText = QString::null) 90 { 91 return messageYesNo (aParent, aType, aMessage, QString::null, 92 aAutoConfirmId, aYesText, aNoText); 93 } 94 95 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage, 96 const QString &aDetails = QString::null, 97 const char *aAutoConfirmId = 0, 98 const QString &aOkText = QString::null, 99 const QString &aCancelText = QString::null) 100 { 101 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId, 102 QIMessageBox::Ok | QIMessageBox::Default, 103 QIMessageBox::Cancel | QIMessageBox::Escape, 104 0, 105 aOkText, aCancelText, QString::null) & 106 QIMessageBox::ButtonMask) == QIMessageBox::Ok; 107 } 108 109 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage, 110 const char *aAutoConfirmId, 111 const QString &aOkText = QString::null, 112 const QString &aCancelText = QString::null) 113 { 114 return messageOkCancel (aParent, aType, aMessage, QString::null, 115 aAutoConfirmId, aOkText, aCancelText); 78 116 } 79 117 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r5656 r5763 233 233 * When all button arguments are zero, a single 'Ok' button is shown. 234 234 * 235 * If a utoConfirmId is not null, then the message box will contain a235 * If aAutoConfirmId is not null, then the message box will contain a 236 236 * checkbox "Don't show this message again" below the message text and its 237 237 * state will be saved in the global config. When the checkbox is in the … … 242 242 * button is defined in button arguments). 243 243 * 244 * @param parent245 * parent widget or 0 to use the desktop as the parent. Also,244 * @param aParent 245 * Parent widget or 0 to use the desktop as the parent. Also, 246 246 * #mainWindowShown can be used to determine the currently shown VBox 247 * main window (Selector or Console) 248 * @param type249 * one of values of the Type enum, that defines the message box250 * title and icon 251 * @param msg252 * message text to display (can contain sinmple Qt-html tags)253 * @param details254 * detailed message description displayed under the main message text using247 * main window (Selector or Console). 248 * @param aType 249 * One of values of the Type enum, that defines the message box 250 * title and icon. 251 * @param aMessage 252 * Message text to display (can contain sinmple Qt-html tags). 253 * @param aDetails 254 * Detailed message description displayed under the main message text using 255 255 * QTextEdit (that provides rich text support and scrollbars when necessary). 256 * If equals to QString::null, no details text box is shown 257 * @param a utoConfirmId256 * If equals to QString::null, no details text box is shown. 257 * @param aAutoConfirmId 258 258 * ID used to save the auto confirmation state across calls. If null, 259 259 * the auto confirmation feature is turned off (and no checkbox is shown) 260 * @param b1 261 * first button code or 0, see QIMessageBox 262 * @param b2 263 * second button code or 0, see QIMessageBox 264 * @param b3 265 * third button code or 0, see QIMessageBox 266 * @param name 267 * name of the underlying QIMessageBox object. If NULL, a value of 268 * autoConfirmId is used. 260 * @param aButton1 261 * First button code or 0, see QIMessageBox for a list of codes. 262 * @param aButton2 263 * Second button code or 0, see QIMessageBox for a list of codes. 264 * @param aButton3 265 * Third button code or 0, see QIMessageBox for a list of codes. 266 * @param aText1 267 * Optional custom text for the first button. 268 * @param aText2 269 * Optional custom text for the second button. 270 * @param aText3 271 * Optional custom text for the third button. 269 272 * 270 273 * @return 271 274 * code of the button pressed by the user 272 275 */ 273 int VBoxProblemReporter::message (QWidget *parent, Type type, const QString &msg, 274 const QString &details, 275 const char *autoConfirmId, 276 int b1, int b2, int b3, 277 const char *name) 278 { 279 if (b1 == 0 && b2 == 0 && b3 == 0) 280 b1 = QIMessageBox::Ok | QIMessageBox::Default; 276 int VBoxProblemReporter::message (QWidget *aParent, Type aType, const QString &aMessage, 277 const QString &aDetails /* = QString::null */, 278 const char *aAutoConfirmId /* = 0 */, 279 int aButton1 /* = 0 */, int aButton2 /* = 0 */, 280 int aButton3 /* = 0 */, 281 const QString &aText1 /* = QString::null */, 282 const QString &aText2 /* = QString::null */, 283 const QString &aText3 /* = QString::null */) 284 { 285 if (aButton1 == 0 && aButton2 == 0 && aButton3 == 0) 286 aButton1 = QIMessageBox::Ok | QIMessageBox::Default; 281 287 282 288 CVirtualBox vbox; 283 289 QStringList msgs; 284 290 285 if (a utoConfirmId)291 if (aAutoConfirmId) 286 292 { 287 293 vbox = vboxGlobal().virtualBox(); 288 294 msgs = QStringList::split (',', vbox.GetExtraData (VBoxDefs::GUI_SuppressMessages)); 289 if (msgs.findIndex (a utoConfirmId) >= 0) {295 if (msgs.findIndex (aAutoConfirmId) >= 0) { 290 296 int rc = AutoConfirmed; 291 if (b1 & QIMessageBox::Default) rc |= (b1 & QIMessageBox::ButtonMask); 292 if (b2 & QIMessageBox::Default) rc |= (b2 & QIMessageBox::ButtonMask); 293 if (b3 & QIMessageBox::Default) rc |= (b3 & QIMessageBox::ButtonMask); 297 if (aButton1 & QIMessageBox::Default) 298 rc |= (aButton1 & QIMessageBox::ButtonMask); 299 if (aButton2 & QIMessageBox::Default) 300 rc |= (aButton2 & QIMessageBox::ButtonMask); 301 if (aButton3 & QIMessageBox::Default) 302 rc |= (aButton3 & QIMessageBox::ButtonMask); 294 303 return rc; 295 304 } … … 299 308 QIMessageBox::Icon icon; 300 309 301 switch ( type)310 switch (aType) 302 311 { 303 312 default: … … 328 337 } 329 338 330 if (!name) 331 name = autoConfirmId; 332 QIMessageBox *box = new QIMessageBox (title, msg, icon, b1, b2, b3, parent, name); 333 334 if (details) 335 { 336 box->setDetailsText (details); 339 QIMessageBox *box = new QIMessageBox (title, aMessage, icon, aButton1, aButton2, 340 aButton3, aParent, aAutoConfirmId); 341 342 if (!aText1.isNull()) 343 box->setButtonText (0, aText1); 344 if (!aText2.isNull()) 345 box->setButtonText (1, aText2); 346 if (!aText3.isNull()) 347 box->setButtonText (2, aText3); 348 349 if (aDetails) 350 { 351 box->setDetailsText (aDetails); 337 352 box->setDetailsShown (true); 338 353 } 339 354 340 if (a utoConfirmId)355 if (aAutoConfirmId) 341 356 { 342 357 box->setFlagText (tr ("Do not show this message again", "msg box flag")); … … 346 361 int rc = box->exec(); 347 362 348 if (a utoConfirmId)363 if (aAutoConfirmId) 349 364 { 350 365 if (box->isFlagChecked()) 351 366 { 352 msgs << a utoConfirmId;367 msgs << aAutoConfirmId; 353 368 vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, msgs.join (",")); 354 369 } … … 360 375 } 361 376 362 /** @fn message (QWidget *, Type, const QString &, const char *, int, int, int, const char *) 377 /** @fn message (QWidget *, Type, const QString &, const char *, int, int, 378 * int, const QString &, const QString &, const QString &) 363 379 * 364 380 * A shortcut to #message() that doesn't require to specify the details … … 366 382 */ 367 383 368 /** 384 /** @fn messageYesNo (QWidget *, Type, const QString &, const QString &, const char *) 385 * 369 386 * A shortcut to #message() that shows 'Yes' and 'No' buttons ('Yes' is the 370 387 * default) and returns true when the user selects Yes. 371 388 */ 372 bool VBoxProblemReporter::messageYesNo ( 373 QWidget *parent, Type type, const QString &msg, 374 const QString &details, 375 const char *autoConfirmId, 376 const char *name 377 ) 378 { 379 return (message (parent, type, msg, details, autoConfirmId, 380 QIMessageBox::Yes | QIMessageBox::Default, 381 QIMessageBox::No | QIMessageBox::Escape, 382 0, name) & QIMessageBox::ButtonMask) == QIMessageBox::Yes; 383 } 384 385 /** @fn messageYesNo (QWidget *, Type, const QString &, const char *, const char *) 389 390 /** @fn messageYesNo (QWidget *, Type, const QString &, const char *) 386 391 * 387 392 * A shortcut to #messageYesNo() that doesn't require to specify the details … … 907 912 { 908 913 QString msg; 914 QString button; 909 915 QString name; 910 916 … … 916 922 "<p>This operation cannot be undone.</p>") 917 923 .arg (name); 924 button = tr ("Delete", "machine"); 918 925 } 919 926 else … … 928 935 "GUI.</p>") 929 936 .arg (name); 930 } 931 932 return messageYesNo (&vboxGlobal().selectorWnd(), Question, msg); 937 button = tr ("Unregister", "machine"); 938 } 939 940 return messageOkCancel (&vboxGlobal().selectorWnd(), Question, msg, 941 0 /* aAutoConfirmId */, button); 933 942 } 934 943 935 944 bool VBoxProblemReporter::confirmDiscardSavedState (const CMachine &machine) 936 945 { 937 return messageYesNo ( 938 &vboxGlobal().selectorWnd(), 939 Question, 946 return messageOkCancel (&vboxGlobal().selectorWnd(), Question, 940 947 tr ("<p>Are you sure you want to discard the saved state of " 941 948 "the virtual machine <b>%1</b>?</p>" … … 943 950 "the machine without doing a proper shutdown by means of the " 944 951 "guest OS.</p>") 945 .arg (machine.GetName()) 946 ); 952 .arg (machine.GetName()), 953 0 /* aAutoConfirmId */, 954 tr ("Discard", "saved state")); 947 955 } 948 956 … … 950 958 const QString &usage) 951 959 { 952 return messageYesNo ( 953 parent, 954 Question, 960 return messageOkCancel (parent, Question, 955 961 tr ("<p>Releasing this media image will detach it from the " 956 962 "following virtual machine(s): <b>%1</b>.</p>" 957 963 "<p>Continue?</p>") 958 964 .arg (usage), 959 "confirmReleaseImage" 960 );965 "confirmReleaseImage", 966 tr ("Continue", "detach image")); 961 967 } 962 968 … … 964 970 const QString &src) 965 971 { 966 message ( 967 parent, 968 Info, 969 tr ( 970 "<p>The image file <b>%1</b> already exists. " 972 message (parent, Info, 973 tr ("<p>The image file <b>%1</b> already exists. " 971 974 "You cannot create a new virtual hard disk that uses this file, " 972 975 "because it can be already used by another virtual hard disk.</p>" 973 "<p>Please specify a different image file name.</p>" 974 ) 975 .arg (src) 976 ); 976 "<p>Please specify a different image file name.</p>") 977 .arg (src)); 977 978 } 978 979 … … 983 984 tr ("<p>Do you want to delete this hard disk's image file " 984 985 "<nobr><b>%1</b>?</nobr></p>" 985 "<p>If you select <b>No</b> then the virtual hard disk will be " 986 "<p>If you select <b>Delete</b> then the image file will be permanently " 987 "deleted after unregistering the hard disk. This operation " 988 "cannot be undone.</p>" 989 "<p>If you select <b>Unregister</b> then the virtual hard disk will be " 986 990 "unregistered and removed from the collection, but the image file " 987 "will be left on your physical disk.</p>" 988 "<p>If you select <b>Yes</b> then the image file will be permanently " 989 "deleted after unregistering the hard disk. This operation " 990 "cannot be undone.</p>") 991 "will be left on your physical disk.</p>") 991 992 .arg (src), 992 0, /* a utoConfirmId */993 0, /* aAutoConfirmId */ 993 994 QIMessageBox::Yes, 994 995 QIMessageBox::No | QIMessageBox::Default, 995 QIMessageBox::Cancel | QIMessageBox::Escape); 996 QIMessageBox::Cancel | QIMessageBox::Escape, 997 tr ("Delete", "hard disk"), 998 tr ("Unregister", "hard disk")); 996 999 } 997 1000 … … 1011 1014 const QString &src) 1012 1015 { 1013 return message (parent, Question,1016 return messageOkCancel (parent, Question, 1014 1017 tr ("<p>Do you want to remove (unregister) the virtual hard disk " 1015 1018 "<nobr><b>%1</b>?</nobr></p>") 1016 1019 .arg (src), 1017 0, /* autoConfirmId */ 1018 QIMessageBox::Ok | QIMessageBox::Default, 1019 QIMessageBox::Cancel | QIMessageBox::Escape); 1020 } 1021 1020 0 /* aAutoConfirmId */, 1021 tr ("Unregister", "hard disk")); 1022 } 1022 1023 1023 1024 void VBoxProblemReporter::cannotCreateHardDiskImage ( 1024 1025 QWidget *parent, const CVirtualBox &vbox, const QString &src, 1025 const CVirtualDiskImage &vdi, const CProgress &progress 1026 ){1027 message (parent, Error,1026 const CVirtualDiskImage &vdi, const CProgress &progress) 1027 { 1028 message (parent, Error, 1028 1029 tr ("Failed to create the virtual hard disk image <nobr><b>%1</b>.</nobr>") 1029 1030 .arg (src), … … 1324 1325 "download this CD image from the Internet?</p>") 1325 1326 .arg (aSrc1).arg (aSrc2), 1326 0, /* a utoConfirmId */1327 0, /* aAutoConfirmId */ 1327 1328 QIMessageBox::Yes | QIMessageBox::Default, 1328 1329 QIMessageBox::No | QIMessageBox::Escape); … … 1341 1342 ulong aSize) 1342 1343 { 1343 return message (&vboxGlobal().consoleWnd(), Question, 1344 tr ("<p>Are you sure you want to download the VirtualBox " 1345 "Guest Additions CD image from " 1346 "<nobr><a href=\"%1\">%2</a></nobr> " 1347 "(size %3 bytes)?</p>").arg (aURL).arg (aURL).arg (aSize), 1348 0, /* autoConfirmId */ 1349 QIMessageBox::Yes | QIMessageBox::Default, 1350 QIMessageBox::No | QIMessageBox::Escape); 1344 return messageOkCancel (&vboxGlobal().consoleWnd(), Question, 1345 tr ("<p>Are you sure you want to download the VirtualBox " 1346 "Guest Additions CD image from " 1347 "<nobr><a href=\"%1\">%2</a></nobr> " 1348 "(size %3 bytes)?</p>").arg (aURL).arg (aURL).arg (aSize), 1349 0, /* aAutoConfirmId */ 1350 tr ("Download", "additions")); 1351 1351 } 1352 1352 … … 1354 1354 const QString &aSrc) 1355 1355 { 1356 return message (&vboxGlobal().consoleWnd(), Question, 1357 tr ("<p>The VirtualBox Guest Additions CD image has been " 1358 "successfully downloaded from " 1359 "<nobr><a href=\"%1\">%2</a></nobr> " 1360 "and saved locally as <nobr><b>%3</b>.</nobr></p>" 1361 "<p>Do you want to register this CD image and mount it " 1362 "on the virtual CD/DVD drive?</p>") 1363 .arg (aURL).arg (aURL).arg (aSrc), 1364 0, /* autoConfirmId */ 1365 QIMessageBox::Yes | QIMessageBox::Default, 1366 QIMessageBox::No | QIMessageBox::Escape); 1356 return messageOkCancel (&vboxGlobal().consoleWnd(), Question, 1357 tr ("<p>The VirtualBox Guest Additions CD image has been " 1358 "successfully downloaded from " 1359 "<nobr><a href=\"%1\">%2</a></nobr> " 1360 "and saved locally as <nobr><b>%3</b>.</nobr></p>" 1361 "<p>Do you want to register this CD image and mount it " 1362 "on the virtual CD/DVD drive?</p>") 1363 .arg (aURL).arg (aURL).arg (aSrc), 1364 0, /* aAutoConfirmId */ 1365 tr ("Mount", "additions")); 1367 1366 } 1368 1367 … … 1502 1501 1503 1502 /* Close the previous (outdated) window if any. We use kName as 1504 * a utoConfirmId which is also used as the widget name by default. */1503 * aAutoConfirmId which is also used as the widget name by default. */ 1505 1504 { 1506 1505 QWidget *outdated = … … 1533 1532 "corresponding action from the menu bar." 1534 1533 "</p>"), 1535 kNames [1] /* a utoConfirmId */);1534 kNames [1] /* aAutoConfirmId */); 1536 1535 1537 1536 return !(rc & AutoConfirmed); … … 1545 1544 "display or pressing the host key) in order to use the " 1546 1545 "mouse inside the guest OS.</p>"), 1547 kNames [0] /* a utoConfirmId */);1546 kNames [0] /* aAutoConfirmId */); 1548 1547 1549 1548 return !(rc & AutoConfirmed); … … 1637 1636 1638 1637 /* Close the previous (outdated) window if any. We use kName as 1639 * a utoConfirmId which is also used as the widget name by default. */1638 * aAutoConfirmId which is also used as the widget name by default. */ 1640 1639 { 1641 1640 QWidget *outdated = VBoxGlobal::findWidget (NULL, kName, "QIMessageBox"); … … 1691 1690 "it is recommended to press <b>OK</b> now.</p>") 1692 1691 .arg (aLogFolder), 1693 0, /* a utoConfirmId */1692 0, /* aAutoConfirmId */ 1694 1693 QIMessageBox::Ok | QIMessageBox::Default, 1695 1694 QIMessageBox::Ignore | QIMessageBox::Escape); … … 1703 1702 bool VBoxProblemReporter::confirmVMReset (QWidget *aParent) 1704 1703 { 1705 return message YesNo(aParent, Question,1704 return messageOkCancel (aParent, Question, 1706 1705 tr ("<p>Do you really want to reset the virtual machine?</p>" 1707 1706 "<p>When the machine is reset, unsaved data of all applications " 1708 1707 "running inside it will be lost.</p>"), 1709 "confirmVMReset" /* autoConfirmId */); 1708 "confirmVMReset" /* aAutoConfirmId */, 1709 tr ("Reset", "machine")); 1710 1710 } 1711 1711 1712 1712 int VBoxProblemReporter::remindAboutUnsetHD (QWidget *aParent) 1713 1713 { 1714 return message ( 1715 aParent, 1716 Warning, 1714 return message (aParent, Warning, 1717 1715 tr ("<p>You didn't attach a hard disk to the new virtual machine. " 1718 1716 "The machine will not be able to boot unless you attach " … … 1720 1718 "media to it later using the machine settings dialog or the First " 1721 1719 "Run Wizard.</p><p>Do you want to continue?</p>"), 1722 0, /* a utoConfirmId */1720 0, /* aAutoConfirmId */ 1723 1721 QIMessageBox::Yes, 1724 1722 QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape); … … 1728 1726 { 1729 1727 message (mainWindowShown(), Critical, 1730 1731 1732 1728 tr ("<p>Cannot run VirtualBox in <i>VM Selector</i> " 1729 "mode due to local restrictions.</p>" 1730 "<p>The application will now terminate.</p>")); 1733 1731 } 1734 1732
Note:
See TracChangeset
for help on using the changeset viewer.