- Timestamp:
- Jul 8, 2016 4:04:06 PM (9 years ago)
- 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 5 5 6 6 /* 7 * Copyright (C) 2006-201 4Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 31 31 QIArrowButtonSwitch::QIArrowButtonSwitch(QWidget *pParent /* = 0 */) 32 32 : QIRichToolButton(pParent) 33 , m_ buttonState(ButtonState_Collapsed)33 , m_fExpanded(false) 34 34 { 35 35 /* Update icon: */ … … 37 37 } 38 38 39 void QIArrowButtonSwitch::setIcon ForButtonState(QIArrowButtonSwitch::ButtonState buttonState, const QIcon &icon)39 void QIArrowButtonSwitch::setIcons(const QIcon &iconCollapsed, const QIcon &iconExpanded) 40 40 { 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 48 void QIArrowButtonSwitch::setExpanded(bool fExpanded) 49 { 50 /* Set button state: */ 51 m_fExpanded = fExpanded; 43 52 /* Update icon: */ 44 53 updateIcon(); … … 47 56 void QIArrowButtonSwitch::sltButtonClicked() 48 57 { 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; 52 60 /* Update icon: */ 53 61 updateIcon(); … … 60 68 { 61 69 /* 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; 64 72 default: break; 65 73 } … … 68 76 } 69 77 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 5 5 6 6 /* 7 * Copyright (C) 2006-201 4Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 21 21 /* Qt includes: */ 22 #include <QMap>23 22 #include <QIcon> 24 23 … … 35 34 public: 36 35 37 /** Button states. */38 enum ButtonState { ButtonState_Collapsed, ButtonState_Expanded };39 40 36 /** Constructor, passes @a pParent to the QIRichToolButton constructor. */ 41 37 QIArrowButtonSwitch(QWidget *pParent = 0); 42 38 43 /** Defines the @a icon for the @a buttonState. */44 void setIcon ForButtonState(ButtonState buttonState, const QIcon &icon);39 /** Defines the @a iconCollapsed and the @a iconExpanded. */ 40 void setIcons(const QIcon &iconCollapsed, const QIcon &iconExpanded); 45 41 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; } 48 46 49 47 protected slots: … … 60 58 61 59 /** Updates icon according button-state. */ 62 void updateIcon() ;60 void updateIcon() { setIcon(m_fExpanded ? m_iconExpanded : m_iconCollapsed); } 63 61 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; 68 69 }; 69 70 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowSplitter.cpp
r62038 r62143 253 253 /* Configure switch-button: */ 254 254 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")); 259 257 connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateNavigationButtonsVisibility())); 260 258 connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateDetailsBrowserVisibility())); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp
r62140 r62143 71 71 m_pMACButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 72 72 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")); 77 75 78 76 /* Setup connections: */
Note:
See TracChangeset
for help on using the changeset viewer.