]> git.sesse.net Git - vlc/commitdiff
Qt: Go To Time dialog: set default time to current (fix #5511)
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 19 Nov 2011 17:42:51 +0000 (18:42 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 19 Nov 2011 17:44:16 +0000 (18:44 +0100)
modules/gui/qt4/dialogs/gototime.cpp
modules/gui/qt4/dialogs/gototime.hpp

index 19a4d26c52e8f898d68d9004774f646188444167..42d7329bdb13cd2cdc37ef2ab8221055a90825cd 100644 (file)
@@ -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) );
 }
index a173d104af82557b831057bd653112f1320ce34c..38b0676a3f1f7ea558da9dae4a1231255fb631d0 100644 (file)
@@ -39,8 +39,11 @@ private:
 private slots:
     void close();
     void cancel();
+    void reset();
 
     friend class    Singleton<GotoTimeDialog>;
+public:
+    void toggleVisible();
 };
 
 #endif