VirtualBox

Changeset 68540 in vbox


Ignore:
Timestamp:
Aug 29, 2017 2:22:33 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: Adapting UIPopupPane to support error details

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r68435 r68540  
    439439        src/widgets/UIPopupBox.h \
    440440        src/widgets/UIPopupPane.h \
    441         src/widgets/UIPopupPaneTextPane.h \
     441        src/widgets/UIPopupPaneMessage.h \
     442        src/widgets/UIPopupPaneDetails.h \
    442443        src/widgets/UIPopupPaneButtonPane.h \
    443444        src/widgets/UIPopupStack.h \
     
    755756        src/widgets/UIPopupBox.cpp \
    756757        src/widgets/UIPopupPane.cpp \
    757         src/widgets/UIPopupPaneTextPane.cpp \
     758        src/widgets/UIPopupPaneMessage.cpp \
     759        src/widgets/UIPopupPaneDetails.cpp \
    758760        src/widgets/UIPopupPaneButtonPane.cpp \
    759761        src/widgets/UIPopupStack.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r62493 r68540  
    2121/* Qt includes: */
    2222# include <QPainter>
     23# include <QTextEdit>
    2324
    2425/* GUI includes: */
    2526# include "UIPopupPane.h"
    26 # include "UIPopupPaneTextPane.h"
     27# include "UIPopupPaneMessage.h"
     28# include "UIPopupPaneDetails.h"
    2729# include "UIPopupPaneButtonPane.h"
    2830# include "UIAnimationFramework.h"
    2931# include "QIMessageBox.h"
     32
     33/* Other VBox includes: */
     34# include <iprt/assert.h>
    3035
    3136#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    4853    , m_iHoveredOpacity(250)
    4954    , m_iOpacity(m_fHovered ? m_iHoveredOpacity : m_iDefaultOpacity)
    50     , m_pTextPane(0), m_pButtonPane(0)
     55    , m_pMessagePane(0), m_pDetailsPane(0), m_pButtonPane(0)
    5156{
    5257    /* Prepare: */
     
    6873    /* Fetch new message: */
    6974    m_strMessage = strMessage;
    70     m_pTextPane->setText(m_strMessage);
     75    m_pMessagePane->setText(m_strMessage);
    7176}
    7277
     
    7984    /* Fetch new details: */
    8085    m_strDetails = strDetails;
     86    m_pDetailsPane->setText(prepareDetailsText());
    8187}
    8288
     
    103109    const int iButtonPaneMinimumHeight = buttonPaneMinimumSizeHint.height();
    104110    const int iTextPaneWidth = iWidth - 2 * m_iLayoutMargin - m_iLayoutSpacing - iButtonPaneMinimumWidth;
    105     const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();
     111    const int iTextPaneHeight = m_pMessagePane->minimumSizeHint().height();
    106112    const int iMaximumHeight = qMax(iTextPaneHeight, iButtonPaneMinimumHeight);
    107113    const int iMinimumHeight = qMin(iTextPaneHeight, iButtonPaneMinimumHeight);
    108114    const int iHeightShift = (iMaximumHeight - iMinimumHeight) / 2;
    109115    const bool fTextPaneShifted = iTextPaneHeight < iButtonPaneMinimumHeight;
    110 
    111     /* Text-pane: */
    112     m_pTextPane->move(m_iLayoutMargin,
    113                       fTextPaneShifted ? m_iLayoutMargin + iHeightShift : m_iLayoutMargin);
    114     m_pTextPane->resize(iTextPaneWidth,
    115                         iTextPaneHeight);
    116     m_pTextPane->layoutContent();
     116    const int iTextPaneYOffset = fTextPaneShifted ? m_iLayoutMargin + iHeightShift : m_iLayoutMargin;
     117
     118    /* Message-pane: */
     119    m_pMessagePane->move(m_iLayoutMargin, iTextPaneYOffset);
     120    m_pMessagePane->resize(iTextPaneWidth, iTextPaneHeight);
     121    m_pMessagePane->layoutContent();
    117122
    118123    /* Button-pane: */
     
    120125                        m_iLayoutMargin);
    121126    m_pButtonPane->resize(iButtonPaneMinimumWidth,
    122                           iHeight - 2 * m_iLayoutMargin);
     127                          iHeight - m_iLayoutSpacing);
     128
     129    /* Details-pane: */
     130    if(m_pDetailsPane->isVisible())
     131    {
     132        m_pDetailsPane->move(m_iLayoutMargin,
     133                             iTextPaneYOffset + iTextPaneHeight + m_iLayoutSpacing);
     134        m_pDetailsPane->resize(iTextPaneWidth + iButtonPaneMinimumWidth,
     135                               m_pDetailsPane->minimumSizeHint().height() -  m_iLayoutMargin);
     136        m_pDetailsPane->layoutContent();
     137    }
    123138}
    124139
     
    129144}
    130145
    131 void UIPopupPane::sltHandleProposalForWidth(int iWidth)
    132 {
    133     /* Make sure text-pane exists: */
    134     if (!m_pTextPane)
    135         return;
     146void UIPopupPane::sltHandleProposalForSize(QSize newSize)
     147{
     148    /* Prepare the width: */
     149    int iWidth = newSize.width();
    136150
    137151    /* Subtract layout margins: */
     
    142156    iWidth -= m_pButtonPane->minimumSizeHint().width();
    143157
    144     /* Propose resulting width to text-pane: */
    145     emit sigProposeTextPaneWidth(iWidth);
     158    /* Propose resulting width to the panes: */
     159    emit sigProposePaneWidth(iWidth);
     160
     161    /* Prepare the height: */
     162    int iHeight = newSize.height();
     163    /* Determine maximum height of the message-pane / button-pane: */
     164    int iExtraHeight = qMax(m_pMessagePane->expandedSizeHint().height(),
     165                            m_pButtonPane->minimumSizeHint().height());
     166
     167    /* Subtract height of the message pane: */
     168    iHeight -= iExtraHeight;
     169    /* Subtract layout margins: */
     170    iHeight -= 2 * m_iLayoutMargin;
     171    /* Subtract layout spacing: */
     172    iHeight -= m_iLayoutSpacing;
     173
     174    /* Propose resulting height to details-pane: */
     175    emit sigProposeDetailsPaneHeight(iHeight);
    146176}
    147177
     
    155185        {
    156186            /* Take into account widgets: */
    157             iMinimumWidthHint += m_pTextPane->minimumSizeHint().width();
     187            iMinimumWidthHint += m_pMessagePane->minimumSizeHint().width();
    158188            iMinimumWidthHint += m_iLayoutSpacing;
    159189            iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width();
     
    168198        {
    169199            /* Take into account widgets: */
    170             const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();
     200            const int iTextPaneHeight = m_pMessagePane->minimumSizeHint().height();
    171201            const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height();
    172202            iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);
     203            /* Add the height of details-pane only if it is visible: */
     204            if (m_pDetailsPane->isVisible())
     205                iMinimumHeightHint += m_pDetailsPane->minimumSizeHint().height();
    173206        }
    174207    }
     
    218251void UIPopupPane::prepareContent()
    219252{
    220     /* Create message-label: */
    221     m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fFocused);
    222     {
    223         /* Prepare label: */
    224         connect(this, SIGNAL(sigProposeTextPaneWidth(int)), m_pTextPane, SLOT(sltHandleProposalForWidth(int)));
    225         connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint()));
    226         m_pTextPane->installEventFilter(this);
     253    /* Create message-pane: */
     254    m_pMessagePane = new UIPopupPaneMessage(this, m_strMessage, m_fFocused);
     255    {
     256        /* Configure message-pane: */
     257        connect(this, SIGNAL(sigProposePaneWidth(int)), m_pMessagePane, SLOT(sltHandleProposalForWidth(int)));
     258        connect(m_pMessagePane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint()));
     259        m_pMessagePane->installEventFilter(this);
    227260    }
    228261
     
    230263    m_pButtonPane = new UIPopupPaneButtonPane(this);
    231264    {
    232         /* Prepare button-box: */
     265        /* Configure button-box: */
    233266        connect(m_pButtonPane, SIGNAL(sigButtonClicked(int)), this, SLOT(sltButtonClicked(int)));
    234267        m_pButtonPane->installEventFilter(this);
     
    236269    }
    237270
     271    /* Create details-pane: */
     272    m_pDetailsPane = new UIPopupPaneDetails(this, prepareDetailsText(), m_fFocused);
     273    {
     274        /* Configure details-pane: */
     275        connect(this, &UIPopupPane::sigProposePaneWidth,         m_pDetailsPane, &UIPopupPaneDetails::sltHandleProposalForWidth);
     276        connect(this, &UIPopupPane::sigProposeDetailsPaneHeight, m_pDetailsPane, &UIPopupPaneDetails::sltHandleProposalForHeight);
     277        connect(m_pDetailsPane, &UIPopupPaneDetails::sigSizeHintChanged, this, &UIPopupPane::sltUpdateSizeHint);
     278        m_pDetailsPane->installEventFilter(this);
     279    }
     280
    238281    /* Prepare focus rules: */
    239282    setFocusPolicy(Qt::StrongFocus);
    240     m_pTextPane->setFocusPolicy(Qt::StrongFocus);
     283    m_pMessagePane->setFocusPolicy(Qt::StrongFocus);
    241284    m_pButtonPane->setFocusPolicy(Qt::StrongFocus);
     285    m_pDetailsPane->setFocusPolicy(Qt::StrongFocus);
    242286    setFocusProxy(m_pButtonPane);
    243     m_pTextPane->setFocusProxy(m_pButtonPane);
     287    m_pMessagePane->setFocusProxy(m_pButtonPane);
     288    m_pDetailsPane->setFocusProxy(m_pButtonPane);
    244289
    245290    /* Translate UI finally: */
     
    268313void UIPopupPane::retranslateToolTips()
    269314{
    270     /* Translate pane & text-pane tool-tips: */
     315    /* Translate pane & message-pane tool-tips: */
    271316    if (m_fFocused)
    272317    {
    273318        setToolTip(QString());
    274         m_pTextPane->setToolTip(QString());
     319        m_pMessagePane->setToolTip(QString());
    275320    }
    276321    else
    277322    {
    278323        setToolTip(QApplication::translate("UIPopupCenter", "Click for full details"));
    279         m_pTextPane->setToolTip(QApplication::translate("UIPopupCenter", "Click for full details"));
     324        m_pMessagePane->setToolTip(QApplication::translate("UIPopupCenter", "Click for full details"));
    280325    }
    281326}
     
    443488}
    444489
     490QString UIPopupPane::prepareDetailsText() const
     491{
     492    if (m_strDetails.isEmpty())
     493        return QString();
     494
     495    QStringPairList aDetailsList;
     496    prepareDetailsList(aDetailsList);
     497    if (aDetailsList.isEmpty())
     498        return QString();
     499
     500    if (aDetailsList.size() == 1)
     501        return tr("<p><b>Details:</b>") + m_strDetails + "</p>";
     502
     503    QString strResultText;
     504    for (int iListIdx = 0; iListIdx < aDetailsList.size(); ++iListIdx)
     505    {
     506        strResultText += tr("<p><b>Details:</b> (%1 of %2)").arg(iListIdx + 1).arg(aDetailsList.size());
     507        const QString strFirstPart = aDetailsList.at(iListIdx).first;
     508        const QString strSecondPart = aDetailsList.at(iListIdx).second;
     509        if (strFirstPart.isEmpty())
     510            strResultText += strSecondPart + "</p>";
     511        else
     512            strResultText += QString("%1<br>%2").arg(strFirstPart, strSecondPart) + "</p>";
     513    }
     514    return strResultText;
     515}
     516
     517void UIPopupPane::prepareDetailsList(QStringPairList &aDetailsList) const
     518{
     519    if (m_strDetails.isEmpty())
     520        return;
     521
     522    /* Split details into paragraphs: */
     523    QStringList aParagraphs(m_strDetails.split("<!--EOP-->", QString::SkipEmptyParts));
     524    /* Make sure details-text has at least one paragraph: */
     525    AssertReturnVoid(!aParagraphs.isEmpty());
     526
     527    /* Enumerate all the paragraphs: */
     528    foreach (const QString &strParagraph, aParagraphs)
     529    {
     530        /* Split each paragraph into pairs: */
     531        QStringList aParts(strParagraph.split("<!--EOM-->", QString::KeepEmptyParts));
     532        /* Make sure each paragraph consist of 2 parts: */
     533        AssertReturnVoid(aParts.size() == 2);
     534        /* Append each pair into details-list: */
     535        aDetailsList << QStringPair(aParts.at(0), aParts.at(1));
     536    }
     537}
     538
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r62493 r68540  
    2727
    2828/* Forward declaration: */
    29 class UIPopupPaneTextPane;
     29class UIPopupPaneMessage;
     30class UIPopupPaneDetails;
    3031class UIPopupPaneButtonPane;
    3132class UIAnimation;
     
    5960
    6061    /* Notifiers: Layout stuff: */
    61     void sigProposeTextPaneWidth(int iWidth);
     62    void sigProposePaneWidth(int iWidth);
     63    void sigProposeDetailsPaneHeight(int iHeight);
    6264    void sigSizeHintChanged();
    6365
     
    8486    void layoutContent();
    8587
     88public slots:
     89
     90    /* Handler: Layout stuff: */
     91    void sltHandleProposalForSize(QSize newSize);
     92
    8693private slots:
    8794
     
    8996    void sltMarkAsShown();
    9097
    91     /* Handlers: Layout stuff: */
    92     void sltHandleProposalForWidth(int iWidth);
     98    /* Handler: Layout stuff: */
    9399    void sltUpdateSizeHint();
    94100
     
    97103
    98104private:
     105
     106    /* Type definitions: */
     107    typedef QPair<QString, QString> QStringPair;
     108    typedef QList<QStringPair> QStringPairList;
    99109
    100110    /* Helpers: Prepare stuff: */
     
    134144    void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
    135145
     146    /* Helpers: Details stuff: */
     147    QString prepareDetailsText() const;
     148    void prepareDetailsList(QStringPairList &aDetailsList) const;
     149
    136150    /* Variables: General stuff: */
    137151    bool m_fPolished;
     
    164178
    165179    /* Widgets: */
    166     UIPopupPaneTextPane *m_pTextPane;
     180    UIPopupPaneMessage    *m_pMessagePane;
     181    UIPopupPaneDetails    *m_pDetailsPane;
    167182    UIPopupPaneButtonPane *m_pButtonPane;
    168183};
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneDetails.cpp

    r68537 r68540  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIPopupPaneTextPane class implementation.
     3 * VBox Qt GUI - UIPopupPaneDetails class implementation.
    44 */
    55
     
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121/* Qt includes: */
    22 # include <QLabel>
    2322# include <QCheckBox>
     23# include <QTextDocument>
     24# include <QTextEdit>
    2425
    2526/* GUI includes: */
    26 # include "UIPopupPaneTextPane.h"
     27# include "UIPopupPaneDetails.h"
    2728# include "UIAnimationFramework.h"
    2829
     
    3031
    3132
    32 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused)
     33UIPopupPaneDetails::UIPopupPaneDetails(QWidget *pParent, const QString &strText, bool fFocused)
    3334    : QWidget(pParent)
    3435    , m_iLayoutMargin(0)
    3536    , m_iLayoutSpacing(10)
    3637    , m_strText(strText)
    37     , m_pLabel(0)
    38     , m_iDesiredLabelWidth(-1)
     38    , m_pTextEdit(0)
     39    , m_iDesiredTextEditWidth(-1)
     40    , m_iDesiredTextEditHeight(-1)
    3941    , m_fFocused(fFocused)
    4042    , m_pAnimation(0)
     
    4446}
    4547
    46 void UIPopupPaneTextPane::setText(const QString &strText)
     48void UIPopupPaneDetails::setText(const QString &strText)
    4749{
    4850    /* Make sure the text has changed: */
    49     if (m_pLabel->text() == strText)
     51    if (m_strText == strText)
    5052        return;
    5153
    5254    /* Fetch new text: */
    5355    m_strText = strText;
    54     m_pLabel->setText(m_strText);
    55 
    56     /* Update size-hint: */
    57     updateSizeHint();
    58 }
    59 
    60 QSize UIPopupPaneTextPane::minimumSizeHint() const
     56    m_pTextEdit->setText(m_strText);
     57
     58    /* Update size-hint/visibility: */
     59    updateSizeHint();
     60    updateVisibility();
     61}
     62
     63QSize UIPopupPaneDetails::minimumSizeHint() const
    6164{
    6265    /* Check if desired-width set: */
    63     if (m_iDesiredLabelWidth >= 0)
     66    if (m_iDesiredTextEditWidth >= 0)
    6467        /* Dependent size-hint: */
    6568        return m_minimumSizeHint;
     
    6871}
    6972
    70 void UIPopupPaneTextPane::setMinimumSizeHint(const QSize &minimumSizeHint)
     73void UIPopupPaneDetails::setMinimumSizeHint(const QSize &minimumSizeHint)
    7174{
    7275    /* Make sure the size-hint has changed: */
     
    8184}
    8285
    83 void UIPopupPaneTextPane::layoutContent()
     86void UIPopupPaneDetails::layoutContent()
    8487{
    8588    /* Variables: */
    8689    const int iWidth = width();
    8790    const int iHeight = height();
    88     const int iLabelWidth = m_labelSizeHint.width();
    89     const int iLabelHeight = m_labelSizeHint.height();
    90 
    91     /* Label: */
    92     m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin);
    93     m_pLabel->resize(qMin(iWidth, iLabelWidth), qMin(iHeight, iLabelHeight));
    94 }
    95 
    96 void UIPopupPaneTextPane::sltHandleProposalForWidth(int iWidth)
     91    const int iTextEditWidth = m_textEditSizeHint.width();
     92    const int iTextEditHeight = m_textEditSizeHint.height();
     93
     94    /* TextEdit: */
     95    m_pTextEdit->move(m_iLayoutMargin, m_iLayoutMargin);
     96    m_pTextEdit->resize(qMin(iWidth, iTextEditWidth), qMin(iHeight, iTextEditHeight));
     97}
     98
     99void UIPopupPaneDetails::updateVisibility()
     100{
     101    if (m_fFocused && !m_strText.isEmpty())
     102        show();
     103    else
     104        hide();
     105}
     106
     107void UIPopupPaneDetails::sltHandleProposalForWidth(int iWidth)
    97108{
    98109    /* Make sure the desired-width has changed: */
    99     if (m_iDesiredLabelWidth == iWidth)
     110    if (m_iDesiredTextEditWidth == iWidth)
    100111        return;
    101112
    102113    /* Fetch new desired-width: */
    103     m_iDesiredLabelWidth = iWidth;
     114    m_iDesiredTextEditWidth = iWidth;
    104115
    105116    /* Update size-hint: */
     
    107118}
    108119
    109 void UIPopupPaneTextPane::sltFocusEnter()
     120void UIPopupPaneDetails::sltHandleProposalForHeight(int iHeight)
     121{
     122    /* Make sure the desired-height has changed: */
     123    if (m_iDesiredTextEditHeight == iHeight)
     124        return;
     125
     126    /* Fetch new desired-height: */
     127    m_iDesiredTextEditHeight = iHeight;
     128
     129    /* Update size-hint: */
     130    updateSizeHint();
     131}
     132
     133void UIPopupPaneDetails::sltFocusEnter()
    110134{
    111135    /* Ignore if already focused: */
     
    116140    m_fFocused = true;
    117141
     142    /* Update visibility: */
     143    updateVisibility();
     144
    118145    /* Notify listeners: */
    119146    emit sigFocusEnter();
    120147}
    121148
    122 void UIPopupPaneTextPane::sltFocusLeave()
     149void UIPopupPaneDetails::sltFocusLeave()
    123150{
    124151    /* Ignore if already unfocused: */
     
    129156    m_fFocused = false;
    130157
     158    /* Update visibility: */
     159    updateVisibility();
     160
    131161    /* Notify listeners: */
    132162    emit sigFocusLeave();
    133163}
    134164
    135 void UIPopupPaneTextPane::prepare()
     165void UIPopupPaneDetails::prepare()
    136166{
    137167    /* Prepare content: */
     
    140170    prepareAnimation();
    141171
    142     /* Update size-hint: */
    143     updateSizeHint();
    144 }
    145 
    146 void UIPopupPaneTextPane::prepareContent()
    147 {
    148     /* Create label: */
    149     m_pLabel = new QLabel(this);
     172    /* Update size-hint/visibility: */
     173    updateSizeHint();
     174    updateVisibility();
     175}
     176
     177void UIPopupPaneDetails::prepareContent()
     178{
     179    /* Create text-editor: */
     180    m_pTextEdit = new QTextEdit(this);
    150181    {
    151         /* Prepare label: */
    152         m_pLabel->setFont(tuneFont(m_pLabel->font()));
    153         m_pLabel->setWordWrap(true);
    154         m_pLabel->setFocusPolicy(Qt::NoFocus);
    155         m_pLabel->setText(m_strText);
     182        /* Configure text-editor: */
     183        m_pTextEdit->setFont(tuneFont(m_pTextEdit->font()));
     184        m_pTextEdit->setText(m_strText);
     185        m_pTextEdit->setFocusProxy(this);
     186        m_pTextEdit->setLineWrapMode(QTextEdit::NoWrap);
    156187    }
    157188}
    158189
    159 void UIPopupPaneTextPane::prepareAnimation()
     190void UIPopupPaneDetails::prepareAnimation()
    160191{
    161192    /* Propagate parent signals: */
     
    167198}
    168199
    169 void UIPopupPaneTextPane::updateSizeHint()
     200void UIPopupPaneDetails::updateSizeHint()
    170201{
    171202    /* Recalculate collapsed size-hint: */
    172203    {
    173         /* Collapsed size-hint contains only one-text-line label: */
    174         QFontMetrics fm(m_pLabel->font(), m_pLabel);
    175         m_collapsedSizeHint = QSize(m_iDesiredLabelWidth, fm.height());
     204        /* Collapsed size-hint with 0 height: */
     205        m_collapsedSizeHint = QSize(m_iDesiredTextEditWidth, 0);
    176206    }
    177207
    178208    /* Recalculate expanded size-hint: */
    179209    {
     210        int iNewHeight = m_iDesiredTextEditHeight;
     211        QTextDocument *pTextDocument = m_pTextEdit->document();
     212        if(pTextDocument)
     213        {
     214            /* Adjust text-edit size: */
     215            pTextDocument->adjustSize();
     216            /* Get corresponding QTextDocument size: */
     217            QSize textSize = pTextDocument->size().toSize();
     218            /* Make sure the text edits height is no larger than that of container widget: */
     219            iNewHeight = qMin(iNewHeight, textSize.height());
     220        }
    180221        /* Recalculate label size-hint: */
    181         m_labelSizeHint = QSize(m_iDesiredLabelWidth, m_pLabel->heightForWidth(m_iDesiredLabelWidth));
     222        m_textEditSizeHint = QSize(m_iDesiredTextEditWidth, iNewHeight);
    182223        /* Expanded size-hint contains full-size label: */
    183         m_expandedSizeHint = m_labelSizeHint;
     224        m_expandedSizeHint = m_textEditSizeHint;
    184225    }
    185226
     
    196237
    197238/* static */
    198 QFont UIPopupPaneTextPane::tuneFont(QFont font)
     239QFont UIPopupPaneDetails::tuneFont(QFont font)
    199240{
    200241#if defined(VBOX_WS_MAC)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneDetails.h

    r68537 r68540  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIPopupPaneTextPane class declaration.
     3 * VBox Qt GUI - UIPopupPaneDetails class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef __UIPopupPaneTextPane_h__
    19 #define __UIPopupPaneTextPane_h__
     18#ifndef ___UIPopupPaneDetails_h___
     19#define ___UIPopupPaneDetails_h___
    2020
    2121/* Qt includes: */
     
    2323
    2424/* Forward declarations: */
    25 class QLabel;
     25class QTextEdit;
    2626class UIAnimation;
    2727
    2828/* Popup-pane text-pane prototype class: */
    29 class UIPopupPaneTextPane : public QWidget
     29class UIPopupPaneDetails : public QWidget
    3030{
    3131    Q_OBJECT;
     
    4646
    4747    /* Constructor: */
    48     UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused);
     48    UIPopupPaneDetails(QWidget *pParent, const QString &strText, bool fFocused);
    4949
    5050    /* API: Text stuff: */
     
    5656    void layoutContent();
    5757
    58 private slots:
     58    /* Property: Focus stuff: */
     59    QSize collapsedSizeHint() const { return m_collapsedSizeHint; }
     60    QSize expandedSizeHint() const { return m_expandedSizeHint; }
    5961
    60     /* Handler: Layout stuff: */
     62public slots:
     63
     64    /* Handlers: Layout stuff: */
    6165    void sltHandleProposalForWidth(int iWidth);
     66    void sltHandleProposalForHeight(int iHeight);
    6267
    6368    /* Handlers: Focus stuff: */
     
    7479    /* Helper: Layout stuff: */
    7580    void updateSizeHint();
    76 
    77     /* Property: Focus stuff: */
    78     QSize collapsedSizeHint() const { return m_collapsedSizeHint; }
    79     QSize expandedSizeHint() const { return m_expandedSizeHint; }
     81    void updateVisibility();
    8082
    8183    /* Static helper: Font stuff: */
     
    8587    const int m_iLayoutMargin;
    8688    const int m_iLayoutSpacing;
    87     QSize m_labelSizeHint;
     89    QSize m_textEditSizeHint;
    8890    QSize m_collapsedSizeHint;
    8991    QSize m_expandedSizeHint;
     
    9294    /* Variables: Widget stuff: */
    9395    QString m_strText;
    94     QLabel *m_pLabel;
    95     int m_iDesiredLabelWidth;
     96    QTextEdit *m_pTextEdit;
     97    int m_iDesiredTextEditWidth;
     98    int m_iDesiredTextEditHeight;
    9699
    97100    /* Variables: Focus stuff: */
     
    100103};
    101104
    102 #endif /* __UIPopupPaneTextPane_h__ */
     105#endif /* !___UIPopupPaneDetails_h___ */
     106
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneMessage.cpp

    r68537 r68540  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIPopupPaneTextPane class implementation.
     3 * VBox Qt GUI - UIPopupPaneMessage class implementation.
    44 */
    55
     
    2424
    2525/* GUI includes: */
    26 # include "UIPopupPaneTextPane.h"
     26# include "UIPopupPaneMessage.h"
    2727# include "UIAnimationFramework.h"
    2828
     
    3030
    3131
    32 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused)
     32UIPopupPaneMessage::UIPopupPaneMessage(QWidget *pParent, const QString &strText, bool fFocused)
    3333    : QWidget(pParent)
    3434    , m_iLayoutMargin(0)
     
    4444}
    4545
    46 void UIPopupPaneTextPane::setText(const QString &strText)
     46void UIPopupPaneMessage::setText(const QString &strText)
    4747{
    4848    /* Make sure the text has changed: */
    49     if (m_pLabel->text() == strText)
     49    if (m_strText == strText)
    5050        return;
    5151
     
    5858}
    5959
    60 QSize UIPopupPaneTextPane::minimumSizeHint() const
     60QSize UIPopupPaneMessage::minimumSizeHint() const
    6161{
    6262    /* Check if desired-width set: */
     
    6868}
    6969
    70 void UIPopupPaneTextPane::setMinimumSizeHint(const QSize &minimumSizeHint)
     70void UIPopupPaneMessage::setMinimumSizeHint(const QSize &minimumSizeHint)
    7171{
    7272    /* Make sure the size-hint has changed: */
     
    8181}
    8282
    83 void UIPopupPaneTextPane::layoutContent()
     83void UIPopupPaneMessage::layoutContent()
    8484{
    8585    /* Variables: */
     
    9494}
    9595
    96 void UIPopupPaneTextPane::sltHandleProposalForWidth(int iWidth)
     96void UIPopupPaneMessage::sltHandleProposalForWidth(int iWidth)
    9797{
    9898    /* Make sure the desired-width has changed: */
     
    107107}
    108108
    109 void UIPopupPaneTextPane::sltFocusEnter()
     109void UIPopupPaneMessage::sltFocusEnter()
    110110{
    111111    /* Ignore if already focused: */
     
    120120}
    121121
    122 void UIPopupPaneTextPane::sltFocusLeave()
     122void UIPopupPaneMessage::sltFocusLeave()
    123123{
    124124    /* Ignore if already unfocused: */
     
    133133}
    134134
    135 void UIPopupPaneTextPane::prepare()
     135void UIPopupPaneMessage::prepare()
    136136{
    137137    /* Prepare content: */
     
    144144}
    145145
    146 void UIPopupPaneTextPane::prepareContent()
     146void UIPopupPaneMessage::prepareContent()
    147147{
    148148    /* Create label: */
    149149    m_pLabel = new QLabel(this);
    150150    {
    151         /* Prepare label: */
     151        /* Configure label: */
    152152        m_pLabel->setFont(tuneFont(m_pLabel->font()));
    153153        m_pLabel->setWordWrap(true);
     
    157157}
    158158
    159 void UIPopupPaneTextPane::prepareAnimation()
     159void UIPopupPaneMessage::prepareAnimation()
    160160{
    161161    /* Propagate parent signals: */
     
    167167}
    168168
    169 void UIPopupPaneTextPane::updateSizeHint()
     169void UIPopupPaneMessage::updateSizeHint()
    170170{
    171171    /* Recalculate collapsed size-hint: */
     
    196196
    197197/* static */
    198 QFont UIPopupPaneTextPane::tuneFont(QFont font)
     198QFont UIPopupPaneMessage::tuneFont(QFont font)
    199199{
    200200#if defined(VBOX_WS_MAC)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneMessage.h

    r68537 r68540  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIPopupPaneTextPane class declaration.
     3 * VBox Qt GUI - UIPopupPaneMessage class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef __UIPopupPaneTextPane_h__
    19 #define __UIPopupPaneTextPane_h__
     18#ifndef ___UIPopupPaneMessage_h___
     19#define ___UIPopupPaneMessage_h___
    2020
    2121/* Qt includes: */
     
    2727
    2828/* Popup-pane text-pane prototype class: */
    29 class UIPopupPaneTextPane : public QWidget
     29class UIPopupPaneMessage : public QWidget
    3030{
    3131    Q_OBJECT;
     
    4646
    4747    /* Constructor: */
    48     UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused);
     48    UIPopupPaneMessage(QWidget *pParent, const QString &strText, bool fFocused);
    4949
    5050    /* API: Text stuff: */
     
    5555    void setMinimumSizeHint(const QSize &minimumSizeHint);
    5656    void layoutContent();
     57
     58    /* Property: Focus stuff: */
     59    QSize collapsedSizeHint() const { return m_collapsedSizeHint; }
     60    QSize expandedSizeHint() const { return m_expandedSizeHint; }
    5761
    5862private slots:
     
    7478    /* Helper: Layout stuff: */
    7579    void updateSizeHint();
    76 
    77     /* Property: Focus stuff: */
    78     QSize collapsedSizeHint() const { return m_collapsedSizeHint; }
    79     QSize expandedSizeHint() const { return m_expandedSizeHint; }
    8080
    8181    /* Static helper: Font stuff: */
     
    100100};
    101101
    102 #endif /* __UIPopupPaneTextPane_h__ */
     102#endif /* !___UIPopupPaneMessage_h___ */
     103
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp

    r64334 r68540  
    6262                                       buttonDescriptions);
    6363
    64     /* Propagate width: */
    65     propagateWidth();
     64    /* Propagate size: */
     65    propagateSize();
    6666}
    6767
     
    230230                m_pScrollViewport->setCursor(Qt::ArrowCursor);
    231231                /* Connect scroll-viewport: */
    232                 connect(this, SIGNAL(sigProposeStackViewportWidth(int)),
    233                         m_pScrollViewport, SLOT(sltHandleProposalForWidth(int)));
     232                connect(this, &UIPopupStack::sigProposeStackViewportSize,
     233                        m_pScrollViewport, &UIPopupStackViewport::sltHandleProposalForSize);
    234234                connect(m_pScrollViewport, SIGNAL(sigSizeHintChanged()),
    235235                        this, SLOT(sltAdjustGeometry()));
     
    260260        case QEvent::Resize:
    261261        {
    262             /* Propagate width: */
    263             propagateWidth();
     262            /* Propagate size: */
     263            propagateSize();
    264264            /* Adjust geometry: */
    265265            sltAdjustGeometry();
     
    281281void UIPopupStack::showEvent(QShowEvent*)
    282282{
    283     /* Propagate width: */
    284     propagateWidth();
     283    /* Propagate size: */
     284    propagateSize();
    285285    /* Adjust geometry: */
    286286    sltAdjustGeometry();
    287287}
    288288
    289 void UIPopupStack::propagateWidth()
     289void UIPopupStack::propagateSize()
    290290{
    291291    /* Make sure parent is currently set: */
     
    293293        return;
    294294
    295     /* Get parent width: */
    296     int iWidth = parentWidget()->width();
     295    /* Get parent size: */
     296    QSize newSize = parentWidget()->size();
    297297    /* Subtract left/right layout margins: */
    298298    if (m_pMainLayout)
     
    300300        int iLeft, iTop, iRight, iBottom;
    301301        m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    302         iWidth -= (iLeft + iRight);
     302        newSize.setWidth(newSize.width() - (iLeft + iRight));
     303        newSize.setHeight(newSize.height() - (iTop + iBottom));
    303304    }
    304305    /* Subtract scroll-area frame-width: */
    305306    if (m_pScrollArea)
    306307    {
    307         iWidth -= 2 * m_pScrollArea->frameWidth();
    308     }
    309 
    310     /* Propose resulting width to viewport: */
    311     emit sigProposeStackViewportWidth(iWidth);
     308        newSize.setWidth(newSize.width() - (2 * m_pScrollArea->frameWidth()));
     309        newSize.setHeight(newSize.height() - (2 * m_pScrollArea->frameWidth()));
     310    }
     311    newSize.setHeight(newSize.height() - (m_iParentMenuBarHeight + m_iParentStatusBarHeight));
     312
     313    /* Propose resulting size to viewport: */
     314    emit sigProposeStackViewportSize(newSize);
    312315}
    313316
     
    339342            /* Search for existing status-bar child: */
    340343            if (QStatusBar *pStatusBar = pMainWindow->findChild<QStatusBar*>())
    341                 return pStatusBar->height();
     344                if(pStatusBar->isVisible())
     345                    return pStatusBar->height();
     346
    342347        }
    343348    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h

    r62493 r68540  
    3939
    4040    /* Notifier: Layout stuff: */
    41     void sigProposeStackViewportWidth(int iWidth);
     41    void sigProposeStackViewportSize(QSize newSize);
    4242
    4343    /* Notifier: Popup-pane stuff: */
     
    8888
    8989    /* Helper: Layout stuff: */
    90     void propagateWidth();
     90    void propagateSize();
    9191
    9292    /* Static helpers: Prepare stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.cpp

    r62493 r68540  
    5858
    5959    /* Attach popup-pane connection: */
    60     connect(this, SIGNAL(sigProposePopupPaneWidth(int)), pPopupPane, SLOT(sltHandleProposalForWidth(int)));
     60    connect(this, &UIPopupStackViewport::sigProposePopupPaneSize, pPopupPane, &UIPopupPane::sltHandleProposalForSize);
    6161    connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry()));
    6262    connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int)));
     
    100100}
    101101
    102 void UIPopupStackViewport::sltHandleProposalForWidth(int iWidth)
     102void UIPopupStackViewport::sltHandleProposalForSize(QSize newSize)
    103103{
    104104    /* Subtract layout margins: */
    105     iWidth -= 2 * m_iLayoutMargin;
    106 
    107     /* Propagate resulting width to popups: */
    108     emit sigProposePopupPaneWidth(iWidth);
     105    newSize.setWidth(newSize.width() - 2 * m_iLayoutMargin);
     106    newSize.setHeight(newSize.height() - 2 * m_iLayoutMargin);
     107
     108    /* Propagate resulting size to popups: */
     109    emit sigProposePopupPaneSize(newSize);
    109110}
    110111
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.h

    r62493 r68540  
    3434
    3535    /* Notifiers: Layout stuff: */
    36     void sigProposePopupPaneWidth(int iWidth);
     36    void sigProposePopupPaneSize(QSize newSize);
    3737    void sigSizeHintChanged();
    3838
     
    5959    QSize minimumSizeHint() const { return m_minimumSizeHint; }
    6060
     61public slots:
     62
     63    /* Handler: Layout stuff: */
     64    void sltHandleProposalForSize(QSize newSize);
     65
    6166private slots:
    6267
    63     /* Handlers: Layout stuff: */
    64     void sltHandleProposalForWidth(int iWidth);
     68    /* Handler: Layout stuff: */
    6569    void sltAdjustGeometry();
    6670
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