VirtualBox

Changeset 47615 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 8, 2013 4:10:59 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Popup-center: More wise button management; Allowing popups without buttons.

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

Legend:

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

    r47609 r47615  
    9191{
    9292    /* Make sure parent is set! */
    93     AssertMsg(pParent, ("Parent is NULL!"));
     93    AssertMsg(pParent, ("Parent is NULL!\n"));
    9494    if (!pParent)
    9595        return;
     
    109109{
    110110    /* Make sure parent is set! */
    111     AssertMsg(pParent, ("Parent is NULL!"));
     111    AssertMsg(pParent, ("Parent is NULL!\n"));
    112112    if (!pParent)
    113113        return;
     
    127127{
    128128    /* Make sure parent is set! */
    129     AssertMsg(pParent, ("Parent is NULL!"));
     129    AssertMsg(pParent, ("Parent is NULL!\n"));
    130130    if (!pParent)
    131131        return;
     
    151151void UIPopupCenter::message(QWidget *pParent, const QString &strPopupPaneID,
    152152                            const QString &strMessage, const QString &strDetails,
    153                             int iButton1 /*= 0*/, int iButton2 /*= 0*/,
    154153                            const QString &strButtonText1 /*= QString()*/,
    155154                            const QString &strButtonText2 /*= QString()*/,
     
    158157    showPopupPane(pParent, strPopupPaneID,
    159158                  strMessage, strDetails,
    160                   iButton1, iButton2,
    161159                  strButtonText1, strButtonText2,
    162160                  fProposeAutoConfirmation);
    163161}
    164162
    165 void UIPopupCenter::error(QWidget *pParent, const QString &strPopupPaneID,
    166                           const QString &strMessage, const QString &strDetails,
     163void UIPopupCenter::popup(QWidget *pParent, const QString &strPopupPaneID,
     164                          const QString &strMessage)
     165{
     166    message(pParent, strPopupPaneID, strMessage, QString());
     167}
     168
     169void UIPopupCenter::alert(QWidget *pParent, const QString &strPopupPaneID,
     170                          const QString &strMessage,
    167171                          bool fProposeAutoConfirmation /*= false*/)
    168172{
    169     message(pParent, strPopupPaneID,
    170             strMessage, strDetails,
    171             AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape /* 1st button */,
    172             0 /* 2nd button */,
     173    message(pParent, strPopupPaneID, strMessage, QString(),
    173174            QApplication::translate("UIMessageCenter", "Close") /* 1st button text */,
    174175            QString() /* 2nd button text */,
     
    176177}
    177178
    178 void UIPopupCenter::alert(QWidget *pParent, const QString &strPopupPaneID,
    179                           const QString &strMessage,
    180                           bool fProposeAutoConfirmation /*= false*/)
    181 {
    182     error(pParent, strPopupPaneID,
    183           strMessage, QString(),
    184           fProposeAutoConfirmation);
    185 }
    186 
    187179void UIPopupCenter::question(QWidget *pParent, const QString &strPopupPaneID,
    188180                             const QString &strMessage,
    189                              int iButton1 /*= 0*/, int iButton2 /*= 0*/,
    190181                             const QString &strButtonText1 /*= QString()*/,
    191182                             const QString &strButtonText2 /*= QString()*/,
    192183                             bool fProposeAutoConfirmation /*= false*/)
    193184{
    194     message(pParent, strPopupPaneID,
    195             strMessage, QString(),
    196             iButton1, iButton2,
     185    message(pParent, strPopupPaneID, strMessage, QString(),
    197186            strButtonText1, strButtonText2,
    198187            fProposeAutoConfirmation);
    199188}
    200189
    201 void UIPopupCenter::questionBinary(QWidget *pParent, const QString &strPopupPaneID,
    202                                    const QString &strMessage,
    203                                    const QString &strOkButtonText /*= QString()*/,
    204                                    const QString &strCancelButtonText /*= QString()*/,
    205                                    bool fProposeAutoConfirmation /*= false*/)
    206 {
    207     question(pParent, strPopupPaneID,
    208              strMessage,
    209              AlertButton_Ok | AlertButtonOption_Default,
    210              AlertButton_Cancel | AlertButtonOption_Escape,
    211              strOkButtonText,
    212              strCancelButtonText,
    213              fProposeAutoConfirmation);
    214 }
    215 
    216190void UIPopupCenter::recall(QWidget *pParent, const QString &strPopupPaneID)
    217191{
     
    221195void UIPopupCenter::showPopupPane(QWidget *pParent, const QString &strPopupPaneID,
    222196                                  const QString &strMessage, const QString &strDetails,
    223                                   int iButton1, int iButton2,
    224                                   QString strButtonText1, QString strButtonText2,
    225                                   bool fProposeAutoConfirmation)
    226 {
    227     /* Make sure parent is set! */
    228     AssertMsg(pParent, ("Parent is NULL!"));
    229     if (!pParent)
    230         return;
    231 
    232     /* Make sure at least one button is valid: */
    233     if (iButton1 == 0 && iButton2 == 0)
    234     {
     197                                  QString strButtonText1 /*= QString()*/, QString strButtonText2 /*= QString()*/,
     198                                  bool fProposeAutoConfirmation /*= false*/)
     199{
     200    /* Make sure parent is set! */
     201    AssertMsg(pParent, ("Parent is NULL!\n"));
     202    if (!pParent)
     203        return;
     204
     205    /* Prepare buttons: */
     206    int iButton1 = 0;
     207    int iButton2 = 0;
     208    /* Make sure single button is properly configured: */
     209    if (!strButtonText1.isEmpty() && strButtonText2.isEmpty())
    235210        iButton1 = AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape;
    236         strButtonText1 = QApplication::translate("UIMessageCenter", "Close");
     211    else if (strButtonText1.isEmpty() && !strButtonText2.isEmpty())
     212        iButton2 = AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape;
     213    /* Make sure buttons are unique if set both: */
     214    else if (!strButtonText1.isEmpty() && !strButtonText2.isEmpty())
     215    {
     216        iButton1 = AlertButton_Ok | AlertButtonOption_Default;
     217        iButton2 = AlertButton_Cancel | AlertButtonOption_Escape;
     218        /* If user made a mistake in button names, we will fix that: */
     219        if (strButtonText1 == strButtonText2)
     220        {
     221            strButtonText1 = QApplication::translate("UIMessageCenter", "Ok");
     222            strButtonText1 = QApplication::translate("UIMessageCenter", "Cancel");
     223        }
    237224    }
    238225
    239226    /* Check if popup-pane was auto-confirmed before: */
    240     if (fProposeAutoConfirmation)
     227    if ((iButton1 || iButton2) && fProposeAutoConfirmation)
    241228    {
    242229        QStringList confirmedPopupList = vboxGlobal().virtualBox().GetExtraData(GUI_SuppressMessages).split(',');
     
    285272        /* Compose button description map: */
    286273        QMap<int, QString> buttonDescriptions;
    287         if (iButton1 != 0 && !buttonDescriptions.contains(iButton1))
     274        if (iButton1 != 0)
    288275            buttonDescriptions[iButton1] = strButtonText1;
    289         if (iButton2 != 0 && !buttonDescriptions.contains(iButton2))
     276        if (iButton2 != 0)
    290277            buttonDescriptions[iButton2] = strButtonText2;
    291278        /* Create new one: */
     
    298285{
    299286    /* Make sure parent is set! */
    300     AssertMsg(pParent, ("Parent is NULL!"));
     287    AssertMsg(pParent, ("Parent is NULL!\n"));
    301288    if (!pParent)
    302289        return;
     
    336323    if (!m_stacks.contains(strPopupStackID))
    337324    {
    338         AssertMsgFailed(("Popup-stack already destroyed!"));
     325        AssertMsgFailed(("Popup-stack already destroyed!\n"));
    339326        return;
    340327    }
     
    351338{
    352339    /* Make sure parent is set! */
    353     AssertMsg(pParent, ("Parent is NULL!"));
     340    AssertMsg(pParent, ("Parent is NULL!\n"));
    354341    if (!pParent)
    355342        return QString();
     
    367354{
    368355    /* Make sure parent is set! */
    369     AssertMsg(pParent, ("Parent is NULL!"));
     356    AssertMsg(pParent, ("Parent is NULL!\n"));
    370357    if (!pParent)
    371358        return;
     
    395382{
    396383    /* Make sure parent is set! */
    397     AssertMsg(pParent, ("Parent is NULL!"));
     384    AssertMsg(pParent, ("Parent is NULL!\n"));
    398385    if (!pParent)
    399386        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

    r47523 r47615  
    5858
    5959    /* API: Main message function.
    60      * Provides one-two buttons.
    61      * Used directly only in exceptional cases: */
     60     * Provides up to two buttons.
     61     * Its interface, do NOT use it directly! */
    6262    void message(QWidget *pParent, const QString &strPopupPaneID,
    6363                 const QString &strMessage, const QString &strDetails,
    64                  int iButton1 = 0, int iButton2 = 0,
    6564                 const QString &strButtonText1 = QString(),
    6665                 const QString &strButtonText2 = QString(),
     
    6867
    6968    /* API: Wrapper to 'message' function.
    70      * Provides single OK button: */
    71     void error(QWidget *pParent, const QString &strPopupPaneID,
    72                const QString &strMessage, const QString &strDetails,
    73                bool fProposeAutoConfirmation = false);
     69     * Omits details, provides no buttons: */
     70    void popup(QWidget *pParent, const QString &strPopupPaneID,
     71               const QString &strMessage);
    7472
    75     /* API: Wrapper to 'error' function.
    76      * Omits details: */
     73    /* API: Wrapper to 'message' function.
     74     * Omits details, provides one button: */
    7775    void alert(QWidget *pParent, const QString &strPopupPaneID,
    7876               const QString &strMessage,
     
    8078
    8179    /* API: Wrapper to 'message' function.
    82      * Omits details, provides up to two buttons.
    83      * Used directly only in exceptional cases: */
     80     * Omits details, provides up to two buttons: */
    8481    void question(QWidget *pParent, const QString &strPopupPaneID,
    8582                  const QString &strMessage,
    86                   int iButton1 = 0, int iButton2 = 0,
    8783                  const QString &strButtonText1 = QString(),
    8884                  const QString &strButtonText2 = QString(),
    8985                  bool fProposeAutoConfirmation = false);
    90 
    91     /* API: Wrapper to 'question' function,
    92      * Question providing two buttons (OK and Cancel by default): */
    93     void questionBinary(QWidget *pParent, const QString &strPopupPaneID,
    94                         const QString &strMessage,
    95                         const QString &strOkButtonText = QString(),
    96                         const QString &strCancelButtonText = QString(),
    97                         bool fProposeAutoConfirmation = false);
    9886
    9987    /* API: Recall function,
     
    131119    void showPopupPane(QWidget *pParent, const QString &strPopupPaneID,
    132120                       const QString &strMessage, const QString &strDetails,
    133                        int iButton1, int iButton2,
    134                        QString strButtonText1, QString strButtonText2,
    135                        bool fProposeAutoConfirmation);
     121                       QString strButtonText1 = QString(), QString strButtonText2 = QString(),
     122                       bool fProposeAutoConfirmation = false);
    136123    void hidePopupPane(QWidget *pParent, const QString &strPopupPaneID);
    137124
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