VirtualBox

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


Ignore:
Timestamp:
Apr 18, 2013 1:09:08 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85102
Message:

FE/Qt: Popup-center, popup-pane: Implementing main framework stuff (part 7).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc

    r41461 r45605  
    243243        <file alias="restore_16px.png">images/restore_16px.png</file>
    244244        <file alias="close_16px.png">images/close_16px.png</file>
     245        <file alias="ok_16px.png">images/ok_16px.png</file>
     246        <file alias="cancel_16px.png">images/cancel_16px.png</file>
    245247    </qresource>
    246248</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp

    r45586 r45605  
    158158        if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)
    159159            iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape;
     160        /* Compose button description map: */
     161        QMap<int, QString> buttonDescriptions;
     162        if (iButton1 != 0 && !buttonDescriptions.contains(iButton1))
     163            buttonDescriptions[iButton1] = strButtonText1;
     164        if (iButton2 != 0 && !buttonDescriptions.contains(iButton2))
     165            buttonDescriptions[iButton2] = strButtonText2;
     166        if (iButton3 != 0 && !buttonDescriptions.contains(iButton3))
     167            buttonDescriptions[iButton3] = strButtonText3;
    160168        /* Create popup-pane and insert it into our map: */
    161169        QWidget *pPopupBoxParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
    162         pPopupPane = new UIPopupPane(pPopupBoxParent, strId,
    163                                      strMessage, strDetails,
    164                                      iButton1, iButton2, iButton3,
    165                                      strButtonText1, strButtonText2, strButtonText3);
     170        pPopupPane = new UIPopupPane(pPopupBoxParent, strId, strMessage, strDetails, buttonDescriptions);
    166171        m_popups.insert(strId, pPopupPane);
    167172        /* Attach popup-pane connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r45592 r45605  
    1919
    2020/* Qt includes: */
     21#include <QHBoxLayout>
    2122#include <QVBoxLayout>
    2223#include <QLabel>
    2324#include <QPushButton>
    2425#include <QEvent>
     26#include <QKeyEvent>
    2527#include <QMainWindow>
    2628#include <QStatusBar>
     
    3234/* GUI includes: */
    3335#include "UIPopupPane.h"
    34 #include "QIDialogButtonBox.h"
     36#include "UIIconPool.h"
     37#include "QIToolButton.h"
    3538
    3639/* Other VBox includes: */
     
    129132public:
    130133
    131     /* Constructor/destructor: */
     134    /* Constructor: */
    132135    UIPopupPaneFrame(QWidget *pParent = 0);
    133     ~UIPopupPaneFrame();
    134136
    135137private:
    136138
    137     /* Helpers: Prepare/cleanup stuff: */
     139    /* Helper: Prepare stuff: */
    138140    void prepare();
    139     void cleanup();
    140 
    141     /* Handlers: Event stuff: */
     141
     142    /* Handler: Event stuff: */
    142143    void paintEvent(QPaintEvent *pEvent);
    143144
     
    170171public:
    171172
    172     /* Constructor/destructor: */
     173    /* Constructor: */
    173174    UIPopupPaneTextPane(QWidget *pParent = 0);
    174     ~UIPopupPaneTextPane();
    175175
    176176    /* API: Text stuff: */
     
    192192private:
    193193
    194     /* Helpers: Prepare/cleanup stuff: */
     194    /* Helperss: Prepare stuff: */
    195195    void prepare();
    196     void cleanup();
    197 
    198     /* Helper: Content stuff: */
    199196    void prepareContent();
    200197
     
    219216
    220217
     218/* Popup-pane button-pane prototype class: */
     219class UIPopupPaneButtonPane : public QWidget
     220{
     221    Q_OBJECT;
     222
     223signals:
     224
     225    /* Notifier: Button stuff: */
     226    void sigButtonClicked(int iButtonID);
     227
     228public:
     229
     230    /* Constructor: */
     231    UIPopupPaneButtonPane(QWidget *pParent = 0);
     232
     233    /* API: Button stuff: */
     234    void setButtons(const QMap<int, QString> &buttonDescriptions);
     235
     236private slots:
     237
     238    /* Handler: Button stuff: */
     239    void sltButtonClicked();
     240
     241private:
     242
     243    /* Helpers: Prepare/cleanup stuff: */
     244    void prepare();
     245    void prepareLayouts();
     246    void prepareButtons();
     247    void cleanupButtons();
     248
     249    /* Handler: Event stuff: */
     250    void keyPressEvent(QKeyEvent *pEvent);
     251
     252    /* Static helpers: Button stuff: */
     253    static QIToolButton* addButton(int iButtonID, const QString &strToolTip);
     254    static QString defaultToolTip(int iButtonID);
     255    static QIcon defaultIcon(int iButtonID);
     256
     257    /* Widgets: */
     258    QHBoxLayout *m_pButtonLayout;
     259    QMap<int, QString> m_buttonDescriptions;
     260    QMap<int, QIToolButton*> m_buttons;
     261    int m_iDefaultButton;
     262    int m_iEscapeButton;
     263};
     264
     265
    221266UIPopupPane::UIPopupPane(QWidget *pParent, const QString &strId,
    222267                         const QString &strMessage, const QString &strDetails,
    223                          int iButton1, int iButton2, int iButton3,
    224                          const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3)
     268                         const QMap<int, QString> &buttonDescriptions)
    225269    : QWidget(pParent)
    226270    , m_fPolished(false)
     
    228272    , m_iMainLayoutMargin(2), m_iMainFrameLayoutMargin(10), m_iMainFrameLayoutSpacing(5)
    229273    , m_iParentStatusBarHeight(parentStatusBarHeight(pParent))
    230     , m_strMessage(strMessage), m_strDetails(strDetails)
    231     , m_iButton1(iButton1), m_iButton2(iButton2), m_iButton3(iButton3)
    232     , m_strButtonText1(strButtonText1), m_strButtonText2(strButtonText2), m_strButtonText3(strButtonText3)
    233     , m_iButtonEsc(0)
    234     , m_fHovered(false)
    235     , m_fFocused(false)
    236     , m_pMainFrame(0), m_pTextPane(0), m_pButtonBox(0)
    237     , m_pButton1(0), m_pButton2(0), m_pButton3(0)
     274    , m_strMessage(strMessage), m_strDetails(strDetails), m_buttonDescriptions(buttonDescriptions)
     275    , m_fHovered(false) , m_fFocused(false)
     276    , m_pMainFrame(0), m_pTextPane(0), m_pButtonPane(0)
    238277{
    239278    /* Prepare: */
    240279    prepare();
    241 }
    242 
    243 UIPopupPane::~UIPopupPane()
    244 {
    245     /* Cleanup: */
    246     cleanup();
    247280}
    248281
     
    266299    /* Fetch new details: */
    267300    m_strDetails = strDetails;
     301}
     302
     303void UIPopupPane::sltButtonClicked(int iButtonID)
     304{
     305    done(iButtonID & AlertButtonMask);
    268306}
    269307
     
    295333}
    296334
    297 void UIPopupPane::cleanup()
    298 {
     335void UIPopupPane::prepareContent()
     336{
     337    /* Prepare this: */
     338    installEventFilter(this);
     339    /* Create main-frame: */
     340    m_pMainFrame = new UIPopupPaneFrame(this);
     341    {
     342        /* Prepare frame: */
     343        m_pMainFrame->installEventFilter(this);
     344        m_pMainFrame->setFocusPolicy(Qt::StrongFocus);
     345        /* Create message-label: */
     346        m_pTextPane = new UIPopupPaneTextPane(m_pMainFrame);
     347        {
     348            /* Prepare label: */
     349            connect(m_pTextPane, SIGNAL(sigSizeChanged()),
     350                    this, SLOT(sltAdjustGeomerty()));
     351            m_pTextPane->installEventFilter(this);
     352            m_pTextPane->setFocusPolicy(Qt::StrongFocus);
     353            m_pTextPane->setText(m_strMessage);
     354        }
     355        /* Create button-box: */
     356        m_pButtonPane = new UIPopupPaneButtonPane(m_pMainFrame);
     357        {
     358            /* Prepare button-box: */
     359            connect(m_pButtonPane, SIGNAL(sigButtonClicked(int)),
     360                    this, SLOT(sltButtonClicked(int)));
     361            m_pButtonPane->installEventFilter(this);
     362            m_pButtonPane->setButtons(m_buttonDescriptions);
     363            m_pButtonPane->setFocusPolicy(Qt::StrongFocus);
     364            m_pMainFrame->setFocusProxy(m_pButtonPane);
     365            m_pTextPane->setFocusProxy(m_pButtonPane);
     366        }
     367    }
    299368}
    300369
     
    349418            case QEvent::FocusOut:
    350419            {
    351                 if (m_fFocused && (pWatched == m_pButton1 ||
    352                                    pWatched == m_pButton2 ||
    353                                    pWatched == m_pButton3))
     420                if (m_fFocused)
    354421                {
    355422                    m_fFocused = false;
     
    385452}
    386453
    387 void UIPopupPane::keyPressEvent(QKeyEvent *pEvent)
    388 {
    389     /* Preprocess Escape key: */
    390     if (pEvent->key() == Qt::Key_Escape && m_iButtonEsc)
    391     {
    392         done(m_iButtonEsc);
    393         return;
    394     }
    395     /* Handle all the other keys: */
    396     QWidget::keyPressEvent(pEvent);
    397 }
    398 
    399454int UIPopupPane::minimumWidthHint() const
    400455{
     
    411466            iMinimumWidthHint += m_pTextPane->width();
    412467            iMinimumWidthHint += m_iMainFrameLayoutSpacing;
    413             iMinimumWidthHint += m_pButtonBox->minimumSizeHint().width();
     468            iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width();
    414469        }
    415470    }
     
    432487            /* Take into account widgets: */
    433488            const int iTextPaneHeight = m_pTextPane->height();
    434             const int iButtonBoxHeight = m_pButtonBox->minimumSizeHint().height();
     489            const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height();
    435490            iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);
    436491        }
     
    456511        m_pTextPane->setDesiredWidth(iWidth - 2 * m_iMainLayoutMargin
    457512                                            - 2 * m_iMainFrameLayoutMargin
    458                                             - m_pButtonBox->minimumSizeHint().width());
     513                                            - m_pButtonPane->minimumSizeHint().width());
    459514    }
    460515
     
    481536            const int iTextPaneWidth = m_pTextPane->width();
    482537            const int iTextPaneHeight = m_pTextPane->height();
    483             const QSize buttonBoxMinimumSizeHint = m_pButtonBox->minimumSizeHint();
     538            const QSize buttonBoxMinimumSizeHint = m_pButtonPane->minimumSizeHint();
    484539            const int iButtonBoxWidth = buttonBoxMinimumSizeHint.width();
    485540            const int iButtonBoxHeight = buttonBoxMinimumSizeHint.height();
     
    493548            m_pTextPane->resize(iTextPaneWidth, iTextPaneHeight);
    494549            /* Button-box: */
    495             m_pButtonBox->move(m_iMainFrameLayoutMargin + iTextPaneWidth + m_iMainFrameLayoutSpacing,
    496                                m_iMainFrameLayoutMargin);
    497             m_pButtonBox->resize(iButtonBoxWidth,
    498                                  iMainFrameHeight - 2 * m_iMainFrameLayoutMargin);
     550            m_pButtonPane->move(m_iMainFrameLayoutMargin + iTextPaneWidth + m_iMainFrameLayoutSpacing,
     551                                m_iMainFrameLayoutMargin);
     552            m_pButtonPane->resize(iButtonBoxWidth,
     553                                  iMainFrameHeight - 2 * m_iMainFrameLayoutMargin);
    499554        }
    500     }
    501 }
    502 
    503 void UIPopupPane::prepareContent()
    504 {
    505     /* Prepare this: */
    506     installEventFilter(this);
    507     /* Create main-frame: */
    508     m_pMainFrame = new UIPopupPaneFrame(this);
    509     {
    510         /* Prepare frame: */
    511         m_pMainFrame->installEventFilter(this);
    512         m_pMainFrame->setFocusPolicy(Qt::StrongFocus);
    513         /* Create message-label: */
    514         m_pTextPane = new UIPopupPaneTextPane(m_pMainFrame);
    515         {
    516             /* Prepare label: */
    517             connect(m_pTextPane, SIGNAL(sigSizeChanged()),
    518                     this, SLOT(sltAdjustGeomerty()));
    519             m_pTextPane->installEventFilter(this);
    520             m_pTextPane->setFocusPolicy(Qt::StrongFocus);
    521             m_pTextPane->setText(m_strMessage);
    522         }
    523         /* Create button-box: */
    524         m_pButtonBox = new QIDialogButtonBox(m_pMainFrame);
    525         {
    526             /* Prepare button-box: */
    527             m_pButtonBox->installEventFilter(this);
    528             m_pButtonBox->setOrientation(Qt::Vertical);
    529             prepareButtons();
    530         }
    531     }
    532 }
    533 
    534 void UIPopupPane::prepareButtons()
    535 {
    536     /* Prepare descriptions: */
    537     QList<int> descriptions;
    538     descriptions << m_iButton1 << m_iButton2 << m_iButton3;
    539 
    540     /* Choose 'escape' button: */
    541     foreach (int iButton, descriptions)
    542         if (iButton & AlertButtonOption_Escape)
    543         {
    544             m_iButtonEsc = iButton & AlertButtonMask;
    545             break;
    546         }
    547 
    548     /* Create buttons: */
    549     QList<QPushButton*> buttons = createButtons(m_pButtonBox, descriptions);
    550 
    551     /* Install focus-proxy into the 'default' button: */
    552     foreach (QPushButton *pButton, buttons)
    553         if (pButton && pButton->isDefault())
    554         {
    555             m_pMainFrame->setFocusProxy(pButton);
    556             m_pTextPane->setFocusProxy(pButton);
    557             break;
    558         }
    559 
    560     /* Prepare button 1: */
    561     m_pButton1 = buttons[0];
    562     if (m_pButton1)
    563     {
    564         m_pButton1->installEventFilter(this);
    565         connect(m_pButton1, SIGNAL(clicked()), SLOT(done1()));
    566         if (!m_strButtonText1.isEmpty())
    567             m_pButton1->setText(m_strButtonText1);
    568     }
    569     /* Prepare button 2: */
    570     m_pButton2 = buttons[1];
    571     if (m_pButton2)
    572     {
    573         m_pButton2->installEventFilter(this);
    574         connect(m_pButton2, SIGNAL(clicked()), SLOT(done2()));
    575         if (!m_strButtonText2.isEmpty())
    576             m_pButton1->setText(m_strButtonText2);
    577     }
    578     /* Prepare button 3: */
    579     m_pButton3 = buttons[2];
    580     if (m_pButton3)
    581     {
    582         m_pButton3->installEventFilter(this);
    583         connect(m_pButton3, SIGNAL(clicked()), SLOT(done3()));
    584         if (!m_strButtonText3.isEmpty())
    585             m_pButton1->setText(m_strButtonText3);
    586555    }
    587556}
     
    607576}
    608577
    609 /* static */
    610 QList<QPushButton*> UIPopupPane::createButtons(QIDialogButtonBox *pButtonBox, const QList<int> descriptions)
    611 {
    612     /* Create button according descriptions: */
    613     QList<QPushButton*> buttons;
    614     foreach (int iButton, descriptions)
    615         buttons << createButton(pButtonBox, iButton);
    616     /* Return buttons: */
    617     return buttons;
    618 }
    619 
    620 /* static */
    621 QPushButton* UIPopupPane::createButton(QIDialogButtonBox *pButtonBox, int iButton)
    622 {
    623     /* Null for AlertButton_NoButton: */
    624     if (iButton == 0)
    625         return 0;
    626 
    627     /* Prepare button text & role: */
    628     QString strText;
    629     QDialogButtonBox::ButtonRole role;
    630     switch (iButton & AlertButtonMask)
    631     {
    632         case AlertButton_Ok:      strText = QIMessageBox::tr("OK");     role = QDialogButtonBox::AcceptRole; break;
    633         case AlertButton_Cancel:  strText = QIMessageBox::tr("Cancel"); role = QDialogButtonBox::RejectRole; break;
    634         case AlertButton_Choice1: strText = QIMessageBox::tr("Yes");    role = QDialogButtonBox::YesRole; break;
    635         case AlertButton_Choice2: strText = QIMessageBox::tr("No");     role = QDialogButtonBox::NoRole; break;
    636         default: return 0;
    637     }
    638 
    639     /* Create push-button: */
    640     QPushButton *pButton = pButtonBox->addButton(strText, role);
    641 
    642     /* Configure button: */
    643     pButton->setFocusPolicy(Qt::StrongFocus);
    644 
    645     /* Configure 'default' button: */
    646     if (iButton & AlertButtonOption_Default)
    647         pButton->setDefault(true);
    648 
    649     /* Return button: */
    650     return pButton;
    651 }
    652 
    653578
    654579UIPopupPaneFrame::UIPopupPaneFrame(QWidget *pParent /*= 0*/)
     
    661586    /* Prepare: */
    662587    prepare();
    663 }
    664 
    665 UIPopupPaneFrame::~UIPopupPaneFrame()
    666 {
    667     /* Cleanup: */
    668     cleanup();
    669588}
    670589
     
    680599                                                   m_iDefaultOpacity, m_iHoveredOpacity, m_iHoverAnimationDuration,
    681600                                                   SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave()));
    682 }
    683 
    684 void UIPopupPaneFrame::cleanup()
    685 {
    686601}
    687602
     
    732647}
    733648
    734 UIPopupPaneTextPane::~UIPopupPaneTextPane()
    735 {
    736     /* Cleanup: */
    737     cleanup();
    738 }
    739 
    740649void UIPopupPaneTextPane::setText(const QString &strText)
    741650{
     
    803712    /* Prepare content: */
    804713    prepareContent();
    805 }
    806 
    807 void UIPopupPaneTextPane::cleanup()
    808 {
    809714}
    810715
     
    854759}
    855760
     761
     762UIPopupPaneButtonPane::UIPopupPaneButtonPane(QWidget *pParent /*= 0*/)
     763    : QWidget(pParent)
     764    , m_iDefaultButton(0)
     765    , m_iEscapeButton(0)
     766{
     767    /* Prepare: */
     768    prepare();
     769}
     770
     771void UIPopupPaneButtonPane::setButtons(const QMap<int, QString> &buttonDescriptions)
     772{
     773    /* Make sure something changed: */
     774    if (m_buttonDescriptions == buttonDescriptions)
     775        return;
     776
     777    /* Assign new button-descriptions: */
     778    m_buttonDescriptions = buttonDescriptions;
     779    /* Recreate buttons: */
     780    cleanupButtons();
     781    prepareButtons();
     782}
     783
     784void UIPopupPaneButtonPane::sltButtonClicked()
     785{
     786    /* Make sure the slot is called by the button: */
     787    QIToolButton *pButton = qobject_cast<QIToolButton*>(sender());
     788    if (!pButton)
     789        return;
     790
     791    /* Make sure we still have that button: */
     792    int iButtonID = m_buttons.key(pButton, 0);
     793    if (!iButtonID)
     794        return;
     795
     796    /* Notify listeners button was clicked: */
     797    emit sigButtonClicked(iButtonID);
     798}
     799
     800void UIPopupPaneButtonPane::prepare()
     801{
     802    /* Prepare layouts: */
     803    prepareLayouts();
     804}
     805
     806void UIPopupPaneButtonPane::prepareLayouts()
     807{
     808    /* Create layouts: */
     809    m_pButtonLayout = new QHBoxLayout;
     810    m_pButtonLayout->setContentsMargins(0, 0, 0, 0);
     811    m_pButtonLayout->setSpacing(0);
     812    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     813    pMainLayout->setContentsMargins(0, 0, 0, 0);
     814    pMainLayout->setSpacing(0);
     815    pMainLayout->addLayout(m_pButtonLayout);
     816    pMainLayout->addStretch();
     817}
     818
     819void UIPopupPaneButtonPane::prepareButtons()
     820{
     821    /* Add all the buttons: */
     822    const QList<int> &buttonsIDs = m_buttonDescriptions.keys();
     823    foreach (int iButtonID, buttonsIDs)
     824        if (QIToolButton *pButton = addButton(iButtonID, m_buttonDescriptions[iButtonID]))
     825        {
     826            m_pButtonLayout->addWidget(pButton);
     827            m_buttons[iButtonID] = pButton;
     828            connect(pButton, SIGNAL(clicked(bool)), this, SLOT(sltButtonClicked()));
     829            if (pButton->property("default").toBool())
     830                m_iDefaultButton = iButtonID;
     831            if (pButton->property("escape").toBool())
     832                m_iEscapeButton = iButtonID;
     833        }
     834}
     835
     836void UIPopupPaneButtonPane::cleanupButtons()
     837{
     838    /* Remove all the buttons: */
     839    const QList<int> &buttonsIDs = m_buttons.keys();
     840    foreach (int iButtonID, buttonsIDs)
     841    {
     842        delete m_buttons[iButtonID];
     843        m_buttons.remove(iButtonID);
     844    }
     845}
     846
     847void UIPopupPaneButtonPane::keyPressEvent(QKeyEvent *pEvent)
     848{
     849    /* Depending on pressed key: */
     850    switch (pEvent->key())
     851    {
     852        case Qt::Key_Enter:
     853        case Qt::Key_Return:
     854        {
     855            if (m_iDefaultButton)
     856            {
     857                pEvent->accept();
     858                emit sigButtonClicked(m_iDefaultButton);
     859                return;
     860            }
     861            break;
     862        }
     863        case Qt::Key_Escape:
     864        {
     865            if (m_iEscapeButton)
     866            {
     867                pEvent->accept();
     868                emit sigButtonClicked(m_iEscapeButton);
     869                return;
     870            }
     871            break;
     872        }
     873        default:
     874            break;
     875    }
     876    /* Call to base-class: */
     877    QWidget::keyPressEvent(pEvent);
     878}
     879
     880/* static */
     881QIToolButton* UIPopupPaneButtonPane::addButton(int iButtonID, const QString &strToolTip)
     882{
     883    /* Create button: */
     884    QIToolButton *pButton = new QIToolButton;
     885    pButton->setToolTip(strToolTip.isEmpty() ? defaultToolTip(iButtonID) : strToolTip);
     886    pButton->setIcon(defaultIcon(iButtonID));
     887
     888    /* Sign the 'default' button: */
     889    if (iButtonID & AlertButtonOption_Default)
     890        pButton->setProperty("default", true);
     891    /* Sign the 'escape' button: */
     892    if (iButtonID & AlertButtonOption_Escape)
     893        pButton->setProperty("escape", true);
     894
     895    /* Return button: */
     896    return pButton;
     897}
     898
     899/* static */
     900QString UIPopupPaneButtonPane::defaultToolTip(int iButtonID)
     901{
     902    QString strToolTip;
     903    switch (iButtonID & AlertButtonMask)
     904    {
     905        case AlertButton_Ok:      strToolTip = QIMessageBox::tr("OK");     break;
     906        case AlertButton_Cancel:  strToolTip = QIMessageBox::tr("Cancel"); break;
     907        case AlertButton_Choice1: strToolTip = QIMessageBox::tr("Yes");    break;
     908        case AlertButton_Choice2: strToolTip = QIMessageBox::tr("No");     break;
     909        default:                  strToolTip = QString();                  break;
     910    }
     911    return strToolTip;
     912}
     913
     914/* static */
     915QIcon UIPopupPaneButtonPane::defaultIcon(int iButtonID)
     916{
     917    QIcon icon;
     918    switch (iButtonID & AlertButtonMask)
     919    {
     920        case AlertButton_Ok:      icon = UIIconPool::iconSet(":/ok_16px.png");     break;
     921        case AlertButton_Cancel:  icon = UIIconPool::iconSet(":/cancel_16px.png"); break;
     922        case AlertButton_Choice1: break;
     923        case AlertButton_Choice2: break;
     924        default:                  break;
     925    }
     926    return icon;
     927}
     928
    856929#include "UIPopupPane.moc"
    857930
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r45592 r45605  
    2222/* Qt includes: */
    2323#include <QWidget>
     24#include <QMap>
    2425
    2526/* GUI includes: */
     
    3031class QLabel;
    3132class QPushButton;
    32 class QIDialogButtonBox;
    3333class UIPopupPane;
    3434class UIPopupPaneFrame;
    3535class UIPopupPaneTextPane;
     36class UIPopupPaneButtonPane;
    3637
    3738/* UIAnimationFramework namespace: */
     
    6869public:
    6970
    70     /* Constructor/destructor: */
     71    /* Constructor: */
    7172    UIPopupPane(QWidget *pParent, const QString &strId,
    7273                const QString &strMessage, const QString &strDetails,
    73                 int iButton1, int iButton2, int iButton3,
    74                 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3);
    75     ~UIPopupPane();
     74                const QMap<int, QString> &buttonDescriptions);
    7675
    7776    /* API: Id stuff: */
     
    8483private slots:
    8584
    86     /* Handlers: Done slot variants for every button: */
    87     void done1() { done(m_iButton1 & AlertButtonMask); }
    88     void done2() { done(m_iButton2 & AlertButtonMask); }
    89     void done3() { done(m_iButton3 & AlertButtonMask); }
     85    /* Handler: Button stuff: */
     86    void sltButtonClicked(int iButtonID);
    9087
    9188    /* Handler: Layout stuff: */
     
    9491private:
    9592
    96     /* Helpers: Prepare/cleanup stuff: */
     93    /* Helpers: Prepare stuff: */
    9794    void prepare();
    98     void cleanup();
     95    void prepareContent();
    9996
    10097    /* Handler: Event-filter stuff: */
     
    104101    virtual void showEvent(QShowEvent *pEvent);
    105102    virtual void polishEvent(QShowEvent *pEvent);
    106     virtual void keyPressEvent(QKeyEvent *pEvent);
    107103
    108104    /* Helper: Layout stuff: */
     
    113109    void updateLayout();
    114110
    115     /* Helpers: Prepare stuff: */
    116     void prepareContent();
    117     void prepareButtons();
    118 
    119111    /* Helper: Complete stuff: */
    120112    void done(int iButtonCode);
     
    122114    /* Static helpers: Prepare stuff: */
    123115    static int parentStatusBarHeight(QWidget *pParent);
    124     static QList<QPushButton*> createButtons(QIDialogButtonBox *pButtonBox, const QList<int> description);
    125     static QPushButton* createButton(QIDialogButtonBox *pButtonBox, int iButton);
    126116
    127117    /* Variables: */
     
    139129
    140130    /* Variables: Button stuff: */
    141     int m_iButton1, m_iButton2, m_iButton3;
    142     QString m_strButtonText1, m_strButtonText2, m_strButtonText3;
    143     int m_iButtonEsc;
     131    QMap<int, QString> m_buttonDescriptions;
    144132
    145133    /* Variables: Animation stuff: */
     
    150138    UIPopupPaneFrame *m_pMainFrame;
    151139    UIPopupPaneTextPane *m_pTextPane;
    152     QIDialogButtonBox *m_pButtonBox;
    153     QPushButton *m_pButton1, *m_pButton2, *m_pButton3;
     140    UIPopupPaneButtonPane *m_pButtonPane;
    154141};
    155142
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