Changeset 76988 in vbox
- Timestamp:
- Jan 25, 2019 1:09:08 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
-
manager/chooser/UIChooserItemGroup.cpp (modified) (1 diff)
-
widgets/graphics/UIGraphicsButton.cpp (modified) (8 diffs)
-
widgets/graphics/UIGraphicsButton.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r76867 r76988 1753 1753 QPalette::HighlightedText : QPalette::ButtonText)); 1754 1754 1755 /* Update buttons: */1756 if (m_pToggleButton)1757 m_pToggleButton->setParentSelected(model()->currentItems().contains(this));1758 if (m_pEnterButton)1759 m_pEnterButton->setParentSelected(model()->currentItems().contains(this));1760 if (m_pExitButton)1761 m_pExitButton->setParentSelected(model()->currentItems().contains(this));1762 1763 1755 /* Paint name: */ 1764 1756 int iNameX = iHorizontalMargin + iParentIndent * level(); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp
r76987 r76988 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIGraphicsButton class definition.3 * VBox Qt GUI - UIGraphicsButton class implementation. 4 4 */ 5 5 … … 32 32 : QIGraphicsWidget(pParent) 33 33 , m_icon(icon) 34 , m_fParentSelected(false)35 34 , m_enmClickPolicy(ClickPolicy_OnRelease) 36 35 , m_iDelayId(0) … … 38 37 , m_dIconScaleIndex(0) 39 38 { 40 /* Refresh finally: */41 39 refresh(); 42 }43 44 void UIGraphicsButton::setParentSelected(bool fParentSelected)45 {46 if (m_fParentSelected == fParentSelected)47 return;48 m_fParentSelected = fParentSelected;49 update();50 40 } 51 41 … … 86 76 case GraphicsButton_Icon: 87 77 return m_icon; 88 default: break; 78 default: 79 break; 89 80 } 90 81 return QVariant(); 91 82 } 92 83 93 QSizeF UIGraphicsButton::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const94 { 95 /* Calculations for minimum size: */96 if ( which== Qt::MinimumSize)97 { 98 /* Variables: */99 int iMargin = data(GraphicsButton_Margin).toInt();100 QSize iconSize = data(GraphicsButton_IconSize).toSize();101 /* Calculations: */84 QSizeF UIGraphicsButton::sizeHint(Qt::SizeHint enmType, const QSizeF &constraint /* = QSizeF() */) const 85 { 86 /* For minimum size-hint: */ 87 if (enmType == Qt::MinimumSize) 88 { 89 /* Prepare variables: */ 90 const int iMargin = data(GraphicsButton_Margin).toInt(); 91 const QSize iconSize = data(GraphicsButton_IconSize).toSize(); 92 /* Perform calculations: */ 102 93 int iWidth = 2 * iMargin + iconSize.width(); 103 94 int iHeight = 2 * iMargin + iconSize.height(); 104 95 return QSize(iWidth, iHeight); 105 96 } 97 106 98 /* Call to base-class: */ 107 return QIGraphicsWidget::sizeHint( which, constraint);99 return QIGraphicsWidget::sizeHint(enmType, constraint); 108 100 } 109 101 … … 114 106 const QIcon icon = data(GraphicsButton_Icon).value<QIcon>(); 115 107 const QSize expectedIconSize = data(GraphicsButton_IconSize).toSize(); 116 /* Determine which QWindow this QGraphicsWidget belongs to: */ 108 109 /* Determine which QWindow this QGraphicsWidget belongs to. 110 * This is required for proper HiDPI-aware pixmap calculations. */ 117 111 QWindow *pWindow = 0; 118 112 if ( scene() … … 121 115 && scene()->views().first()->window()) 122 116 pWindow = scene()->views().first()->window()->windowHandle(); 123 /* Acquire pixmap: */ 117 118 /* Acquire pixmap, adjust it to be in center of button if necessary: */ 124 119 const QPixmap pixmap = icon.pixmap(pWindow, expectedIconSize); 125 120 const QSize actualIconSize = pixmap.size() / pixmap.devicePixelRatio(); … … 132 127 } 133 128 134 /* Just draw the pixmap: */129 /* Draw the pixmap finally: */ 135 130 pPainter->drawPixmap(position, pixmap); 136 131 } … … 205 200 /* Refresh geometry: */ 206 201 updateGeometry(); 207 /* Resize to minimum size : */202 /* Resize to minimum size-hint: */ 208 203 resize(minimumSizeHint()); 209 204 } 210 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.h
r76987 r76988 33 33 class QPropertyAnimation; 34 34 35 /* Graphics-button representation:*/35 /** QIGraphicsWidget subclass providing GUI with graphics-button representation. */ 36 36 class UIGraphicsButton : public QIGraphicsWidget 37 37 { … … 40 40 signals: 41 41 42 /* Notify listeners about button was clicked:*/42 /** Notifies listeners about button was clicked. */ 43 43 void sigButtonClicked(); 44 44 … … 48 48 enum ClickPolicy { ClickPolicy_OnRelease, ClickPolicy_OnPress }; 49 49 50 /* Constructor: */ 50 /** Constructs graphics button passing @a pParent to the base-class. 51 * @param icon Brings the button icon. */ 51 52 UIGraphicsButton(QIGraphicsWidget *pParent, const QIcon &icon); 52 53 /* API: Parent stuff: */54 void setParentSelected(bool fParentSelected);55 53 56 54 /** Defines icon scale @a dIndex. */ … … 66 64 protected: 67 65 68 /* Data enumerator:*/66 /** Data enumerator. */ 69 67 enum GraphicsButton 70 68 { … … 74 72 }; 75 73 76 /* Data provider: */74 /** Returns data stored for certain @a iKey: */ 77 75 virtual QVariant data(int iKey) const; 78 76 79 /* Size hint stuff:*/80 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;77 /** Returns size-hint of certain @a enmType, restricted by passed @a constraint. */ 78 virtual QSizeF sizeHint(Qt::SizeHint enmType, const QSizeF &constraint = QSizeF()) const /* override */; 81 79 82 /* Paint stuff:*/83 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0) ;80 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */ 81 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0) /* override */; 84 82 85 /* Mouse handlers: */ 86 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 87 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent); 83 /** Handles mouse-press @a pEvent. */ 84 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) /* override */; 85 /** Handles mouse-release @a pEvent. */ 86 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent) /* override */; 88 87 89 88 /** Handles timer @a pEvent. */ 90 89 virtual void timerEvent(QTimerEvent *pEvent) /* override */; 91 90 92 /* Helpers: Update stuff: */ 91 /** Updates button. 92 * @todo rename to prepare() */ 93 93 virtual void refresh(); 94 94 95 95 private: 96 96 97 /* Variables:*/97 /** Holds the button icon. */ 98 98 QIcon m_icon; 99 bool m_fParentSelected;100 99 101 100 /** Holds the click policy. */ … … 112 111 113 112 #endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsButton_h */ 114
Note:
See TracChangeset
for help on using the changeset viewer.

