儲存庫 vbox 的更動 42795
- 時間撮記:
- 2012-8-13 下午05:24:30 (12 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src
- 檔案:
-
- 修改 10 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r42734 r42795 295 295 { 296 296 /* Layout hints: */ 297 case GroupItemData_HorizonalMargin: return 8;297 case GroupItemData_HorizonalMargin: return 5; 298 298 case GroupItemData_VerticalMargin: return 5; 299 299 case GroupItemData_MajorSpacing: return 10; 300 300 case GroupItemData_MinorSpacing: return 3; 301 301 /* Pixmaps: */ 302 case GroupItemData_ToggleButtonPixmap: return UIIconPool::iconSet(":/arrow_right_10px.png");303 case GroupItemData_EnterButtonPixmap: return UIIconPool::iconSet(":/start_16px.png");304 302 case GroupItemData_GroupPixmap: return UIIconPool::iconSet(":/nw_16px.png"); 305 303 case GroupItemData_MachinePixmap: return UIIconPool::iconSet(":/machine_16px.png"); … … 652 650 653 651 /* Layout exit-button: */ 654 int iExitButtonX = iHorizontalMargin ;652 int iExitButtonX = iHorizontalMargin + 2; 655 653 int iExitButtonY = iExitButtonHeight == iFullHeaderHeight ? iVerticalMargin : 656 654 iVerticalMargin + (iFullHeaderHeight - iExitButtonHeight) / 2; … … 1207 1205 int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 1208 1206 1207 /* Update buttons: */ 1208 if (m_pToggleButton) 1209 m_pToggleButton->setParentSelected(model()->selectionList().contains(this)); 1210 if (m_pEnterButton) 1211 m_pEnterButton->setParentSelected(model()->selectionList().contains(this)); 1212 if (m_pExitButton) 1213 m_pExitButton->setParentSelected(model()->selectionList().contains(this)); 1214 1209 1215 /* Paint name: */ 1210 1216 int iNameX = iHorizontalMargin + iMajorSpacing; … … 1212 1218 iNameX += toggleButtonSize.width(); 1213 1219 else if (!isMainRoot()) 1214 iNameX += exitButtonSize.width();1220 iNameX += 2 + exitButtonSize.width(); 1215 1221 int iNameY = nameSize.height() == iFullHeaderHeight ? iVerticalMargin : 1216 1222 iVerticalMargin + (iFullHeaderHeight - nameSize.height()) / 2; … … 1345 1351 /* Setup toggle-button: */ 1346 1352 m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened()); 1347 m_pToggleButton->setIcon(data(GroupItemData_ToggleButtonPixmap).value<QIcon>());1348 1353 connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart())); 1349 1354 connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool))); … … 1351 1356 1352 1357 /* Setup enter-button: */ 1353 m_pEnterButton = new UIGraphicsButton(this); 1354 m_pEnterButton->setIcon(data(GroupItemData_EnterButtonPixmap).value<QIcon>()); 1358 m_pEnterButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow); 1355 1359 connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot())); 1356 1360 m_pEnterButton->hide(); … … 1369 1373 { 1370 1374 /* Setup exit-button: */ 1371 m_pExitButton = new UIGraphicsButton(this); 1372 m_pExitButton->setIcon(data(GroupItemData_EnterButtonPixmap).value<QIcon>()); 1375 m_pExitButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow); 1373 1376 connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot())); 1374 1377 QSizeF sh = m_pExitButton->minimumSizeHint(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r42734 r42795 96 96 GroupItemData_MinorSpacing, 97 97 /* Pixmaps: */ 98 GroupItemData_ToggleButtonPixmap,99 GroupItemData_EnterButtonPixmap,100 98 GroupItemData_GroupPixmap, 101 99 GroupItemData_MachinePixmap, -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r42760 r42795 793 793 794 794 /* Create buttons: */ 795 m_pSettingsButton = new UIGraphicsZoomButton(m_pToolBar, UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Left); 795 m_pSettingsButton = new UIGraphicsZoomButton(m_pToolBar, 796 data(MachineItemData_SettingsButtonPixmap).value<QIcon>(), 797 UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Left); 796 798 m_pSettingsButton->setIndent(m_pToolBar->toolBarMargin() - 1); 797 m_pSettingsButton->setIcon(data(MachineItemData_SettingsButtonPixmap).value<QIcon>());798 799 m_pToolBar->insertItem(m_pSettingsButton, 0, 0); 799 800 800 m_pStartButton = new UIGraphicsZoomButton(m_pToolBar, UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Right); 801 m_pStartButton = new UIGraphicsZoomButton(m_pToolBar, 802 data(MachineItemData_StartButtonPixmap).value<QIcon>(), 803 UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Right); 801 804 m_pStartButton->setIndent(m_pToolBar->toolBarMargin() - 1); 802 m_pStartButton->setIcon(data(MachineItemData_StartButtonPixmap).value<QIcon>());803 805 m_pToolBar->insertItem(m_pStartButton, 0, 1); 804 806 805 m_pPauseButton = new UIGraphicsZoomButton(m_pToolBar, UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Left); 807 m_pPauseButton = new UIGraphicsZoomButton(m_pToolBar, 808 data(MachineItemData_PauseButtonPixmap).value<QIcon>(), 809 UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Left); 806 810 m_pPauseButton->setIndent(m_pToolBar->toolBarMargin() - 1); 807 m_pPauseButton->setIcon(data(MachineItemData_PauseButtonPixmap).value<QIcon>());808 811 m_pToolBar->insertItem(m_pPauseButton, 1, 0); 809 812 810 m_pCloseButton = new UIGraphicsZoomButton(m_pToolBar, UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Right); 813 m_pCloseButton = new UIGraphicsZoomButton(m_pToolBar, 814 data(MachineItemData_CloseButtonPixmap).value<QIcon>(), 815 UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Right); 811 816 m_pCloseButton->setIndent(m_pToolBar->toolBarMargin() - 1); 812 m_pCloseButton->setIcon(data(MachineItemData_CloseButtonPixmap).value<QIcon>());813 817 m_pToolBar->insertItem(m_pCloseButton, 1, 1); 814 818 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42722 r42795 171 171 /* Pixmaps: */ 172 172 case ElementData_Pixmap: return m_icon; 173 case ElementData_ButtonPixmap: return m_buttonIcon;174 173 /* Fonts: */ 175 174 case ElementData_NameFont: … … 393 392 { 394 393 /* Setup toggle-button: */ 395 m_buttonIcon = UIIconPool::iconSet(":/arrow_right_10px.png");396 394 m_pButton = new UIGraphicsRotatorButton(this, "additionalHeight", !m_fClosed, true /* reflected */); 397 m_pButton->setIcon(m_buttonIcon);398 395 connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart())); 399 396 connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool))); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r42722 r42795 97 97 /* Pixmaps: */ 98 98 ElementData_Pixmap, 99 ElementData_ButtonPixmap,100 99 /* Fonts: */ 101 100 ElementData_NameFont, … … 190 189 QIcon m_icon; 191 190 QString m_strName; 192 QIcon m_buttonIcon;193 191 bool m_fClosed; 194 192 UIGraphicsRotatorButton *m_pButton; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp
r42678 r42795 21 21 #include <QPainter> 22 22 #include <QGraphicsSceneMouseEvent> 23 #include <QPropertyAnimation> 23 24 24 25 /* GUI includes: */ 25 26 #include "UIGraphicsButton.h" 26 27 27 UIGraphicsButton::UIGraphicsButton(QIGraphicsWidget *pParent )28 UIGraphicsButton::UIGraphicsButton(QIGraphicsWidget *pParent, const QIcon &icon) 28 29 : QIGraphicsWidget(pParent) 30 , m_icon(icon) 31 , m_buttonType(UIGraphicsButtonType_Iconified) 32 , m_pAnimation(0) 33 , m_fParentSelected(false) 34 , m_fHovered(false) 35 , m_iColor(-1) 29 36 { 30 37 /* Refresh finally: */ … … 32 39 } 33 40 34 void UIGraphicsButton::setIcon(const QIcon &icon) 35 { 36 /* Remember icon: */ 37 m_icon = icon; 38 /* Relayout/redraw button: */ 41 UIGraphicsButton::UIGraphicsButton(QIGraphicsWidget *pParent, UIGraphicsButtonType buttonType) 42 : QIGraphicsWidget(pParent) 43 , m_buttonType(buttonType) 44 , m_pAnimation(0) 45 , m_fParentSelected(false) 46 , m_fHovered(false) 47 , m_iColor(-1) 48 { 49 /* Refresh finally: */ 39 50 refresh(); 51 52 /* Prepare animation: */ 53 setAcceptHoverEvents(true); 54 m_pAnimation = new QPropertyAnimation(this, "color", this); 55 m_pAnimation->setDuration(1000); 56 m_pAnimation->setLoopCount(-1); 57 reconfigureAnimation(); 58 } 59 60 void UIGraphicsButton::setParentSelected(bool fParentSelected) 61 { 62 if (m_fParentSelected == fParentSelected) 63 return; 64 m_fParentSelected = fParentSelected; 65 reconfigureAnimation(); 40 66 } 41 67 … … 71 97 void UIGraphicsButton::paint(QPainter *pPainter, const QStyleOptionGraphicsItem* /* pOption */, QWidget* /* pWidget = 0 */) 72 98 { 73 /* Variables: */99 /* Prepare variables: */ 74 100 int iMargin = data(GraphicsButton_Margin).toInt(); 101 QIcon icon = data(GraphicsButton_Icon).value<QIcon>(); 75 102 QSize iconSize = data(GraphicsButton_IconSize).toSize(); 76 QIcon icon = data(GraphicsButton_Icon).value<QIcon>(); 77 78 /* Draw pixmap: */ 79 pPainter->drawPixmap(/* Pixmap rectangle: */ 80 QRect(QPoint(iMargin, iMargin), iconSize), 81 /* Pixmap size: */ 82 icon.pixmap(iconSize)); 103 104 /* Which type button has: */ 105 switch (m_buttonType) 106 { 107 case UIGraphicsButtonType_Iconified: 108 { 109 /* Just draw the pixmap: */ 110 pPainter->drawPixmap(QRect(QPoint(iMargin, iMargin), iconSize), icon.pixmap(iconSize)); 111 break; 112 } 113 case UIGraphicsButtonType_DirectArrow: 114 { 115 /* Prepare variables: */ 116 QPalette pal = palette(); 117 QColor windowColor = pal.color(QPalette::Window); 118 119 /* Setup: */ 120 pPainter->setRenderHint(QPainter::Antialiasing); 121 QPen pen = pPainter->pen(); 122 pen.setColor(windowColor.darker(color())); 123 pen.setWidth(2); 124 pen.setCapStyle(Qt::RoundCap); 125 126 /* Draw path: */ 127 QPainterPath circlePath; 128 circlePath.moveTo(iMargin, iMargin); 129 circlePath.lineTo(iMargin + iconSize.width() / 2, iMargin); 130 circlePath.arcTo(QRectF(circlePath.currentPosition(), iconSize).translated(-iconSize.width() / 2, 0), 90, -180); 131 circlePath.lineTo(iMargin, iMargin + iconSize.height()); 132 circlePath.closeSubpath(); 133 pPainter->strokePath(circlePath, pen); 134 135 /* Draw triangle: */ 136 QPainterPath linePath; 137 linePath.moveTo(iMargin + 5, iMargin + 5); 138 linePath.lineTo(iMargin + iconSize.height() - 5, iMargin + iconSize.width() / 2); 139 linePath.lineTo(iMargin + 5, iMargin + iconSize.width() - 5); 140 pPainter->strokePath(linePath, pen); 141 break; 142 } 143 case UIGraphicsButtonType_RoundArrow: 144 { 145 /* Prepare variables: */ 146 QPalette pal = palette(); 147 QColor windowColor = pal.color(QPalette::Window); 148 149 /* Setup: */ 150 pPainter->setRenderHint(QPainter::Antialiasing); 151 QPen pen = pPainter->pen(); 152 pen.setColor(windowColor.darker(color())); 153 pen.setWidth(2); 154 pen.setCapStyle(Qt::RoundCap); 155 156 /* Draw circle: */ 157 QPainterPath circlePath; 158 circlePath.moveTo(iMargin, iMargin); 159 circlePath.addEllipse(QRectF(circlePath.currentPosition(), iconSize)); 160 pPainter->strokePath(circlePath, pen); 161 162 /* Draw triangle: */ 163 QPainterPath linePath; 164 linePath.moveTo(iMargin + 5, iMargin + 5); 165 linePath.lineTo(iMargin + iconSize.height() - 5, iMargin + iconSize.width() / 2); 166 linePath.lineTo(iMargin + 5, iMargin + iconSize.width() - 5); 167 pPainter->strokePath(linePath, pen); 168 break; 169 } 170 } 171 } 172 173 void UIGraphicsButton::hideEvent(QHideEvent*) 174 { 175 setHovered(false); 83 176 } 84 177 … … 97 190 } 98 191 192 void UIGraphicsButton::hoverMoveEvent(QGraphicsSceneHoverEvent*) 193 { 194 setHovered(true); 195 } 196 197 void UIGraphicsButton::hoverLeaveEvent(QGraphicsSceneHoverEvent*) 198 { 199 setHovered(false); 200 } 201 99 202 void UIGraphicsButton::refresh() 100 203 { … … 105 208 } 106 209 210 void UIGraphicsButton::reconfigureAnimation() 211 { 212 setColor(m_fParentSelected ? 105 : 140); 213 m_pAnimation->setStartValue(m_fParentSelected ? 105 : 140); 214 m_pAnimation->setEndValue(m_fParentSelected ? 105 : 140); 215 m_pAnimation->setKeyValueAt(0.5, m_fParentSelected ? 130 : 115); 216 } 217 218 bool UIGraphicsButton::hovered() const 219 { 220 return m_fHovered; 221 } 222 223 void UIGraphicsButton::setHovered(bool fHovered) 224 { 225 if (m_fHovered == fHovered) 226 return; 227 228 m_fHovered = fHovered; 229 if (m_fHovered) 230 { 231 m_pAnimation->start(); 232 } 233 else 234 { 235 m_pAnimation->stop(); 236 setColor(m_fParentSelected ? 105 : 140); 237 } 238 } 239 240 int UIGraphicsButton::color() const 241 { 242 return m_iColor; 243 } 244 245 void UIGraphicsButton::setColor(int iColor) 246 { 247 m_iColor = iColor; 248 update(); 249 } 250 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.h
r42678 r42795 28 28 /* Forward declarations: */ 29 29 class QGraphicsSceneMouseEvent; 30 class QGraphicsSceneHoverEvent; 31 class QPropertyAnimation; 32 33 /* Graphics-button types: */ 34 enum UIGraphicsButtonType 35 { 36 UIGraphicsButtonType_Iconified, 37 UIGraphicsButtonType_DirectArrow, 38 UIGraphicsButtonType_RoundArrow 39 }; 30 40 31 41 /* Graphics-button representation: */ … … 33 43 { 34 44 Q_OBJECT; 45 Q_PROPERTY(int color READ color WRITE setColor); 35 46 36 47 signals: … … 42 53 43 54 /* Constructor: */ 44 UIGraphicsButton(QIGraphicsWidget *pParent); 55 UIGraphicsButton(QIGraphicsWidget *pParent, const QIcon &icon); 56 UIGraphicsButton(QIGraphicsWidget *pParent, UIGraphicsButtonType buttonType); 45 57 46 /* API: Icon setter: */47 void set Icon(const QIcon &icon);58 /* API: Parent stuff: */ 59 void setParentSelected(bool fParentSelected); 48 60 49 61 protected: … … 66 78 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0); 67 79 80 /* Hide event: */ 81 void hideEvent(QHideEvent *pEvent); 82 68 83 /* Mouse handlers: */ 69 84 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 70 85 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent); 86 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 87 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent); 71 88 72 89 /* Helpers: Update stuff: */ 73 90 virtual void refresh(); 91 92 /* Helpers: Hover animation stuff: */ 93 void reconfigureAnimation(); 94 bool hovered() const; 95 void setHovered(bool fHovered); 96 int color() const; 97 void setColor(int iColor); 74 98 75 99 private: … … 77 101 /* Variables: */ 78 102 QIcon m_icon; 103 UIGraphicsButtonType m_buttonType; 104 QPropertyAnimation *m_pAnimation; 105 bool m_fParentSelected; 106 bool m_fHovered; 107 int m_iColor; 79 108 }; 80 109 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.cpp
r42526 r42795 32 32 bool fReflected /* = false */, 33 33 int iAnimationDuration /* = 300 */) 34 : UIGraphicsButton(pParent )34 : UIGraphicsButton(pParent, UIGraphicsButtonType_RoundArrow) 35 35 , m_fReflected(fReflected) 36 36 , m_state(fToggled ? UIGraphicsRotatorButtonState_Rotated : UIGraphicsRotatorButtonState_Default) … … 102 102 /* Start state-machine: */ 103 103 m_pAnimationMachine->start(); 104 105 /* Refresh: */ 106 refresh(); 104 107 } 105 108 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsZoomButton.cpp
r42526 r42795 28 28 #include "UIGraphicsZoomButton.h" 29 29 30 UIGraphicsZoomButton::UIGraphicsZoomButton(QIGraphicsWidget *pParent, int iDirection)31 : UIGraphicsButton(pParent )30 UIGraphicsZoomButton::UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection) 31 : UIGraphicsButton(pParent, icon) 32 32 , m_iIndent(4) 33 33 , m_iDirection(iDirection) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsZoomButton.h
r42526 r42795 54 54 55 55 /* Constructor: */ 56 UIGraphicsZoomButton(QIGraphicsWidget *pParent, int iDirection);56 UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection); 57 57 58 58 /* API: Zoom stuff: */
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器