Commit d0389324 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Rework a bit the OpenDialog calls in order to fix the double-click issue when transcoding.

should Close #1698
parent 985301f8
...@@ -183,7 +183,7 @@ void FileOpenPanel::accept() ...@@ -183,7 +183,7 @@ void FileOpenPanel::accept()
void FileOpenBox::accept() void FileOpenBox::accept()
{ {
OpenDialog::getInstance( NULL, NULL )->play(); OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
} }
/* Function called by Open Dialog when clicked on cancel */ /* Function called by Open Dialog when clicked on cancel */
......
...@@ -37,31 +37,36 @@ ...@@ -37,31 +37,36 @@
OpenDialog *OpenDialog::instance = NULL; OpenDialog *OpenDialog::instance = NULL;
OpenDialog* OpenDialog::getInstance( QWidget *parent, intf_thread_t *p_intf, 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 */ /* Creation */
if( !instance ) if( !instance )
instance = new OpenDialog( parent, p_intf, modal, _action_flag ); instance = new OpenDialog( parent, p_intf, b_selectMode, _action_flag );
else else if( !b_rawInstance )
{ {
/* Request the instance but change small details: /* Request the instance but change small details:
- Button menu - Button menu
- Modality on top of the parent dialog */ - 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->i_action_flag = _action_flag;
instance->setMenuAction(); instance->setMenuAction();
if( modal ) instance->setWindowModality( Qt::WindowModal );
} }
return instance; return instance;
} }
OpenDialog::OpenDialog( QWidget *parent, OpenDialog::OpenDialog( QWidget *parent,
intf_thread_t *_p_intf, intf_thread_t *_p_intf,
bool modal, bool b_selectMode,
int _action_flag ) : QVLCDialog( parent, _p_intf ) int _action_flag ) : QVLCDialog( parent, _p_intf )
{ {
i_action_flag = _action_flag; i_action_flag = _action_flag;
if( modal ) /* Select mode */ if( b_selectMode ) /* Select mode */
{ {
setWindowModality( Qt::WindowModal ); setWindowModality( Qt::WindowModal );
i_action_flag = SELECT; i_action_flag = SELECT;
...@@ -142,7 +147,7 @@ OpenDialog::OpenDialog( QWidget *parent, ...@@ -142,7 +147,7 @@ OpenDialog::OpenDialog( QWidget *parent,
CONNECT( ui.slaveText, textChanged( QString ), this, updateMRL() ); CONNECT( ui.slaveText, textChanged( QString ), this, updateMRL() );
CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() ); CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() );
CONNECT( ui.startTimeSpinBox, valueChanged( int ), this, updateMRL() ); CONNECT( ui.startTimeSpinBox, valueChanged( int ), this, updateMRL() );
BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() ); BUTTONACT( ui.advancedCheckBox, toggleAdvancedPanel() );
/* Buttons action */ /* Buttons action */
BUTTONACT( playButton, selectSlots() ); BUTTONACT( playButton, selectSlots() );
...@@ -190,12 +195,12 @@ void OpenDialog::setMenuAction() ...@@ -190,12 +195,12 @@ void OpenDialog::setMenuAction()
playButton->setText( qtr( "&Play" ) ); playButton->setText( qtr( "&Play" ) );
} }
playButton->show(); playButton->show();
playButton->setDefault( true );
selectButton->hide(); selectButton->hide();
playButton->setDefault( true );
} }
} }
void OpenDialog::showTab( int i_tab=0 ) void OpenDialog::showTab( int i_tab )
{ {
ui.Tab->setCurrentIndex( i_tab ); ui.Tab->setCurrentIndex( i_tab );
show(); show();
...@@ -243,14 +248,15 @@ void OpenDialog::cancel() ...@@ -243,14 +248,15 @@ void OpenDialog::cancel()
mainMRL.clear(); mainMRL.clear();
/* If in Select Mode, reject instead of hiding */ /* If in Select Mode, reject instead of hiding */
if( windowModality() != Qt::NonModal ) reject(); if( i_action_flag == SELECT ) reject();
else hide(); else hide();
} }
/* If EnterKey is pressed */ /* If EnterKey is pressed */
void OpenDialog::close() void OpenDialog::close()
{ {
if( windowModality() != Qt::NonModal ) /* If in Select Mode, accept instead of selecting a Slot */
if( i_action_flag == SELECT )
accept(); accept();
else else
selectSlots(); selectSlots();
...@@ -292,7 +298,7 @@ void OpenDialog::finish( bool b_enqueue = false ) ...@@ -292,7 +298,7 @@ void OpenDialog::finish( bool b_enqueue = false )
toggleVisible(); toggleVisible();
mrl = ui.advancedLineInput->text(); mrl = ui.advancedLineInput->text();
if( windowModality() == Qt::NonModal ) if( i_action_flag != SELECT )
{ {
QStringList tempMRL = SeparateEntries( mrl ); QStringList tempMRL = SeparateEntries( mrl );
for( size_t i = 0; i < tempMRL.size(); i++ ) for( size_t i = 0; i < tempMRL.size(); i++ )
......
...@@ -35,6 +35,23 @@ ...@@ -35,6 +35,23 @@
#include "ui/open.h" #include "ui/open.h"
#include "components/open_panels.hpp" #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 QString;
class QTabWidget; class QTabWidget;
...@@ -43,7 +60,7 @@ class OpenDialog : public QVLCDialog ...@@ -43,7 +60,7 @@ class OpenDialog : public QVLCDialog
Q_OBJECT; Q_OBJECT;
public: public:
static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf, 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() static void killInstance()
{ {
...@@ -52,7 +69,7 @@ public: ...@@ -52,7 +69,7 @@ public:
} }
virtual ~OpenDialog(); virtual ~OpenDialog();
void showTab( int ); void showTab( int = OPEN_FILE_TAB );
QString getMRL(){ return mrl; } QString getMRL(){ return mrl; }
public slots: public slots:
...@@ -63,7 +80,7 @@ public slots: ...@@ -63,7 +80,7 @@ public slots:
void transcode(); void transcode();
private: private:
OpenDialog( QWidget *parent, intf_thread_t *, bool modal, OpenDialog( QWidget *parent, intf_thread_t *, bool b_selectMode,
int _action_flag = 0 ); int _action_flag = 0 );
static OpenDialog *instance; static OpenDialog *instance;
......
...@@ -375,7 +375,7 @@ void VLMDialog::clearWidgets() ...@@ -375,7 +375,7 @@ void VLMDialog::clearWidgets()
void VLMDialog::selectInput() void VLMDialog::selectInput()
{ {
OpenDialog *o = OpenDialog::getInstance( this, p_intf, SELECT, true ); OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true );
o->exec(); o->exec();
ui.inputLedit->setText( o->getMRL() ); ui.inputLedit->setText( o->getMRL() );
} }
......
...@@ -260,7 +260,7 @@ void DialogsProvider::openCaptureDialog() ...@@ -260,7 +260,7 @@ void DialogsProvider::openCaptureDialog()
/* Same as the open one, but force the enqueue */ /* Same as the open one, but force the enqueue */
void DialogsProvider::PLAppendDialog() 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 ); ->showTab( OPEN_FILE_TAB );
} }
...@@ -453,14 +453,14 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl, ...@@ -453,14 +453,14 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
void DialogsProvider::openThenStreamingDialogs() void DialogsProvider::openThenStreamingDialogs()
{ {
OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_STREAM ) OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
->showTab( 0 ); ->showTab( OPEN_FILE_TAB );
} }
void DialogsProvider::openThenTranscodingDialogs() void DialogsProvider::openThenTranscodingDialogs()
{ {
OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_SAVE ) OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
->showTab( 0 ); ->showTab( OPEN_FILE_TAB );
} }
/**************************************************************************** /****************************************************************************
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "dialogs/interaction.hpp" #include "dialogs/interaction.hpp"
#include "dialogs/open.hpp"
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
...@@ -77,22 +78,6 @@ enum { ...@@ -77,22 +78,6 @@ enum {
EXT_FILTER_SUBTITLE = 0x10, 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 QEvent;
class QSignalMapper; class QSignalMapper;
class QVLCMenu; class QVLCMenu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment