VirtualBox

Changeset 42797 in vbox for trunk/src


Ignore:
Timestamp:
Aug 13, 2012 7:20:21 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Reverting part of r80032.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp

    r42795 r42797  
    2121#include <QPainter>
    2222#include <QGraphicsSceneMouseEvent>
    23 #include <QPropertyAnimation>
    2423
    2524/* GUI includes: */
     
    3029    , m_icon(icon)
    3130    , m_buttonType(UIGraphicsButtonType_Iconified)
    32     , m_pAnimation(0)
    3331    , m_fParentSelected(false)
    34     , m_fHovered(false)
    35     , m_iColor(-1)
    3632{
    3733    /* Refresh finally: */
     
    4238    : QIGraphicsWidget(pParent)
    4339    , m_buttonType(buttonType)
    44     , m_pAnimation(0)
    4540    , m_fParentSelected(false)
    46     , m_fHovered(false)
    47     , m_iColor(-1)
    4841{
    4942    /* Refresh finally: */
    5043    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();
    5844}
    5945
     
    6349        return;
    6450    m_fParentSelected = fParentSelected;
    65     reconfigureAnimation();
     51    update();
    6652}
    6753
     
    115101            /* Prepare variables: */
    116102            QPalette pal = palette();
    117             QColor windowColor = pal.color(QPalette::Window);
     103            QColor backgroundColor = pal.color(m_fParentSelected ? QPalette::Highlight : QPalette::Window);
     104            QColor buttonColor = pal.color(QPalette::Window);
     105            if (backgroundColor.black() > 128)
     106                buttonColor = buttonColor.darker(95);
     107            else
     108                buttonColor = buttonColor.darker(160);
    118109
    119110            /* Setup: */
    120111            pPainter->setRenderHint(QPainter::Antialiasing);
    121112            QPen pen = pPainter->pen();
    122             pen.setColor(windowColor.darker(color()));
     113            pen.setColor(buttonColor);
    123114            pen.setWidth(2);
    124115            pen.setCapStyle(Qt::RoundCap);
     
    145136            /* Prepare variables: */
    146137            QPalette pal = palette();
    147             QColor windowColor = pal.color(QPalette::Window);
     138            QColor backgroundColor = pal.color(m_fParentSelected ? QPalette::Highlight : QPalette::Window);
     139            QColor buttonColor = pal.color(QPalette::Window);
     140            if (backgroundColor.black() > 128)
     141                buttonColor = buttonColor.darker(95);
     142            else
     143                buttonColor = buttonColor.darker(160);
    148144
    149145            /* Setup: */
    150146            pPainter->setRenderHint(QPainter::Antialiasing);
    151147            QPen pen = pPainter->pen();
    152             pen.setColor(windowColor.darker(color()));
     148            pen.setColor(buttonColor);
    153149            pen.setWidth(2);
    154150            pen.setCapStyle(Qt::RoundCap);
     
    171167}
    172168
    173 void UIGraphicsButton::hideEvent(QHideEvent*)
    174 {
    175     setHovered(false);
    176 }
    177 
    178169void UIGraphicsButton::mousePressEvent(QGraphicsSceneMouseEvent *pEvent)
    179170{
     
    190181}
    191182
    192 void UIGraphicsButton::hoverMoveEvent(QGraphicsSceneHoverEvent*)
    193 {
    194     setHovered(true);
    195 }
    196 
    197 void UIGraphicsButton::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
    198 {
    199     setHovered(false);
    200 }
    201 
    202183void UIGraphicsButton::refresh()
    203184{
     
    208189}
    209190
    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

    r42795 r42797  
    4343{
    4444    Q_OBJECT;
    45     Q_PROPERTY(int color READ color WRITE setColor);
    4645
    4746signals:
     
    7877    virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0);
    7978
    80     /* Hide event: */
    81     void hideEvent(QHideEvent *pEvent);
    82 
    8379    /* Mouse handlers: */
    8480    virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
    8581    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);
    86     virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
    87     virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
    8882
    8983    /* Helpers: Update stuff: */
    9084    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);
    9885
    9986private:
     
    10289    QIcon m_icon;
    10390    UIGraphicsButtonType m_buttonType;
    104     QPropertyAnimation *m_pAnimation;
    10591    bool m_fParentSelected;
    106     bool m_fHovered;
    107     int m_iColor;
    10892};
    10993
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