Commit 4c8750b0 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4: Really split the TimeLabel into its own class.

Code simplification and TimeLabel in the FSC.
(cherry picked from commit 44e31c0f)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0e61448e
......@@ -1040,6 +1040,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
fsLayout->addWidget( slider, 0, 1, 1, 9 );
fsLayout->addWidget( fasterButton, 0, 10 );
/* Second line */
fsLayout->addWidget( playButton, 1, 0, 1, 2 );
fsLayout->addLayout( controlButLayout, 1, 2 );
......@@ -1049,8 +1050,12 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
fsLayout->addWidget( advControls, 1, 6, Qt::AlignVCenter );
fsLayout->setColumnStretch( 7, 10 );
fsLayout->addWidget( volMuteLabel, 1, 8 );
fsLayout->addWidget( volumeSlider, 1, 9, 1, 2 );
TimeLabel *timeLabel = new TimeLabel( p_intf );
fsLayout->addWidget( timeLabel, 1, 8 );
fsLayout->addWidget( volMuteLabel, 1, 9 );
fsLayout->addWidget( volumeSlider, 1, 10,1, 2 );
/* hiding timer */
p_hideTimer = new QTimer( this );
......@@ -1081,6 +1086,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
fullscreenButton->setIcon( QIcon( ":/defullscreen" ) );
vlc_mutex_init_recursive( &lock );
setMinimumWidth( 450 );
}
FullscreenControllerWidget::~FullscreenControllerWidget()
......@@ -1619,3 +1625,37 @@ void CoverArtLabel::doUpdate()
}
}
TimeLabel::TimeLabel( intf_thread_t *_p_intf ) :QLabel(), p_intf( _p_intf )
{
b_remainingTime = false;
setText( " --:--/--:-- " );
setAlignment( Qt::AlignRight | Qt::AlignVCenter );
setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplayPosition( float, int, int ) );
}
void TimeLabel::setDisplayPosition( float pos, int time, int length )
{
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
secstotimestr( psz_length, length );
secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
: time );
QString timestr;
timestr.sprintf( "%s/%s", psz_time,
( !length && time ) ? "--:--" : psz_length );
/* Add a minus to remaining time*/
if( b_remainingTime && length ) setText( " -"+timestr+" " );
else setText( " "+timestr+" " );
}
void TimeLabel::toggleTimeDisplay()
{
b_remainingTime = !b_remainingTime;
}
......@@ -332,16 +332,25 @@ private:
class TimeLabel : public QLabel
{
Q_OBJECT
void mousePressEvent( QMouseEvent *event )
public:
TimeLabel( intf_thread_t *_p_intf );
protected:
virtual void mousePressEvent( QMouseEvent *event )
{
emit timeLabelClicked();
toggleTimeDisplay();
}
void mouseDoubleClickEvent( QMouseEvent *event )
virtual void mouseDoubleClickEvent( QMouseEvent *event )
{
toggleTimeDisplay();
emit timeLabelDoubleClicked();
}
private slots:
void setDisplayPosition( float pos, int time, int length );
private:
intf_thread_t *p_intf;
bool b_remainingTime;
void toggleTimeDisplay();
signals:
void timeLabelClicked();
void timeLabelDoubleClicked();
};
......
......@@ -146,8 +146,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Connect the input manager to the GUI elements it manages */
/* It is also connected to the control->slider, see the ControlsWidget */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplayPosition( float, int, int ) );
/* Change the SpeedRate in the Status */
CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
......@@ -300,11 +298,7 @@ inline void MainInterface::createStatusBar()
* Status Bar *
****************/
/* Widgets Creation*/
b_remainingTime = false;
timeLabel = new TimeLabel;
timeLabel->setText( " --:--/--:-- " );
timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
timeLabel->setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
timeLabel = new TimeLabel( p_intf );
nameLabel = new QLabel;
nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
| Qt::TextSelectableByKeyboard );
......@@ -327,9 +321,7 @@ inline void MainInterface::createStatusBar()
- double clicking opens the goto time dialog
- right-clicking and clicking just toggle between remaining and
elapsed time.*/
CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
/* Speed Label behaviour:
- right click gives the vertical speed slider */
......@@ -863,27 +855,6 @@ void MainInterface::visual()
/************************************************************************
* Other stuff
************************************************************************/
void MainInterface::setDisplayPosition( float pos, int time, int length )
{
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
secstotimestr( psz_length, length );
secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
: time );
QString timestr;
timestr.sprintf( "%s/%s", psz_time,
( !length && time ) ? "--:--" : psz_length );
/* Add a minus to remaining time*/
if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );
else timeLabel->setText( " "+timestr+" " );
}
void MainInterface::toggleTimeDisplay()
{
b_remainingTime = !b_remainingTime;
}
void MainInterface::setName( QString name )
{
input_name = name; /* store it for the QSystray use */
......
......@@ -133,7 +133,6 @@ private:
bool playlistVisible; ///< Is the playlist visible ?
bool visualSelectorEnabled;
bool notificationEnabled; /// Systray Notifications
bool b_remainingTime; /* Show elapsed or remaining time */
bool bgWasVisible;
int i_visualmode; ///< Visual Mode
pl_dock_e i_pl_dock;
......@@ -171,8 +170,6 @@ private slots:
void setRate( int );
void setName( QString );
void setVLCWindowsTitle( QString title = "" );
void setDisplayPosition( float, int, int );
void toggleTimeDisplay();
#if 0
void visual();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment