From d0389324b91b56a96bc6bbcb2c417ca824a892ab Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sat, 26 Jul 2008 14:49:24 -0700 Subject: [PATCH] Rework a bit the OpenDialog calls in order to fix the double-click issue when transcoding. should Close #1698 --- modules/gui/qt4/components/open_panels.cpp | 2 +- modules/gui/qt4/dialogs/open.cpp | 30 +++++++++++++--------- modules/gui/qt4/dialogs/open.hpp | 23 ++++++++++++++--- modules/gui/qt4/dialogs/vlm.cpp | 2 +- modules/gui/qt4/dialogs_provider.cpp | 10 ++++---- modules/gui/qt4/dialogs_provider.hpp | 17 +----------- 6 files changed, 46 insertions(+), 38 deletions(-) diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp index 100e52950f..5270983a9c 100644 --- a/modules/gui/qt4/components/open_panels.cpp +++ b/modules/gui/qt4/components/open_panels.cpp @@ -183,7 +183,7 @@ void FileOpenPanel::accept() void FileOpenBox::accept() { - OpenDialog::getInstance( NULL, NULL )->play(); + OpenDialog::getInstance( NULL, NULL, true )->selectSlots(); } /* Function called by Open Dialog when clicked on cancel */ diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp index ea2c5e18b3..02826db4b3 100644 --- a/modules/gui/qt4/dialogs/open.cpp +++ b/modules/gui/qt4/dialogs/open.cpp @@ -37,31 +37,36 @@ OpenDialog *OpenDialog::instance = NULL; OpenDialog* OpenDialog::getInstance( QWidget *parent, intf_thread_t *p_intf, - int _action_flag, bool modal ) + bool b_rawInstance, int _action_flag, bool b_selectMode ) { /* Creation */ if( !instance ) - instance = new OpenDialog( parent, p_intf, modal, _action_flag ); - else + instance = new OpenDialog( parent, p_intf, b_selectMode, _action_flag ); + else if( !b_rawInstance ) { /* Request the instance but change small details: - Button menu - Modality on top of the parent dialog */ + if( b_selectMode ) + { + instance->setWindowModality( Qt::WindowModal ); + _action_flag = SELECT; /* This should be useless, but we never know + if the call is correct */ + } instance->i_action_flag = _action_flag; instance->setMenuAction(); - if( modal ) instance->setWindowModality( Qt::WindowModal ); } return instance; } OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, - bool modal, + bool b_selectMode, int _action_flag ) : QVLCDialog( parent, _p_intf ) { i_action_flag = _action_flag; - if( modal ) /* Select mode */ + if( b_selectMode ) /* Select mode */ { setWindowModality( Qt::WindowModal ); i_action_flag = SELECT; @@ -142,7 +147,7 @@ OpenDialog::OpenDialog( QWidget *parent, CONNECT( ui.slaveText, textChanged( QString ), this, updateMRL() ); CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() ); CONNECT( ui.startTimeSpinBox, valueChanged( int ), this, updateMRL() ); - BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() ); + BUTTONACT( ui.advancedCheckBox, toggleAdvancedPanel() ); /* Buttons action */ BUTTONACT( playButton, selectSlots() ); @@ -190,12 +195,12 @@ void OpenDialog::setMenuAction() playButton->setText( qtr( "&Play" ) ); } playButton->show(); - playButton->setDefault( true ); selectButton->hide(); + playButton->setDefault( true ); } } -void OpenDialog::showTab( int i_tab=0 ) +void OpenDialog::showTab( int i_tab ) { ui.Tab->setCurrentIndex( i_tab ); show(); @@ -243,14 +248,15 @@ void OpenDialog::cancel() mainMRL.clear(); /* If in Select Mode, reject instead of hiding */ - if( windowModality() != Qt::NonModal ) reject(); + if( i_action_flag == SELECT ) reject(); else hide(); } /* If EnterKey is pressed */ void OpenDialog::close() { - if( windowModality() != Qt::NonModal ) + /* If in Select Mode, accept instead of selecting a Slot */ + if( i_action_flag == SELECT ) accept(); else selectSlots(); @@ -292,7 +298,7 @@ void OpenDialog::finish( bool b_enqueue = false ) toggleVisible(); mrl = ui.advancedLineInput->text(); - if( windowModality() == Qt::NonModal ) + if( i_action_flag != SELECT ) { QStringList tempMRL = SeparateEntries( mrl ); for( size_t i = 0; i < tempMRL.size(); i++ ) diff --git a/modules/gui/qt4/dialogs/open.hpp b/modules/gui/qt4/dialogs/open.hpp index 1f2a02583b..73a07e48bb 100644 --- a/modules/gui/qt4/dialogs/open.hpp +++ b/modules/gui/qt4/dialogs/open.hpp @@ -35,6 +35,23 @@ #include "ui/open.h" #include "components/open_panels.hpp" +enum { + OPEN_FILE_TAB, + OPEN_DISC_TAB, + OPEN_NETWORK_TAB, + OPEN_CAPTURE_TAB, + OPEN_TAB_MAX +}; + +enum { + OPEN_AND_PLAY, + OPEN_AND_ENQUEUE, + OPEN_AND_STREAM, + OPEN_AND_SAVE, + SELECT /* Special mode to select a MRL (for VLM or similar */ +}; + + class QString; class QTabWidget; @@ -43,7 +60,7 @@ class OpenDialog : public QVLCDialog Q_OBJECT; public: static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf, - int _action_flag = 0, bool modal = false ); + bool b_rawInstance = false, int _action_flag = 0, bool b_selectMode = false ); static void killInstance() { @@ -52,7 +69,7 @@ public: } virtual ~OpenDialog(); - void showTab( int ); + void showTab( int = OPEN_FILE_TAB ); QString getMRL(){ return mrl; } public slots: @@ -63,7 +80,7 @@ public slots: void transcode(); private: - OpenDialog( QWidget *parent, intf_thread_t *, bool modal, + OpenDialog( QWidget *parent, intf_thread_t *, bool b_selectMode, int _action_flag = 0 ); static OpenDialog *instance; diff --git a/modules/gui/qt4/dialogs/vlm.cpp b/modules/gui/qt4/dialogs/vlm.cpp index 12bf3b4ded..12ad9bf4e4 100644 --- a/modules/gui/qt4/dialogs/vlm.cpp +++ b/modules/gui/qt4/dialogs/vlm.cpp @@ -375,7 +375,7 @@ void VLMDialog::clearWidgets() void VLMDialog::selectInput() { - OpenDialog *o = OpenDialog::getInstance( this, p_intf, SELECT, true ); + OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true ); o->exec(); ui.inputLedit->setText( o->getMRL() ); } diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp index 98d11ab919..4d7992ac2a 100644 --- a/modules/gui/qt4/dialogs_provider.cpp +++ b/modules/gui/qt4/dialogs_provider.cpp @@ -260,7 +260,7 @@ void DialogsProvider::openCaptureDialog() /* Same as the open one, but force the enqueue */ void DialogsProvider::PLAppendDialog() { - OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_ENQUEUE) + OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_ENQUEUE) ->showTab( OPEN_FILE_TAB ); } @@ -453,14 +453,14 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl, void DialogsProvider::openThenStreamingDialogs() { - OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_STREAM ) - ->showTab( 0 ); + OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM ) + ->showTab( OPEN_FILE_TAB ); } void DialogsProvider::openThenTranscodingDialogs() { - OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_SAVE ) - ->showTab( 0 ); + OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE ) + ->showTab( OPEN_FILE_TAB ); } /**************************************************************************** diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp index 7d661a5f07..97c19c6e5c 100644 --- a/modules/gui/qt4/dialogs_provider.hpp +++ b/modules/gui/qt4/dialogs_provider.hpp @@ -35,6 +35,7 @@ #include "qt4.hpp" #include "dialogs/interaction.hpp" +#include "dialogs/open.hpp" #include #include @@ -77,22 +78,6 @@ enum { EXT_FILTER_SUBTITLE = 0x10, }; -enum { - OPEN_FILE_TAB, - OPEN_DISC_TAB, - OPEN_NETWORK_TAB, - OPEN_CAPTURE_TAB, - OPEN_TAB_MAX -}; - -enum { - OPEN_AND_PLAY, - OPEN_AND_STREAM, - OPEN_AND_SAVE, - OPEN_AND_ENQUEUE, - SELECT -}; - class QEvent; class QSignalMapper; class QVLCMenu; -- 2.39.2