Qt: don't use a modal dialog for continuing the playback
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 15 Aug 2014 03:44:30 +0000 (05:44 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 15 Aug 2014 03:44:30 +0000 (05:44 +0200)
Close #11705 #11703

modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/qt4.cpp

index 4ab1f58..1a04f51 100644 (file)
@@ -136,12 +136,7 @@ void InputManager::setInput( input_thread_t *_p_input )
                     !var_GetFloat( p_input, "start-time" ) &&
                     !var_GetFloat( p_input, "stop-time" ) )
             {
-                if( QMessageBox::question( NULL,
-                            _("Continue playback?"),
-                            _("Do you want to restart the playback where left off?"),
-                            QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes )
-                        == QMessageBox::Yes )
-                    var_SetTime( p_input, "time", (int64_t)i_time * 1000 );
+                emit continuePlayback( (int64_t)i_time * 1000 );
             }
         }
     }
index af66ee0..60719b8 100644 (file)
@@ -223,6 +223,8 @@ signals:
     void titleChanged( bool );
     void chapterChanged( bool );
     void inputCanSeek( bool );
+    /// You can continuePlayback
+    void continuePlayback( int64_t );
     /// Statistics are updated
     void statisticsUpdated( input_item_t* );
     void infoChanged( input_item_t* );
index ac0a42f..8b76e5a 100644 (file)
@@ -60,6 +60,8 @@
 #include <QStackedWidget>
 #include <QFileInfo>
 
+#include <QTimer>
+
 #include <vlc_keys.h>                       /* Wheel event */
 #include <vlc_vout_display.h>               /* vout_thread_t and VOUT_ events */
 
@@ -364,6 +366,56 @@ void MainInterface::reloadPrefs()
     }
 }
 
+void MainInterface::createContinueDialog( QWidget *w )
+{
+    /* Create non-modal continueDialog */
+    continueDialog = new QWidget( w );
+    continueDialog->hide();
+    QHBoxLayout *continueDialogLayout = new QHBoxLayout( continueDialog );
+    continueDialogLayout->setSpacing( 0 ); continueDialogLayout->setMargin( 0 );
+
+    QLabel *continueLabel = new QLabel( qtr( "Do you want to restart the playback where left off?") );
+    QToolButton *cancel = new QToolButton( continueDialog );
+    cancel->setAutoRaise( true );
+    cancel->setText( "X" );
+    QPushButton *ok = new QPushButton( qtr("&Continue")  );
+
+    continueDialogLayout->addWidget(continueLabel);
+    continueDialogLayout->addStretch( 1 );
+    continueDialogLayout->addWidget( ok );
+    continueDialogLayout->addWidget( cancel );
+
+    CONNECT( cancel, clicked(), continueDialog, hide() );
+    BUTTONACT(ok, continuePlayback() );
+
+    CONNECT( THEMIM->getIM(), continuePlayback(int64_t), this, showContinueDialog(int64_t) );
+
+    w->layout()->addWidget( continueDialog );
+}
+
+void MainInterface::showContinueDialog( int64_t _time ) {
+    int setting = var_InheritInteger( p_intf, "qt-continue" );
+
+    if( setting == 0 )
+        return;
+
+    i_continueTime = _time;
+
+    if( setting == 2)
+        continuePlayback();
+    else
+    {
+        continueDialog->setVisible(true);
+        QTimer::singleShot(6000, continueDialog, SLOT(hide()));
+    }
+}
+
+void MainInterface::continuePlayback()
+{
+    var_SetTime( THEMIM->getInput(), "time", i_continueTime );
+    continueDialog->hide();
+}
+
 void MainInterface::createMainWidget( QSettings *creationSettings )
 {
     /* Create the main Widget and the mainLayout */
@@ -373,6 +425,7 @@ void MainInterface::createMainWidget( QSettings *creationSettings )
     main->setContentsMargins( 0, 0, 0, 0 );
     mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 );
 
+    createContinueDialog( main );
     /* */
     stackCentralW = new QVLCStackedWidget( main );
 
index c1452d1..73ff968 100644 (file)
@@ -111,6 +111,7 @@ private:
     void createMainWidget( QSettings* );
     void createStatusBar();
     void createPlaylist();
+    void createContinueDialog( QWidget *w );
 
     /* Systray */
     void createSystray();
@@ -146,6 +147,10 @@ private:
     PlaylistWidget      *playlistWidget;
     //VisualSelector      *visualSelector;
 
+    /* continue */
+    QWidget             *continueDialog;
+    int64_t             i_continueTime;
+
     /* Status Bar */
     QLabel              *nameLabel;
     QLabel              *cryptedLabel;
@@ -252,6 +257,9 @@ private slots:
     void setBoss();
     void setRaise();
 
+    void showContinueDialog( int64_t);
+    void continuePlayback();
+
 signals:
     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
                       unsigned *pi_width, unsigned *pi_height );
index ea6fd01..2beda6f 100644 (file)
@@ -185,12 +185,21 @@ static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
 
 #define FULLSCREEN_CONTROL_PIXELS N_( "Fullscreen controller mouse sensitivity" )
 
+#define CONTINUE_PLAYBACK_TEXT N_("Continue playback?")
+
 static const int i_notification_list[] =
     { NOTIFICATION_NEVER, NOTIFICATION_MINIMIZED, NOTIFICATION_ALWAYS };
 
 static const char *const psz_notification_list_text[] =
     { N_("Never"), N_("When minimized"), N_("Always") };
 
+static const int i_continue_list[] =
+    { 0, 1, 2 };
+
+static const char *const psz_continue_list_text[] =
+    { N_("Never"), N_("Ask"), N_("Always") };
+
+
 /**********************************************************************/
 vlc_module_begin ()
     set_shortname( "Qt" )
@@ -233,6 +242,8 @@ vlc_module_begin ()
               RECENTPLAY_TEXT, false )
     add_string( "qt-recentplay-filter", "",
                 RECENTPLAY_FILTER_TEXT, RECENTPLAY_FILTER_LONGTEXT, false )
+    add_integer( "qt-continue", 1, CONTINUE_PLAYBACK_TEXT, CONTINUE_PLAYBACK_TEXT, false )
+            change_integer_list(i_continue_list, psz_continue_list_text )
 
 #ifdef UPDATE_CHECK
     add_bool( "qt-updates-notif", true, UPDATER_TEXT,