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()
void FileOpenBox::accept()
{
OpenDialog::getInstance( NULL, NULL )->play();
OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
}
/* Function called by Open Dialog when clicked on cancel */
......
......@@ -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++ )
......
......@@ -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;
......
......@@ -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() );
}
......
......@@ -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 );
}
/****************************************************************************
......
......@@ -35,6 +35,7 @@
#include "qt4.hpp"
#include "dialogs/interaction.hpp"
#include "dialogs/open.hpp"
#include <QObject>
#include <QTimer>
......@@ -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;
......
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