From 8be768a9cfb2c468b0e8917f045df81b592735a9 Mon Sep 17 00:00:00 2001 From: Francois Cartegnie Date: Sat, 19 Nov 2011 18:42:51 +0100 Subject: [PATCH] Qt: Go To Time dialog: set default time to current (fix #5511) --- modules/gui/qt4/dialogs/gototime.cpp | 24 ++++++++++++++++++++++-- modules/gui/qt4/dialogs/gototime.hpp | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt4/dialogs/gototime.cpp b/modules/gui/qt4/dialogs/gototime.cpp index 19a4d26c52..42d7329bdb 100644 --- a/modules/gui/qt4/dialogs/gototime.cpp +++ b/modules/gui/qt4/dialogs/gototime.cpp @@ -62,22 +62,38 @@ GotoTimeDialog::GotoTimeDialog( intf_thread_t *_p_intf) timeEdit->setAlignment( Qt::AlignRight ); timeEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); + QPushButton *resetButton = new QPushButton( QIcon(":/update"), "" ); + resetButton->setToolTip( qtr("Reset") ); + mainLayout->addWidget( timeIntro, 0, 0, 1, 1 ); mainLayout->addWidget( timeEdit, 0, 1, 1, 1 ); + mainLayout->addWidget( resetButton, 0, 2, 1, 1 ); - mainLayout->addWidget( buttonBox, 1, 0, 1, 2 ); + mainLayout->addWidget( buttonBox, 1, 0, 1, 3 ); BUTTONACT( gotoButton, close() ); BUTTONACT( cancelButton, cancel() ); + BUTTONACT( resetButton, reset() ); } GotoTimeDialog::~GotoTimeDialog() { } +void GotoTimeDialog::toggleVisible() +{ + reset(); + if ( !isVisible() && THEMIM->getIM()->hasInput() ) + { + int64_t i_time = var_GetTime( THEMIM->getInput(), "time" ); + timeEdit->setTime( timeEdit->time().addSecs( i_time / 1000000 ) ); + } + QVLCDialog::toggleVisible(); +} + void GotoTimeDialog::cancel() { - timeEdit->setTime( QTime( 0, 0, 0) ); + reset(); toggleVisible(); } @@ -90,5 +106,9 @@ void GotoTimeDialog::close() var_SetTime( THEMIM->getInput(), "time", i_time ); } toggleVisible(); +} + +void GotoTimeDialog::reset() +{ timeEdit->setTime( QTime( 0, 0, 0) ); } diff --git a/modules/gui/qt4/dialogs/gototime.hpp b/modules/gui/qt4/dialogs/gototime.hpp index a173d104af..38b0676a3f 100644 --- a/modules/gui/qt4/dialogs/gototime.hpp +++ b/modules/gui/qt4/dialogs/gototime.hpp @@ -39,8 +39,11 @@ private: private slots: void close(); void cancel(); + void reset(); friend class Singleton; +public: + void toggleVisible(); }; #endif -- 2.39.2