VirtualBox

Changeset 62143 in vbox for trunk/src


Ignore:
Timestamp:
Jul 8, 2016 4:04:06 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Small rework/cleanup for QIArrowButtonSwitch class: Replacing button state with bool flag, extending an API.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonSwitch.cpp

    r52730 r62143  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131QIArrowButtonSwitch::QIArrowButtonSwitch(QWidget *pParent /* = 0 */)
    3232    : QIRichToolButton(pParent)
    33     , m_buttonState(ButtonState_Collapsed)
     33    , m_fExpanded(false)
    3434{
    3535    /* Update icon: */
     
    3737}
    3838
    39 void QIArrowButtonSwitch::setIconForButtonState(QIArrowButtonSwitch::ButtonState buttonState, const QIcon &icon)
     39void QIArrowButtonSwitch::setIcons(const QIcon &iconCollapsed, const QIcon &iconExpanded)
    4040{
    41     /* Assign icon: */
    42     m_icons[buttonState] = icon;
     41    /* Assign icons: */
     42    m_iconCollapsed = iconCollapsed;
     43    m_iconExpanded = iconExpanded;
     44    /* Update icon: */
     45    updateIcon();
     46}
     47
     48void QIArrowButtonSwitch::setExpanded(bool fExpanded)
     49{
     50    /* Set button state: */
     51    m_fExpanded = fExpanded;
    4352    /* Update icon: */
    4453    updateIcon();
     
    4756void QIArrowButtonSwitch::sltButtonClicked()
    4857{
    49     /* Toggle button-state: */
    50     m_buttonState = m_buttonState == ButtonState_Collapsed ?
    51                     ButtonState_Expanded : ButtonState_Collapsed;
     58    /* Toggle button state: */
     59    m_fExpanded = !m_fExpanded;
    5260    /* Update icon: */
    5361    updateIcon();
     
    6068    {
    6169        /* Animate-click for the Space key: */
    62         case Qt::Key_Minus: if (m_buttonState == ButtonState_Expanded) return animateClick(); break;
    63         case Qt::Key_Plus: if (m_buttonState == ButtonState_Collapsed) return animateClick(); break;
     70        case Qt::Key_Minus: if (m_fExpanded) return animateClick(); break;
     71        case Qt::Key_Plus: if (!m_fExpanded) return animateClick(); break;
    6472        default: break;
    6573    }
     
    6876}
    6977
    70 void QIArrowButtonSwitch::updateIcon()
    71 {
    72     setIcon(m_icons.value(m_buttonState));
    73 }
    74 
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonSwitch.h

    r55401 r62143  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020
    2121/* Qt includes: */
    22 #include <QMap>
    2322#include <QIcon>
    2423
     
    3534public:
    3635
    37     /** Button states. */
    38     enum ButtonState { ButtonState_Collapsed, ButtonState_Expanded };
    39 
    4036    /** Constructor, passes @a pParent to the QIRichToolButton constructor. */
    4137    QIArrowButtonSwitch(QWidget *pParent = 0);
    4238
    43     /** Defines the @a icon for the @a buttonState. */
    44     void setIconForButtonState(ButtonState buttonState, const QIcon &icon);
     39    /** Defines the @a iconCollapsed and the @a iconExpanded. */
     40    void setIcons(const QIcon &iconCollapsed, const QIcon &iconExpanded);
    4541
    46     /** Returns whether button-state is ButtonState_Expanded. */
    47     bool isExpanded() const { return m_buttonState == ButtonState_Expanded; }
     42    /** Defines whether the button is @a fExpanded. */
     43    void setExpanded(bool fExpanded);
     44    /** Returns whether the button is expanded. */
     45    bool isExpanded() const { return m_fExpanded; }
    4846
    4947protected slots:
     
    6058
    6159    /** Updates icon according button-state. */
    62     void updateIcon();
     60    void updateIcon() { setIcon(m_fExpanded ? m_iconExpanded : m_iconCollapsed); }
    6361
    64     /** Holds the button-state. */
    65     ButtonState m_buttonState;
    66     /** Holds icons for button-states. */
    67     QMap<ButtonState, QIcon> m_icons;
     62    /** Holds whether the button is expanded. */
     63    bool m_fExpanded;
     64
     65    /** Holds the icon for collapsed button. */
     66    QIcon m_iconCollapsed;
     67    /** Holds the icon for expanded button. */
     68    QIcon m_iconExpanded;
    6869};
    6970
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowSplitter.cpp

    r62038 r62143  
    253253                /* Configure switch-button: */
    254254                m_pSwitchButton->setIconSize(QSize(iIconMetric, iIconMetric));
    255                 m_pSwitchButton->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Collapsed,
    256                                                        UIIconPool::iconSet(":/arrow_right_10px.png"));
    257                 m_pSwitchButton->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Expanded,
    258                                                        UIIconPool::iconSet(":/arrow_down_10px.png"));
     255                m_pSwitchButton->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"),
     256                                          UIIconPool::iconSet(":/arrow_down_10px.png"));
    259257                connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateNavigationButtonsVisibility()));
    260258                connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateDetailsBrowserVisibility()));
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r62140 r62143  
    7171    m_pMACButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
    7272    m_pAdvancedArrow->setIconSize(QSize(iIconMetric, iIconMetric));
    73     m_pAdvancedArrow->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Collapsed,
    74                                             UIIconPool::iconSet(":/arrow_right_10px.png"));
    75     m_pAdvancedArrow->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Expanded,
    76                                             UIIconPool::iconSet(":/arrow_down_10px.png"));
     73    m_pAdvancedArrow->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"),
     74                               UIIconPool::iconSet(":/arrow_down_10px.png"));
    7775
    7876    /* Setup connections: */
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