[vlc-commits] qt: remove obsolete EasterEgg and Background Widget
Pierre Lamot
git at videolan.org
Fri May 29 12:00:40 CEST 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri May 29 11:32:44 2020 +0200| [d93395eb3d49e4eaef669c0cc68e57d12214ee1e] | committer: Pierre Lamot
qt: remove obsolete EasterEgg and Background Widget
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d93395eb3d49e4eaef669c0cc68e57d12214ee1e
---
.../gui/qt/widgets/native/interface_widgets.cpp | 249 ---------------------
.../gui/qt/widgets/native/interface_widgets.hpp | 62 -----
2 files changed, 311 deletions(-)
diff --git a/modules/gui/qt/widgets/native/interface_widgets.cpp b/modules/gui/qt/widgets/native/interface_widgets.cpp
index 7e40bcea5f..39d6381dd5 100644
--- a/modules/gui/qt/widgets/native/interface_widgets.cpp
+++ b/modules/gui/qt/widgets/native/interface_widgets.cpp
@@ -403,255 +403,6 @@ void VideoWidget::release( void )
updateGeometry();
}
-/**********************************************************************
- * Background Widget. Show a simple image background. Currently,
- * it's album art if present or cone.
- **********************************************************************/
-
-BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
- :QWidget( NULL ), p_intf( _p_i ), b_expandPixmap( false ), b_withart( true )
-{
- /* A dark background */
- setAutoFillBackground( true );
- QPalette plt = palette();
- plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
- plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
- setPalette( plt );
-
- /* Init the cone art */
- updateDefaultArt( ":/logo/vlc128.png" );
- updateArt( "" );
-
- /* fade in animator */
- setProperty( "opacity", 1.0 );
- fadeAnimation = new QPropertyAnimation( this, "opacity", this );
- fadeAnimation->setDuration( 1000 );
- fadeAnimation->setStartValue( 0.0 );
- fadeAnimation->setEndValue( 1.0 );
- fadeAnimation->setEasingCurve( QEasingCurve::OutSine );
- CONNECT( fadeAnimation, valueChanged( const QVariant & ),
- this, update() );
-
- connect( THEMIM, QOverload<QString>::of(&PlayerController::artChanged),
- this, &BackgroundWidget::updateArt );
- connect( THEMIM, &PlayerController::nameChanged,
- this, &BackgroundWidget::titleUpdated );
-}
-
-void BackgroundWidget::updateArt( const QString& url )
-{
- if ( !url.isEmpty() )
- pixmapUrl = url;
- else
- pixmapUrl = defaultArt;
- update();
-}
-
-void BackgroundWidget::updateDefaultArt( const QString& url )
-{
- if ( !url.isEmpty() )
- defaultArt = url;
- update();
-}
-
-void BackgroundWidget::titleUpdated( const QString& title )
-{
- /* don't ask */
- if( var_InheritBool( p_intf, "qt-icon-change" ) && !title.isEmpty() )
- {
- int i_pos = title.indexOf( "Ki" /* Bps */ "ll", 0, Qt::CaseInsensitive );
- if( i_pos != -1 &&
- i_pos + 5 == title.indexOf( "Bi" /* directional */ "ll",
- i_pos, Qt::CaseInsensitive ) )
- updateDefaultArt( ":/logo/vlc128-kb.png" );
- else
- updateDefaultArt( ":/logo/vlc128.png" );
- }
-}
-
-void BackgroundWidget::showEvent( QShowEvent * e )
-{
- Q_UNUSED( e );
- if ( b_withart ) fadeAnimation->start();
-}
-
-void BackgroundWidget::paintEvent( QPaintEvent *e )
-{
- if ( !b_withart )
- {
- /* we just want background autofill */
- QWidget::paintEvent( e );
- return;
- }
-
- int i_maxwidth, i_maxheight;
- QPixmap pixmap = QPixmap( pixmapUrl );
- QPainter painter(this);
-
-#if HAS_QT56
- qreal dpr = devicePixelRatioF();
-#else
- qreal dpr = devicePixelRatio();
-#endif
- pixmap.setDevicePixelRatio( dpr );
-
- i_maxwidth = __MIN( maximumWidth(), width() ) - MARGIN * 2;
- i_maxheight = __MIN( maximumHeight(), height() ) - MARGIN * 2;
-
- painter.setOpacity( property( "opacity" ).toFloat() );
-
- if ( height() > MARGIN * 2 )
- {
- /* Scale down the pixmap if the widget is too small */
- if( pixmap.width() > i_maxwidth || pixmap.height() > i_maxheight )
- {
- pixmap = pixmap.scaled( i_maxwidth * dpr, i_maxheight * dpr ,
- Qt::KeepAspectRatio, Qt::SmoothTransformation );
- }
- else
- if ( b_expandPixmap &&
- pixmap.width() < width() && pixmap.height() < height() )
- {
- pixmap = pixmap.scaled(
- (width() - MARGIN * 2) * dpr,
- (height() - MARGIN * 2) * dpr ,
- Qt::KeepAspectRatio, Qt::SmoothTransformation);
- }
- else if (dpr != 1.0)
- {
- pixmap = pixmap.scaled( pixmap.width() * dpr, pixmap.height() * dpr,
- Qt::KeepAspectRatio, Qt::SmoothTransformation );
- }
-
- painter.drawPixmap(
- MARGIN + ( i_maxwidth - ( pixmap.width() / dpr ) ) / 2,
- MARGIN + ( i_maxheight - ( pixmap.height() / dpr ) ) / 2,
- pixmap);
- }
- QWidget::paintEvent( e );
-}
-
-void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
-{
- THEDP->setPopupMenu();
- event->accept();
-}
-
-EasterEggBackgroundWidget::EasterEggBackgroundWidget( intf_thread_t *p_intf )
- : BackgroundWidget( p_intf )
-{
- flakes = new std::list<flake *>();
- i_rate = 2;
- i_speed = 1;
- b_enabled = false;
- timer = new QTimer( this );
- timer->setInterval( 100 );
- CONNECT( timer, timeout(), this, spawnFlakes() );
- if ( isVisible() && b_enabled ) timer->start();
- defaultArt = QString( ":/logo/vlc128-xmas.png" );
- updateArt( "" );
-}
-
-EasterEggBackgroundWidget::~EasterEggBackgroundWidget()
-{
- timer->stop();
- delete timer;
- reset();
- delete flakes;
-}
-
-void EasterEggBackgroundWidget::showEvent( QShowEvent *e )
-{
- if ( b_enabled ) timer->start();
- BackgroundWidget::showEvent( e );
-}
-
-void EasterEggBackgroundWidget::hideEvent( QHideEvent *e )
-{
- timer->stop();
- reset();
- BackgroundWidget::hideEvent( e );
-}
-
-void EasterEggBackgroundWidget::resizeEvent( QResizeEvent *e )
-{
- reset();
- BackgroundWidget::resizeEvent( e );
-}
-
-void EasterEggBackgroundWidget::animate()
-{
- b_enabled = true;
- if ( isVisible() ) timer->start();
-}
-
-void EasterEggBackgroundWidget::spawnFlakes()
-{
- if ( ! isVisible() ) return;
-
- double w = (double) width() / RAND_MAX;
-
- int i_spawn = ( (double) qrand() / RAND_MAX ) * i_rate;
-
- auto it = flakes->begin();
- while( it != flakes->end() )
- {
- flake *current = *it;
- current->point.setY( current->point.y() + i_speed );
- if ( current->point.y() + i_speed >= height() )
- {
- delete current;
- it = flakes->erase( it );
- }
- else
- ++it;
- }
-
- if ( flakes->size() < MAX_FLAKES )
- for ( int i=0; i<i_spawn; i++ )
- {
- flake *f = new flake;
- f->point.setX( qrand() * w );
- f->b_fat = ( qrand() < ( RAND_MAX * .33 ) );
- flakes->push_back( f );
- }
- update();
-}
-
-void EasterEggBackgroundWidget::reset()
-{
- for(flake* f: *flakes)
- delete f;
- flakes->clear();
-}
-
-void EasterEggBackgroundWidget::paintEvent( QPaintEvent *e )
-{
- QPainter painter(this);
-
- painter.setBrush( QBrush( QColor(Qt::white) ) );
- painter.setPen( QPen(Qt::white) );
-
- auto it = flakes->cbegin();
- while( it != flakes->cend() )
- {
- const flake * const f = *(it++);
- if ( f->b_fat )
- {
- /* Xsnow like :p */
- painter.drawPoint( f->point.x(), f->point.y() -1 );
- painter.drawPoint( f->point.x() + 1, f->point.y() );
- painter.drawPoint( f->point.x(), f->point.y() +1 );
- painter.drawPoint( f->point.x() - 1, f->point.y() );
- }
- else
- {
- painter.drawPoint( f->point );
- }
- }
-
- BackgroundWidget::paintEvent( e );
-}
CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
: QLabel( parent ), p_intf( _p_i ), p_item( NULL )
diff --git a/modules/gui/qt/widgets/native/interface_widgets.hpp b/modules/gui/qt/widgets/native/interface_widgets.hpp
index 2418cf5bf4..22454617c6 100644
--- a/modules/gui/qt/widgets/native/interface_widgets.hpp
+++ b/modules/gui/qt/widgets/native/interface_widgets.hpp
@@ -97,68 +97,6 @@ private slots:
void hideCursor();
};
-/******************** Background Widget ****************/
-class BackgroundWidget : public QWidget
-{
- Q_OBJECT
-public:
- BackgroundWidget( intf_thread_t * );
- void setExpandstoHeight( bool b_expand ) { b_expandPixmap = b_expand; }
- void setWithArt( bool b_withart_ ) { b_withart = b_withart_; };
-private:
- intf_thread_t *p_intf;
- QString pixmapUrl;
- bool b_expandPixmap;
- bool b_withart;
- QPropertyAnimation *fadeAnimation;
- void contextMenuEvent( QContextMenuEvent *event ) Q_DECL_OVERRIDE;
-protected:
- void paintEvent( QPaintEvent *e ) Q_DECL_OVERRIDE;
- void showEvent( QShowEvent * e ) Q_DECL_OVERRIDE;
- void updateDefaultArt( const QString& );
- static const int MARGIN = 5;
- QString defaultArt;
-public slots:
- void toggle(){ isVisible() ? hide() : show(); }
- void updateArt( const QString& );
- void titleUpdated( const QString& );
-};
-
-class EasterEggBackgroundWidget : public BackgroundWidget
-{
- Q_OBJECT
-
-public:
- EasterEggBackgroundWidget( intf_thread_t * );
- virtual ~EasterEggBackgroundWidget();
-
-public slots:
- void animate();
-
-protected:
- void paintEvent( QPaintEvent *e ) Q_DECL_OVERRIDE;
- void showEvent( QShowEvent *e ) Q_DECL_OVERRIDE;
- void hideEvent( QHideEvent * ) Q_DECL_OVERRIDE;
- void resizeEvent( QResizeEvent * ) Q_DECL_OVERRIDE;
-
-private slots:
- void spawnFlakes();
- void reset();
-
-private:
- struct flake
- {
- QPoint point;
- bool b_fat;
- };
- QTimer *timer;
- std::list<flake *> *flakes;
- int i_rate;
- int i_speed;
- bool b_enabled;
- static const int MAX_FLAKES = 1000;
-};
-
class CoverArtLabel : public QLabel
{
Q_OBJECT
More information about the vlc-commits
mailing list