VirtualBox

儲存庫 vbox 的更動 42795


忽略:
時間撮記:
2012-8-13 下午05:24:30 (12 年 以前)
作者:
vboxsync
訊息:

FE/Qt: 6234: Support for VM groups: Chooser-view / details-view button rework.

位置:
trunk/src/VBox/Frontends/VirtualBox/src
檔案:
修改 10 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r42734 r42795  
    295295    {
    296296        /* Layout hints: */
    297         case GroupItemData_HorizonalMargin: return 8;
     297        case GroupItemData_HorizonalMargin: return 5;
    298298        case GroupItemData_VerticalMargin: return 5;
    299299        case GroupItemData_MajorSpacing: return 10;
    300300        case GroupItemData_MinorSpacing: return 3;
    301301        /* Pixmaps: */
    302         case GroupItemData_ToggleButtonPixmap: return UIIconPool::iconSet(":/arrow_right_10px.png");
    303         case GroupItemData_EnterButtonPixmap: return UIIconPool::iconSet(":/start_16px.png");
    304302        case GroupItemData_GroupPixmap: return UIIconPool::iconSet(":/nw_16px.png");
    305303        case GroupItemData_MachinePixmap: return UIIconPool::iconSet(":/machine_16px.png");
     
    652650
    653651                /* Layout exit-button: */
    654                 int iExitButtonX = iHorizontalMargin;
     652                int iExitButtonX = iHorizontalMargin + 2;
    655653                int iExitButtonY = iExitButtonHeight == iFullHeaderHeight ? iVerticalMargin :
    656654                                   iVerticalMargin + (iFullHeaderHeight - iExitButtonHeight) / 2;
     
    12071205    int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
    12081206
     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
    12091215    /* Paint name: */
    12101216    int iNameX = iHorizontalMargin + iMajorSpacing;
     
    12121218        iNameX += toggleButtonSize.width();
    12131219    else if (!isMainRoot())
    1214         iNameX += exitButtonSize.width();
     1220        iNameX += 2 + exitButtonSize.width();
    12151221    int iNameY = nameSize.height() == iFullHeaderHeight ? iVerticalMargin :
    12161222                 iVerticalMargin + (iFullHeaderHeight - nameSize.height()) / 2;
     
    13451351        /* Setup toggle-button: */
    13461352        m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened());
    1347         m_pToggleButton->setIcon(data(GroupItemData_ToggleButtonPixmap).value<QIcon>());
    13481353        connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart()));
    13491354        connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool)));
     
    13511356
    13521357        /* 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);
    13551359        connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot()));
    13561360        m_pEnterButton->hide();
     
    13691373    {
    13701374        /* 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);
    13731376        connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot()));
    13741377        QSizeF sh = m_pExitButton->minimumSizeHint();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r42734 r42795  
    9696        GroupItemData_MinorSpacing,
    9797        /* Pixmaps: */
    98         GroupItemData_ToggleButtonPixmap,
    99         GroupItemData_EnterButtonPixmap,
    10098        GroupItemData_GroupPixmap,
    10199        GroupItemData_MachinePixmap,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp

    r42760 r42795  
    793793
    794794    /* 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);
    796798    m_pSettingsButton->setIndent(m_pToolBar->toolBarMargin() - 1);
    797     m_pSettingsButton->setIcon(data(MachineItemData_SettingsButtonPixmap).value<QIcon>());
    798799    m_pToolBar->insertItem(m_pSettingsButton, 0, 0);
    799800
    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);
    801804    m_pStartButton->setIndent(m_pToolBar->toolBarMargin() - 1);
    802     m_pStartButton->setIcon(data(MachineItemData_StartButtonPixmap).value<QIcon>());
    803805    m_pToolBar->insertItem(m_pStartButton, 0, 1);
    804806
    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);
    806810    m_pPauseButton->setIndent(m_pToolBar->toolBarMargin() - 1);
    807     m_pPauseButton->setIcon(data(MachineItemData_PauseButtonPixmap).value<QIcon>());
    808811    m_pToolBar->insertItem(m_pPauseButton, 1, 0);
    809812
    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);
    811816    m_pCloseButton->setIndent(m_pToolBar->toolBarMargin() - 1);
    812     m_pCloseButton->setIcon(data(MachineItemData_CloseButtonPixmap).value<QIcon>());
    813817    m_pToolBar->insertItem(m_pCloseButton, 1, 1);
    814818
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r42722 r42795  
    171171        /* Pixmaps: */
    172172        case ElementData_Pixmap: return m_icon;
    173         case ElementData_ButtonPixmap: return m_buttonIcon;
    174173        /* Fonts: */
    175174        case ElementData_NameFont:
     
    393392{
    394393    /* Setup toggle-button: */
    395     m_buttonIcon = UIIconPool::iconSet(":/arrow_right_10px.png");
    396394    m_pButton = new UIGraphicsRotatorButton(this, "additionalHeight", !m_fClosed, true /* reflected */);
    397     m_pButton->setIcon(m_buttonIcon);
    398395    connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart()));
    399396    connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool)));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42722 r42795  
    9797        /* Pixmaps: */
    9898        ElementData_Pixmap,
    99         ElementData_ButtonPixmap,
    10099        /* Fonts: */
    101100        ElementData_NameFont,
     
    190189    QIcon m_icon;
    191190    QString m_strName;
    192     QIcon m_buttonIcon;
    193191    bool m_fClosed;
    194192    UIGraphicsRotatorButton *m_pButton;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp

    r42678 r42795  
    2121#include <QPainter>
    2222#include <QGraphicsSceneMouseEvent>
     23#include <QPropertyAnimation>
    2324
    2425/* GUI includes: */
    2526#include "UIGraphicsButton.h"
    2627
    27 UIGraphicsButton::UIGraphicsButton(QIGraphicsWidget *pParent)
     28UIGraphicsButton::UIGraphicsButton(QIGraphicsWidget *pParent, const QIcon &icon)
    2829    : 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)
    2936{
    3037    /* Refresh finally: */
     
    3239}
    3340
    34 void UIGraphicsButton::setIcon(const QIcon &icon)
    35 {
    36     /* Remember icon: */
    37     m_icon = icon;
    38     /* Relayout/redraw button: */
     41UIGraphicsButton::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: */
    3950    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
     60void UIGraphicsButton::setParentSelected(bool fParentSelected)
     61{
     62    if (m_fParentSelected == fParentSelected)
     63        return;
     64    m_fParentSelected = fParentSelected;
     65    reconfigureAnimation();
    4066}
    4167
     
    7197void UIGraphicsButton::paint(QPainter *pPainter, const QStyleOptionGraphicsItem* /* pOption */, QWidget* /* pWidget = 0 */)
    7298{
    73     /* Variables: */
     99    /* Prepare variables: */
    74100    int iMargin = data(GraphicsButton_Margin).toInt();
     101    QIcon icon = data(GraphicsButton_Icon).value<QIcon>();
    75102    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
     173void UIGraphicsButton::hideEvent(QHideEvent*)
     174{
     175    setHovered(false);
    83176}
    84177
     
    97190}
    98191
     192void UIGraphicsButton::hoverMoveEvent(QGraphicsSceneHoverEvent*)
     193{
     194    setHovered(true);
     195}
     196
     197void UIGraphicsButton::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
     198{
     199    setHovered(false);
     200}
     201
    99202void UIGraphicsButton::refresh()
    100203{
     
    105208}
    106209
     210void 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
     218bool UIGraphicsButton::hovered() const
     219{
     220    return m_fHovered;
     221}
     222
     223void 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
     240int UIGraphicsButton::color() const
     241{
     242    return m_iColor;
     243}
     244
     245void 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  
    2828/* Forward declarations: */
    2929class QGraphicsSceneMouseEvent;
     30class QGraphicsSceneHoverEvent;
     31class QPropertyAnimation;
     32
     33/* Graphics-button types: */
     34enum UIGraphicsButtonType
     35{
     36    UIGraphicsButtonType_Iconified,
     37    UIGraphicsButtonType_DirectArrow,
     38    UIGraphicsButtonType_RoundArrow
     39};
    3040
    3141/* Graphics-button representation: */
     
    3343{
    3444    Q_OBJECT;
     45    Q_PROPERTY(int color READ color WRITE setColor);
    3546
    3647signals:
     
    4253
    4354    /* Constructor: */
    44     UIGraphicsButton(QIGraphicsWidget *pParent);
     55    UIGraphicsButton(QIGraphicsWidget *pParent, const QIcon &icon);
     56    UIGraphicsButton(QIGraphicsWidget *pParent, UIGraphicsButtonType buttonType);
    4557
    46     /* API: Icon setter: */
    47     void setIcon(const QIcon &icon);
     58    /* API: Parent stuff: */
     59    void setParentSelected(bool fParentSelected);
    4860
    4961protected:
     
    6678    virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0);
    6779
     80    /* Hide event: */
     81    void hideEvent(QHideEvent *pEvent);
     82
    6883    /* Mouse handlers: */
    6984    virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
    7085    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);
     86    virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
     87    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
    7188
    7289    /* Helpers: Update stuff: */
    7390    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);
    7498
    7599private:
     
    77101    /* Variables: */
    78102    QIcon m_icon;
     103    UIGraphicsButtonType m_buttonType;
     104    QPropertyAnimation *m_pAnimation;
     105    bool m_fParentSelected;
     106    bool m_fHovered;
     107    int m_iColor;
    79108};
    80109
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.cpp

    r42526 r42795  
    3232                                                 bool fReflected /* = false */,
    3333                                                 int iAnimationDuration /* = 300 */)
    34     : UIGraphicsButton(pParent)
     34    : UIGraphicsButton(pParent, UIGraphicsButtonType_RoundArrow)
    3535    , m_fReflected(fReflected)
    3636    , m_state(fToggled ? UIGraphicsRotatorButtonState_Rotated : UIGraphicsRotatorButtonState_Default)
     
    102102    /* Start state-machine: */
    103103    m_pAnimationMachine->start();
     104
     105    /* Refresh: */
     106    refresh();
    104107}
    105108
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsZoomButton.cpp

    r42526 r42795  
    2828#include "UIGraphicsZoomButton.h"
    2929
    30 UIGraphicsZoomButton::UIGraphicsZoomButton(QIGraphicsWidget *pParent, int iDirection)
    31     : UIGraphicsButton(pParent)
     30UIGraphicsZoomButton::UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection)
     31    : UIGraphicsButton(pParent, icon)
    3232    , m_iIndent(4)
    3333    , m_iDirection(iDirection)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsZoomButton.h

    r42526 r42795  
    5454
    5555    /* Constructor: */
    56     UIGraphicsZoomButton(QIGraphicsWidget *pParent, int iDirection);
     56    UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection);
    5757
    5858    /* API: Zoom stuff: */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette