[vlc-commits] Qt: don't use a modal dialog for continuing the playback
Jean-Baptiste Kempf
git at videolan.org
Fri Aug 15 20:39:26 CEST 2014
vlc/vlc-2.2 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Aug 15 05:44:30 2014 +0200| [a1029e49c270d8c5519ad75d58269f45845fcdf3] | committer: Jean-Baptiste Kempf
Qt: don't use a modal dialog for continuing the playback
Close #11705 #11703
(cherry picked from commit a3f6eeeb90422e40a2650d05be667b410aec3668)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=a1029e49c270d8c5519ad75d58269f45845fcdf3
---
modules/gui/qt4/input_manager.cpp | 7 +----
modules/gui/qt4/input_manager.hpp | 2 ++
modules/gui/qt4/main_interface.cpp | 53 ++++++++++++++++++++++++++++++++++++
modules/gui/qt4/main_interface.hpp | 8 ++++++
modules/gui/qt4/qt4.cpp | 11 ++++++++
5 files changed, 75 insertions(+), 6 deletions(-)
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 4ab1f58..1a04f51 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -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 );
}
}
}
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index af66ee0..60719b8 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -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* );
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index f5d601e..4734749 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -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 */
@@ -366,6 +368,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 */
@@ -375,6 +427,7 @@ void MainInterface::createMainWidget( QSettings *creationSettings )
main->setContentsMargins( 0, 0, 0, 0 );
mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 );
+ createContinueDialog( main );
/* */
stackCentralW = new QVLCStackedWidget( main );
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index cea8847..e3f36a7 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -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;
@@ -254,6 +259,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 );
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index ea6fd01..2beda6f 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -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,
More information about the vlc-commits
mailing list