vlc | branch: master | Edward Wang <[email protected]> | Sun Jan 1 14:04:58 2012 -0500| [abfcd0d5d391256477a45e0b3d07b90ce924e561] | committer: Jean-Baptiste Kempf
Qt4: allow more types of timeLabel in toolbars Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=abfcd0d5d391256477a45e0b3d07b90ce924e561 --- modules/gui/qt4/components/controller.cpp | 6 ++ modules/gui/qt4/components/controller.hpp | 2 + modules/gui/qt4/components/interface_widgets.cpp | 58 +++++++++++++++++----- modules/gui/qt4/components/interface_widgets.hpp | 12 ++++- modules/gui/qt4/dialogs/toolbar.cpp | 8 +++ 5 files changed, 73 insertions(+), 13 deletions(-) diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp index d1fad22..e61a1b5 100644 --- a/modules/gui/qt4/components/controller.cpp +++ b/modules/gui/qt4/components/controller.cpp @@ -471,6 +471,12 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); break; + case TIME_LABEL_ELAPSED: + widget = new TimeLabel( p_intf, TimeLabel::Elapsed ); + break; + case TIME_LABEL_REMAINING: + widget = new TimeLabel( p_intf, TimeLabel::Remaining ); + break; default: msg_Warn( p_intf, "This should not happen %i", button ); break; diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp index 8052c75..2d5f1e4 100644 --- a/modules/gui/qt4/components/controller.hpp +++ b/modules/gui/qt4/components/controller.hpp @@ -101,6 +101,8 @@ typedef enum buttonType_e PLAYBACK_BUTTONS, ASPECT_RATIO_COMBOBOX, SPEED_LABEL, + TIME_LABEL_ELAPSED, + TIME_LABEL_REMAINING, SPECIAL_MAX, WIDGET_SPACER = 0x40, diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index 9c8f8d8..419b5e6 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -549,17 +549,33 @@ void CoverArtLabel::askForUpdate() THEMIM->getIM()->requestArtUpdate(); } -TimeLabel::TimeLabel( intf_thread_t *_p_intf ) +TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType ) : QLabel(), p_intf( _p_intf ), bufTimer( new QTimer(this) ), - buffering( false ), showBuffering(false), bufVal( -1 ) + buffering( false ), showBuffering(false), bufVal( -1 ), displayType( _displayType ) { b_remainingTime = false; - setText( " --:--/--:-- " ); + switch( _displayType ) { + case TimeLabel::Elapsed: + setText( " --:-- " ); + setToolTip( qtr("Elapsed time") ); + break; + case TimeLabel::Remaining: + setText( " --:-- " ); + setToolTip( qtr("Total/Remaining time") + + QString("\n-") + + qtr("Click to toggle between total and remaining time") + ); + break; + case TimeLabel::Both: + setText( " --:--/--:-- " ); + setToolTip( QString( "- " ) + + qtr( "Click to toggle between elapsed and remaining time" ) + + QString( "\n- " ) + + qtr( "Double click to jump to a chosen time position" ) ); + break; + } setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - setToolTip( QString( "- " ) - + qtr( "Click to toggle between elapsed and remaining time" ) - + QString( "\n- " ) - + qtr( "Double click to jump to a chosen time position" ) ); + bufTimer->setSingleShot( true ); CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ), @@ -567,6 +583,8 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf ) CONNECT( THEMIM->getIM(), cachingChanged( float ), this, updateBuffering( float ) ); CONNECT( bufTimer, timeout(), this, updateBuffering() ); + + this->setContentsMargins( 4, 0, 4, 0 ); } void TimeLabel::setDisplayPosition( float pos, int64_t t, int length ) @@ -576,7 +594,10 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length ) if( pos == -1.f ) { - setText( " --:--/--:-- " ); + if( displayType == TimeLabel::Both ) + setText( " --:--/--:-- " ); + else + setText( " --:-- " ); return; } @@ -585,14 +606,27 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length ) secstotimestr( psz_length, length ); secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time : time ); - - QString timestr = QString( " %1%2/%3 " ) + switch( displayType ) + { + case TimeLabel::Elapsed: + setText( QString(" ") + QString( psz_time ) + QString(" ") ); + break; + case TimeLabel::Remaining: + if( b_remainingTime ) + setText( QString(" -") + QString( psz_time ) + QString(" ") ); + else + setText( QString(" ") + QString( psz_length ) + QString(" ") ); + break; + case TimeLabel::Both: + default: + QString timestr = QString( " %1%2/%3 " ) .arg( QString( (b_remainingTime && length) ? "-" : "" ) ) .arg( QString( psz_time ) ) .arg( QString( ( !length && time ) ? "--:--" : psz_length ) ); - setText( timestr ); - + setText( timestr ); + break; + } cachedLength = length; } diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index 5de9b32..cd95276 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -122,15 +122,24 @@ class TimeLabel : public QLabel { Q_OBJECT public: - TimeLabel( intf_thread_t *_p_intf ); + enum Display + { + Elapsed, + Remaining, + Both + }; + + TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType = TimeLabel::Both ); protected: virtual void mousePressEvent( QMouseEvent *event ) { + if( displayType == TimeLabel::Elapsed ) return; toggleTimeDisplay(); event->accept(); } virtual void mouseDoubleClickEvent( QMouseEvent *event ) { + if( displayType != TimeLabel::Both ) return; event->accept(); toggleTimeDisplay(); emit timeLabelDoubleClicked(); @@ -144,6 +153,7 @@ private: bool buffering; bool showBuffering; float bufVal; + TimeLabel::Display displayType; char psz_length[MSTRTIME_MAX_SIZE]; char psz_time[MSTRTIME_MAX_SIZE]; diff --git a/modules/gui/qt4/dialogs/toolbar.cpp b/modules/gui/qt4/dialogs/toolbar.cpp index ce5194b..bd1e982 100644 --- a/modules/gui/qt4/dialogs/toolbar.cpp +++ b/modules/gui/qt4/dialogs/toolbar.cpp @@ -453,6 +453,14 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Speed selector") ); break; + case TIME_LABEL_ELAPSED: + widget = new QLabel( "2:42", this ); + widgetItem->setText( qtr("Elasped time") ); + break; + case TIME_LABEL_REMAINING: + widget = new QLabel( "-2:42", this ); + widgetItem->setText( qtr("Total/Remaining time") ); + break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
