VirtualBox

Changeset 45245 in vbox


Ignore:
Timestamp:
Mar 29, 2013 9:08:00 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84626
Message:

FE/Qt: Message-center cleanup (part 4).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r45244 r45245  
    8484}
    8585
    86 int UIMessageCenter::message(QWidget *pParent, MessageType type, const QString &strMessage,
    87                              const QString &strDetails /* = QString::null */,
     86int UIMessageCenter::message(QWidget *pParent, MessageType type,
     87                             const QString &strMessage,
     88                             const QString &strDetails /* = QString() */,
    8889                             const char *pcszAutoConfirmId /* = 0 */,
    89                              int button1 /* = 0 */,
    90                              int button2 /* = 0 */,
    91                              int button3 /* = 0 */,
    92                              const QString &strText1 /* = QString::null */,
    93                              const QString &strText2 /* = QString::null */,
    94                              const QString &strText3 /* = QString::null */) const
    95 {
    96     if (button1 == 0 && button2 == 0 && button3 == 0)
    97         button1 = QIMessageBox::Ok | QIMessageBox::Default;
    98 
     90                             int iButton1 /* = 0 */,
     91                             int iButton2 /* = 0 */,
     92                             int iButton3 /* = 0 */,
     93                             const QString &strButton1 /* = QString() */,
     94                             const QString &strButton2 /* = QString() */,
     95                             const QString &strButton3 /* = QString() */) const
     96{
     97    /* Choose the 'default' button: */
     98    if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)
     99        iButton1 = QIMessageBox::Ok | QIMessageBox::Default;
     100
     101    /* Check if message-box was auto-confirmed before: */
    99102    CVirtualBox vbox;
    100     QStringList msgs;
    101 
     103    QStringList confirmedMessageList;
    102104    if (pcszAutoConfirmId)
    103105    {
    104106        vbox = vboxGlobal().virtualBox();
    105         msgs = vbox.GetExtraData(GUI_SuppressMessages).split(',');
    106         if (msgs.contains(pcszAutoConfirmId))
     107        confirmedMessageList = vbox.GetExtraData(GUI_SuppressMessages).split(',');
     108        if (confirmedMessageList.contains(pcszAutoConfirmId))
    107109        {
    108             int rc = AutoConfirmed;
    109             if (button1 & QIMessageBox::Default)
    110                 rc |= (button1 & QIMessageBox::ButtonMask);
    111             if (button2 & QIMessageBox::Default)
    112                 rc |= (button2 & QIMessageBox::ButtonMask);
    113             if (button3 & QIMessageBox::Default)
    114                 rc |= (button3 & QIMessageBox::ButtonMask);
    115             return rc;
     110            int iResultCode = AutoConfirmed;
     111            if (iButton1 & QIMessageBox::Default)
     112                iResultCode |= (iButton1 & QIMessageBox::ButtonMask);
     113            if (iButton2 & QIMessageBox::Default)
     114                iResultCode |= (iButton2 & QIMessageBox::ButtonMask);
     115            if (iButton3 & QIMessageBox::Default)
     116                iResultCode |= (iButton3 & QIMessageBox::ButtonMask);
     117            return iResultCode;
    116118        }
    117119    }
    118120
     121    /* Choose title and icon: */
    119122    QString title;
    120123    QIMessageBox::Icon icon;
    121 
    122124    switch (type)
    123125    {
     
    150152
    151153    /* Create message-box: */
    152     QWidget *pBoxParent = mwManager().realParentWindow(pParent);
    153     QPointer<QIMessageBox> pBox = new QIMessageBox(title, strMessage, icon,
    154                                                    button1, button2, button3,
    155                                                    pBoxParent, pcszAutoConfirmId);
    156     mwManager().registerNewParent(pBox, pBoxParent);
    157 
    158     /* Configure message-box: */
    159     connect(this, SIGNAL(sigToCloseAllWarnings()), pBox, SLOT(deleteLater()));
    160 
    161     /* Prepare confirmation: */
     154    QWidget *pMessageBoxParent = mwManager().realParentWindow(pParent);
     155    QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon,
     156                                                          iButton1, iButton2, iButton3,
     157                                                          pMessageBoxParent, pcszAutoConfirmId);
     158    mwManager().registerNewParent(pMessageBox, pMessageBoxParent);
     159
     160    /* Prepare auto-confirmation check-box: */
    162161    if (pcszAutoConfirmId)
    163162    {
    164         pBox->setFlagText(tr("Do not show this message again", "msg box flag"));
    165         pBox->setFlagChecked(false);
    166     }
    167 
    168     /* Configure button-text: */
    169     if (!strText1.isNull())
    170         pBox->setButtonText(0, strText1);
    171     if (!strText2.isNull())
    172         pBox->setButtonText(1, strText2);
    173     if (!strText3.isNull())
    174         pBox->setButtonText(2, strText3);
     163        pMessageBox->setFlagText(tr("Do not show this message again", "msg box flag"));
     164        pMessageBox->setFlagChecked(false);
     165    }
    175166
    176167    /* Configure details: */
    177168    if (!strDetails.isEmpty())
    178         pBox->setDetailsText(strDetails);
    179 
    180     /* Show box: */
    181     int rc = pBox->exec();
    182 
    183     /* Make sure box still valid: */
    184     if (!pBox)
    185         return rc;
    186 
    187     /* Cleanup confirmation: */
     169        pMessageBox->setDetailsText(strDetails);
     170
     171    /* Configure button-text: */
     172    if (!strButton1.isNull())
     173        pMessageBox->setButtonText(0, strButton1);
     174    if (!strButton2.isNull())
     175        pMessageBox->setButtonText(1, strButton2);
     176    if (!strButton3.isNull())
     177        pMessageBox->setButtonText(2, strButton3);
     178
     179    /* Show message-box: */
     180    int iResultCode = pMessageBox->exec();
     181
     182    /* Make sure message-box still valid: */
     183    if (!pMessageBox)
     184        return iResultCode;
     185
     186    /* Remember auto-confirmation check-box value: */
    188187    if (pcszAutoConfirmId)
    189188    {
    190         if (pBox->isFlagChecked())
     189        if (pMessageBox->isFlagChecked())
    191190        {
    192             msgs << pcszAutoConfirmId;
    193             vbox.SetExtraData(GUI_SuppressMessages, msgs.join(","));
     191            confirmedMessageList << pcszAutoConfirmId;
     192            vbox.SetExtraData(GUI_SuppressMessages, confirmedMessageList.join(","));
    194193        }
    195194    }
    196195
    197196    /* Delete message-box: */
    198     if (pBox)
    199         delete pBox;
    200 
    201     return rc;
    202 }
    203 
    204 int UIMessageCenter::messageWithOption(QWidget *pParent,
    205                                        MessageType type,
     197    delete pMessageBox;
     198
     199    /* Return result-code: */
     200    return iResultCode;
     201}
     202
     203int UIMessageCenter::messageWithOption(QWidget *pParent, MessageType type,
    206204                                       const QString &strMessage,
    207205                                       const QString &strOptionText,
    208206                                       bool fDefaultOptionValue /* = true */,
    209                                        const QString &strDetails /* = QString::null */,
     207                                       const QString &strDetails /* = QString() */,
    210208                                       int iButton1 /* = 0 */,
    211209                                       int iButton2 /* = 0 */,
    212210                                       int iButton3 /* = 0 */,
    213                                        const QString &strButtonName1 /* = QString::null */,
    214                                        const QString &strButtonName2 /* = QString::null */,
    215                                        const QString &strButtonName3 /* = QString::null */) const
     211                                       const QString &strButtonName1 /* = QString() */,
     212                                       const QString &strButtonName2 /* = QString() */,
     213                                       const QString &strButtonName3 /* = QString() */) const
    216214{
    217215    /* If no buttons are set, using single 'OK' button: */
     
    256254                                                   iButton1, iButton2, iButton3, pBoxParent);
    257255    mwManager().registerNewParent(pBox, pBoxParent);
    258 
    259     /* Configure box: */
    260     connect(this, SIGNAL(sigToCloseAllWarnings()), pBox, SLOT(deleteLater()));
    261256
    262257    /* Load option: */
     
    911906                             tr("Create a snapshot of the current machine state"),
    912907                             !vboxGlobal().virtualBox().GetExtraDataStringList(GUI_InvertMessageOption).contains("askAboutSnapshotRestoring"),
    913                              QString::null /* details */,
     908                             QString() /* details */,
    914909                             QIMessageBox::Ok | QIMessageBox::Default,
    915910                             QIMessageBox::Cancel | QIMessageBox::Escape,
    916911                             0 /* 3rd button */,
    917                              tr("Restore"), tr("Cancel"), QString::null /* 3rd button text */) :
     912                             tr("Restore"), tr("Cancel"), QString() /* 3rd button text */) :
    918913           message(mainWindowShown(), MessageType_Question,
    919914                   tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>").arg(strSnapshotName),
     
    922917                   QIMessageBox::Cancel | QIMessageBox::Escape,
    923918                   0 /* 3rd button */,
    924                    tr("Restore"), tr("Cancel"), QString::null /* 3rd button text */);
     919                   tr("Restore"), tr("Cancel"), QString() /* 3rd button text */);
    925920}
    926921
     
    25922587        type == UIMediumType_Floppy && !fIsHostDrive ?
    25932588            tr("floppy image", "failed to mount ...") :
    2594         QString::null;
     2589        QString();
    25952590
    25962591    Assert(!strType.isNull());
     
    28392834{
    28402835    CVirtualBox vbox = vboxGlobal().virtualBox();
    2841     vbox.SetExtraData(GUI_SuppressMessages, QString::null);
     2836    vbox.SetExtraData(GUI_SuppressMessages, QString());
    28422837}
    28432838
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45244 r45245  
    5858signals:
    5959
    60     void sigToCloseAllWarnings();
    61 
    6260    /* Stuff supporting interthreading: */
    6361    void sigCannotCreateHostInterface(const CHost &host, QWidget *pParent);
     
    8583    };
    8684
    87     /* API: Shown warning registration stuff: */
     85    /* API: Warning registration stuff: */
    8886    bool warningShown(const QString &strWarningName) const;
    8987    void setWarningShown(const QString &strWarningName, bool fWarningShown);
    9088
    9189    /* API: Message posting stuff: Main function: */
    92     int message(QWidget *pParent, MessageType type, const QString &strMessage,
    93                 const QString &strDetails = QString::null,
     90    int message(QWidget *pParent, MessageType type,
     91                const QString &strMessage,
     92                const QString &strDetails = QString(),
    9493                const char *pcszAutoConfirmId = 0,
    9594                int button1 = 0, int button2 = 0, int button3 = 0,
    96                 const QString &strText1 = QString::null,
    97                 const QString &strText2 = QString::null,
    98                 const QString &strText3 = QString::null) const;
     95                const QString &strText1 = QString(),
     96                const QString &strText2 = QString(),
     97                const QString &strText3 = QString()) const;
    9998
    10099    /* API: Message posting stuff: Wrapper to above function: */
    101     int message(QWidget *pParent, MessageType type, const QString &strMessage,
     100    int message(QWidget *pParent, MessageType type,
     101                const QString &strMessage,
    102102                const char *pcszAutoConfirmId,
    103103                int button1 = 0, int button2 = 0, int button3 = 0,
    104                 const QString &strText1 = QString::null,
    105                 const QString &strText2 = QString::null,
    106                 const QString &strText3 = QString::null) const
    107     {
    108         return message(pParent, type, strMessage, QString::null, pcszAutoConfirmId,
     104                const QString &strText1 = QString(),
     105                const QString &strText2 = QString(),
     106                const QString &strText3 = QString()) const
     107    {
     108        return message(pParent, type, strMessage, QString(), pcszAutoConfirmId,
    109109                       button1, button2, button3, strText1, strText2, strText3);
    110110    }
    111111
    112112    /* API: Message posting stuff: Wrapper to above function: */
    113     bool messageYesNo(QWidget *pParent, MessageType type, const QString &strMessage,
    114                       const QString &strDetails = QString::null,
     113    bool messageYesNo(QWidget *pParent, MessageType type,
     114                      const QString &strMessage,
     115                      const QString &strDetails = QString(),
    115116                      const char *pcszAutoConfirmId = 0,
    116                       const QString &strYesText = QString::null,
    117                       const QString &strNoText = QString::null) const
     117                      const QString &strYesText = QString(),
     118                      const QString &strNoText = QString()) const
    118119    {
    119120        return(message(pParent, type, strMessage, strDetails, pcszAutoConfirmId,
     
    121122                       QIMessageBox::No | QIMessageBox::Escape,
    122123                       0,
    123                        strYesText, strNoText, QString::null) &
     124                       strYesText, strNoText, QString()) &
    124125               QIMessageBox::ButtonMask) == QIMessageBox::Yes;
    125126    }
    126127
    127128    /* API: Message posting stuff: Wrapper to above function: */
    128     bool messageYesNo(QWidget *pParent, MessageType type, const QString &strMessage,
     129    bool messageYesNo(QWidget *pParent, MessageType type,
     130                      const QString &strMessage,
    129131                      const char *pcszAutoConfirmId,
    130                       const QString &strYesText = QString::null,
    131                       const QString &strNoText = QString::null) const
    132     {
    133         return messageYesNo(pParent, type, strMessage, QString::null,
     132                      const QString &strYesText = QString(),
     133                      const QString &strNoText = QString()) const
     134    {
     135        return messageYesNo(pParent, type, strMessage, QString(),
    134136                            pcszAutoConfirmId, strYesText, strNoText);
    135137    }
    136138
    137139    /* API: Message posting stuff: Wrapper to above function: */
    138     bool messageOkCancel(QWidget *pParent, MessageType type, const QString &strMessage,
    139                          const QString &strDetails = QString::null,
     140    bool messageOkCancel(QWidget *pParent, MessageType type,
     141                         const QString &strMessage,
     142                         const QString &strDetails = QString(),
    140143                         const char *pcszAutoConfirmId = 0,
    141                          const QString &strOkText = QString::null,
    142                          const QString &strCancelText = QString::null) const
     144                         const QString &strOkText = QString(),
     145                         const QString &strCancelText = QString()) const
    143146    {
    144147        return(message(pParent, type, strMessage, strDetails, pcszAutoConfirmId,
     
    146149                       QIMessageBox::Cancel | QIMessageBox::Escape,
    147150                       0,
    148                        strOkText, strCancelText, QString::null) &
     151                       strOkText, strCancelText, QString()) &
    149152               QIMessageBox::ButtonMask) == QIMessageBox::Ok;
    150153    }
    151154
    152155    /* API: Message posting stuff: Wrapper to above function: */
    153     bool messageOkCancel(QWidget *pParent, MessageType type, const QString &strMessage,
     156    bool messageOkCancel(QWidget *pParent, MessageType type,
     157                         const QString &strMessage,
    154158                         const char *pcszAutoConfirmId,
    155                          const QString &strOkText = QString::null,
    156                          const QString &strCancelText = QString::null) const
    157     {
    158         return messageOkCancel(pParent, type, strMessage, QString::null,
     159                         const QString &strOkText = QString(),
     160                         const QString &strCancelText = QString()) const
     161    {
     162        return messageOkCancel(pParent, type, strMessage, QString(),
    159163                               pcszAutoConfirmId, strOkText, strCancelText);
    160164    }
    161165
    162166    /* API: Message posting stuff: One more main function: */
    163     int messageWithOption(QWidget *pParent,
    164                           MessageType type,
     167    int messageWithOption(QWidget *pParent, MessageType type,
    165168                          const QString &strMessage,
    166169                          const QString &strOptionText,
    167170                          bool fDefaultOptionValue = true,
    168                           const QString &strDetails = QString::null,
    169                           int iButton1 = 0,
    170                           int iButton2 = 0,
    171                           int iButton3 = 0,
    172                           const QString &strButtonName1 = QString::null,
    173                           const QString &strButtonName2 = QString::null,
    174                           const QString &strButtonName3 = QString::null) const;
     171                          const QString &strDetails = QString(),
     172                          int iButton1 = 0, int iButton2 = 0, int iButton3 = 0,
     173                          const QString &strButtonName1 = QString(),
     174                          const QString &strButtonName2 = QString(),
     175                          const QString &strButtonName3 = QString()) const;
    175176
    176177    /* API: Progress-dialog stuff: */
Note: See TracChangeset for help on using the changeset viewer.

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