VirtualBox

Ignore:
Timestamp:
Jun 26, 2013 5:35:03 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86750
Message:

FE/Qt: Runtime UI: Video Capture LED: Movie-reel animation.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc

    r46777 r46810  
    255255        <file alias="shared_clipboard_16px.png">images/shared_clipboard_16px.png</file>
    256256        <file alias="shared_clipboard_disabled_16px.png">images/shared_clipboard_disabled_16px.png</file>
     257        <file alias="movie_reel_16px.png">images/movie_reel_16px.png</file>
    257258    </qresource>
    258259</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r46708 r46810  
    2020/* Qt includes: */
    2121#include <QTimer>
     22#include <QPainter>
    2223
    2324/* GUI includes: */
     
    2627#include "UIMachineDefs.h"
    2728#include "UIConverter.h"
     29#include "UIAnimationFramework.h"
    2830
    2931/* COM includes: */
     
    491493{
    492494    Q_OBJECT;
     495    Q_PROPERTY(double rotationAngleStart READ rotationAngleStart);
     496    Q_PROPERTY(double rotationAngleFinal READ rotationAngleFinal);
     497    Q_PROPERTY(double rotationAngle READ rotationAngle WRITE setRotationAngle);
    493498
    494499public:
     
    498503    {
    499504        UIIndicatorStateVideoCapture_Disabled = 0,
    500         UIIndicatorStateVideoCapture_Enabled  = 1,
    501         UIIndicatorStateVideoCapture_Writing  = 2
     505        UIIndicatorStateVideoCapture_Enabled  = 1
    502506    };
    503507
     
    505509    UIIndicatorVideoCapture(CSession &session)
    506510        : m_session(session)
    507         , m_pUpdateTimer(new QTimer(this))
     511        , m_pAnimation(0)
     512        , m_dRotationAngle(0)
    508513    {
    509514        /* Assign state icons: */
    510         setStateIcon(UIIndicatorStateVideoCapture_Disabled, QPixmap(":/video_capture_disabled_16px.png"));
    511         setStateIcon(UIIndicatorStateVideoCapture_Enabled,  QPixmap(":/video_capture_16px.png"));
    512         setStateIcon(UIIndicatorStateVideoCapture_Writing,  QPixmap(":/video_capture_write_16px.png"));
    513 
    514         /* Connect timer to update active state: */
    515         connect(m_pUpdateTimer, SIGNAL(timeout()), SLOT(sltUpdateState()));
    516         m_pUpdateTimer->start(500);
     515        setStateIcon(UIIndicatorStateVideoCapture_Disabled, QPixmap(":/movie_reel_16px.png"));
     516        setStateIcon(UIIndicatorStateVideoCapture_Enabled, QPixmap(":/movie_reel_16px.png"));
     517
     518        /* Prepare *enabled* state animation: */
     519        m_pAnimation = UIAnimationLoop::installAnimationLoop(this, "rotationAngle",
     520                                                                   "rotationAngleStart", "rotationAngleFinal",
     521                                                                   1000);
    517522
    518523        /* Translate finally: */
     
    540545            }
    541546            case UIIndicatorStateVideoCapture_Enabled:
    542             case UIIndicatorStateVideoCapture_Writing:
    543547            {
    544548                strToolTip += QApplication::translate("UIIndicatorsPool", "<nobr><b>Video capture file:</b> %1</nobr>")
     
    552556    }
    553557
    554 protected slots:
    555 
    556     /* Handler: Update stuff: */
    557     void sltUpdateState()
    558     {
    559         /* Toggle state from 'Enabled' to 'Writing': */
     558public slots:
     559
     560    /* Handler: State stuff: */
     561    void setState(int iState)
     562    {
     563        /* Update animation state: */
     564        switch (iState)
     565        {
     566            case UIIndicatorStateVideoCapture_Disabled:
     567                m_pAnimation->stop();
     568                m_dRotationAngle = 0;
     569                break;
     570            case UIIndicatorStateVideoCapture_Enabled:
     571                m_pAnimation->start();
     572                break;
     573            default:
     574                break;
     575        }
     576
     577        /* Call to base-class: */
     578        QIStateIndicator::setState(iState);
     579    }
     580
     581protected:
     582
     583    /* Handler: Translate stuff: */
     584    void retranslateUi()
     585    {
     586        updateAppearance();
     587    }
     588
     589    /* Handler: Paint stuff: */
     590    void paintEvent(QPaintEvent*)
     591    {
     592        /* Create new painter: */
     593        QPainter painter(this);
     594        /* Configure painter for *enabled* state: */
    560595        if (state() == UIIndicatorStateVideoCapture_Enabled)
    561             setState(UIIndicatorStateVideoCapture_Writing);
    562         /* Toggle state from 'Writing' to 'Enabled': */
    563         else if (state() == UIIndicatorStateVideoCapture_Writing)
    564             setState(UIIndicatorStateVideoCapture_Enabled);
    565     }
    566 
    567 protected:
    568 
    569     /* Handler: Translate stuff: */
    570     void retranslateUi()
    571     {
    572         updateAppearance();
    573     }
     596        {
     597            /* Shift rotation origin according pixmap center: */
     598            painter.translate(height() / 2, height() / 2);
     599            /* Rotate painter: */
     600            painter.rotate(rotationAngle());
     601            /* Unshift rotation origin according pixmap center: */
     602            painter.translate(- height() / 2, - height() / 2);
     603        }
     604        /* Draw contents: */
     605        drawContents(&painter);
     606    }
     607
     608    /* Properties: Rotation stuff: */
     609    double rotationAngleStart() const { return 0; }
     610    double rotationAngleFinal() const { return 360; }
     611    double rotationAngle() const { return m_dRotationAngle; }
     612    void setRotationAngle(double dRotationAngle) { m_dRotationAngle = dRotationAngle; update(); }
    574613
    575614    /* For compatibility reason we do it here,
    576615     * later this should be moved to QIStateIndicator. */
    577616    CSession &m_session;
    578     QTimer *m_pUpdateTimer;
     617    UIAnimationLoop *m_pAnimation;
     618    double m_dRotationAngle;
    579619};
    580620
Note: See TracChangeset for help on using the changeset viewer.

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