VirtualBox

Changeset 5763 in vbox


Ignore:
Timestamp:
Nov 15, 2007 6:14:21 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
26148
Message:

FE/Qt: Use more informative verbs in yes/no message boxes (#2502).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r5656 r5763  
    5151    // helpers
    5252
    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);
    78116    }
    79117
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r5656 r5763  
    233233 *  When all button arguments are zero, a single 'Ok' button is shown.
    234234 *
    235  *  If autoConfirmId is not null, then the message box will contain a
     235 *  If aAutoConfirmId is not null, then the message box will contain a
    236236 *  checkbox "Don't show this message again" below the message text and its
    237237 *  state will be saved in the global config. When the checkbox is in the
     
    242242 *  button is defined in button arguments).
    243243 *
    244  *  @param  parent
    245  *      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,
    246246 *      #mainWindowShown can be used to determine the currently shown VBox
    247  *      main window (Selector or Console)
    248  *  @param  type
    249  *      one of values of the Type enum, that defines the message box
    250  *      title and icon
    251  *  @param  msg
    252  *      message text to display (can contain sinmple Qt-html tags)
    253  *  @param  details
    254  *      detailed message description displayed under the main message text using
     247 *      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
    255255 *      QTextEdit (that provides rich text support and scrollbars when necessary).
    256  *      If equals to QString::null, no details text box is shown
    257  *  @param  autoConfirmId
     256 *      If equals to QString::null, no details text box is shown.
     257 *  @param  aAutoConfirmId
    258258 *      ID used to save the auto confirmation state across calls. If null,
    259259 *      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.
    269272 *
    270273 *  @return
    271274 *      code of the button pressed by the user
    272275 */
    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;
     276int 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;
    281287
    282288    CVirtualBox vbox;
    283289    QStringList msgs;
    284290
    285     if (autoConfirmId)
     291    if (aAutoConfirmId)
    286292    {
    287293        vbox = vboxGlobal().virtualBox();
    288294        msgs = QStringList::split (',', vbox.GetExtraData (VBoxDefs::GUI_SuppressMessages));
    289         if (msgs.findIndex (autoConfirmId) >= 0) {
     295        if (msgs.findIndex (aAutoConfirmId) >= 0) {
    290296            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);
    294303            return rc;
    295304        }
     
    299308    QIMessageBox::Icon icon;
    300309
    301     switch (type)
     310    switch (aType)
    302311    {
    303312        default:
     
    328337    }
    329338
    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);
    337352        box->setDetailsShown (true);
    338353    }
    339354
    340     if (autoConfirmId)
     355    if (aAutoConfirmId)
    341356    {
    342357        box->setFlagText (tr ("Do not show this message again", "msg box flag"));
     
    346361    int rc = box->exec();
    347362
    348     if (autoConfirmId)
     363    if (aAutoConfirmId)
    349364    {
    350365        if (box->isFlagChecked())
    351366        {
    352             msgs << autoConfirmId;
     367            msgs << aAutoConfirmId;
    353368            vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, msgs.join (","));
    354369        }
     
    360375}
    361376
    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 &)
    363379 *
    364380 *  A shortcut to #message() that doesn't require to specify the details
     
    366382 */
    367383
    368 /**
     384/** @fn messageYesNo (QWidget *, Type, const QString &, const QString &, const char *)
     385 *
    369386 *  A shortcut to #message() that shows 'Yes' and 'No' buttons ('Yes' is the
    370387 *  default) and returns true when the user selects Yes.
    371388 */
    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 *)
    386391 *
    387392 *  A shortcut to #messageYesNo() that doesn't require to specify the details
     
    907912{
    908913    QString msg;
     914    QString button;
    909915    QString name;
    910916
     
    916922                  "<p>This operation cannot be undone.</p>")
    917923                  .arg (name);
     924        button = tr ("Delete", "machine");
    918925    }
    919926    else
     
    928935                  "GUI.</p>")
    929936                  .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);
    933942}
    934943
    935944bool VBoxProblemReporter::confirmDiscardSavedState (const CMachine &machine)
    936945{
    937     return messageYesNo (
    938         &vboxGlobal().selectorWnd(),
    939         Question,
     946    return messageOkCancel (&vboxGlobal().selectorWnd(), Question,
    940947        tr ("<p>Are you sure you want to discard the saved state of "
    941948            "the virtual machine <b>%1</b>?</p>"
     
    943950            "the machine without doing a proper shutdown by means of the "
    944951            "guest OS.</p>")
    945             .arg (machine.GetName())
    946     );
     952            .arg (machine.GetName()),
     953        0 /* aAutoConfirmId */,
     954        tr ("Discard", "saved state"));
    947955}
    948956
     
    950958                                               const QString &usage)
    951959{
    952     return messageYesNo (
    953         parent,
    954         Question,
     960    return messageOkCancel (parent, Question,
    955961        tr ("<p>Releasing this media image will detach it from the "
    956962            "following virtual machine(s): <b>%1</b>.</p>"
    957963            "<p>Continue?</p>")
    958964            .arg (usage),
    959         "confirmReleaseImage"
    960     );
     965        "confirmReleaseImage",
     966        tr ("Continue", "detach image"));
    961967}
    962968
     
    964970                                                           const QString &src)
    965971{
    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. "
    971974            "You cannot create a new virtual hard disk that uses this file, "
    972975            "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));
    977978}
    978979
     
    983984        tr ("<p>Do you want to delete this hard disk's image file "
    984985            "<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 "
    986990            "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>")
    991992            .arg (src),
    992         0, /* autoConfirmId */
     993        0, /* aAutoConfirmId */
    993994        QIMessageBox::Yes,
    994995        QIMessageBox::No | QIMessageBox::Default,
    995         QIMessageBox::Cancel | QIMessageBox::Escape);
     996        QIMessageBox::Cancel | QIMessageBox::Escape,
     997        tr ("Delete", "hard disk"),
     998        tr ("Unregister", "hard disk"));
    996999}
    9971000
     
    10111014                                                    const QString &src)
    10121015{
    1013     return message (parent, Question,
     1016    return messageOkCancel (parent, Question,
    10141017        tr ("<p>Do you want to remove (unregister) the virtual hard disk "
    10151018            "<nobr><b>%1</b>?</nobr></p>")
    10161019            .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}
    10221023
    10231024void VBoxProblemReporter::cannotCreateHardDiskImage (
    10241025    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,
    10281029        tr ("Failed to create the virtual hard disk image <nobr><b>%1</b>.</nobr>")
    10291030            .arg (src),
     
    13241325                        "download this CD image from the Internet?</p>")
    13251326                        .arg (aSrc1).arg (aSrc2),
    1326                     0, /* autoConfirmId */
     1327                    0, /* aAutoConfirmId */
    13271328                    QIMessageBox::Yes | QIMessageBox::Default,
    13281329                    QIMessageBox::No | QIMessageBox::Escape);
     
    13411342                                                   ulong aSize)
    13421343{
    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"));
    13511351}
    13521352
     
    13541354                                                const QString &aSrc)
    13551355{
    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"));
    13671366}
    13681367
     
    15021501
    15031502    /* Close the previous (outdated) window if any. We use kName as
    1504      * autoConfirmId which is also used as the widget name by default. */
     1503     * aAutoConfirmId which is also used as the widget name by default. */
    15051504    {
    15061505        QWidget *outdated =
     
    15331532                "corresponding action from the menu bar."
    15341533                "</p>"),
    1535             kNames [1] /* autoConfirmId */);
     1534            kNames [1] /* aAutoConfirmId */);
    15361535
    15371536        return !(rc & AutoConfirmed);
     
    15451544                "display or pressing the host key) in order to use the "
    15461545                "mouse inside the guest OS.</p>"),
    1547             kNames [0] /* autoConfirmId */);
     1546            kNames [0] /* aAutoConfirmId */);
    15481547
    15491548        return !(rc & AutoConfirmed);
     
    16371636
    16381637    /* Close the previous (outdated) window if any. We use kName as
    1639      * autoConfirmId which is also used as the widget name by default. */
     1638     * aAutoConfirmId which is also used as the widget name by default. */
    16401639    {
    16411640        QWidget *outdated = VBoxGlobal::findWidget (NULL, kName, "QIMessageBox");
     
    16911690            "it is recommended to press <b>OK</b> now.</p>")
    16921691            .arg (aLogFolder),
    1693         0, /* autoConfirmId */
     1692        0, /* aAutoConfirmId */
    16941693        QIMessageBox::Ok | QIMessageBox::Default,
    16951694        QIMessageBox::Ignore | QIMessageBox::Escape);
     
    17031702bool VBoxProblemReporter::confirmVMReset (QWidget *aParent)
    17041703{
    1705     return messageYesNo (aParent, Question,
     1704    return messageOkCancel (aParent, Question,
    17061705        tr ("<p>Do you really want to reset the virtual machine?</p>"
    17071706            "<p>When the machine is reset, unsaved data of all applications "
    17081707            "running inside it will be lost.</p>"),
    1709         "confirmVMReset" /* autoConfirmId */);
     1708        "confirmVMReset" /* aAutoConfirmId */,
     1709        tr ("Reset", "machine"));
    17101710}
    17111711
    17121712int VBoxProblemReporter::remindAboutUnsetHD (QWidget *aParent)
    17131713{
    1714     return message (
    1715         aParent,
    1716         Warning,
     1714    return message (aParent, Warning,
    17171715        tr ("<p>You didn't attach a hard disk to the new virtual machine. "
    17181716            "The machine will not be able to boot unless you attach "
     
    17201718            "media to it later using the machine settings dialog or the First "
    17211719            "Run Wizard.</p><p>Do you want to continue?</p>"),
    1722         0, /* autoConfirmId */
     1720        0, /* aAutoConfirmId */
    17231721        QIMessageBox::Yes,
    17241722        QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape);
     
    17281726{
    17291727    message (mainWindowShown(), Critical,
    1730              tr ("<p>Cannot run VirtualBox in <i>VM Selector</i> "
    1731                  "mode due to local restrictions.</p>"
    1732                  "<p>The application will now terminate.</p>"));
     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>"));
    17331731}
    17341732
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette