VirtualBox

Changeset 45523 in vbox


Ignore:
Timestamp:
Apr 12, 2013 3:33:59 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Popup center: Moving popup-pane stuff into corresponding separate files.

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

Legend:

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

    r45431 r45523  
    383383        src/widgets/UILineTextEdit.h \
    384384        src/widgets/UIPopupBox.h \
     385        src/widgets/UIPopupPane.h \
    385386        src/widgets/UIProgressDialog.h \
    386387        src/widgets/UISpacerWidgets.h \
     
    456457        src/settings/machine/UIMachineSettingsUSB.cpp \
    457458        src/widgets/UIHotKeyEditor.cpp \
     459        src/widgets/UIPopupPane.cpp \
    458460        src/wizards/importappliance/UIWizardImportApp.cpp
    459461
     
    627629        src/widgets/UILineTextEdit.cpp \
    628630        src/widgets/UIPopupBox.cpp \
     631        src/widgets/UIPopupPane.cpp \
    629632        src/widgets/UIProgressDialog.cpp \
    630633        src/widgets/UISpecialControls.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp

    r45522 r45523  
    1818 */
    1919
    20 /* Qt includes: */
    21 #include <QVBoxLayout>
    22 #include <QLabel>
    23 #include <QPushButton>
    24 #include <QEvent>
    25 #include <QMainWindow>
    26 #include <QStatusBar>
    27 #include <QPainter>
    28 #include <QStateMachine>
    29 #include <QPropertyAnimation>
    30 #include <QSignalTransition>
    31 
    3220/* GUI includes: */
    3321#include "UIPopupCenter.h"
    3422#include "UIModalWindowManager.h"
    35 #include "QIDialogButtonBox.h"
     23#include "UIPopupPane.h"
    3624
    3725/* Other VBox includes: */
     
    8371                            const QString &strButtonText3 /* = QString() */) const
    8472{
    85     showPopupBox(pParent, strId,
    86                  strMessage, strDetails,
    87                  iButton1, iButton2, iButton3,
    88                  strButtonText1, strButtonText2, strButtonText3);
     73    showPopupPane(pParent, strId,
     74                  strMessage, strDetails,
     75                  iButton1, iButton2, iButton3,
     76                  strButtonText1, strButtonText2, strButtonText3);
    8977}
    9078
     
    148136}
    149137
    150 void UIPopupCenter::showPopupBox(QWidget *pParent, const QString &strId,
     138void UIPopupCenter::showPopupPane(QWidget *pParent, const QString &strId,
    151139                                 const QString &strMessage, const QString &strDetails,
    152140                                 int iButton1, int iButton2, int iButton3,
     
    214202}
    215203
    216 void UIAnimationFramework::installPropertyAnimation(QWidget *pParent, const QByteArray &strPropertyName,
    217                                                     int iStartValue, int iFinalValue, int iAnimationDuration,
    218                                                     const char *pSignalForward, const char *pSignalBackward)
    219 {
    220     /* State-machine: */
    221     QStateMachine *pStateMachine = new QStateMachine(pParent);
    222     /* State-machine 'start' state: */
    223     QState *pStateStart = new QState(pStateMachine);
    224     /* State-machine 'final' state: */
    225     QState *pStateFinal = new QState(pStateMachine);
    226 
    227     /* State-machine 'forward' animation: */
    228     QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pParent, strPropertyName, pParent);
    229     pForwardAnimation->setDuration(iAnimationDuration);
    230     pForwardAnimation->setStartValue(iStartValue);
    231     pForwardAnimation->setEndValue(iFinalValue);
    232     /* State-machine 'backward' animation: */
    233     QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pParent, strPropertyName, pParent);
    234     pBackwardAnimation->setDuration(iAnimationDuration);
    235     pBackwardAnimation->setStartValue(iFinalValue);
    236     pBackwardAnimation->setEndValue(iStartValue);
    237 
    238     /* State-machine state transitions: */
    239     QSignalTransition *pDefaultToHovered = pStateStart->addTransition(pParent, pSignalForward, pStateFinal);
    240     pDefaultToHovered->addAnimation(pForwardAnimation);
    241     QSignalTransition *pHoveredToDefault = pStateFinal->addTransition(pParent, pSignalBackward, pStateStart);
    242     pHoveredToDefault->addAnimation(pBackwardAnimation);
    243 
    244     /* Initial state is 'start': */
    245     pStateMachine->setInitialState(pStateStart);
    246     /* Start hover-machine: */
    247     pStateMachine->start();
    248 }
    249 
    250 UIPopupPane::UIPopupPane(QWidget *pParent, const QString &strId,
    251                          const QString &strMessage, const QString &strDetails,
    252                          int iButton1, int iButton2, int iButton3,
    253                          const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3)
    254     : QWidget(pParent)
    255     , m_fPolished(false)
    256     , m_strId(strId)
    257     , m_iMainLayoutMargin(2), m_iMainFrameLayoutMargin(10), m_iMainFrameLayoutSpacing(5)
    258     , m_iParentStatusBarHeight(parentStatusBarHeight(pParent))
    259     , m_strMessage(strMessage), m_strDetails(strDetails)
    260     , m_iButton1(iButton1), m_iButton2(iButton2), m_iButton3(iButton3)
    261     , m_strButtonText1(strButtonText1), m_strButtonText2(strButtonText2), m_strButtonText3(strButtonText3)
    262     , m_iButtonEsc(0)
    263     , m_fHovered(false)
    264     , m_pMainFrame(0), m_pTextPane(0), m_pButtonBox(0)
    265     , m_pButton1(0), m_pButton2(0), m_pButton3(0)
    266 {
    267     /* Prepare: */
    268     prepare();
    269 }
    270 
    271 UIPopupPane::~UIPopupPane()
    272 {
    273     /* Cleanup: */
    274     cleanup();
    275 }
    276 
    277 void UIPopupPane::sltAdjustGeomerty()
    278 {
    279     /* Get parent attributes: */
    280     const int iWidth = parentWidget()->width();
    281     const int iHeight = parentWidget()->height();
    282 
    283     /* Adjust text-pane according parent width: */
    284     if (m_pTextPane)
    285     {
    286         m_pTextPane->setDesiredWidth(iWidth - 2 * m_iMainLayoutMargin
    287                                             - 2 * m_iMainFrameLayoutMargin
    288                                             - m_pButtonBox->minimumSizeHint().width());
    289     }
    290 
    291     /* Resize popup according parent width: */
    292     resize(iWidth, minimumSizeHint().height());
    293 
    294     /* Move popup according parent: */
    295     move(0, iHeight - height() - m_iParentStatusBarHeight);
    296 
    297     /* Raise popup according parent: */
    298     raise();
    299 
    300     /* Update layout: */
    301     updateLayout();
    302 }
    303 
    304 void UIPopupPane::prepare()
    305 {
    306     /* Install event-filter to parent: */
    307     parent()->installEventFilter(this);
    308     /* Prepare content: */
    309     prepareContent();
    310 }
    311 
    312 void UIPopupPane::cleanup()
    313 {
    314 }
    315 
    316 bool UIPopupPane::eventFilter(QObject *pWatched, QEvent *pEvent)
    317 {
    318     /* If its parent event came: */
    319     if (pWatched == parent())
    320     {
    321         /* Make sure its resize event came: */
    322         if (pEvent->type() != QEvent::Resize)
    323             return false;
    324 
    325         /* Adjust geometry: */
    326         sltAdjustGeomerty();
    327     }
    328     /* Other objects subscribed for hovering: */
    329     else
    330     {
    331         /* Depending on event-type: */
    332         switch (pEvent->type())
    333         {
    334             /* Something is hovered: */
    335             case QEvent::HoverEnter:
    336             case QEvent::Enter:
    337             {
    338                 if (!m_fHovered)
    339                 {
    340                     m_fHovered = true;
    341                     emit sigHoverEnter();
    342                 }
    343                 break;
    344             }
    345             /* Nothing is hovered: */
    346             case QEvent::Leave:
    347             {
    348                 if (pWatched == this && m_fHovered)
    349                 {
    350                     m_fHovered = false;
    351                     emit sigHoverLeave();
    352                 }
    353                 break;
    354             }
    355             /* Default case: */
    356             default: break;
    357         }
    358     }
    359     /* Do not filter anything: */
    360     return false;
    361 }
    362 
    363 void UIPopupPane::showEvent(QShowEvent *pEvent)
    364 {
    365     /* Make sure we should polish dialog: */
    366     if (m_fPolished)
    367         return;
    368 
    369     /* Call to polish-event: */
    370     polishEvent(pEvent);
    371 
    372     /* Mark dialog as polished: */
    373     m_fPolished = true;
    374 }
    375 
    376 void UIPopupPane::polishEvent(QShowEvent*)
    377 {
    378     /* Adjust geometry: */
    379     sltAdjustGeomerty();
    380 }
    381 
    382 void UIPopupPane::keyPressEvent(QKeyEvent *pEvent)
    383 {
    384     /* Preprocess Escape key: */
    385     if (pEvent->key() == Qt::Key_Escape && m_iButtonEsc)
    386     {
    387         done(m_iButtonEsc);
    388         return;
    389     }
    390     /* Handle all the other keys: */
    391     QWidget::keyPressEvent(pEvent);
    392 }
    393 
    394 int UIPopupPane::minimumWidthHint() const
    395 {
    396     /* Prepare minimum width hint: */
    397     int iMinimumWidthHint = 0;
    398 
    399     /* Take into account main layout: */
    400     iMinimumWidthHint += 2 * m_iMainLayoutMargin;
    401     {
    402         /* Take into account main-frame layout: */
    403         iMinimumWidthHint += 2 * m_iMainFrameLayoutMargin;
    404         {
    405             /* Take into account widgets: */
    406             iMinimumWidthHint += m_pTextPane->minimumSizeHint().width();
    407             iMinimumWidthHint += m_iMainFrameLayoutSpacing;
    408             iMinimumWidthHint += m_pButtonBox->minimumSizeHint().width();
    409         }
    410     }
    411 
    412     /* Return minimum width hint: */
    413     return iMinimumWidthHint;
    414 }
    415 
    416 int UIPopupPane::minimumHeightHint() const
    417 {
    418     /* Prepare minimum height hint: */
    419     int iMinimumHeightHint = 0;
    420 
    421     /* Take into account main layout: */
    422     iMinimumHeightHint += 2 * m_iMainLayoutMargin;
    423     {
    424         /* Take into account main-frame layout: */
    425         iMinimumHeightHint += 2 * m_iMainFrameLayoutMargin;
    426         {
    427             /* Take into account widgets: */
    428             const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();
    429             const int iButtonBoxHeight = m_pButtonBox->minimumSizeHint().height();
    430             iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);
    431         }
    432     }
    433 
    434     /* Return minimum height hint: */
    435     return iMinimumHeightHint;
    436 }
    437 
    438 QSize UIPopupPane::minimumSizeHint() const
    439 {
    440     return QSize(minimumWidthHint(), minimumHeightHint());
    441 }
    442 
    443 void UIPopupPane::updateLayout()
    444 {
    445     /* This attributes: */
    446     const int iWidth = width();
    447     const int iHeight = height();
    448     /* Main layout: */
    449     {
    450         /* Main-frame: */
    451         m_pMainFrame->move(m_iMainLayoutMargin,
    452                            m_iMainLayoutMargin);
    453         m_pMainFrame->resize(iWidth - 2 * m_iMainLayoutMargin,
    454                              iHeight - 2 * m_iMainLayoutMargin);
    455         const int iMainFrameHeight = m_pMainFrame->height();
    456         /* Main-frame layout: */
    457         {
    458             /* Text-pane: */
    459             const int iTextPaneWidth = m_pTextPane->minimumSizeHint().width();
    460             m_pTextPane->move(m_iMainFrameLayoutMargin,
    461                               m_iMainFrameLayoutMargin);
    462             m_pTextPane->resize(iTextPaneWidth,
    463                                 iMainFrameHeight - 2 * m_iMainFrameLayoutMargin);
    464             /* Button-box: */
    465             const int iButtonBoxWidth = m_pButtonBox->minimumSizeHint().width();
    466             m_pButtonBox->move(m_iMainFrameLayoutMargin + iTextPaneWidth + m_iMainFrameLayoutSpacing,
    467                                m_iMainFrameLayoutMargin);
    468             m_pButtonBox->resize(iButtonBoxWidth,
    469                                  iMainFrameHeight - 2 * m_iMainFrameLayoutMargin);
    470         }
    471     }
    472 }
    473 
    474 void UIPopupPane::prepareContent()
    475 {
    476     /* Prepare this: */
    477     installEventFilter(this);
    478     setFocusPolicy(Qt::StrongFocus);
    479     /* Create main-frame: */
    480     m_pMainFrame = new UIPopupPaneFrame(this);
    481     {
    482         /* Prepare frame: */
    483         m_pMainFrame->installEventFilter(this);
    484         /* Create message-label: */
    485         m_pTextPane = new UIPopupPaneTextPane(m_pMainFrame);
    486         {
    487             /* Prepare label: */
    488             connect(m_pTextPane, SIGNAL(sigGeometryChanged()),
    489                     this, SLOT(sltAdjustGeomerty()));
    490             m_pTextPane->installEventFilter(this);
    491             m_pTextPane->setFocusPolicy(Qt::StrongFocus);
    492             m_pTextPane->setText(m_strMessage);
    493         }
    494         /* Create button-box: */
    495         m_pButtonBox = new QIDialogButtonBox(m_pMainFrame);
    496         {
    497             /* Prepare button-box: */
    498             m_pButtonBox->installEventFilter(this);
    499             m_pButtonBox->setOrientation(Qt::Vertical);
    500             prepareButtons();
    501         }
    502     }
    503 }
    504 
    505 void UIPopupPane::prepareButtons()
    506 {
    507     /* Prepare descriptions: */
    508     QList<int> descriptions;
    509     descriptions << m_iButton1 << m_iButton2 << m_iButton3;
    510 
    511     /* Choose 'escape' button: */
    512     foreach (int iButton, descriptions)
    513         if (iButton & AlertButtonOption_Escape)
    514         {
    515             m_iButtonEsc = iButton & AlertButtonMask;
    516             break;
    517         }
    518 
    519     /* Create buttons: */
    520     QList<QPushButton*> buttons = createButtons(m_pButtonBox, descriptions);
    521 
    522     /* Install focus-proxy into the 'default' button: */
    523     foreach (QPushButton *pButton, buttons)
    524         if (pButton && pButton->isDefault())
    525         {
    526             setFocusProxy(pButton);
    527             m_pTextPane->setFocusProxy(pButton);
    528             break;
    529         }
    530 
    531     /* Prepare button 1: */
    532     m_pButton1 = buttons[0];
    533     if (m_pButton1)
    534     {
    535         connect(m_pButton1, SIGNAL(clicked()), SLOT(done1()));
    536         if (!m_strButtonText1.isEmpty())
    537             m_pButton1->setText(m_strButtonText1);
    538     }
    539     /* Prepare button 2: */
    540     m_pButton2 = buttons[1];
    541     if (m_pButton2)
    542     {
    543         connect(m_pButton2, SIGNAL(clicked()), SLOT(done2()));
    544         if (!m_strButtonText2.isEmpty())
    545             m_pButton1->setText(m_strButtonText2);
    546     }
    547     /* Prepare button 3: */
    548     m_pButton3 = buttons[2];
    549     if (m_pButton3)
    550     {
    551         connect(m_pButton3, SIGNAL(clicked()), SLOT(done3()));
    552         if (!m_strButtonText3.isEmpty())
    553             m_pButton1->setText(m_strButtonText3);
    554     }
    555 }
    556 
    557 void UIPopupPane::done(int iButtonCode)
    558 {
    559     /* Close the window: */
    560     close();
    561 
    562     /* Notify listeners: */
    563     emit sigDone(iButtonCode);
    564 }
    565 
    566 /* static */
    567 int UIPopupPane::parentStatusBarHeight(QWidget *pParent)
    568 {
    569     /* Check if passed parent is QMainWindow and contains status-bar: */
    570     if (QMainWindow *pParentWindow = qobject_cast<QMainWindow*>(pParent))
    571         if (pParentWindow->statusBar())
    572             return pParentWindow->statusBar()->height();
    573     /* Zero by default: */
    574     return 0;
    575 }
    576 
    577 /* static */
    578 QList<QPushButton*> UIPopupPane::createButtons(QIDialogButtonBox *pButtonBox, const QList<int> descriptions)
    579 {
    580     /* Create button according descriptions: */
    581     QList<QPushButton*> buttons;
    582     foreach (int iButton, descriptions)
    583         buttons << createButton(pButtonBox, iButton);
    584     /* Return buttons: */
    585     return buttons;
    586 }
    587 
    588 /* static */
    589 QPushButton* UIPopupPane::createButton(QIDialogButtonBox *pButtonBox, int iButton)
    590 {
    591     /* Null for AlertButton_NoButton: */
    592     if (iButton == 0)
    593         return 0;
    594 
    595     /* Prepare button text & role: */
    596     QString strText;
    597     QDialogButtonBox::ButtonRole role;
    598     switch (iButton & AlertButtonMask)
    599     {
    600         case AlertButton_Ok:      strText = QIMessageBox::tr("OK");     role = QDialogButtonBox::AcceptRole; break;
    601         case AlertButton_Cancel:  strText = QIMessageBox::tr("Cancel"); role = QDialogButtonBox::RejectRole; break;
    602         case AlertButton_Choice1: strText = QIMessageBox::tr("Yes");    role = QDialogButtonBox::YesRole; break;
    603         case AlertButton_Choice2: strText = QIMessageBox::tr("No");     role = QDialogButtonBox::NoRole; break;
    604         default: return 0;
    605     }
    606 
    607     /* Create push-button: */
    608     QPushButton *pButton = pButtonBox->addButton(strText, role);
    609 
    610     /* Configure 'default' button: */
    611     if (iButton & AlertButtonOption_Default)
    612     {
    613         pButton->setDefault(true);
    614         pButton->setFocusPolicy(Qt::StrongFocus);
    615         pButton->setFocus();
    616     }
    617 
    618     /* Return button: */
    619     return pButton;
    620 }
    621 
    622 UIPopupPaneFrame::UIPopupPaneFrame(QWidget *pParent /*= 0*/)
    623     : QWidget(pParent)
    624     , m_iHoverAnimationDuration(300)
    625     , m_iDefaultOpacity(128)
    626     , m_iHoveredOpacity(230)
    627     , m_iOpacity(m_iDefaultOpacity)
    628 {
    629     /* Prepare: */
    630     prepare();
    631 }
    632 
    633 UIPopupPaneFrame::~UIPopupPaneFrame()
    634 {
    635     /* Cleanup: */
    636     cleanup();
    637 }
    638 
    639 void UIPopupPaneFrame::prepare()
    640 {
    641     /* Install 'hover' animation for 'opacity' property: */
    642     connect(parent(), SIGNAL(sigHoverEnter()), this, SIGNAL(sigHoverEnter()));
    643     connect(parent(), SIGNAL(sigHoverLeave()), this, SIGNAL(sigHoverLeave()));
    644     UIAnimationFramework::installPropertyAnimation(this, QByteArray("opacity"),
    645                                                    m_iDefaultOpacity, m_iHoveredOpacity, m_iHoverAnimationDuration,
    646                                                    SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave()));
    647 }
    648 
    649 void UIPopupPaneFrame::cleanup()
    650 {
    651 }
    652 
    653 void UIPopupPaneFrame::paintEvent(QPaintEvent*)
    654 {
    655     /* Compose painting rectangle: */
    656     const QRect rect(0, 0, width(), height());
    657 
    658     /* Create painter: */
    659     QPainter painter(this);
    660     painter.setRenderHint(QPainter::Antialiasing);
    661 
    662     /* Configure painter clipping: */
    663     QPainterPath path;
    664     int iDiameter = 5;
    665     QSizeF arcSize(2 * iDiameter, 2 * iDiameter);
    666     path.moveTo(iDiameter, 0);
    667     path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-iDiameter, 0), 90, 90);
    668     path.lineTo(path.currentPosition().x(), rect.height() - iDiameter);
    669     path.arcTo(QRectF(path.currentPosition(), arcSize).translated(0, -iDiameter), 180, 90);
    670     path.lineTo(rect.width() - iDiameter, path.currentPosition().y());
    671     path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-iDiameter, -2 * iDiameter), 270, 90);
    672     path.lineTo(path.currentPosition().x(), iDiameter);
    673     path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-2 * iDiameter, -iDiameter), 0, 90);
    674     path.closeSubpath();
    675     painter.setClipPath(path);
    676 
    677     /* Fill with background: */
    678     QColor currentColor(palette().color(QPalette::Window));
    679     QColor newColor(currentColor.red(), currentColor.green(), currentColor.blue(), opacity());
    680     painter.fillRect(rect, newColor);
    681 }
    682 
    683 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent /*= 0*/)
    684     : QWidget(pParent)
    685     , m_pLabel(0)
    686     , m_iDesiredWidth(-1)
    687     , m_iHoverAnimationDuration(300)
    688     , m_iDefaultPercentage(1)
    689     , m_iHoveredPercentage(100)
    690     , m_iPercentage(m_iDefaultPercentage)
    691 {
    692     /* Prepare: */
    693     prepare();
    694 }
    695 
    696 UIPopupPaneTextPane::~UIPopupPaneTextPane()
    697 {
    698     /* Cleanup: */
    699     cleanup();
    700 }
    701 
    702 void UIPopupPaneTextPane::setText(const QString &strText)
    703 {
    704     /* Make sure the text is changed: */
    705     if (m_pLabel->text() == strText)
    706         return;
    707     /* Update the pane for new text: */
    708     m_pLabel->setText(strText);
    709     updateGeometry();
    710 }
    711 
    712 void UIPopupPaneTextPane::setDesiredWidth(int iDesiredWidth)
    713 {
    714     /* Make sure the desired-width is changed: */
    715     if (m_iDesiredWidth == iDesiredWidth)
    716         return;
    717     /* Update the pane for new desired-width: */
    718     m_iDesiredWidth = iDesiredWidth;
    719     updateGeometry();
    720 }
    721 
    722 QSize UIPopupPaneTextPane::minimumSizeHint() const
    723 {
    724     /* Check if desired-width set: */
    725     if (m_iDesiredWidth >= 0)
    726         /* Return dependent size-hint: */
    727         return QSize(m_iDesiredWidth, (int)(((qreal)percentage() / 100) * m_pLabel->heightForWidth(m_iDesiredWidth)));
    728     /* Return golden-rule size-hint by default: */
    729     return m_pLabel->minimumSizeHint();
    730 }
    731 
    732 void UIPopupPaneTextPane::prepare()
    733 {
    734     /* Install 'hover' animation for 'height' property: */
    735     connect(parent(), SIGNAL(sigHoverEnter()), this, SIGNAL(sigHoverEnter()));
    736     connect(parent(), SIGNAL(sigHoverLeave()), this, SIGNAL(sigHoverLeave()));
    737     UIAnimationFramework::installPropertyAnimation(this, QByteArray("percentage"),
    738                                                    m_iDefaultPercentage, m_iHoveredPercentage, m_iHoverAnimationDuration,
    739                                                    SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave()));
    740     /* Prepare content: */
    741     prepareContent();
    742 }
    743 
    744 void UIPopupPaneTextPane::cleanup()
    745 {
    746 }
    747 
    748 void UIPopupPaneTextPane::prepareContent()
    749 {
    750     /* Create main layout: */
    751     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    752     {
    753         /* Prepare layout: */
    754         pMainLayout->setContentsMargins(0, 0, 0, 0);
    755         pMainLayout->setSpacing(0);
    756         /* Create label: */
    757         m_pLabel = new QLabel;
    758         {
    759             /* Add into layout: */
    760             pMainLayout->addWidget(m_pLabel);
    761             /* Prepare label: */
    762             m_pLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    763             m_pLabel->setWordWrap(true);
    764         }
    765         /* Activate layout: */
    766         updateGeometry();
    767     }
    768 }
    769 
    770 void UIPopupPaneTextPane::setPercentage(int iPercentage)
    771 {
    772     m_iPercentage = iPercentage;
    773     updateGeometry();
    774     emit sigGeometryChanged();
    775 }
    776 
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

    r45522 r45523  
    2323#include <QMap>
    2424#include <QObject>
    25 #include <QWidget>
    2625#include <QPointer>
    2726
    28 /* GUI includes: */
    29 #include "QIMessageBox.h"
     27/* Forward declaration: */
     28class QWidget;
     29class UIPopupPane;
    3030
    31 /* Forward declaration: */
    32 class QPushButton;
    33 class QLabel;
    34 class QIDialogButtonBox;
    35 class UIPopupPane;
    36 class UIPopupPaneFrame;
    37 class UIPopupPaneTextPane;
    38 
    39 /* Global popup-center object: */
     31/* Popup-center singleton: */
    4032class UIPopupCenter: public QObject
    4133{
     
    4436signals:
    4537
    46     /* Notifier: Popup complete stuff: */
     38    /* Notifier: Popup done stuff: */
    4739    void sigPopupDone(QString strId, int iButtonCode) const;
    4840
     
    109101    ~UIPopupCenter();
    110102
    111     /* Helper: Popup-box stuff: */
    112     void showPopupBox(QWidget *pParent, const QString &strId,
    113                       const QString &strMessage, const QString &strDetails,
    114                       int iButton1, int iButton2, int iButton3,
    115                       const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3) const;
     103    /* Helper: Popup-pane stuff: */
     104    void showPopupPane(QWidget *pParent, const QString &strId,
     105                       const QString &strMessage, const QString &strDetails,
     106                       int iButton1, int iButton2, int iButton3,
     107                       const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3) const;
    116108
    117     /* Variables: */
     109    /* Variables: Popup-pane stuff: */
    118110    mutable QMap<QString, QPointer<UIPopupPane> > m_popups;
    119111
     
    127119inline UIPopupCenter& popupCenter() { return *UIPopupCenter::instance(); }
    128120
    129 /* UIAnimationFramework namespace: */
    130 namespace UIAnimationFramework
    131 {
    132     /* API: Animation stuff: */
    133     void installPropertyAnimation(QWidget *pParent, const QByteArray &strPropertyName,
    134                                   int iStartValue, int iFinalValue, int iAnimationDuration,
    135                                   const char *pSignalForward, const char *pSignalBackward);
    136 }
    137 
    138 /* Popup-pane prototype class: */
    139 class UIPopupPane : public QWidget
    140 {
    141     Q_OBJECT;
    142 
    143 signals:
    144 
    145     /* Notifiers: Hover stuff: */
    146     void sigHoverEnter();
    147     void sigHoverLeave();
    148 
    149     /* Notifier: Complete stuff: */
    150     void sigDone(int iButtonCode) const;
    151 
    152 public:
    153 
    154     /* Constructor/destructor: */
    155     UIPopupPane(QWidget *pParent, const QString &strId,
    156                 const QString &strMessage, const QString &strDetails,
    157                 int iButton1, int iButton2, int iButton3,
    158                 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3);
    159     ~UIPopupPane();
    160 
    161     /* API: Id stuff: */
    162     const QString& id() const { return m_strId; }
    163 
    164 private slots:
    165 
    166     /* Handlers: Done slot variants for every button: */
    167     void done1() { done(m_iButton1 & AlertButtonMask); }
    168     void done2() { done(m_iButton2 & AlertButtonMask); }
    169     void done3() { done(m_iButton3 & AlertButtonMask); }
    170 
    171     /* Handler: Layout stuff: */
    172     void sltAdjustGeomerty();
    173 
    174 private:
    175 
    176     /* Helpers: Prepare/cleanup stuff: */
    177     void prepare();
    178     void cleanup();
    179 
    180     /* Handler: Event-filter stuff: */
    181     bool eventFilter(QObject *pWatched, QEvent *pEvent);
    182 
    183     /* Handlers: Event stuff: */
    184     virtual void showEvent(QShowEvent *pEvent);
    185     virtual void polishEvent(QShowEvent *pEvent);
    186     virtual void keyPressEvent(QKeyEvent *pEvent);
    187 
    188     /* Helper: Layout stuff: */
    189     int minimumWidthHint() const;
    190     int minimumHeightHint() const;
    191     QSize minimumSizeHint() const;
    192     void updateLayout();
    193 
    194     /* Helpers: Prepare stuff: */
    195     void prepareContent();
    196     void prepareButtons();
    197 
    198     /* Helper: Complete stuff: */
    199     void done(int iButtonCode);
    200 
    201     /* Static helpers: Prepare stuff: */
    202     static int parentStatusBarHeight(QWidget *pParent);
    203     static QList<QPushButton*> createButtons(QIDialogButtonBox *pButtonBox, const QList<int> description);
    204     static QPushButton* createButton(QIDialogButtonBox *pButtonBox, int iButton);
    205 
    206     /* Variables: */
    207     bool m_fPolished;
    208     const QString m_strId;
    209 
    210     /* Variables: Layout stuff: */
    211     const int m_iMainLayoutMargin;
    212     const int m_iMainFrameLayoutMargin;
    213     const int m_iMainFrameLayoutSpacing;
    214     const int m_iParentStatusBarHeight;
    215 
    216     /* Variables: Text stuff: */
    217     QString m_strMessage, m_strDetails;
    218 
    219     /* Variables: Button stuff: */
    220     int m_iButton1, m_iButton2, m_iButton3;
    221     QString m_strButtonText1, m_strButtonText2, m_strButtonText3;
    222     int m_iButtonEsc;
    223 
    224     /* Variables: Hover stuff: */
    225     bool m_fHovered;
    226 
    227     /* Widgets: */
    228     UIPopupPaneFrame *m_pMainFrame;
    229     UIPopupPaneTextPane *m_pTextPane;
    230     QIDialogButtonBox *m_pButtonBox;
    231     QPushButton *m_pButton1, *m_pButton2, *m_pButton3;
    232 };
    233 
    234 /* Popup-pane frame prototype class: */
    235 class UIPopupPaneFrame : public QWidget
    236 {
    237     Q_OBJECT;
    238     Q_PROPERTY(int opacity READ opacity WRITE setOpacity);
    239 
    240 signals:
    241 
    242     /* Notifiers: Hover stuff: */
    243     void sigHoverEnter();
    244     void sigHoverLeave();
    245 
    246 public:
    247 
    248     /* Constructor/destructor: */
    249     UIPopupPaneFrame(QWidget *pParent = 0);
    250     ~UIPopupPaneFrame();
    251 
    252 private:
    253 
    254     /* Helpers: Prepare/cleanup stuff: */
    255     void prepare();
    256     void cleanup();
    257 
    258     /* Handlers: Event stuff: */
    259     void paintEvent(QPaintEvent *pEvent);
    260 
    261     /* Property: Hover stuff: */
    262     int opacity() const { return m_iOpacity; }
    263     void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
    264 
    265     /* Variables: Hover stuff: */
    266     const int m_iHoverAnimationDuration;
    267     const int m_iDefaultOpacity;
    268     const int m_iHoveredOpacity;
    269     int m_iOpacity;
    270 };
    271 
    272 /* Popup-pane text-pane prototype class: */
    273 class UIPopupPaneTextPane : public QWidget
    274 {
    275     Q_OBJECT;
    276     Q_PROPERTY(int percentage READ percentage WRITE setPercentage);
    277 
    278 signals:
    279 
    280     /* Notifiers: Hover stuff: */
    281     void sigHoverEnter();
    282     void sigHoverLeave();
    283     void sigGeometryChanged();
    284 
    285 public:
    286 
    287     /* Constructor/destructor: */
    288     UIPopupPaneTextPane(QWidget *pParent = 0);
    289     ~UIPopupPaneTextPane();
    290 
    291     /* API: Text stuff: */
    292     void setText(const QString &strText);
    293 
    294     /* API: Set desired width: */
    295     void setDesiredWidth(int iDesiredWidth);
    296 
    297     /* API: Minimum size-hint stuff: */
    298     QSize minimumSizeHint() const;
    299 
    300 private:
    301 
    302     /* Helpers: Prepare/cleanup stuff: */
    303     void prepare();
    304     void cleanup();
    305 
    306     /* Helper: Content stuff: */
    307     void prepareContent();
    308 
    309     /* Property: Hover stuff: */
    310     int percentage() const { return m_iPercentage; }
    311     void setPercentage(int iPercentage);
    312 
    313     /* Variables: Label stuff: */
    314     QLabel *m_pLabel;
    315     int m_iDesiredWidth;
    316 
    317     /* Variables: Hover stuff: */
    318     const int m_iHoverAnimationDuration;
    319     const int m_iDefaultPercentage;
    320     const int m_iHoveredPercentage;
    321     int m_iPercentage;
    322 };
    323 
    324121#endif /* __UIPopupCenter_h__ */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r45522 r45523  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIPopupCenter class implementation
     5 * UIPopupPane class implementation
    66 */
    77
     
    3131
    3232/* GUI includes: */
    33 #include "UIPopupCenter.h"
    34 #include "UIModalWindowManager.h"
     33#include "UIPopupPane.h"
    3534#include "QIDialogButtonBox.h"
    3635
    3736/* Other VBox includes: */
    3837#include <VBox/sup.h>
    39 
    40 /* static */
    41 UIPopupCenter* UIPopupCenter::m_spInstance = 0;
    42 UIPopupCenter* UIPopupCenter::instance() { return m_spInstance; }
    43 
    44 /* static */
    45 void UIPopupCenter::create()
    46 {
    47     /* Make sure instance is NOT created yet: */
    48     if (m_spInstance)
    49         return;
    50 
    51     /* Create instance: */
    52     new UIPopupCenter;
    53 }
    54 
    55 /* static */
    56 void UIPopupCenter::destroy()
    57 {
    58     /* Make sure instance is NOT destroyed yet: */
    59     if (!m_spInstance)
    60         return;
    61 
    62     /* Destroy instance: */
    63     delete m_spInstance;
    64 }
    65 
    66 UIPopupCenter::UIPopupCenter()
    67 {
    68     /* Assign instance: */
    69     m_spInstance = this;
    70 }
    71 
    72 UIPopupCenter::~UIPopupCenter()
    73 {
    74     /* Unassign instance: */
    75     m_spInstance = 0;
    76 }
    77 
    78 void UIPopupCenter::message(QWidget *pParent, const QString &strId,
    79                             const QString &strMessage, const QString &strDetails,
    80                             int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,
    81                             const QString &strButtonText1 /* = QString() */,
    82                             const QString &strButtonText2 /* = QString() */,
    83                             const QString &strButtonText3 /* = QString() */) const
    84 {
    85     showPopupBox(pParent, strId,
    86                  strMessage, strDetails,
    87                  iButton1, iButton2, iButton3,
    88                  strButtonText1, strButtonText2, strButtonText3);
    89 }
    90 
    91 void UIPopupCenter::error(QWidget *pParent, const QString &strId,
    92                           const QString &strMessage, const QString &strDetails) const
    93 {
    94     message(pParent, strId,
    95             strMessage, strDetails,
    96             AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape);
    97 }
    98 
    99 void UIPopupCenter::alert(QWidget *pParent, const QString &strId,
    100                           const QString &strMessage) const
    101 {
    102     error(pParent, strId,
    103           strMessage, QString());
    104 }
    105 
    106 void UIPopupCenter::question(QWidget *pParent, const QString &strId,
    107                              const QString &strMessage,
    108                              int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,
    109                              const QString &strButtonText1 /*= QString()*/,
    110                              const QString &strButtonText2 /*= QString()*/,
    111                              const QString &strButtonText3 /*= QString()*/) const
    112 {
    113     message(pParent, strId,
    114             strMessage, QString(),
    115             iButton1, iButton2, iButton3,
    116             strButtonText1, strButtonText2, strButtonText3);
    117 }
    118 
    119 void UIPopupCenter::questionBinary(QWidget *pParent, const QString &strId,
    120                                    const QString &strMessage,
    121                                    const QString &strOkButtonText /*= QString()*/,
    122                                    const QString &strCancelButtonText /*= QString()*/) const
    123 {
    124     question(pParent, strId,
    125              strMessage,
    126              AlertButton_Ok | AlertButtonOption_Default,
    127              AlertButton_Cancel | AlertButtonOption_Escape,
    128              0 /* third button */,
    129              strOkButtonText,
    130              strCancelButtonText,
    131              QString() /* third button */);
    132 }
    133 
    134 void UIPopupCenter::questionTrinary(QWidget *pParent, const QString &strId,
    135                                     const QString &strMessage,
    136                                     const QString &strChoice1ButtonText /*= QString()*/,
    137                                     const QString &strChoice2ButtonText /*= QString()*/,
    138                                     const QString &strCancelButtonText /*= QString()*/) const
    139 {
    140     question(pParent, strId,
    141              strMessage,
    142              AlertButton_Choice1,
    143              AlertButton_Choice2 | AlertButtonOption_Default,
    144              AlertButton_Cancel | AlertButtonOption_Escape,
    145              strChoice1ButtonText,
    146              strChoice2ButtonText,
    147              strCancelButtonText);
    148 }
    149 
    150 void UIPopupCenter::showPopupBox(QWidget *pParent, const QString &strId,
    151                                  const QString &strMessage, const QString &strDetails,
    152                                  int iButton1, int iButton2, int iButton3,
    153                                  const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3) const
    154 {
    155     /* Choose at least one button by 'default': */
    156     if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)
    157         iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape;
    158 
    159     /* Create popup-box window: */
    160     QWidget *pPopupBoxParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
    161     UIPopupPane *pPopupBox = new UIPopupPane(pPopupBoxParent, strId,
    162                                              strMessage, strDetails,
    163                                              iButton1, iButton2, iButton3,
    164                                              strButtonText1, strButtonText2, strButtonText3);
    165     m_popups.insert(strId, pPopupBox);
    166     connect(pPopupBox, SIGNAL(sigDone(int)), this, SLOT(sltPopupDone(int)));
    167     pPopupBox->show();
    168 }
    169 
    170 void UIPopupCenter::sltPopupDone(int iButtonCode) const
    171 {
    172     /* Make sure the sender is popup: */
    173     const UIPopupPane *pPopup = qobject_cast<UIPopupPane*>(sender());
    174     if (!pPopup)
    175         return;
    176 
    177     /* Make sure the popup is still exists: */
    178     const QString strPopupID(pPopup->id());
    179     const bool fIsPopupStillHere = m_popups.contains(strPopupID);
    180     AssertMsg(fIsPopupStillHere, ("Popup already destroyed!"));
    181     if (!fIsPopupStillHere)
    182         return;
    183 
    184     /* Notify listeners: */
    185     emit sigPopupDone(strPopupID, iButtonCode);
    186 
    187     /* Cleanup the popup: */
    188     m_popups.remove(strPopupID);
    189     delete pPopup;
    190 }
    191 
    192 void UIPopupCenter::remindAboutMouseIntegration(bool fSupportsAbsolute) const
    193 {
    194     if (fSupportsAbsolute)
    195     {
    196         alert(0, QString("remindAboutMouseIntegrationOn"),
    197               tr("<p>The Virtual Machine reports that the guest OS supports <b>mouse pointer integration</b>. "
    198                  "This means that you do not need to <i>capture</i> the mouse pointer to be able to use it in your guest OS -- "
    199                  "all mouse actions you perform when the mouse pointer is over the Virtual Machine's display "
    200                  "are directly sent to the guest OS. If the mouse is currently captured, it will be automatically uncaptured.</p>"
    201                  "<p>The mouse icon on the status bar will look like&nbsp;<img src=:/mouse_seamless_16px.png/>&nbsp;to inform you "
    202                  "that mouse pointer integration is supported by the guest OS and is currently turned on.</p>"
    203                  "<p><b>Note</b>: Some applications may behave incorrectly in mouse pointer integration mode. "
    204                  "You can always disable it for the current session (and enable it again) "
    205                  "by selecting the corresponding action from the menu bar.</p>"));
    206     }
    207     else
    208     {
    209         alert(0, QString("remindAboutMouseIntegrationOff"),
    210               tr("<p>The Virtual Machine reports that the guest OS does not support <b>mouse pointer integration</b> "
    211                  "in the current video mode. You need to capture the mouse (by clicking over the VM display "
    212                  "or pressing the host key) in order to use the mouse inside the guest OS.</p>"));
    213     }
    214 }
    21538
    21639void UIAnimationFramework::installPropertyAnimation(QWidget *pParent, const QByteArray &strPropertyName,
     
    24770    pStateMachine->start();
    24871}
     72
     73
     74/* Popup-pane frame prototype class: */
     75class UIPopupPaneFrame : public QWidget
     76{
     77    Q_OBJECT;
     78    Q_PROPERTY(int opacity READ opacity WRITE setOpacity);
     79
     80signals:
     81
     82    /* Notifiers: Hover stuff: */
     83    void sigHoverEnter();
     84    void sigHoverLeave();
     85
     86public:
     87
     88    /* Constructor/destructor: */
     89    UIPopupPaneFrame(QWidget *pParent = 0);
     90    ~UIPopupPaneFrame();
     91
     92private:
     93
     94    /* Helpers: Prepare/cleanup stuff: */
     95    void prepare();
     96    void cleanup();
     97
     98    /* Handlers: Event stuff: */
     99    void paintEvent(QPaintEvent *pEvent);
     100
     101    /* Property: Hover stuff: */
     102    int opacity() const { return m_iOpacity; }
     103    void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
     104
     105    /* Variables: Hover stuff: */
     106    const int m_iHoverAnimationDuration;
     107    const int m_iDefaultOpacity;
     108    const int m_iHoveredOpacity;
     109    int m_iOpacity;
     110};
     111
     112
     113/* Popup-pane text-pane prototype class: */
     114class UIPopupPaneTextPane : public QWidget
     115{
     116    Q_OBJECT;
     117    Q_PROPERTY(int percentage READ percentage WRITE setPercentage);
     118
     119signals:
     120
     121    /* Notifiers: Hover stuff: */
     122    void sigHoverEnter();
     123    void sigHoverLeave();
     124    void sigGeometryChanged();
     125
     126public:
     127
     128    /* Constructor/destructor: */
     129    UIPopupPaneTextPane(QWidget *pParent = 0);
     130    ~UIPopupPaneTextPane();
     131
     132    /* API: Text stuff: */
     133    void setText(const QString &strText);
     134
     135    /* API: Set desired width: */
     136    void setDesiredWidth(int iDesiredWidth);
     137
     138    /* API: Minimum size-hint stuff: */
     139    QSize minimumSizeHint() const;
     140
     141private:
     142
     143    /* Helpers: Prepare/cleanup stuff: */
     144    void prepare();
     145    void cleanup();
     146
     147    /* Helper: Content stuff: */
     148    void prepareContent();
     149
     150    /* Property: Hover stuff: */
     151    int percentage() const { return m_iPercentage; }
     152    void setPercentage(int iPercentage);
     153
     154    /* Variables: Label stuff: */
     155    QLabel *m_pLabel;
     156    int m_iDesiredWidth;
     157
     158    /* Variables: Hover stuff: */
     159    const int m_iHoverAnimationDuration;
     160    const int m_iDefaultPercentage;
     161    const int m_iHoveredPercentage;
     162    int m_iPercentage;
     163};
     164
    249165
    250166UIPopupPane::UIPopupPane(QWidget *pParent, const QString &strId,
     
    620536}
    621537
     538
    622539UIPopupPaneFrame::UIPopupPaneFrame(QWidget *pParent /*= 0*/)
    623540    : QWidget(pParent)
     
    681598}
    682599
     600
    683601UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent /*= 0*/)
    684602    : QWidget(pParent)
     
    775693}
    776694
     695#include "UIPopupPane.moc"
     696
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r45522 r45523  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * UIPopupCenter class declaration
     4 * UIPopupPane class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIPopupCenter_h__
    20 #define __UIPopupCenter_h__
     19#ifndef __UIPopupPane_h__
     20#define __UIPopupPane_h__
    2121
    2222/* Qt includes: */
    23 #include <QMap>
    24 #include <QObject>
    2523#include <QWidget>
    26 #include <QPointer>
    2724
    2825/* GUI includes: */
     
    3027
    3128/* Forward declaration: */
     29class QLabel;
    3230class QPushButton;
    33 class QLabel;
    3431class QIDialogButtonBox;
    3532class UIPopupPane;
    3633class UIPopupPaneFrame;
    3734class UIPopupPaneTextPane;
    38 
    39 /* Global popup-center object: */
    40 class UIPopupCenter: public QObject
    41 {
    42     Q_OBJECT;
    43 
    44 signals:
    45 
    46     /* Notifier: Popup complete stuff: */
    47     void sigPopupDone(QString strId, int iButtonCode) const;
    48 
    49 public:
    50 
    51     /* Static API: Create/destroy stuff: */
    52     static void create();
    53     static void destroy();
    54 
    55     /* API: Main message function, used directly only in exceptional cases: */
    56     void message(QWidget *pParent, const QString &strId,
    57                  const QString &strMessage, const QString &strDetails,
    58                  int iButton1 = 0, int iButton2 = 0, int iButton3 = 0,
    59                  const QString &strButtonText1 = QString(),
    60                  const QString &strButtonText2 = QString(),
    61                  const QString &strButtonText3 = QString()) const;
    62 
    63     /* API: Wrapper to 'message' function.
    64      * Provides single OK button: */
    65     void error(QWidget *pParent, const QString &strId,
    66                const QString &strMessage, const QString &strDetails) const;
    67 
    68     /* API: Wrapper to 'error' function.
    69      * Omits details: */
    70     void alert(QWidget *pParent, const QString &strId,
    71                const QString &strMessage) const;
    72 
    73     /* API: Wrapper to 'message' function.
    74      * Omits details, provides two or three buttons: */
    75     void question(QWidget *pParent, const QString &strId,
    76                   const QString &strMessage,
    77                   int iButton1 = 0, int iButton2 = 0, int iButton3 = 0,
    78                   const QString &strButtonText1 = QString(),
    79                   const QString &strButtonText2 = QString(),
    80                   const QString &strButtonText3 = QString()) const;
    81 
    82     /* API: Wrapper to 'question' function,
    83      * Question providing two buttons (OK and Cancel by default): */
    84     void questionBinary(QWidget *pParent, const QString &strId,
    85                         const QString &strMessage,
    86                         const QString &strOkButtonText = QString(),
    87                         const QString &strCancelButtonText = QString()) const;
    88 
    89     /* API: Wrapper to 'question' function,
    90      * Question providing three buttons (Yes, No and Cancel by default): */
    91     void questionTrinary(QWidget *pParent, const QString &strId,
    92                          const QString &strMessage,
    93                          const QString &strChoice1ButtonText = QString(),
    94                          const QString &strChoice2ButtonText = QString(),
    95                          const QString &strCancelButtonText = QString()) const;
    96 
    97     /* API: Runtime UI stuff: */
    98     void remindAboutMouseIntegration(bool fSupportsAbsolute) const;
    99 
    100 private slots:
    101 
    102     /* Handler: Popup done stuff: */
    103     void sltPopupDone(int iButtonCode) const;
    104 
    105 private:
    106 
    107     /* Constructor/destructor: */
    108     UIPopupCenter();
    109     ~UIPopupCenter();
    110 
    111     /* Helper: Popup-box stuff: */
    112     void showPopupBox(QWidget *pParent, const QString &strId,
    113                       const QString &strMessage, const QString &strDetails,
    114                       int iButton1, int iButton2, int iButton3,
    115                       const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3) const;
    116 
    117     /* Variables: */
    118     mutable QMap<QString, QPointer<UIPopupPane> > m_popups;
    119 
    120     /* Instance stuff: */
    121     static UIPopupCenter* m_spInstance;
    122     static UIPopupCenter* instance();
    123     friend UIPopupCenter& popupCenter();
    124 };
    125 
    126 /* Shortcut to the static UIPopupCenter::instance() method: */
    127 inline UIPopupCenter& popupCenter() { return *UIPopupCenter::instance(); }
    12835
    12936/* UIAnimationFramework namespace: */
     
    232139};
    233140
    234 /* Popup-pane frame prototype class: */
    235 class UIPopupPaneFrame : public QWidget
    236 {
    237     Q_OBJECT;
    238     Q_PROPERTY(int opacity READ opacity WRITE setOpacity);
    239 
    240 signals:
    241 
    242     /* Notifiers: Hover stuff: */
    243     void sigHoverEnter();
    244     void sigHoverLeave();
    245 
    246 public:
    247 
    248     /* Constructor/destructor: */
    249     UIPopupPaneFrame(QWidget *pParent = 0);
    250     ~UIPopupPaneFrame();
    251 
    252 private:
    253 
    254     /* Helpers: Prepare/cleanup stuff: */
    255     void prepare();
    256     void cleanup();
    257 
    258     /* Handlers: Event stuff: */
    259     void paintEvent(QPaintEvent *pEvent);
    260 
    261     /* Property: Hover stuff: */
    262     int opacity() const { return m_iOpacity; }
    263     void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
    264 
    265     /* Variables: Hover stuff: */
    266     const int m_iHoverAnimationDuration;
    267     const int m_iDefaultOpacity;
    268     const int m_iHoveredOpacity;
    269     int m_iOpacity;
    270 };
    271 
    272 /* Popup-pane text-pane prototype class: */
    273 class UIPopupPaneTextPane : public QWidget
    274 {
    275     Q_OBJECT;
    276     Q_PROPERTY(int percentage READ percentage WRITE setPercentage);
    277 
    278 signals:
    279 
    280     /* Notifiers: Hover stuff: */
    281     void sigHoverEnter();
    282     void sigHoverLeave();
    283     void sigGeometryChanged();
    284 
    285 public:
    286 
    287     /* Constructor/destructor: */
    288     UIPopupPaneTextPane(QWidget *pParent = 0);
    289     ~UIPopupPaneTextPane();
    290 
    291     /* API: Text stuff: */
    292     void setText(const QString &strText);
    293 
    294     /* API: Set desired width: */
    295     void setDesiredWidth(int iDesiredWidth);
    296 
    297     /* API: Minimum size-hint stuff: */
    298     QSize minimumSizeHint() const;
    299 
    300 private:
    301 
    302     /* Helpers: Prepare/cleanup stuff: */
    303     void prepare();
    304     void cleanup();
    305 
    306     /* Helper: Content stuff: */
    307     void prepareContent();
    308 
    309     /* Property: Hover stuff: */
    310     int percentage() const { return m_iPercentage; }
    311     void setPercentage(int iPercentage);
    312 
    313     /* Variables: Label stuff: */
    314     QLabel *m_pLabel;
    315     int m_iDesiredWidth;
    316 
    317     /* Variables: Hover stuff: */
    318     const int m_iHoverAnimationDuration;
    319     const int m_iDefaultPercentage;
    320     const int m_iHoveredPercentage;
    321     int m_iPercentage;
    322 };
    323 
    324 #endif /* __UIPopupCenter_h__ */
     141#endif /* __UIPopupPane_h__ */
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