VirtualBox

Changeset 71513 in vbox


Ignore:
Timestamp:
Mar 26, 2018 2:11:28 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Heavy cleanup for UIPopupPaneButtonPane.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneButtonPane.cpp

    r69500 r71513  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222# include <QApplication>
    2323# include <QHBoxLayout>
     24# include <QKeyEvent>
    2425# include <QVBoxLayout>
    25 # include <QKeyEvent>
    2626
    2727/* GUI includes: */
     28# include "QIMessageBox.h"
     29# include "QIToolButton.h"
     30# include "UIIconPool.h"
    2831# include "UIPopupPaneButtonPane.h"
    29 # include "UIIconPool.h"
    30 # include "QIToolButton.h"
    31 # include "QIMessageBox.h"
    3232
    3333#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    5151    /* Assign new button-descriptions: */
    5252    m_buttonDescriptions = buttonDescriptions;
     53
    5354    /* Recreate buttons: */
    5455    cleanupButtons();
     
    8081void UIPopupPaneButtonPane::prepareLayouts()
    8182{
    82     /* Create layouts: */
    83     m_pButtonLayout = new QHBoxLayout;
    84     m_pButtonLayout->setContentsMargins(0, 0, 0, 0);
    85     m_pButtonLayout->setSpacing(0);
     83    /* Create main-layout: */
    8684    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    87     pMainLayout->setContentsMargins(0, 0, 0, 0);
    88     pMainLayout->setSpacing(0);
    89     pMainLayout->addLayout(m_pButtonLayout);
    90     pMainLayout->addStretch();
     85    if (pMainLayout)
     86    {
     87        /* Configure layout: */
     88        pMainLayout->setSpacing(0);
     89        pMainLayout->setContentsMargins(0, 0, 0, 0);
     90
     91        /* Create button-layout: */
     92        m_pButtonLayout = new QHBoxLayout;
     93        if (m_pButtonLayout)
     94        {
     95            /* Configure layout: */
     96            m_pButtonLayout->setSpacing(0);
     97            m_pButtonLayout->setContentsMargins(0, 0, 0, 0);
     98
     99            /* Add into layout: */
     100            pMainLayout->addLayout(m_pButtonLayout);
     101        }
     102
     103        /* Add stretch: */
     104        pMainLayout->addStretch();
     105    }
    91106}
    92107
     
    153168
    154169/* static */
    155 QIToolButton* UIPopupPaneButtonPane::addButton(int iButtonID, const QString &strToolTip)
     170QIToolButton *UIPopupPaneButtonPane::addButton(int iButtonID, const QString &strToolTip)
    156171{
    157172    /* Create button: */
    158173    QIToolButton *pButton = new QIToolButton;
    159     pButton->removeBorder();
    160     pButton->setToolTip(strToolTip.isEmpty() ? defaultToolTip(iButtonID) : strToolTip);
    161     pButton->setIcon(defaultIcon(iButtonID));
    162 
    163     /* Sign the 'default' button: */
    164     if (iButtonID & AlertButtonOption_Default)
    165         pButton->setProperty("default", true);
    166     /* Sign the 'escape' button: */
    167     if (iButtonID & AlertButtonOption_Escape)
    168         pButton->setProperty("escape", true);
     174    if (pButton)
     175    {
     176        /* Configure button: */
     177        pButton->removeBorder();
     178        pButton->setToolTip(strToolTip.isEmpty() ? defaultToolTip(iButtonID) : strToolTip);
     179        pButton->setIcon(defaultIcon(iButtonID));
     180
     181        /* Sign the 'default' button: */
     182        if (iButtonID & AlertButtonOption_Default)
     183            pButton->setProperty("default", true);
     184        /* Sign the 'escape' button: */
     185        if (iButtonID & AlertButtonOption_Escape)
     186            pButton->setProperty("escape", true);
     187    }
    169188
    170189    /* Return button: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneButtonPane.h

    r69500 r71513  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIPopupPaneButtonPane_h__
    19 #define __UIPopupPaneButtonPane_h__
     18#ifndef ___UIPopupPaneButtonPane_h___
     19#define ___UIPopupPaneButtonPane_h___
    2020
    2121/* Qt includes: */
     
    2525/* Forward declarations: */
    2626class QHBoxLayout;
     27class QIcon;
    2728class QKeyEvent;
     29class QString;
    2830class QIToolButton;
    2931
    30 /* Popup-pane button-pane prototype class: */
     32/** QWidget extension providing GUI with popup-pane button-pane prototype class. */
    3133class UIPopupPaneButtonPane : public QWidget
    3234{
     
    3537signals:
    3638
    37     /* Notifier: Button stuff: */
     39    /** Notifies about button with @a iButtonID being clicked. */
    3840    void sigButtonClicked(int iButtonID);
    3941
    4042public:
    4143
    42     /* Constructor: */
     44    /** Constructs popup-button pane passing @a pParent to the base-class. */
    4345    UIPopupPaneButtonPane(QWidget *pParent = 0);
    4446
    45     /* API: Button stuff: */
     47    /** Defines @a buttonDescriptions. */
    4648    void setButtons(const QMap<int, QString> &buttonDescriptions);
     49    /** Returns default button. */
    4750    int defaultButton() const { return m_iDefaultButton; }
     51    /** Returns escape button. */
    4852    int escapeButton() const { return m_iEscapeButton; }
    4953
    5054private slots:
    5155
    52     /* Handler: Button stuff: */
     56    /** Handles button click. */
    5357    void sltButtonClicked();
    5458
    5559private:
    5660
    57     /* Helpers: Prepare/cleanup stuff: */
     61    /** Prepares all. */
    5862    void prepare();
     63    /** Prepares layouts. */
    5964    void prepareLayouts();
     65    /** Prepares buttons. */
    6066    void prepareButtons();
     67    /** Cleanups buttons. */
    6168    void cleanupButtons();
    6269
    63     /* Handler: Event stuff: */
    64     void keyPressEvent(QKeyEvent *pEvent);
     70    /** Handles key-press @a pEvent. */
     71    virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;
    6572
    66     /* Static helpers: Button stuff: */
    67     static QIToolButton* addButton(int iButtonID, const QString &strToolTip);
     73    /** Adds button with @a iButtonID and @a strToolTip. */
     74    static QIToolButton *addButton(int iButtonID, const QString &strToolTip);
     75    /** Returns default tool-tip for button @a iButtonID. */
    6876    static QString defaultToolTip(int iButtonID);
     77    /** Returns default icon for button @a iButtonID. */
    6978    static QIcon defaultIcon(int iButtonID);
    7079
    71     /* Variables: Widget stuff: */
     80    /** Holds the button layout. */
    7281    QHBoxLayout *m_pButtonLayout;
    73     QMap<int, QString> m_buttonDescriptions;
     82
     83    /** Holds the button descriptions. */
     84    QMap<int, QString>       m_buttonDescriptions;
     85    /** Holds the button instances. */
    7486    QMap<int, QIToolButton*> m_buttons;
     87
     88    /** Holds default button. */
    7589    int m_iDefaultButton;
     90    /** Holds escape button. */
    7691    int m_iEscapeButton;
    7792};
    7893
    79 #endif /* __UIPopupPaneButtonPane_h__ */
     94#endif /* !___UIPopupPaneButtonPane_h___ */
     95
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