From 5c853cf55f24e39425c2bf67ec61b407d1684de3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sat, 8 Sep 2007 01:45:16 +0000 Subject: [PATCH] Qt4 - MainInterface, implement the feature request to show elapsed/remaining time in the statusBar() through a menu. --- modules/gui/qt4/main_interface.cpp | 21 ++++++++++++++++----- modules/gui/qt4/main_interface.hpp | 5 +++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index fc9ff0701a..e531b8ab81 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -134,6 +134,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) /** * TODO: do we add a label for the current Volume ? **/ + b_remainingTime = false; timeLabel = new QLabel; nameLabel = new QLabel; speedLabel = new QLabel( "1.0x" ); @@ -144,6 +145,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) statusBar()->addPermanentWidget( timeLabel, 2 ); speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu ); timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu ); + CONNECT( speedLabel, customContextMenuRequested( QPoint ), this, showSpeedMenu( QPoint ) ); CONNECT( timeLabel, customContextMenuRequested( QPoint ), @@ -400,7 +402,8 @@ void MainInterface::showSpeedMenu( QPoint pos ) void MainInterface::showTimeMenu( QPoint pos ) { QMenu menu( this ); - menu.addAction( "Not Implemented Yet" ); + menu.addAction( qtr("Elapsed Time") , this, SLOT( setElapsedTime() ) ); + menu.addAction( qtr("Remaining Time") , this, SLOT( setRemainTime() ) ); menu.exec( QCursor::pos() ); } @@ -655,12 +658,20 @@ void MainInterface::setDisplay( float pos, int time, int length ) { char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE]; secstotimestr( psz_length, length ); - secstotimestr( psz_time, time ); - QString title; - title.sprintf( "%s/%s", psz_time, psz_length ); - timeLabel->setText( " "+title+" " ); + secstotimestr( psz_time, b_remainingTime ? length - time : time ); + QString title; title.sprintf( "%s/%s", psz_time, psz_length ); + if( b_remainingTime ) timeLabel->setText( " -"+title+" " ); + else timeLabel->setText( " "+title+" " ); } +void MainInterface::toggleTimeDisplay( bool b_remain = false ) +{ + b_remainingTime = ( b_remainingTime ? false : true ); +} + +void MainInterface::setElapsedTime(){ b_remainingTime = false; } +void MainInterface::setRemainTime(){ b_remainingTime = true; } + void MainInterface::setName( QString name ) { input_name = name; diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp index c0bd121180..7106b0fbd2 100644 --- a/modules/gui/qt4/main_interface.hpp +++ b/modules/gui/qt4/main_interface.hpp @@ -113,6 +113,8 @@ private: QLabel *timeLabel; QLabel *speedLabel; QLabel *nameLabel; + + bool b_remainingTime; void customEvent( QEvent *); public slots: @@ -127,6 +129,9 @@ private slots: void setName( QString ); void setVLCWindowsTitle( QString title = "" ); void setDisplay( float, int, int ); + void toggleTimeDisplay( bool ); + void setElapsedTime(); + void setRemainTime(); #if 0 void visual(); #endif -- 2.39.5