Commit 6ee0559d authored by Clément Stenac's avatar Clément Stenac

A bit of cleanup

Add the qtu (Qt To Utf8) and qta (Qt To Ascii) macros
parent 4b0f3f8d
......@@ -342,24 +342,20 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
QWidget( _parent ), p_intf( _p_intf )
{
module_config_t *p_item;
/* Find our module */
module_t *p_module = NULL;
vlc_list_t *p_list = NULL;
global_layout = new QVBoxLayout();
if( data->i_type == TYPE_CATEGORY )
{
/* TODO */
return;
}
return;
else if( data->i_type == TYPE_MODULE )
{
p_module = (module_t *) vlc_object_get( p_intf, data->i_object_id );
}
else
{
/* List the plugins */
int i_index;
vlc_bool_t b_found = VLC_FALSE;
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
vlc_list_t *p_list = vlc_list_find( p_intf,
VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( !p_list ) return;
for( i_index = 0; i_index < p_list->i_count; i_index++ )
......@@ -394,13 +390,12 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
p_item->i_value == data->i_object_id ) ||
( data->i_type == TYPE_CATSUBCAT &&
p_item->i_value == data->i_subcat_id ) )
{
break;
}
if( p_item->i_type == CONFIG_HINT_END ) break;
} while( p_item++ );
}
global_layout = new QVBoxLayout();
QString head;
if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT )
{
......@@ -460,17 +455,14 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
box = new QGroupBox( qfu(p_item->psz_text) );
boxlayout = new QGridLayout();
}
ConfigControl *control;
if( ! box )
{
control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
p_item, NULL, layout, i_line );
}
else
{
control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
p_item, NULL, boxlayout, i_boxline );
}
if( !control )
{
continue;
......@@ -499,11 +491,6 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
scroller->setWidgetResizable( true );
global_layout->addWidget( scroller );
setLayout( global_layout );
#if 0
some_hidden_text = new QLabel( qfu( I_HIDDEN_ADV ) );
some_hidden_text->setWordWrap( true );
setAdvanced( currently_advanced, true );
#endif
}
void PrefsPanel::apply()
......@@ -513,20 +500,17 @@ void PrefsPanel::apply()
for( i = controls.begin() ; i != controls.end() ; i++ )
{
ConfigControl *c = qobject_cast<ConfigControl *>(*i);
fprintf( stderr, "Get a control %s\n", c->getName() );
switch( c->getType() )
{
case 1:
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
fprintf( stderr, "Put %s = %i\n", vicc->getName(),vicc->getValue() );
config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
break;
}
case 2:
{
VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
fprintf( stderr, "Put %s = %f\n", vfcc->getName(),vfcc->getValue() );
config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
break;
}
......@@ -534,9 +518,7 @@ void PrefsPanel::apply()
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(*i);
fprintf( stderr, "Put %s = %s\n", vscc->getName(),vscc->getValue().toAscii().data() );
config_PutPsz( p_intf, vscc->getName(),
vscc->getValue().toAscii().data() );
config_PutPsz( p_intf, vscc->getName(), qta( vscc->getValue() ) );
}
}
}
......@@ -544,36 +526,3 @@ void PrefsPanel::apply()
void PrefsPanel::clean()
{}
#if 0
void PrefsPanel::setAdvanced( bool adv, bool force )
{
bool some_hidden = false;
if( !force && adv == advanced ) return;
advanced = adv;
QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ )
{
if( (*i)->isAdvanced() )
{
if( !advanced )
{
some_hidden = true;
(*i)->hide();
}
else
(*i)->show();
}
}
if( some_hidden_text )
{
global_layout->removeWidget( some_hidden_text );
some_hidden_text->hide();
}
if( some_hidden )
{
global_layout->addWidget( some_hidden_text );
some_hidden_text->show();
}
}
#endif
......@@ -57,9 +57,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
all = new QRadioButton( "All", types ); tl->addWidget( all );
types->setLayout(tl);
small->setChecked( true );
#if 0
adv_chk = new QCheckBox("Advanced options");
#endif
advanced_tree = NULL;
simple_tree = NULL;
simple_panel = NULL;
......@@ -67,9 +65,6 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
main_layout->addWidget( types, 0,0,1,1 );
main_layout->addWidget( tree_panel, 1,0,1,1 );
#if 0
main_layout->addWidget( adv_chk , 2,0,1,1 );
#endif
main_layout->addWidget( main_panel, 0, 1, 2, 1 );
main_layout->setColumnMinimumWidth( 0, 200 );
......@@ -77,10 +72,6 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
main_layout->setColumnStretch( 1,3 );
setSmall();
#if 0
connect( adv_chk, SIGNAL( toggled(bool) ),
this, SLOT( setAdvanced( bool ) ) );
#endif
QPushButton *save, *cancel;
QHBoxLayout *buttonsLayout =
......@@ -96,13 +87,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) );
connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) );
}
#if 0
void PrefsDialog::setAdvanced( bool advanced )
{
if( advanced_panel )
advanced_panel->setAdvanced( advanced );
}
#endif
void PrefsDialog::setAll()
{
if( simple_tree )
......@@ -130,9 +115,6 @@ void PrefsDialog::setAll()
advanced_panel = new PrefsPanel( main_panel );
main_panel_l->addWidget( advanced_panel );
advanced_panel->show();
#if 0
adv_chk->show();
#endif
}
void PrefsDialog::setSmall()
......@@ -161,9 +143,6 @@ void PrefsDialog::setSmall()
simple_panel = new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat );
main_panel_l->addWidget( simple_panel );
simple_panel->show();
#if 0
adv_chk->hide();
#endif
}
PrefsDialog::~PrefsDialog()
......@@ -195,18 +174,11 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
advanced_panel->hide();
}
if( !data->panel )
{
data->panel = new PrefsPanel( p_intf, main_panel , data, true );
#if 0
adv_chk->isChecked() );
#endif
}
advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel );
advanced_panel->show();
#if 0
setAdvanced( adv_chk->isChecked() );
#endif
}
void PrefsDialog::save()
......
......@@ -178,7 +178,7 @@ void DialogsProvider::simplePLAppendDialog()
QString file;
foreach( file, files )
{
const char * psz_utf8 = file.toUtf8().data();
const char * psz_utf8 = qtu( file );
playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8,
PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END );
}
......@@ -190,7 +190,7 @@ void DialogsProvider::simpleMLAppendDialog()
QString file;
foreach( file, files )
{
const char * psz_utf8 = file.toUtf8().data();
const char * psz_utf8 = qtu( file );
playlist_MLAdd( THEPL, psz_utf8, psz_utf8,
PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END );
}
......@@ -202,7 +202,7 @@ void DialogsProvider::simpleOpenDialog()
QString file;
for( size_t i = 0 ; i< files.size(); i++ )
{
const char * psz_utf8 = files[i].toUtf8().data();
const char * psz_utf8 = qtu( files[i] );
/* Play the first one, parse and enqueue the other ones */
playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8,
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
......@@ -217,7 +217,7 @@ void DialogsProvider::openPlaylist()
QString file;
for( size_t i = 0 ; i< files.size(); i++ )
{
const char * psz_utf8 = files[i].toUtf8().data();
const char * psz_utf8 = qtu( files[i] );
/* Play the first one, parse and enqueue the other ones */
playlist_Import( THEPL, psz_utf8, THEPL->p_root_category, VLC_FALSE );
}
......@@ -227,7 +227,7 @@ void DialogsProvider::openDirectory()
{
QString dir = QFileDialog::getExistingDirectory ( 0,
_("Open directory") );
const char *psz_utf8 = dir.toUtf8().data();
const char *psz_utf8 = qtu( dir );
input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8,
0, NULL, -1 );
playlist_PlaylistAddInput( THEPL, p_input,
......@@ -238,8 +238,7 @@ void DialogsProvider::openMLDirectory()
{
QString dir = QFileDialog::getExistingDirectory ( 0,
_("Open directory") );
const char *psz_utf8 = dir.toUtf8().data();
fprintf( stderr, "%s\n", psz_utf8 );
const char *psz_utf8 = qtu( dir );
input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8,
0, NULL, -1 );
playlist_MLAddInput( THEPL, p_input, PLAYLIST_APPEND, PLAYLIST_END );
......
......@@ -41,8 +41,8 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_shortname( (char*)"QT" );
set_description( (char*)_("QT interface") );
set_shortname( (char *)"Qt" );
set_description( (char*)_("Qt interface") );
set_category( CAT_INTERFACE) ;
set_subcategory( SUBCAT_INTERFACE_MAIN );
set_capability( "interface", 100 );
......@@ -72,7 +72,10 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_intf->p_sys->p_playlist )
{
free( p_intf->p_sys );
return VLC_EGENERIC;
}
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
......@@ -107,15 +110,11 @@ static void Run( intf_thread_t *p_intf )
{
if( p_intf->pf_show_dialog )
{
if( vlc_thread_create( p_intf, "QT dialogs", Init, 0, VLC_TRUE ) )
{
msg_Err( p_intf, "failed to create QT dialogs thread" );
}
if( vlc_thread_create( p_intf, "Qt dialogs", Init, 0, VLC_TRUE ) )
msg_Err( p_intf, "failed to create Qt dialogs thread" );
}
else
{
Init( p_intf );
}
}
static void Init( intf_thread_t *p_intf )
......@@ -131,7 +130,7 @@ static void Init( intf_thread_t *p_intf )
// Initialize timers
DialogsProvider::getInstance( p_intf );
/* Normal interface */
// Normal interface
if( !p_intf->pf_show_dialog )
{
MainInterface *p_mi = new MainInterface( p_intf );
......
......@@ -52,6 +52,8 @@ struct intf_sys_t
#define qfu( i ) QString::fromUtf8( i )
#define qtr( i ) QString::fromUtf8( _(i) )
#define qtu( i ) i.toUtf8().data()
#define qta( i ) i.toAscii().data()
static int DialogEvent_Type = QEvent::User + 1;
......
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