Commit c5ee72d4 authored by Clément Stenac's avatar Clément Stenac

Implementation of login, input and progress dialogs in Qt

(untested)
parent 6192caae
......@@ -12,7 +12,7 @@
AUTOMAKE_OPTIONS = subdir-objects
TOUI = ui/input_stats ui/main_interface ui/file_open \
ui/logindialog ui/inputdialog ui/progressdialog ui/sprefs_trivial \
ui/sprefs_trivial \
ui/sprefs_audio ui/sprefs_playlist ui/sprefs_subtitles \
ui/sprefs_video ui/sprefs_interface
UIH = $(TOUI:%=%.h)
......@@ -137,9 +137,6 @@ EXTRA_DIST += \
ui/input_stats.ui \
ui/file_open.ui \
ui/main_interface.ui \
ui/logindialog.ui \
ui/inputdialog.ui \
ui/progressdialog.ui \
ui/sprefs_trivial.ui \
ui/sprefs_audio.ui \
ui/sprefs_video.ui \
......
......@@ -20,12 +20,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include <QMessageBox>
#include "qt4.hpp"
#include "dialogs/errors.hpp"
#include "dialogs/interaction.hpp"
#include "util/qvlcframe.hpp"
#include <vlc/intf.h>
#include "qt4.hpp"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QProgressBar>
#include <QMessageBox>
#include <assert.h>
InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
......@@ -33,9 +39,6 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
{
QVBoxLayout *layout = new QVBoxLayout( this );
int i_ret = -1;
uiLogin = NULL;
uiProgress = NULL;
uiInput = NULL;
panel = NULL;
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
......@@ -46,7 +49,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
{
if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
if( config_GetInt( p_intf, "errors-dialog" ) != 0 )
ErrorsDialog::getInstance( p_intf )->addError(
qfu( p_dialog->psz_title ), qfu( p_dialog->psz_description ) );
i_ret = 0;
......@@ -54,7 +57,7 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else if( p_dialog->i_flags & DIALOG_WARNING )
{
if( config_GetInt( p_intf, "qt-show-errors" ) != 0 )
if( config_GetInt( p_intf, "errors-dialog" ) != 0 )
ErrorsDialog::getInstance( p_intf )->addWarning(
qfu( p_dialog->psz_title ),qfu( p_dialog->psz_description ) );
i_ret = 0;
......@@ -74,16 +77,40 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
panel = new QWidget( 0 );
uiLogin = new Ui::LoginDialog;
uiLogin->setupUi( panel );
uiLogin->description->setText( qfu(p_dialog->psz_description) );
QGridLayout *grid = new QGridLayout;
description = new QLabel( qfu( p_dialog->psz_description ) );
grid->addWidget( description, 0, 0, 1, 2 );
grid->addWidget( new QLabel( qtr( "Login") ), 1, 0 );
loginEdit = new QLineEdit;
grid->addWidget( loginEdit, 1, 1 );
grid->addWidget( new QLabel( qtr("Password") ), 2, 0);
passwordEdit = new QLineEdit;
grid->addWidget( passwordEdit, 2, 1 );
panel->setLayout( grid );
layout->addWidget( panel );
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
progressBar = new QProgressBar;
progressBar->setMaximum( 1000 );
progressBar->setTextVisible( true );
progressBar->setOrientation(Qt::Horizontal);
layout->addWidget( progressBar );
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
description = new QLabel( qfu( p_dialog->psz_description ) );
layout->addWidget( description );
inputEdit = new QLineEdit;
layout->addWidget( inputEdit );
}
else
msg_Err( p_intf, "unknown dialog type" );
......@@ -116,14 +143,16 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
void InteractionDialog::Update()
{
if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
assert( progressBar );
progressBar->setValue( (int)(p_dialog->val.f_float*1000) );
}
}
InteractionDialog::~InteractionDialog()
{
if( panel ) delete panel;
if( uiInput ) delete uiInput;
if( uiProgress) delete uiProgress;
if( uiLogin ) delete uiLogin;
}
void InteractionDialog::defaultB()
......@@ -145,15 +174,12 @@ void InteractionDialog::Finish( int i_ret )
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() );
p_dialog->psz_returned[0] = strdup( qtu( loginEdit->text() ) );
p_dialog->psz_returned[1] = strdup( qtu( passwordEdit->text() ) );
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
p_dialog->psz_returned[0] = strdup(
uiInput->inputEdit->text().toUtf8().data() );
p_dialog->psz_returned[0] = strdup( qtu( inputEdit->text() ) );
}
p_dialog->i_status = ANSWERED_DIALOG;
p_dialog->i_return = i_ret;
......
......@@ -25,15 +25,13 @@
#include <vlc/vlc.h>
#include <vlc_interaction.h>
#undef Q_
#include <ui/inputdialog.h>
#undef Q_
#include <ui/logindialog.h>
#undef Q_
#include <ui/progressdialog.h>
#undef Q_
#include <QWidget>
class QPushButton;
class QLabel;
class QProgressBar;
class QLineEdit;
class InteractionDialog : public QWidget
{
Q_OBJECT
......@@ -47,12 +45,11 @@ private:
QWidget *panel;
intf_thread_t *p_intf;
interaction_dialog_t *p_dialog;
Ui::LoginDialog *uiLogin;
Ui::InputDialog *uiInput;
Ui::ProgressDialog *uiProgress;
QPushButton *defaultButton, *otherButton, *altButton;
QLabel *description;
QProgressBar *progressBar;
QLineEdit *inputEdit, *loginEdit, *passwordEdit;
void Finish( int );
private slots:
......
<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="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>
</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>
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