Commit 14e11ab1 authored by zorglub's avatar zorglub
Browse files

Improve Qt interaction stuff

parent 1990bf6f
......@@ -54,9 +54,10 @@ struct interaction_dialog_t
int i_type; ///< Type identifier
char *psz_title; ///< Title
char *psz_description; ///< Descriptor string
char *psz_defaultButton; ///< default button title (~OK)
char *psz_alternateButton;///< alternate button title (~NO)
char *psz_otherButton; ///< other button title (optional,~Cancel)
char *psz_default_button; ///< default button title (~OK)
char *psz_alternate_button;///< alternate button title (~NO)
/// other button title (optional,~Cancel)
char *psz_other_button;
char *psz_returned[1]; ///< returned responses from the user
......
......@@ -432,11 +432,11 @@ struct module_symbols_t
int (*__intf_Interact_inner) (vlc_object_t *,interaction_dialog_t *);
void (*intf_InteractionManage_inner) (playlist_t *);
void (*intf_InteractionDestroy_inner) (interaction_t *);
void (*__intf_UserFatal_inner) (vlc_object_t*, const char*, const char*, ...);
void (*__intf_UserFatal_inner) (vlc_object_t*, vlc_bool_t, const char*, const char*, ...);
int (*__intf_UserLoginPassword_inner) (vlc_object_t*, const char*, const char*, char **, char **);
int (*__intf_UserYesNo_inner) (vlc_object_t*, const char*, const char*);
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
int (*__intf_UserYesNo_inner) (vlc_object_t*, const char*, const char*, const char*, const char*, const char*);
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float, int);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float, int);
void (*__intf_UserHide_inner) (vlc_object_t *, int);
void *__stats_Create_deprecated;
int (*__stats_Update_inner) (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *);
......@@ -509,7 +509,7 @@ struct module_symbols_t
void (*playlist_AddWhereverNeeded_inner) (playlist_t* , input_item_t*, playlist_item_t*,playlist_item_t*,vlc_bool_t, int);
int (*playlist_DeleteFromItemId_inner) (playlist_t *, int);
void (*playlist_NodeDump_inner) (playlist_t *p_playlist, playlist_item_t *p_item, int i_level);
int (*__intf_UserOkayCancel_inner) (vlc_object_t*, const char*, const char*);
void *__intf_UserOkayCancel_deprecated;
int (*__intf_UserStringInput_inner) (vlc_object_t*, const char*, const char*, char **);
void (*playlist_NodesCreateForSD_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **);
vlc_bool_t (*input_AddSubtitles_inner) (input_thread_t *, char *, vlc_bool_t);
......@@ -520,6 +520,8 @@ struct module_symbols_t
void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float);
void *streaming_ChainToPsz_deprecated;
void (*__intf_UserWarn_inner) (vlc_object_t*, const char*, const char*, ...);
vlc_bool_t (*__intf_UserProgressIsCancelled_inner) (vlc_object_t*, int);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -981,7 +983,6 @@ struct module_symbols_t
# define playlist_AddWhereverNeeded (p_symbols)->playlist_AddWhereverNeeded_inner
# define playlist_DeleteFromItemId (p_symbols)->playlist_DeleteFromItemId_inner
# define playlist_NodeDump (p_symbols)->playlist_NodeDump_inner
# define __intf_UserOkayCancel (p_symbols)->__intf_UserOkayCancel_inner
# define __intf_UserStringInput (p_symbols)->__intf_UserStringInput_inner
# define playlist_NodesCreateForSD (p_symbols)->playlist_NodesCreateForSD_inner
# define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner
......@@ -989,6 +990,8 @@ struct module_symbols_t
# define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner
# define __intf_IntfProgressUpdate (p_symbols)->__intf_IntfProgressUpdate_inner
# define __intf_IntfProgress (p_symbols)->__intf_IntfProgress_inner
# define __intf_UserWarn (p_symbols)->__intf_UserWarn_inner
# define __intf_UserProgressIsCancelled (p_symbols)->__intf_UserProgressIsCancelled_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1453,7 +1456,6 @@ struct module_symbols_t
((p_symbols)->playlist_AddWhereverNeeded_inner) = playlist_AddWhereverNeeded; \
((p_symbols)->playlist_DeleteFromItemId_inner) = playlist_DeleteFromItemId; \
((p_symbols)->playlist_NodeDump_inner) = playlist_NodeDump; \
((p_symbols)->__intf_UserOkayCancel_inner) = __intf_UserOkayCancel; \
((p_symbols)->__intf_UserStringInput_inner) = __intf_UserStringInput; \
((p_symbols)->playlist_NodesCreateForSD_inner) = playlist_NodesCreateForSD; \
((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \
......@@ -1461,6 +1463,8 @@ struct module_symbols_t
((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \
((p_symbols)->__intf_IntfProgressUpdate_inner) = __intf_IntfProgressUpdate; \
((p_symbols)->__intf_IntfProgress_inner) = __intf_IntfProgress; \
((p_symbols)->__intf_UserWarn_inner) = __intf_UserWarn; \
((p_symbols)->__intf_UserProgressIsCancelled_inner) = __intf_UserProgressIsCancelled; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
(p_symbols)->playlist_ItemAddParent_deprecated = NULL; \
......@@ -1492,6 +1496,7 @@ struct module_symbols_t
(p_symbols)->stats_HandlerDestroy_deprecated = NULL; \
(p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \
(p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \
(p_symbols)->__intf_UserOkayCancel_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \
(p_symbols)->stats_TimersClean_deprecated = NULL; \
(p_symbols)->streaming_ChainToPsz_deprecated = NULL; \
......
......@@ -138,9 +138,9 @@
NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : _("Error")];
NSString *o_description = [NSString stringWithUTF8String:p_dialog->psz_description ? p_dialog->psz_description : ""];
NSString *o_defaultButton = p_dialog->psz_defaultButton ? [NSString stringWithUTF8String:p_dialog->psz_defaultButton] : nil;
NSString *o_alternateButton = p_dialog->psz_alternateButton ? [NSString stringWithUTF8String:p_dialog->psz_alternateButton] : nil;
NSString *o_otherButton = p_dialog->psz_otherButton ? [NSString stringWithUTF8String:p_dialog->psz_otherButton] : nil;
NSString *o_defaultButton = p_dialog->psz_default_button ? [NSString stringWithUTF8String:p_dialog->psz_default_button] : nil;
NSString *o_alternateButton = p_dialog->psz_alternate_button ? [NSString stringWithUTF8String:p_dialog->psz_alternate_button] : nil;
NSString *o_otherButton = p_dialog->psz_other_button ? [NSString stringWithUTF8String:p_dialog->psz_other_button] : nil;
vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout != NULL )
......
......@@ -12,8 +12,7 @@
AUTOMAKE_OPTIONS = subdir-objects
TOUI = ui/input_stats ui/main_interface ui/file_open \
ui/okcanceldialog ui/yesnocanceldialog ui/logindialog ui/inputdialog \
ui/progressdialog
ui/logindialog ui/inputdialog ui/progressdialog
UIH = $(TOUI:%=%.h)
TOMOC = main_interface \
......@@ -120,8 +119,6 @@ EXTRA_DIST += \
ui/input_stats.ui \
ui/file_open.ui \
ui/main_interface.ui \
ui/okcanceldialog.ui \
ui/yesnocanceldialog.ui \
ui/logindialog.ui \
ui/inputdialog.ui \
ui/progressdialog.ui \
......
......@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include "dialogs/interaction.hpp"
#include "util/qvlcframe.hpp"
#include <vlc/intf.h>
#include "qt4.hpp"
......@@ -28,43 +29,31 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
p_intf( _p_intf), p_dialog( _p_dialog )
{
uiOkCancel = NULL;
uiYesNoCancel = NULL;
QVBoxLayout *layout = new QVBoxLayout;
uiLogin = NULL;
uiProgress = NULL;
uiInput = NULL;
if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
{
uiOkCancel = new Ui::OKCancelDialog;
uiOkCancel->setupUi( this );
uiOkCancel->description->setText( qfu(p_dialog->psz_description) );
connect( uiOkCancel->okButton, SIGNAL( clicked() ),
this, SLOT( OK() ) );
connect( uiOkCancel->cancelButton, SIGNAL( clicked() ),
this, SLOT( cancel() ) );
}
else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
{
// Create instance of the errors dialog
}
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() ) );
description = new QLabel( 0 );
description->setText( qfu(p_dialog->psz_description) );
layout->addWidget(description);
}
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 )
{
......@@ -75,6 +64,19 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
}
else
msg_Err( p_intf, "unknown dialog type" );
QVLCFrame::doButtons( this, layout,
defaultButton, p_dialog->psz_default_button,
altButton, p_dialog->psz_alternate_button,
otherButton, p_dialog->psz_other_button );
if( p_dialog->psz_default_button )
connect( defaultButton, SIGNAL( clicked() ), this, SLOT( defaultB() ) );
if( p_dialog->psz_alternate_button )
connect( altButton, SIGNAL( clicked() ), this, SLOT( altB() ) );
if( p_dialog->psz_other_button )
connect( otherButton, SIGNAL( clicked() ), this, SLOT( otherB() ) );
setLayout( layout );
setWindowTitle( qfu( p_dialog->psz_title ) );
}
......@@ -84,27 +86,20 @@ 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()
void InteractionDialog::defaultB()
{
Finish( DIALOG_OK_YES );
}
void InteractionDialog::no()
void InteractionDialog::altB()
{
Finish( DIALOG_NO );
}
void InteractionDialog::OK()
{
Finish( DIALOG_OK_YES );
}
void InteractionDialog::cancel()
void InteractionDialog::otherB()
{
Finish( DIALOG_CANCELLED );
}
......
......@@ -49,18 +49,18 @@ public:
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;
QPushButton *defaultButton, *otherButton, *altButton;
QLabel *description;
void Finish( int );
private slots:
void OK();
void yes();
void no();
void cancel();
void defaultB();
void altB();
void otherB();
};
#endif
......@@ -315,8 +315,8 @@ PLItem *PLModel::FindByInput( PLItem *root, int i_id )
return FindInner( root, i_id, true );
}
#define CACHE( i, p ) i_cached_id = i; p_cached_item = p;
#define ICACHE( i, p ) i_cached_input_id = i; p_cached_item_bi = p;
#define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
#define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
{
......@@ -356,13 +356,9 @@ PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
if( childFound )
{
if( b_input )
{
ICACHE( i_id, childFound );
}
ICACHE( i_id, childFound )
else
{
CACHE( i_id, childFound );
}
CACHE( i_id, childFound )
return childFound;
}
}
......
......@@ -12,14 +12,6 @@
<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>
......@@ -55,45 +47,6 @@
</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/>
......
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>OKCancelDialog</class>
<widget class="QWidget" name="OKCancelDialog" >
<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="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>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>
......@@ -24,10 +24,14 @@
#define _QVLCFRAME_H_
#include <QWidget>
#include <QSpacerItem>
#include <QHBoxLayout>
#include <QApplication>
#include <QSettings>
#include <QMainWindow>
#include <QPlastiqueStyle>
#include <QPushButton>
#include "qt4.hpp"
#include <vlc/vlc.h>
class QVLCFrame : public QWidget
......@@ -52,6 +56,39 @@ public:
}
#endif
}
static void doButtons( QWidget *w, QBoxLayout *l,
QPushButton *defaul, char *psz_default,
QPushButton *alt, char *psz_alt,
QPushButton *other, char *psz_other )
{
#ifdef QT42
#else
QHBoxLayout *buttons_layout = new QHBoxLayout;
QSpacerItem *spacerItem = new QSpacerItem( 40, 20,
QSizePolicy::Expanding, QSizePolicy::Minimum);
buttons_layout->addItem( spacerItem );
if( psz_default )
{
defaul = new QPushButton;
buttons_layout->addWidget( defaul );
defaul->setText( qfu( psz_default ) );
}
if( psz_alt )
{
alt = new QPushButton;
buttons_layout->addWidget( alt );
alt->setText( qfu( psz_alt ) );
}
if( psz_other )
{
other = new QPushButton;
buttons_layout->addWidget( other );
other->setText( qfu( psz_other ) );
}
l->addLayout( buttons_layout );
#endif
};
QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
{
......
Supports Markdown
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