Commit 897144d1 authored by Clément Stenac's avatar Clément Stenac

Some cleanup here and there

* Add a CONNECT macro for simple signal->slot connections 
* Untested save support in simple preferences
parent cd3849e8
...@@ -45,9 +45,12 @@ void InputStatsPanel::Update( input_item_t *p_item ) ...@@ -45,9 +45,12 @@ void InputStatsPanel::Update( input_item_t *p_item )
{ QString str; ui.widget->setText( str.sprintf( format, ## calc ) ); } { QString str; ui.widget->setText( str.sprintf( format, ## calc ) ); }
UPDATE( read_text, "%8.0f kB", (float)(p_item->p_stats->i_read_bytes)/1000); UPDATE( read_text, "%8.0f kB", (float)(p_item->p_stats->i_read_bytes)/1000);
UPDATE( input_bitrate_text, "%6.0f kb/s", (float)(p_item->p_stats->f_input_bitrate * 8000 )); UPDATE( input_bitrate_text, "%6.0f kb/s",
UPDATE( demuxed_text, "%8.0f kB", (float)(p_item->p_stats->i_demux_read_bytes)/1000 ); (float)(p_item->p_stats->f_input_bitrate * 8000 ));
UPDATE( stream_bitrate_text, "%6.0f kb/s", (float)(p_item->p_stats->f_demux_bitrate * 8000 )); UPDATE( demuxed_text, "%8.0f kB",
(float)(p_item->p_stats->i_demux_read_bytes)/1000 );
UPDATE( stream_bitrate_text, "%6.0f kb/s",
(float)(p_item->p_stats->f_demux_bitrate * 8000 ));
/* Video */ /* Video */
UPDATE( vdecoded_text, "%5i", p_item->p_stats->i_decoded_video ); UPDATE( vdecoded_text, "%5i", p_item->p_stats->i_decoded_video );
......
...@@ -21,21 +21,23 @@ ...@@ -21,21 +21,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "qt4.hpp"
#include "playlist_model.hpp" #include "playlist_model.hpp"
#include "components/playlist/panels.hpp" #include "components/playlist/panels.hpp"
#include "util/customwidgets.hpp"
#include <QTreeView> #include <QTreeView>
#include <QPushButton> #include <QPushButton>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QKeyEvent> #include <QKeyEvent>
#include "qt4.hpp"
#include <assert.h>
#include <QModelIndexList> #include <QModelIndexList>
#include <QToolBar> #include <QToolBar>
#include <QLabel> #include <QLabel>
#include <QSpacerItem> #include <QSpacerItem>
#include "util/customwidgets.hpp"
#include <assert.h>
StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
playlist_t *p_playlist, playlist_t *p_playlist,
...@@ -52,15 +54,12 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, ...@@ -52,15 +54,12 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
view->header()->setClickable( true ); view->header()->setClickable( true );
view->setSelectionMode( QAbstractItemView::ExtendedSelection ); view->setSelectionMode( QAbstractItemView::ExtendedSelection );
connect( view, SIGNAL( activated( const QModelIndex& ) ), model, CONNECT( view, activated( const QModelIndex& ) ,
SLOT( activateItem( const QModelIndex& ) ) ); model,activateItem( const QModelIndex& ) );
CONNECT( view, rightClicked( QModelIndex , QPoint ),
connect( view, SIGNAL( rightClicked( QModelIndex , QPoint ) ), this, doPopup( QModelIndex, QPoint ) );
this, SLOT( doPopup( QModelIndex, QPoint ) ) ); CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) );
connect( model,
SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ),
this, SLOT( handleExpansion( const QModelIndex& ) ) );
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->setMargin( 0 );
......
...@@ -20,20 +20,7 @@ ...@@ -20,20 +20,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "components/preferences.hpp"
#include "components/preferences_widgets.hpp"
#include "qt4.hpp"
#include <vlc_config_cat.h>
#include <vlc_intf_strings.h>
#include <assert.h>
#include "pixmaps/audio.xpm"
#include "pixmaps/video.xpm"
#include "pixmaps/type_net.xpm"
#include "pixmaps/type_playlist.xpm"
#include "pixmaps/advanced.xpm"
#include "pixmaps/codec.xpm"
#include "pixmaps/intf.xpm"
#include <QApplication> #include <QApplication>
#include <QLabel> #include <QLabel>
#include <QTreeWidget> #include <QTreeWidget>
...@@ -47,10 +34,25 @@ ...@@ -47,10 +34,25 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QGridLayout> #include <QGridLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QPalette> #include <QPalette>
#include <QColor> #include <QColor>
#include "components/preferences.hpp"
#include "components/preferences_widgets.hpp"
#include "qt4.hpp"
#include <vlc_config_cat.h>
#include <vlc_intf_strings.h>
#include <assert.h>
#include "pixmaps/audio.xpm"
#include "pixmaps/video.xpm"
#include "pixmaps/type_net.xpm"
#include "pixmaps/type_playlist.xpm"
#include "pixmaps/advanced.xpm"
#include "pixmaps/codec.xpm"
#include "pixmaps/intf.xpm"
#define ITEM_HEIGHT 25 #define ITEM_HEIGHT 25
/********************************************************************* /*********************************************************************
...@@ -69,9 +71,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -69,9 +71,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
setAlternatingRowColors( true ); setAlternatingRowColors( true );
header()->hide(); header()->hide();
QFont myFont = QApplication::font(0);
myFont.setPointSize( myFont.pointSize() + 3 ); myFont.setBold( true );
#define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b##_xpm )) #define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b##_xpm ))
BI( audio, audio ); BI( audio, audio );
BI( video, video ); BI( video, video );
...@@ -338,7 +337,7 @@ PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent ) ...@@ -338,7 +337,7 @@ PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent )
{} {}
PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
PrefsItemData * data, bool currently_advanced ) : PrefsItemData * data ) :
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
module_config_t *p_item; module_config_t *p_item;
...@@ -464,9 +463,8 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -464,9 +463,8 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
control = ConfigControl::createControl( VLC_OBJECT( p_intf ), control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
p_item, NULL, boxlayout, i_boxline ); p_item, NULL, boxlayout, i_boxline );
if( !control ) if( !control )
{
continue; continue;
}
if( box ) i_boxline++; if( box ) i_boxline++;
else i_line++; else i_line++;
controls.append( control ); controls.append( control );
...@@ -495,34 +493,12 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -495,34 +493,12 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
void PrefsPanel::apply() void PrefsPanel::apply()
{ {
/* todo */
QList<ConfigControl *>::Iterator i; QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ ) for( i = controls.begin() ; i != controls.end() ; i++ )
{ {
ConfigControl *c = qobject_cast<ConfigControl *>(*i); ConfigControl *c = qobject_cast<ConfigControl *>(*i);
switch( c->getType() ) c->doApply( p_intf );
{
case 1:
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
break;
}
case 2:
{
VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
break;
}
case 3:
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(*i);
config_PutPsz( p_intf, vscc->getName(), qta( vscc->getValue() ) );
}
}
} }
} }
void PrefsPanel::clean() void PrefsPanel::clean()
{} {}
...@@ -78,7 +78,7 @@ class PrefsPanel : public QWidget ...@@ -78,7 +78,7 @@ class PrefsPanel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData *, bool ); PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData * );
PrefsPanel( QWidget *); PrefsPanel( QWidget *);
virtual ~PrefsPanel() {}; virtual ~PrefsPanel() {};
void apply(); void apply();
...@@ -87,15 +87,6 @@ private: ...@@ -87,15 +87,6 @@ private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
QList<ConfigControl *> controls; QList<ConfigControl *> controls;
QVBoxLayout *global_layout; QVBoxLayout *global_layout;
#if 0
QLabel *some_hidden_text;
bool advanced;
#endif
public slots:
#if 0
void setAdvanced( bool, bool );
void setAdvanced( bool a ) { return setAdvanced( a, false ); }
#endif
}; };
#endif #endif
...@@ -105,6 +105,32 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -105,6 +105,32 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
return p_control; return p_control;
} }
void ConfigControl::doApply( intf_thread_t *p_intf )
{
switch( getType() )
{
case 1:
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
break;
}
case 2:
{
VFloatConfigControl *vfcc =
qobject_cast<VFloatConfigControl *>(this);
config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
break;
}
case 3:
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(this);
config_PutPsz( p_intf, vscc->getName(), qta( vscc->getValue() ) );
}
}
}
/************************************************************************** /**************************************************************************
* String-based controls * String-based controls
*************************************************************************/ *************************************************************************/
......
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
static ConfigControl * createControl( vlc_object_t*, static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*, module_config_t*,QWidget*,
QGridLayout *, int); QGridLayout *, int);
void doApply( intf_thread_t *);
protected: protected:
vlc_object_t *p_this; vlc_object_t *p_this;
module_config_t *p_item; module_config_t *p_item;
...@@ -196,18 +197,6 @@ public: ...@@ -196,18 +197,6 @@ public:
private: private:
void finish(); void finish();
}; };
#if 0
class FloatConfigControl : public VFloatConfigControl
{
public:
FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
ConfigControl(a,b,c) {};
virtual ~FloatConfigControl() {};
virtual float getValue();
private:
QDoubleSpinBox *spin;
};
#endif
/******************************************************* /*******************************************************
* String-based controls * String-based controls
......
...@@ -22,15 +22,17 @@ ...@@ -22,15 +22,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <QListWidget>
#include <QListWidgetItem>
#include <QString>
#include <QFont>
#include "components/simple_preferences.hpp" #include "components/simple_preferences.hpp"
#include "components/preferences_widgets.hpp" #include "components/preferences_widgets.hpp"
#include "qt4.hpp" #include "qt4.hpp"
#include <vlc_config_cat.h> #include <vlc_config_cat.h>
#include <assert.h> #include <assert.h>
#include <QListWidget>
#include <QListWidgetItem>
#include <QString>
#include <QFont>
#include "pixmaps/advanced_50x50.xpm" #include "pixmaps/advanced_50x50.xpm"
#include "pixmaps/audio_50x50.xpm" #include "pixmaps/audio_50x50.xpm"
...@@ -58,50 +60,23 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -58,50 +60,23 @@ SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) ); setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
setAlternatingRowColors( true ); setAlternatingRowColors( true );
#ifndef WIN32
// Fixme - A bit UGLY
QFont f = font();
int pSize = f.pointSize();
if( pSize > 0 )
f.setPointSize( pSize + 1 );
else
f.setPixelSize( f.pixelSize() + 1 );
setFont( f );
#endif
#define ADD_CATEGORY( id, label, icon ) \ #define ADD_CATEGORY( id, label, icon ) \
addItem( label ); \ addItem( label ); \
item( id )->setIcon( QIcon( QPixmap( icon ) ) ); \ item( id )->setIcon( QIcon( QPixmap( icon ) ) ); \
item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) ); item( id )->setData( Qt::UserRole, qVariantFromValue( (int)id ) );
ADD_CATEGORY( SPrefsVideo, "Video", video_50x50_xpm ); ADD_CATEGORY( SPrefsVideo, qtr("Video"), video_50x50_xpm );
ADD_CATEGORY( SPrefsAudio, "Audio", audio_50x50_xpm ); ADD_CATEGORY( SPrefsAudio, qtr("Audio"), audio_50x50_xpm );
ADD_CATEGORY( SPrefsInputAndCodecs, "Input and Codecs", ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
input_and_codecs_50x50_xpm ); input_and_codecs_50x50_xpm );
ADD_CATEGORY( SPrefsPlaylist, "Playlist", playlist_50x50_xpm ); ADD_CATEGORY( SPrefsPlaylist, qtr("Playlist"), playlist_50x50_xpm );
ADD_CATEGORY( SPrefsInterface, "Interface", interface_50x50_xpm ); ADD_CATEGORY( SPrefsInterface, qtr("Interface"), interface_50x50_xpm );
ADD_CATEGORY( SPrefsSubtitles, "Subtitles", subtitles_50x50_xpm ); ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"), subtitles_50x50_xpm );
ADD_CATEGORY( SPrefsAdvanced, "Advanced", advanced_50x50_xpm ); ADD_CATEGORY( SPrefsAdvanced, qtr("Advanced"), advanced_50x50_xpm );
setCurrentRow( SPrefsInterface ); setCurrentRow( SPrefsInterface );
} }
void SPrefsCatList::applyAll()
{
doAll( false );
}
void SPrefsCatList::cleanAll()
{
doAll( true );
}
/// \todo When cleaning, we should remove the panel ?
void SPrefsCatList::doAll( bool doclean )
{
/* Todo */
}
/********************************************************************* /*********************************************************************
* The Panels * The Panels
*********************************************************************/ *********************************************************************/
...@@ -187,33 +162,15 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -187,33 +162,15 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
} }
} }
void SPrefsPanel::Apply() void SPrefsPanel::apply()
{ {
/* todo: factorize with PrefsPanel */
QList<ConfigControl *>::Iterator i; QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ ) for( i = controls.begin() ; i != controls.end() ; i++ )
{ {
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i); ConfigControl *c = qobject_cast<ConfigControl *>(*i);
if( !vicc ) c->doApply( p_intf );
{
VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
if( !vfcc)
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(*i);
assert( vscc );
config_PutPsz( p_intf, vscc->getName(),
vscc->getValue().toAscii().data() );
continue;
}
config_PutFloat( p_intf, vfcc->getName(),
vfcc->getValue() );
continue;
}
config_PutInt( p_intf, vicc->getName(),
vicc->getValue() );
} }
} }
void SPrefsPanel::Clean() void SPrefsPanel::clean()
{} {}
...@@ -29,13 +29,14 @@ ...@@ -29,13 +29,14 @@
#include <vlc/intf.h> #include <vlc/intf.h>
enum { enum {
SPrefsVideo, SPrefsVideo = 0,
SPrefsAudio, SPrefsAudio,
SPrefsInputAndCodecs, SPrefsInputAndCodecs,
SPrefsPlaylist, SPrefsPlaylist,
SPrefsInterface, SPrefsInterface,
SPrefsSubtitles, SPrefsSubtitles,
SPrefsAdvanced SPrefsAdvanced,
SPrefsMax
}; };
#define SPrefsDefaultCat SPrefsInterface #define SPrefsDefaultCat SPrefsInterface
...@@ -47,12 +48,7 @@ class SPrefsCatList : public QListWidget ...@@ -47,12 +48,7 @@ class SPrefsCatList : public QListWidget
public: public:
SPrefsCatList( intf_thread_t *, QWidget *); SPrefsCatList( intf_thread_t *, QWidget *);
virtual ~SPrefsCatList() {}; virtual ~SPrefsCatList() {};
void applyAll();
void cleanAll();
private: private:
void doAll( bool );
intf_thread_t *p_intf; intf_thread_t *p_intf;
}; };
...@@ -62,8 +58,8 @@ class SPrefsPanel : public QWidget ...@@ -62,8 +58,8 @@ class SPrefsPanel : public QWidget
public: public:
SPrefsPanel( intf_thread_t *, QWidget *, int ); SPrefsPanel( intf_thread_t *, QWidget *, int );
virtual ~SPrefsPanel() {}; virtual ~SPrefsPanel() {};
void Apply(); void apply();
void Clean(); void clean();
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
QList<ConfigControl *> controls; QList<ConfigControl *> controls;
......
...@@ -64,14 +64,10 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf ) ...@@ -64,14 +64,10 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
layout->addWidget(clearButton, 1, 4 ); layout->addWidget(clearButton, 1, 4 );
layout->addWidget(closeButton, 1, 5 ); layout->addWidget(closeButton, 1, 5 );
connect( closeButton, SIGNAL( clicked() ) , CONNECT( closeButton, clicked(), this, close() );
this, SLOT( onCloseButton())); CONNECT( clearButton, clicked(), this, clear() );
connect( clearButton, SIGNAL( clicked() ) , CONNECT( saveLogButton, clicked(), this, save() );
this, SLOT( onClearButton())); CONNECT( THEDP->fixed_timer, timeout(), this, updateLog() );
connect( saveLogButton, SIGNAL( clicked() ) ,
this, SLOT( onSaveButton()));
connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT(updateLog() ) );
} }
MessagesDialog::~MessagesDialog() MessagesDialog::~MessagesDialog()
...@@ -153,25 +149,24 @@ void MessagesDialog::updateLog() ...@@ -153,25 +149,24 @@ void MessagesDialog::updateLog()
} }
} }
void MessagesDialog::onCloseButton() void MessagesDialog::close()
{ {
this->toggleVisible(); this->toggleVisible();
} }
void MessagesDialog::onClearButton() void MessagesDialog::clear()
{ {
messages->clear(); messages->clear();
} }
bool MessagesDialog::onSaveButton() bool MessagesDialog::save()
{ {
QString saveLogFileName = QFileDialog::getSaveFileName( QString saveLogFileName = QFileDialog::getSaveFileName(
this, this, qtr("Choose a filename to save the logs under..."),
"Choose a filename to save the logs under...",
p_intf->p_vlc->psz_homedir, p_intf->p_vlc->psz_homedir,
"Texts / Logs (*.log *.txt);; All (*.*) "); "Texts / Logs (*.log *.txt);; All (*.*) ");
if (saveLogFileName != NULL) if( saveLogFileName != NULL )
{ {
QFile file(saveLogFileName); QFile file(saveLogFileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) { if (!file.open(QFile::WriteOnly | QFile::Text)) {
......
...@@ -50,9 +50,9 @@ private: ...@@ -50,9 +50,9 @@ private:
QTextEdit *messages; QTextEdit *messages;
public slots: public slots:
void updateLog(); void updateLog();
void onCloseButton(); void close();
void onClearButton(); void clear();
bool onSaveButton(); bool save();
}; };
#endif #endif
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QCheckBox> #include <QCheckBox>
PrefsDialog *PrefsDialog::instance = NULL; PrefsDialog *PrefsDialog::instance = NULL;
PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
...@@ -74,18 +75,19 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -74,18 +75,19 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
setSmall(); setSmall();
QPushButton *save, *cancel; QPushButton *save, *cancel;
QHBoxLayout *buttonsLayout = QHBoxLayout *buttonsLayout = QVLCFrame::doButtons( this, NULL,
QVLCFrame::doButtons( this, NULL, &save, _("Save"), &save, _("Save"),
&cancel, _("Cancel"), &cancel, _("Cancel"),
NULL, NULL ); NULL, NULL );
connect( save, SIGNAL( clicked() ), this, SLOT( save() ) );
connect( cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
main_layout->addLayout( buttonsLayout, 2,0, 1 ,3 ); main_layout->addLayout( buttonsLayout, 2,0, 1 ,3 );
setLayout( main_layout ); setLayout( main_layout );
connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) ); CONNECT( save, clicked(), this, save() );
connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) ); CONNECT( cancel, clicked(), this, cancel() );
CONNECT( small, clicked(), this, setSmall() );
CONNECT( all, clicked(), this, setAll() );
for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL;
} }
void PrefsDialog::setAll() void PrefsDialog::setAll()
...@@ -127,9 +129,9 @@ void PrefsDialog::setSmall() ...@@ -127,9 +129,9 @@ void PrefsDialog::setSmall()
if( !simple_tree ) if( !simple_tree )
{ {
simple_tree = new SPrefsCatList( p_intf, tree_panel ); simple_tree = new SPrefsCatList( p_intf, tree_panel );
connect( simple_tree, CONNECT( simple_tree,
SIGNAL( currentItemChanged( QListWidgetItem *, QListWidgetItem *) ), currentItemChanged( QListWidgetItem *, QListWidgetItem *),
this, SLOT( changeSimplePanel( QListWidgetItem * ) ) ); this, changeSimplePanel( QListWidgetItem * ) );
} }
tree_panel_l->addWidget( simple_tree ); tree_panel_l->addWidget( simple_tree );
simple_tree->show(); simple_tree->show();
...@@ -145,10 +147,6 @@ void PrefsDialog::setSmall() ...@@ -145,10 +147,6 @@ void PrefsDialog::setSmall()
simple_panel->show(); simple_panel->show();
} }
PrefsDialog::~PrefsDialog()
{
}
void PrefsDialog::changeSimplePanel( QListWidgetItem *item ) void PrefsDialog::changeSimplePanel( QListWidgetItem *item )
{ {
int number = item->data( Qt::UserRole ).toInt(); int number = item->data( Qt::UserRole ).toInt();
...@@ -156,10 +154,10 @@ void PrefsDialog::changeSimplePanel( QListWidgetItem *item ) ...@@ -156,10 +154,10 @@ void PrefsDialog::changeSimplePanel( QListWidgetItem *item )
{ {
main_panel_l->removeWidget( simple_panel ); main_panel_l->removeWidget( simple_panel );
simple_panel->hide(); simple_panel->hide();
/* Don't do this once it works, you would loose all changes */
delete simple_panel;
} }
if( !simple_panels[number] )
simple_panel = new SPrefsPanel( p_intf, main_panel, number ); simple_panel = new SPrefsPanel( p_intf, main_panel, number );
simple_panels[number] = simple_panel;
main_panel_l->addWidget( simple_panel ); main_panel_l->addWidget( simple_panel );
simple_panel->show(); simple_panel->show();
} }
...@@ -174,7 +172,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -174,7 +172,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
advanced_panel->hide(); advanced_panel->hide();
} }
if( !data->panel ) if( !data->panel )
data->panel = new PrefsPanel( p_intf, main_panel , data, true ); data->panel = new PrefsPanel( p_intf, main_panel , data );
advanced_panel = data->panel; advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
...@@ -184,7 +182,10 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -184,7 +182,10 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
void PrefsDialog::save() void PrefsDialog::save()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
simple_tree->applyAll(); {
for( int i = 0 ; i< SPrefsMax; i++ )
if( simple_panels[i] ) simple_panels[i]->apply();
}
else if( all->isChecked() && advanced_tree ) else if( all->isChecked() && advanced_tree )
advanced_tree->applyAll(); advanced_tree->applyAll();
config_SaveConfigFile( p_intf, NULL ); config_SaveConfigFile( p_intf, NULL );
...@@ -195,8 +196,8 @@ void PrefsDialog::cancel() ...@@ -195,8 +196,8 @@ void PrefsDialog::cancel()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
{ {
simple_tree->cleanAll(); for( int i = 0 ; i< SPrefsMax; i++ )
simple_panel = NULL; if( simple_panels[i] ) simple_panels[i]->clean();
} }
else if( all->isChecked() && advanced_tree ) else if( all->isChecked() && advanced_tree )
{ {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define _PREFS_DIALOG_H_ #define _PREFS_DIALOG_H_
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/simple_preferences.hpp"
class PrefsTree; class PrefsTree;
class SPrefsCatList; class SPrefsCatList;
...@@ -51,7 +52,7 @@ public: ...@@ -51,7 +52,7 @@ public:
instance = new PrefsDialog( _p_intf ); instance = new PrefsDialog( _p_intf );
return instance; return instance;
} }
virtual ~PrefsDialog(); virtual ~PrefsDialog() {};
private: private:
PrefsDialog( intf_thread_t * ); PrefsDialog( intf_thread_t * );
...@@ -59,6 +60,7 @@ private: ...@@ -59,6 +60,7 @@ private:
QHBoxLayout *main_panel_l; QHBoxLayout *main_panel_l;
PrefsPanel *advanced_panel; PrefsPanel *advanced_panel;
SPrefsPanel *simple_panel; SPrefsPanel *simple_panel;
SPrefsPanel *simple_panels[SPrefsMax];
QWidget *tree_panel; QWidget *tree_panel;
QHBoxLayout *tree_panel_l; QHBoxLayout *tree_panel_l;
...@@ -67,9 +69,6 @@ private: ...@@ -67,9 +69,6 @@ private:
QGroupBox *types; QGroupBox *types;
QRadioButton *small,*all; QRadioButton *small,*all;
#if 0
QCheckBox *adv_chk;
#endif
QGridLayout *main_layout; QGridLayout *main_layout;
...@@ -81,9 +80,6 @@ private slots: ...@@ -81,9 +80,6 @@ private slots:
void setSmall(); void setSmall();
void save(); void save();
void cancel(); void cancel();
#if 0
void setAdvanced( bool );
#endif
}; };
#endif #endif
...@@ -19,18 +19,22 @@ ...@@ -19,18 +19,22 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include "qt4.hpp"
#include <QEvent> #include <QEvent>
#include <QApplication>
#include <QSignalMapper>
#include <QFileDialog>
#include "qt4.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "menus.hpp"
#include <vlc_intf_strings.h>
/* The dialogs */
#include "dialogs/playlist.hpp" #include "dialogs/playlist.hpp"
#include "dialogs/prefs_dialog.hpp" #include "dialogs/prefs_dialog.hpp"
#include "dialogs/streaminfo.hpp" #include "dialogs/streaminfo.hpp"
#include "dialogs/messages.hpp" #include "dialogs/messages.hpp"
#include <QApplication>
#include <QSignalMapper>
#include "menus.hpp"
#include <vlc_intf_strings.h>
#include <QFileDialog>
DialogsProvider* DialogsProvider::instance = NULL; DialogsProvider* DialogsProvider::instance = NULL;
...@@ -41,12 +45,11 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) : ...@@ -41,12 +45,11 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
fixed_timer->start( 150 /* milliseconds */ ); fixed_timer->start( 150 /* milliseconds */ );
menusMapper = new QSignalMapper(); menusMapper = new QSignalMapper();
connect( menusMapper, SIGNAL( mapped(QObject *) ), this, CONNECT( menusMapper, mapped(QObject *), this, menuAction( QObject *) );
SLOT(menuAction( QObject *)) );
menusUpdateMapper = new QSignalMapper(); menusUpdateMapper = new QSignalMapper();
connect( menusUpdateMapper, SIGNAL( mapped(QObject *) ), this, CONNECT( menusUpdateMapper, mapped(QObject *),
SLOT(menuUpdateAction( QObject *)) ); this, menuUpdateAction( QObject *) );
} }
void DialogsProvider::customEvent( QEvent *event ) void DialogsProvider::customEvent( QEvent *event )
......
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <QApplication> #include <QApplication>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "dialogs/interaction.hpp" #include "dialogs/interaction.hpp"
#include <assert.h> #include <assert.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
class QEvent; class QEvent;
class QSignalMapper; class QSignalMapper;
...@@ -87,5 +89,4 @@ public slots: ...@@ -87,5 +89,4 @@ public slots:
void quit(); void quit();
}; };
#endif #endif
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include <assert.h> #include <assert.h>
#include "qt4.hpp"
#include "input_manager.hpp" #include "input_manager.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "qt4.hpp"
static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o, static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param ); vlc_value_t n, void *param );
...@@ -41,8 +41,7 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : ...@@ -41,8 +41,7 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
{ {
i_old_playing_status = END_S; i_old_playing_status = END_S;
p_input = NULL; p_input = NULL;
/* Subscribe to updates */ CONNECT( THEDP->fixed_timer, timeout(), this, update() );
connect( THEDP->fixed_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
} }
InputManager::~InputManager() InputManager::~InputManager()
...@@ -174,11 +173,10 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL), ...@@ -174,11 +173,10 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL),
p_input = NULL; p_input = NULL;
im = new InputManager( this, p_intf ); im = new InputManager( this, p_intf );
/* Get timer updates */ /* Get timer updates */
connect( DialogsProvider::getInstance(p_intf)->fixed_timer, CONNECT( THEDP->fixed_timer, timeout(), this, updateInput() );
SIGNAL(timeout() ), this, SLOT( updateInput() ) );
/* Warn our embedded IM about input changes */ /* Warn our embedded IM about input changes */
connect( this, SIGNAL( inputChanged( input_thread_t * ) ), CONNECT( this, inputChanged( input_thread_t * ),
im, SLOT( setInput( input_thread_t * ) ) ); im, setInput( input_thread_t * ) );
} }
MainInputManager::~MainInputManager() MainInputManager::~MainInputManager()
...@@ -232,6 +230,7 @@ static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o, ...@@ -232,6 +230,7 @@ static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
InputManager *im = (InputManager*)param; InputManager *im = (InputManager*)param;
im->b_has_audio = true; im->b_has_audio = true;
} }
static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o, static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param ) vlc_value_t n, void *param )
{ {
......
...@@ -21,15 +21,16 @@ ...@@ -21,15 +21,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "menus.hpp"
#include "dialogs_provider.hpp"
#include "input_manager.hpp"
#include <QMenu> #include <QMenu>
#include <QMenuBar> #include <QMenuBar>
#include <QAction> #include <QAction>
#include <QActionGroup> #include <QActionGroup>
#include <QSignalMapper> #include <QSignalMapper>
#include "menus.hpp"
#include "dialogs_provider.hpp"
#include "input_manager.hpp"
enum enum
{ {
ITEM_NORMAL, ITEM_NORMAL,
...@@ -167,8 +168,7 @@ QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current ) ...@@ -167,8 +168,7 @@ QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
objects.push_back( p_intf->i_object_id ); objects.push_back( p_intf->i_object_id );
QMenu *menu = Populate( p_intf, current, varnames, objects ); QMenu *menu = Populate( p_intf, current, varnames, objects );
connect( menu, SIGNAL( aboutToShow() ), CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
THEDP->menusUpdateMapper, SLOT(map()) );
THEDP->menusUpdateMapper->setMapping( menu, 4 ); THEDP->menusUpdateMapper->setMapping( menu, 4 );
return menu; return menu;
...@@ -695,7 +695,7 @@ void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var, ...@@ -695,7 +695,7 @@ void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
} }
MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type, MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
val, psz_var ); val, psz_var );
connect( action, SIGNAL(triggered()), THEDP->menusMapper, SLOT(map()) ); CONNECT( action, triggered(), THEDP->menusMapper, map() );
THEDP->menusMapper->setMapping( action, itemData ); THEDP->menusMapper->setMapping( action, itemData );
menu->addAction( action ); menu->addAction( action );
} }
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <assert.h>
#include <QIcon> #include <QIcon>
#include <QFont> #include <QFont>
#include "qt4.hpp" #include <QMenu>
#include <QApplication> #include <QApplication>
#include "qt4.hpp"
#include "playlist_model.hpp" #include "playlist_model.hpp"
#include <assert.h>
#include <QMenu>
#include <vlc_intf_strings.h> #include <vlc_intf_strings.h>
#include "pixmaps/type_unknown.xpm" #include "pixmaps/type_unknown.xpm"
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <QModelIndex> #include <QModelIndex>
#include <QObject> #include <QObject>
#include <QEvent> #include <QEvent>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include <QApplication> #include <QApplication>
#include "qt4.hpp" #include "qt4.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "input_manager.hpp" #include "input_manager.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include "../../../share/vlc32x32.xpm" #include "../../../share/vlc32x32.xpm"
/***************************************************************************** /*****************************************************************************
......
...@@ -55,6 +55,8 @@ struct intf_sys_t ...@@ -55,6 +55,8 @@ struct intf_sys_t
#define qtu( i ) i.toUtf8().data() #define qtu( i ) i.toUtf8().data()
#define qta( i ) i.toAscii().data() #define qta( i ) i.toAscii().data()
#define CONNECT( a, b, c, d ) connect( a, SIGNAL( b ), c, SLOT(d) )
static int DialogEvent_Type = QEvent::User + 1; static int DialogEvent_Type = QEvent::User + 1;
class DialogEvent : public QEvent class DialogEvent : public QEvent
......
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