Commit 5fcb0513 authored by Clément Stenac's avatar Clément Stenac

Some more Qt interaction support

parent debc0363
......@@ -12,7 +12,8 @@
AUTOMAKE_OPTIONS = subdir-objects
TOUI = ui/input_stats ui/main_interface ui/file_open \
ui/okcanceldialog
ui/okcanceldialog ui/yesnocanceldialog ui/logindialog ui/inputdialog \
ui/progressdialog
UIH = $(TOUI:%=%.h)
TOMOC = main_interface \
......@@ -119,6 +120,10 @@ EXTRA_DIST += \
ui/file_open.ui \
ui/main_interface.ui \
ui/okcanceldialog.ui \
ui/yesnocanceldialog.ui \
ui/logindialog.ui \
ui/inputdialog.ui \
ui/progressdialog.ui \
pixmaps/advanced.xpm \
pixmaps/audio.xpm \
pixmaps/codec.xpm \
......
......@@ -317,7 +317,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
QWidget( _parent ), p_intf( _p_intf )
{
module_config_t *p_item;
module_t *p_module;
module_t *p_module = NULL;
vlc_list_t *p_list = NULL;
global_layout = new QVBoxLayout();
......
......@@ -22,16 +22,23 @@
#include "dialogs/interaction.hpp"
#include <vlc/intf.h>
#include "qt4.hpp"
InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
interaction_dialog_t *_p_dialog ) :
p_intf( _p_intf), p_dialog( _p_dialog )
interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
p_intf( _p_intf), p_dialog( _p_dialog )
{
uiOkCancel = NULL;
uiYesNoCancel = NULL;
uiLogin = NULL;
uiProgress = NULL;
uiInput = NULL;
if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
uiOkCancel = new Ui::OKCancelDialog;
uiOkCancel->setupUi( this );
uiOkCancel->description->setText( p_dialog->psz_description );
uiOkCancel->description->setText( qfu(p_dialog->psz_description) );
connect( uiOkCancel->okButton, SIGNAL( clicked() ),
this, SLOT( OK() ) );
connect( uiOkCancel->cancelButton, SIGNAL( clicked() ),
......@@ -39,11 +46,25 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
uiYesNoCancel = new Ui::YesNoCancelDialog;
uiYesNoCancel->setupUi( this );
uiYesNoCancel->description->setText( qfu(p_dialog->psz_description) );
connect( uiYesNoCancel->yesButton, SIGNAL( clicked() ),
this, SLOT( yes() ) );
connect( uiYesNoCancel->noButton, SIGNAL( clicked() ),
this, SLOT( no() ) );
connect( uiYesNoCancel->cancelButton, SIGNAL( clicked() ),
this, SLOT( cancel() ) );
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
uiLogin = new Ui::LoginDialog;
uiLogin->setupUi( this );
uiLogin->description->setText( qfu(p_dialog->psz_description) );
connect( uiLogin->okButton, SIGNAL( clicked() ),
this, SLOT( OK() ) );
connect( uiLogin->cancelButton, SIGNAL( clicked() ),
this, SLOT( cancel() ) );
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
......@@ -54,6 +75,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else
msg_Err( p_intf, "unknown dialog type" );
setWindowTitle( qfu( p_dialog->psz_title ) );
}
void InteractionDialog::Update()
......@@ -62,24 +84,49 @@ void InteractionDialog::Update()
InteractionDialog::~InteractionDialog()
{
if( uiYesNoCancel ) delete uiYesNoCancel;
if( uiOkCancel ) delete uiOkCancel;
if( uiInput ) delete uiInput;
if( uiProgress) delete uiProgress;
if( uiLogin ) delete uiLogin;
}
void InteractionDialog::yes()
{
Finish( DIALOG_OK_YES );
}
void InteractionDialog::no()
{
Finish( DIALOG_NO );
}
void InteractionDialog::OK()
{
Finish( DIALOG_OK_YES, NULL, NULL );
Finish( DIALOG_OK_YES );
}
void InteractionDialog::cancel()
{
Finish( DIALOG_CANCELLED, NULL, NULL );
Finish( DIALOG_CANCELLED );
}
void InteractionDialog::Finish( int i_ret, QString *r1, QString *r2 )
void InteractionDialog::Finish( int i_ret )
{
vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
p_dialog->i_status = ANSWERED_DIALOG;
p_dialog->i_return = i_ret;
hide();
vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
p_dialog->psz_returned[0] = strdup(
uiLogin->loginEdit->text().toUtf8().data() );
p_dialog->psz_returned[1] = strdup(
uiLogin->passwordEdit->text().toUtf8().data() );
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
p_dialog->psz_returned[0] = strdup(
uiInput->inputEdit->text().toUtf8().data() );
}
p_dialog->i_status = ANSWERED_DIALOG;
p_dialog->i_return = i_ret;
hide();
vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
}
......@@ -25,7 +25,17 @@
#include <vlc/vlc.h>
#include <vlc_interaction.h>
#undef Q_
#include <ui/okcanceldialog.h>
#undef Q_
#include <ui/yesnocanceldialog.h>
#undef Q_
#include <ui/inputdialog.h>
#undef Q_
#include <ui/logindialog.h>
#undef Q_
#include <ui/progressdialog.h>
#undef Q_
class InteractionDialog : public QWidget
{
......@@ -40,10 +50,16 @@ private:
intf_thread_t *p_intf;
interaction_dialog_t *p_dialog;
Ui::OKCancelDialog *uiOkCancel;
Ui::YesNoCancelDialog *uiYesNoCancel;
Ui::LoginDialog *uiLogin;
Ui::InputDialog *uiInput;
Ui::ProgressDialog *uiProgress;
void Finish( int, QString *, QString * );
void Finish( int );
private slots:
void OK();
void yes();
void no();
void cancel();
};
......
......@@ -154,3 +154,16 @@ static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
QApplication::postEvent( DialogsProvider::getInstance( p_intf ),
static_cast<QEvent*>(event) );
}
/*****************************************************************************
* PopupMenuCB: callback to show the popupmenu.
* We don't show the menu directly here because we don't want the
* caller to block for a too long time.
*****************************************************************************/
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
ShowDialog( p_intf, INTF_DIALOG_POPUPMENU, new_val.b_bool, 0 );
return VLC_SUCCESS;
}
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>InputDialog</class>
<widget class="QWidget" name="InputDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>89</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="description" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="inputEdit" />
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>LoginDialog</class>
<widget class="QWidget" name="LoginDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>129</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Login</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="loginEdit" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Password</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="passwordEdit" />
</item>
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="description" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>ProgressDialog</class>
<widget class="QWidget" name="ProgressDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>91</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="description" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar" >
<property name="value" >
<number>24</number>
</property>
<property name="textVisible" >
<bool>true</bool>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>YesNoCancelDialog</class>
<widget class="QWidget" name="YesNoCancelDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>122</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="description" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="yesButton" >
<property name="text" >
<string>Yes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="noButton" >
<property name="text" >
<string>No</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
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