VirtualBox

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


Ignore:
Timestamp:
Apr 24, 2013 9:58:00 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85235
Message:

FE/Qt: Popup-center, popup-pane: Implementing main framework stuff (part 9): Auto-confirmation support.

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

Legend:

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

    r45659 r45691  
    2222#include "UIPopupStack.h"
    2323#include "QIMessageBox.h"
     24#include "VBoxGlobal.h"
    2425
    2526/* Other VBox includes: */
     
    6768                            const QString &strMessage, const QString &strDetails,
    6869                            int iButton1 /*= 0*/, int iButton2 /*= 0*/,
    69                             const QString &strButtonText1 /* = QString() */,
    70                             const QString &strButtonText2 /* = QString() */)
     70                            const QString &strButtonText1 /*= QString()*/,
     71                            const QString &strButtonText2 /*= QString()*/,
     72                            bool fProposeAutoConfirmation /*= false*/)
    7173{
    7274    showPopupPane(pParent, strId,
    7375                  strMessage, strDetails,
    7476                  iButton1, iButton2,
    75                   strButtonText1, strButtonText2);
     77                  strButtonText1, strButtonText2,
     78                  fProposeAutoConfirmation);
    7679}
    7780
    7881void UIPopupCenter::error(QWidget *pParent, const QString &strId,
    79                           const QString &strMessage, const QString &strDetails)
     82                          const QString &strMessage, const QString &strDetails,
     83                          bool fProposeAutoConfirmation /*= false*/)
    8084{
    8185    message(pParent, strId,
    8286            strMessage, strDetails,
    83             AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape);
     87            AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape /* 1st button */,
     88            0 /* 2nd button */,
     89            QString() /* 1st button text */,
     90            QString() /* 2nd button text */,
     91            fProposeAutoConfirmation);
    8492}
    8593
    8694void UIPopupCenter::alert(QWidget *pParent, const QString &strId,
    87                           const QString &strMessage)
     95                          const QString &strMessage,
     96                          bool fProposeAutoConfirmation /*= false*/)
    8897{
    8998    error(pParent, strId,
    90           strMessage, QString());
     99          strMessage, QString(),
     100          fProposeAutoConfirmation);
    91101}
    92102
     
    95105                             int iButton1 /*= 0*/, int iButton2 /*= 0*/,
    96106                             const QString &strButtonText1 /*= QString()*/,
    97                              const QString &strButtonText2 /*= QString()*/)
     107                             const QString &strButtonText2 /*= QString()*/,
     108                             bool fProposeAutoConfirmation /*= false*/)
    98109{
    99110    message(pParent, strId,
    100111            strMessage, QString(),
    101112            iButton1, iButton2,
    102             strButtonText1, strButtonText2);
     113            strButtonText1, strButtonText2,
     114            fProposeAutoConfirmation);
    103115}
    104116
     
    106118                                   const QString &strMessage,
    107119                                   const QString &strOkButtonText /*= QString()*/,
    108                                    const QString &strCancelButtonText /*= QString()*/)
     120                                   const QString &strCancelButtonText /*= QString()*/,
     121                                   bool fProposeAutoConfirmation /*= false*/)
    109122{
    110123    question(pParent, strId,
     
    113126             AlertButton_Cancel | AlertButtonOption_Escape,
    114127             strOkButtonText,
    115              strCancelButtonText);
     128             strCancelButtonText,
     129             fProposeAutoConfirmation);
    116130}
    117131
    118132void UIPopupCenter::showPopupPane(QWidget *pParent, const QString &strPopupPaneID,
    119                                  const QString &strMessage, const QString &strDetails,
    120                                  int iButton1, int iButton2,
    121                                  const QString &strButtonText1, const QString &strButtonText2)
    122 {
     133                                  const QString &strMessage, const QString &strDetails,
     134                                  int iButton1, int iButton2,
     135                                  const QString &strButtonText1, const QString &strButtonText2,
     136                                  bool fProposeAutoConfirmation)
     137{
     138    /* Make sure at least one button is valid: */
     139    if (iButton1 == 0 && iButton2 == 0)
     140        iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape;
     141
     142    /* Check if popup-pane was auto-confirmed before: */
     143    if (fProposeAutoConfirmation)
     144    {
     145        QStringList confirmedPopupList = vboxGlobal().virtualBox().GetExtraData(GUI_SuppressMessages).split(',');
     146        if (confirmedPopupList.contains(strPopupPaneID))
     147        {
     148            int iResultCode = AlertOption_AutoConfirmed;
     149            if (iButton1 & AlertButtonOption_Default)
     150                iResultCode |= (iButton1 & AlertButtonMask);
     151            else if (iButton2 & AlertButtonOption_Default)
     152                iResultCode |= (iButton2 & AlertButtonMask);
     153            emit sigPopupPaneDone(strPopupPaneID, iResultCode);
     154            return;
     155        }
     156    }
     157
    123158    /* Make sure parent is always set! */
    124159    AssertMsg(pParent, ("Parent is NULL!"));
    125160    if (!pParent)
    126161        return;
     162
    127163    /* Looking for the corresponding popup-stack: */
    128164    QString strPopupStackID = pParent->metaObject()->className();
     
    140176        pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack(pParent);
    141177        /* Attach popup-stack connections: */
    142         connect(pPopupStack, SIGNAL(sigPopupPaneDone(QString, int)), this, SIGNAL(sigPopupPaneDone(QString, int)));
     178        connect(pPopupStack, SIGNAL(sigPopupPaneDone(QString, int)), this, SLOT(sltPopupPaneDone(QString, int)));
    143179        connect(pPopupStack, SIGNAL(sigRemove()), this, SLOT(sltRemovePopupStack()));
    144     }
    145     /* Show popup-stack: */
    146     pPopupStack->show();
    147 
    148     /* Make sure at least one button is valid: */
    149     if (iButton1 == 0 && iButton2 == 0)
    150         iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape;
     180        /* Show popup-stack: */
     181        pPopupStack->show();
     182    }
     183
    151184    /* Compose button description map: */
    152185    QMap<int, QString> buttonDescriptions;
     
    156189        buttonDescriptions[iButton2] = strButtonText2;
    157190    /* Update corresponding popup-pane: */
    158     pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions);
     191    pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions, fProposeAutoConfirmation);
     192}
     193
     194void UIPopupCenter::sltPopupPaneDone(QString strPopupPaneID, int iResultCode)
     195{
     196    /* Was the result auto-confirmated? */
     197    if (iResultCode & AlertOption_AutoConfirmed)
     198    {
     199        /* Remember auto-confirmation fact: */
     200        QStringList confirmedPopupList = vboxGlobal().virtualBox().GetExtraData(GUI_SuppressMessages).split(',');
     201        confirmedPopupList << strPopupPaneID;
     202        vboxGlobal().virtualBox().SetExtraData(GUI_SuppressMessages, confirmedPopupList.join(","));
     203    }
     204
     205    /* Notify listeners: */
     206    emit sigPopupPaneDone(strPopupPaneID, iResultCode);
    159207}
    160208
     
    195243                 "<p><b>Note</b>: Some applications may behave incorrectly in mouse pointer integration mode. "
    196244                 "You can always disable it for the current session (and enable it again) "
    197                  "by selecting the corresponding action from the menu bar.</p>"));
     245                 "by selecting the corresponding action from the menu bar.</p>"),
     246              true);
    198247    }
    199248    else
     
    202251              tr("<p>The Virtual Machine reports that the guest OS does not support <b>mouse pointer integration</b> "
    203252                 "in the current video mode. You need to capture the mouse (by clicking over the VM display "
    204                  "or pressing the host key) in order to use the mouse inside the guest OS.</p>"));
    205     }
    206 }
    207 
     253                 "or pressing the host key) in order to use the mouse inside the guest OS.</p>"),
     254              true);
     255    }
     256}
     257
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

    r45659 r45691  
    3636signals:
    3737
    38     /* Notifier: Popup-pane done stuff: */
    39     void sigPopupPaneDone(QString strID, int iButtonCode);
     38    /* Notifier: Popup-pane stuff: */
     39    void sigPopupPaneDone(QString strPopupPaneID, int iResultCode);
    4040
    4141public:
     
    5252                 int iButton1 = 0, int iButton2 = 0,
    5353                 const QString &strButtonText1 = QString(),
    54                  const QString &strButtonText2 = QString());
     54                 const QString &strButtonText2 = QString(),
     55                 bool fProposeAutoConfirmation = false);
    5556
    5657    /* API: Wrapper to 'message' function.
    5758     * Provides single OK button: */
    5859    void error(QWidget *pParent, const QString &strId,
    59                const QString &strMessage, const QString &strDetails);
     60               const QString &strMessage, const QString &strDetails,
     61               bool fProposeAutoConfirmation = false);
    6062
    6163    /* API: Wrapper to 'error' function.
    6264     * Omits details: */
    6365    void alert(QWidget *pParent, const QString &strId,
    64                const QString &strMessage);
     66               const QString &strMessage,
     67               bool fProposeAutoConfirmation = false);
    6568
    6669    /* API: Wrapper to 'message' function.
     
    7174                  int iButton1 = 0, int iButton2 = 0,
    7275                  const QString &strButtonText1 = QString(),
    73                   const QString &strButtonText2 = QString());
     76                  const QString &strButtonText2 = QString(),
     77                  bool fProposeAutoConfirmation = false);
    7478
    7579    /* API: Wrapper to 'question' function,
     
    7882                        const QString &strMessage,
    7983                        const QString &strOkButtonText = QString(),
    80                         const QString &strCancelButtonText = QString());
     84                        const QString &strCancelButtonText = QString(),
     85                        bool fProposeAutoConfirmation = false);
    8186
    8287    /* API: Runtime UI stuff: */
     
    8489
    8590private slots:
     91
     92    /* Handler: Popup-pane stuff: */
     93    void sltPopupPaneDone(QString strPopupPaneID, int iResultCode);
    8694
    8795    /* Handler: Popup-stack stuff: */
     
    98106                       const QString &strMessage, const QString &strDetails,
    99107                       int iButton1, int iButton2,
    100                        const QString &strButtonText1, const QString &strButtonText2);
     108                       const QString &strButtonText1, const QString &strButtonText2,
     109                       bool fProposeAutoConfirmation);
    101110
    102111    /* Variable: Popup-stack stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r45663 r45691  
    2222#include <QVBoxLayout>
    2323#include <QLabel>
     24#include <QCheckBox>
    2425#include <QKeyEvent>
    2526#include <QPainter>
     
    2930
    3031/* GUI includes: */
     32#include "QIWithRetranslateUI.h"
    3133#include "UIPopupPane.h"
    3234#include "UIIconPool.h"
     
    114116
    115117/* Popup-pane text-pane prototype class: */
    116 class UIPopupPaneTextPane : public QWidget
     118class UIPopupPaneTextPane : public QIWithRetranslateUI<QWidget>
    117119{
    118120    Q_OBJECT;
     
    138140    void setText(const QString &strText);
    139141
    140     /* API: Set desired width: */
     142    /* API: Desired-width stuff: */
    141143    void setDesiredWidth(int iDesiredWidth);
     144
     145    /* API: Auto-confirmation stuff: */
     146    void setProposeAutoConfirmation(bool fPropose);
     147    bool autoConfirmationProposed() const;
     148    bool isAutoConfirmed() const;
    142149
    143150    /* API: Size-hint stuff: */
    144151    QSize minimumSizeHint() const;
    145152    void setMinimumSizeHint(const QSize &minimumSizeHint);
     153    void layoutContent();
    146154
    147155private slots:
     
    150158    void sltFocusEnter();
    151159    void sltFocusLeave();
    152    
     160
    153161private:
    154162
    155     /* Helperss: Prepare stuff: */
     163    /* Helpers: Prepare stuff: */
    156164    void prepare();
    157165    void prepareContent();
     166
     167    /* Helper: Translate stuff: */
     168    void retranslateUi();
    158169
    159170    /* Helper: Size-hint stuff: */
     
    162173    void updateSizeHint();
    163174
    164     /* Variables: Label stuff: */
    165     QLabel *m_pLabel;
    166     int m_iDesiredWidth;
    167 
    168175    /* Variables: Size-hint stuff: */
     176    const int m_iLayoutMargin;
     177    const int m_iLayoutSpacing;
     178    QSize m_labelSizeHint;
     179    QSize m_checkBoxSizeHint;
    169180    QSize m_collapsedSizeHint;
    170181    QSize m_expandedSizeHint;
    171182    QSize m_minimumSizeHint;
     183
     184    /* Variables: Widget stuff: */
     185    QLabel *m_pLabel;
     186    int m_iDesiredLabelWidth;
     187    QCheckBox *m_pAutoConfirmCheckBox;
     188    bool m_fProposeAutoConfirmation;
    172189
    173190    /* Variables: Animation stuff: */
     
    227244UIPopupPane::UIPopupPane(QWidget *pParent,
    228245                         const QString &strMessage, const QString &strDetails,
    229                          const QMap<int, QString> &buttonDescriptions)
     246                         const QMap<int, QString> &buttonDescriptions,
     247                         bool fProposeAutoConfirmation)
    230248    : QWidget(pParent)
    231249    , m_iLayoutMargin(10), m_iLayoutSpacing(5)
    232     , m_strMessage(strMessage), m_strDetails(strDetails), m_buttonDescriptions(buttonDescriptions)
     250    , m_strMessage(strMessage), m_strDetails(strDetails)
     251    , m_fProposeAutoConfirmation(fProposeAutoConfirmation)
     252    , m_buttonDescriptions(buttonDescriptions)
    233253    , m_fHovered(false)
    234254    , m_iDefaultOpacity(128)
     
    261281    /* Fetch new details: */
    262282    m_strDetails = strDetails;
     283}
     284
     285void UIPopupPane::setProposeAutoConfirmation(bool fPropose)
     286{
     287    /* Make sure something changed: */
     288    if (m_fProposeAutoConfirmation == fPropose)
     289        return;
     290
     291    /* Fetch new auto-confirmation proposal: */
     292    m_fProposeAutoConfirmation = fPropose;
     293    m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);
    263294}
    264295
     
    336367    m_pTextPane->resize(iTextPaneWidth,
    337368                        iTextPaneHeight);
     369    m_pTextPane->layoutContent();
    338370    /* Button-box: */
    339371    m_pButtonPane->move(m_iLayoutMargin + iTextPaneWidth + m_iLayoutSpacing,
     
    370402        m_pTextPane->installEventFilter(this);
    371403        m_pTextPane->setText(m_strMessage);
     404        m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);
    372405    }
    373406    /* Create button-box: */
     
    474507}
    475508
    476 void UIPopupPane::done(int iButtonCode)
     509void UIPopupPane::done(int iResultCode)
    477510{
    478511    /* Close the window: */
    479512    close();
    480513
     514    /* Was the popup auto-confirmed? */
     515    if (m_pTextPane->isAutoConfirmed())
     516        iResultCode |= AlertOption_AutoConfirmed;
     517
    481518    /* Notify listeners: */
    482     emit sigDone(iButtonCode);
     519    emit sigDone(iResultCode);
    483520}
    484521
    485522
    486523UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent /*= 0*/)
    487     : QWidget(pParent)
     524    : QIWithRetranslateUI<QWidget>(pParent)
     525    , m_iLayoutMargin(0)
     526    , m_iLayoutSpacing(10)
    488527    , m_pLabel(0)
    489     , m_iDesiredWidth(-1)
     528    , m_iDesiredLabelWidth(-1)
     529    , m_pAutoConfirmCheckBox(0)
     530    , m_fProposeAutoConfirmation(false)
    490531    , m_fFocused(false)
    491532    , m_pAnimation(0)
     
    500541    if (m_pLabel->text() == strText)
    501542        return;
    502     /* Update the pane for new text: */
     543    /* Update the pane for the new text: */
    503544    m_pLabel->setText(strText);
    504545    updateSizeHint();
     
    508549{
    509550    /* Make sure the desired-width is changed: */
    510     if (m_iDesiredWidth == iDesiredWidth)
    511         return;
    512     /* Update the pane for new desired-width: */
    513     m_iDesiredWidth = iDesiredWidth;
     551    if (m_iDesiredLabelWidth == iDesiredWidth)
     552        return;
     553    /* Update the pane for the new desired-width: */
     554    m_iDesiredLabelWidth = iDesiredWidth;
    514555    updateSizeHint();
    515556}
    516557
     558void UIPopupPaneTextPane::setProposeAutoConfirmation(bool fPropose)
     559{
     560    /* Make sure the auto-confirmation-proposal is changed: */
     561    if (m_fProposeAutoConfirmation == fPropose)
     562        return;
     563    /* Update the pane for the new auto-confirmation-proposal: */
     564    m_fProposeAutoConfirmation = fPropose;
     565    updateSizeHint();
     566}
     567
     568bool UIPopupPaneTextPane::autoConfirmationProposed() const
     569{
     570    return m_fProposeAutoConfirmation;
     571}
     572
     573bool UIPopupPaneTextPane::isAutoConfirmed() const
     574{
     575    return autoConfirmationProposed() &&
     576           m_pAutoConfirmCheckBox &&
     577           m_pAutoConfirmCheckBox->isChecked();
     578}
     579
    517580QSize UIPopupPaneTextPane::minimumSizeHint() const
    518581{
    519582    /* Check if desired-width set: */
    520     if (m_iDesiredWidth >= 0)
    521         /* Return dependent size-hint: */
     583    if (m_iDesiredLabelWidth >= 0)
     584        /* Dependent size-hint: */
    522585        return m_minimumSizeHint;
    523     /* Return golden-rule minimum size-hint by default: */
    524     return m_pLabel->minimumSizeHint();
     586    /* Golden-rule size-hint by default: */
     587    return QWidget::minimumSizeHint();
    525588}
    526589
     
    536599}
    537600
     601void UIPopupPaneTextPane::layoutContent()
     602{
     603    /* Variables: */
     604    const int iWidth = width();
     605    const int iHeight = height();
     606    const int iLabelWidth = m_labelSizeHint.width();
     607    const int iLabelHeight = m_labelSizeHint.height();
     608    /* Label: */
     609    m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin);
     610    m_pLabel->resize(qMin(iWidth, iLabelWidth), qMin(iHeight, iLabelHeight));
     611
     612    /* Check-box: */
     613    if (m_fProposeAutoConfirmation)
     614    {
     615        /* Variables: */
     616        const int iCheckBoxWidth = m_checkBoxSizeHint.width();
     617        const int iCheckBoxHeight = m_checkBoxSizeHint.height();
     618        const int iCheckBoxY = m_iLayoutMargin + iLabelHeight + m_iLayoutSpacing;
     619        /* Layout check-box: */
     620        if (iHeight - m_iLayoutMargin - iCheckBoxHeight - iCheckBoxY >= 0)
     621        {
     622            m_pAutoConfirmCheckBox->move(m_iLayoutMargin, iCheckBoxY);
     623            m_pAutoConfirmCheckBox->resize(iCheckBoxWidth, iCheckBoxHeight);
     624            if (m_pAutoConfirmCheckBox->isHidden())
     625                m_pAutoConfirmCheckBox->show();
     626        }
     627        else if (!m_pAutoConfirmCheckBox->isHidden())
     628            m_pAutoConfirmCheckBox->hide();
     629    }
     630    else if (!m_pAutoConfirmCheckBox->isHidden())
     631        m_pAutoConfirmCheckBox->hide();
     632}
     633
    538634void UIPopupPaneTextPane::sltFocusEnter()
    539635{
     636    /* Ignore if already focused: */
     637    if (m_fFocused)
     638        return;
     639
     640    /* Update focus state: */
     641    m_fFocused = true;
     642
     643    /* Notify listeners: */
     644    emit sigFocusEnter();
     645}
     646
     647void UIPopupPaneTextPane::sltFocusLeave()
     648{
     649    /* Ignore if already unfocused: */
    540650    if (!m_fFocused)
    541     {
    542         m_fFocused = true;
    543         emit sigFocusEnter();
    544     }
    545 }
    546 
    547 void UIPopupPaneTextPane::sltFocusLeave()
    548 {
    549     if (m_fFocused)
    550     {
    551         m_fFocused = false;
    552         emit sigFocusLeave();
    553     }
     651        return;
     652
     653    /* Update focus state: */
     654    m_fFocused = false;
     655
     656    /* Notify listeners: */
     657    emit sigFocusLeave();
    554658}
    555659
     
    565669void UIPopupPaneTextPane::prepareContent()
    566670{
    567     /* Create main layout: */
    568     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    569     {
    570         /* Prepare layout: */
    571         pMainLayout->setContentsMargins(0, 0, 0, 0);
    572         pMainLayout->setSpacing(0);
    573         /* Create label: */
    574         m_pLabel = new QLabel;
     671    /* Create label: */
     672    m_pLabel = new QLabel(this);
     673    {
     674        /* Prepare label: */
     675        QFont currentFont = m_pLabel->font();
     676#ifdef Q_WS_MAC
     677        currentFont.setPointSize(currentFont.pointSize() - 2);
     678#else /* Q_WS_MAC */
     679        currentFont.setPointSize(currentFont.pointSize() - 1);
     680#endif /* !Q_WS_MAC */
     681        m_pLabel->setFont(currentFont);
     682        m_pLabel->setWordWrap(true);
     683    }
     684    /* Create check-box: */
     685    m_pAutoConfirmCheckBox = new QCheckBox(this);
     686    {
     687        /* Prepare check-box: */
     688        QFont currentFont = m_pAutoConfirmCheckBox->font();
     689#ifdef Q_WS_MAC
     690        currentFont.setPointSize(currentFont.pointSize() - 2);
     691#else /* Q_WS_MAC */
     692        currentFont.setPointSize(currentFont.pointSize() - 1);
     693#endif /* !Q_WS_MAC */
     694        m_pAutoConfirmCheckBox->setFont(currentFont);
     695    }
     696    /* Translate UI finally: */
     697    retranslateUi();
     698}
     699
     700void UIPopupPaneTextPane::retranslateUi()
     701{
     702    /* Translate auto-confirm check-box: */
     703    m_pAutoConfirmCheckBox->setText(QApplication::translate("UIMessageCenter", "Do not show this message again"));
     704}
     705
     706void UIPopupPaneTextPane::updateSizeHint()
     707{
     708    /* Recalculate collapsed size-hint: */
     709    {
     710        /* Collapsed size-hint contains only one-text-line label: */
     711        QFontMetrics fm(m_pLabel->font(), m_pLabel);
     712        m_collapsedSizeHint = QSize(m_iDesiredLabelWidth, fm.height());
     713    }
     714
     715    /* Recalculate expanded size-hint: */
     716    {
     717        /* Recalculate label size-hint: */
     718        m_labelSizeHint = QSize(m_iDesiredLabelWidth, m_pLabel->heightForWidth(m_iDesiredLabelWidth));
     719        /* Recalculate check-box size-hint: */
     720        m_checkBoxSizeHint = m_fProposeAutoConfirmation ? m_pAutoConfirmCheckBox->sizeHint() : QSize();
     721        /* Expanded size-hint contains full-size label: */
     722        m_expandedSizeHint = m_labelSizeHint;
     723        /* Expanded size-hint can contain check-box: */
     724        if (m_checkBoxSizeHint.isValid())
    575725        {
    576             /* Add into layout: */
    577             pMainLayout->addWidget(m_pLabel);
    578             /* Prepare label: */
    579             QFont currentFont = m_pLabel->font();
    580 #ifdef Q_WS_MAC
    581             currentFont.setPointSize(currentFont.pointSize() - 2);
    582 #else /* Q_WS_MAC */
    583             currentFont.setPointSize(currentFont.pointSize() - 1);
    584 #endif /* !Q_WS_MAC */
    585             m_pLabel->setFont(currentFont);
    586             m_pLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    587             m_pLabel->setWordWrap(true);
     726            m_expandedSizeHint.setWidth(qMax(m_expandedSizeHint.width(), m_checkBoxSizeHint.width()));
     727            m_expandedSizeHint.setHeight(m_expandedSizeHint.height() + m_iLayoutSpacing + m_checkBoxSizeHint.height());
    588728        }
    589729    }
    590 }
    591 
    592 void UIPopupPaneTextPane::updateSizeHint()
    593 {
    594     /* Recalculate size-hints: */
    595     QFontMetrics fm(m_pLabel->font(), m_pLabel);
    596     m_collapsedSizeHint = QSize(m_iDesiredWidth, fm.height());
    597     m_expandedSizeHint = QSize(m_iDesiredWidth, m_pLabel->heightForWidth(m_iDesiredWidth));
     730
     731    /* Update current size-hint: */
    598732    m_minimumSizeHint = m_fFocused ? m_expandedSizeHint : m_collapsedSizeHint;
    599     /* Reinstall animation: */
     733
     734    /* And reinstall size-hint animation: */
    600735    delete m_pAnimation;
    601736    m_pAnimation = UIAnimationFramework::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint",
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r45662 r45691  
    7171
    7272    /* Notifier: Complete stuff: */
    73     void sigDone(int iButtonCode) const;
     73    void sigDone(int iResultCode) const;
    7474
    7575public:
     
    7878    UIPopupPane(QWidget *pParent,
    7979                const QString &strMessage, const QString &strDetails,
    80                 const QMap<int, QString> &buttonDescriptions);
     80                const QMap<int, QString> &buttonDescriptions,
     81                bool fProposeAutoConfirmation);
    8182
    8283    /* API: Text stuff: */
    8384    void setMessage(const QString &strMessage);
    8485    void setDetails(const QString &strDetails);
     86
     87    /* API: Auto-confirmation stuff: */
     88    void setProposeAutoConfirmation(bool fPropose);
    8589
    8690    /* API: Layout stuff: */
     
    109113
    110114    /* Helper: Complete stuff: */
    111     void done(int iButtonCode);
     115    void done(int iResultCode);
    112116
    113117    /* Property: Hover stuff: */
     
    122126    /* Variables: Text stuff: */
    123127    QString m_strMessage, m_strDetails;
     128
     129    /* Variables: Auto-confirmation stuff: */
     130    bool m_fProposeAutoConfirmation;
    124131
    125132    /* Variables: Button stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp

    r45662 r45691  
    4242void UIPopupStack::updatePopupPane(const QString &strPopupPaneID,
    4343                                   const QString &strMessage, const QString &strDetails,
    44                                    const QMap<int, QString> &buttonDescriptions)
     44                                   const QMap<int, QString> &buttonDescriptions,
     45                                   bool fProposeAutoConfirmation)
    4546{
    4647    /* Looking for the corresponding popup-pane: */
     
    5152        /* Get existing one: */
    5253        pPopupPane = m_panes[strPopupPaneID];
    53         /* And update message and details: */
     54        /* Update message and details: */
    5455        pPopupPane->setMessage(strMessage);
    5556        pPopupPane->setDetails(strDetails);
     
    6162        pPopupPane = m_panes[strPopupPaneID] = new UIPopupPane(this,
    6263                                                               strMessage, strDetails,
    63                                                                buttonDescriptions);
     64                                                               buttonDescriptions,
     65                                                               fProposeAutoConfirmation);
    6466        /* Attach popup-pane connection: */
    6567        connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry()));
     
    9092}
    9193
    92 void UIPopupStack::sltPopupPaneDone(int iButtonCode)
     94void UIPopupStack::sltPopupPaneDone(int iResultCode)
    9395{
    9496    /* Make sure the sender is the popup-pane: */
     
    109111
    110112    /* Notify listeners about popup-pane: */
    111     emit sigPopupPaneDone(strPopupPaneID, iButtonCode);
     113    emit sigPopupPaneDone(strPopupPaneID, iResultCode);
    112114
    113115    /* Cleanup the popup-pane: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h

    r45662 r45691  
    3535
    3636    /* Notifier: Popup-pane stuff: */
    37     void sigPopupPaneDone(QString strID, int iButtonCode);
     37    void sigPopupPaneDone(QString strID, int iResultCode);
    3838
    3939    /* Notifier: Popup-stack stuff: */
     
    4848    void updatePopupPane(const QString &strPopupPaneID,
    4949                         const QString &strMessage, const QString &strDetails,
    50                          const QMap<int, QString> &buttonDescriptions);
     50                         const QMap<int, QString> &buttonDescriptions,
     51                         bool fProposeAutoConfirmation);
    5152
    5253private slots:
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