/*****************************************************************************
* preferences_widgets.hpp : Widgets for preferences panels
****************************************************************************
- * Copyright (C) 2006-2007 the VideoLAN team
+ * Copyright (C) 2006-2011 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
# include "config.h"
#endif
-#include <vlc/vlc.h>
-
#include "qt4.hpp"
#include <assert.h>
#include <QLabel>
#include <QDoubleSpinBox>
#include <QPushButton>
-#include <QVector>
#include <QDialog>
+#include <QFontComboBox>
-
-class QFile;
class QTreeWidget;
class QTreeWidgetItem;
class QGroupBox;
class QGridLayout;
class QDialogButtonBox;
class QVBoxLayout;
+class QBoxLayout;
+class SearchLineEdit;
-class ConfigControl : public QObject
+/*******************************************************
+ * Simple widgets
+ *******************************************************/
+
+class InterfacePreviewWidget : public QLabel
{
Q_OBJECT
public:
- ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
- QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
- {
- widget = new QWidget( p );
- }
- ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
- p_this (_p_this ), p_item( _p_conf )
- {
- widget = NULL;
- }
- virtual ~ConfigControl() {};
- virtual int getType() = 0;
- const char * getName() { return p_item->psz_name; }
- QWidget *getWidget() { assert( widget ); return widget; }
- bool isAdvanced() { return p_item->b_advanced; }
- virtual void hide() { getWidget()->hide(); };
- virtual void show() { getWidget()->show(); };
+ InterfacePreviewWidget( QWidget * );
+ enum enum_style {
+ COMPLETE, // aka MPC
+ MINIMAL, // aka WMP12 minimal
+ SKINS };
+public slots:
+ void setPreview( enum_style );
+ void setNormalPreview( bool b_minimal );
+};
- static ConfigControl * createControl( vlc_object_t*,
- module_config_t*,QWidget* );
+/*******************************************************
+ * Variable controls
+ *******************************************************/
+
+class ConfigControl : public QObject
+{
+ Q_OBJECT
+public:
+ virtual int getType() const = 0;
+ const char * getName() const { return p_item->psz_name; }
+ bool isAdvanced() const { return p_item->b_advanced; }
+ void hide() { changeVisibility( false ); }
+ void show() { changeVisibility( true ); }
+ /* ConfigControl factory */
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*,
- QGridLayout *, int& );
- void doApply( intf_thread_t *);
+ QGridLayout *, int line = 0 );
+ /* Inserts control into another layout block, using a sublayout */
+ void insertInto( QBoxLayout * );
+ /* Inserts control into an existing grid layout */
+ void insertIntoExistingGrid( QGridLayout*, int );
+ virtual void doApply() = 0;
protected:
+ ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
+ p_this (_p_this ), p_item( _p_conf ) {}
+ virtual void changeVisibility( bool b ) { Q_UNUSED(b); };
vlc_object_t *p_this;
module_config_t *p_item;
- QString _name;
- QWidget *widget;
- bool _advanced;
+ virtual void fillGrid( QGridLayout*, int ) {};
+signals:
+ void changed();
#if 0
/* You shouldn't use that now..*/
-signals:
void Updated();
#endif
};
{
Q_OBJECT
public:
- VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
- ConfigControl(a,b,c) {};
+ virtual int getValue() const = 0;
+ virtual int getType() const;
+ virtual void doApply();
+protected:
VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
- virtual ~VIntConfigControl() {};
- virtual int getValue() = 0;
- virtual int getType() { return CONFIG_ITEM_INTEGER; }
};
class IntegerConfigControl : public VIntConfigControl
{
Q_OBJECT
public:
- IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int& );
+ IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget * );
IntegerConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* );
- IntegerConfigControl( vlc_object_t *, module_config_t *,
- QLabel*, QSlider* );
- virtual ~IntegerConfigControl() {};
- virtual int getValue();
- virtual void show() { spin->show(); if( label ) label->show(); }
- virtual void hide() { spin->hide(); if( label ) label->hide(); }
-
+ virtual int getValue() const;
protected:
QSpinBox *spin;
+ virtual void changeVisibility( bool b )
+ {
+ spin->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
private:
QLabel *label;
void finish();
class IntegerRangeConfigControl : public IntegerConfigControl
{
+ Q_OBJECT
public:
- IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int& );
+ IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* );
+ IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
+ QLabel*, QSlider* );
private:
void finish();
};
class IntegerRangeSliderConfigControl : public VIntConfigControl
{
+ Q_OBJECT
public:
IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
QLabel *, QSlider * );
- virtual ~IntegerRangeSliderConfigControl() {};
- virtual int getValue();
+ virtual int getValue() const;
protected:
- QSlider *slider;
+ QSlider *slider;
+ virtual void changeVisibility( bool b )
+ {
+ slider->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
private:
- QLabel *label;
- void finish();
+ QLabel *label;
+ void finish();
};
class IntegerListConfigControl : public VIntConfigControl
{
Q_OBJECT
public:
- IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- bool, QGridLayout*, int& );
+ IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
- virtual ~IntegerListConfigControl() {};
- virtual int getValue();
- virtual void hide() { combo->hide(); if( label ) label->hide(); }
- virtual void show() { combo->show(); if( label ) label->show(); }
+ virtual int getValue() const;
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ combo->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
private:
- void finish(module_config_t *, bool );
+ void finish(module_config_t * );
QLabel *label;
QComboBox *combo;
-private slots:
- void actionRequested( int );
-
+ QList<QPushButton *> buttons;
};
class BoolConfigControl : public VIntConfigControl
{
+ Q_OBJECT
public:
- BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int& );
+ BoolConfigControl( vlc_object_t *, module_config_t *, QWidget * );
BoolConfigControl( vlc_object_t *, module_config_t *,
- QLabel *, QCheckBox*, bool );
- virtual ~BoolConfigControl() {};
- virtual int getValue();
- virtual void show() { checkbox->show(); }
- virtual void hide() { checkbox->hide(); }
- virtual int getType() { return CONFIG_ITEM_BOOL; }
+ QLabel *, QAbstractButton* );
+ virtual int getValue() const;
+ virtual int getType() const;
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ checkbox->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
private:
- QCheckBox *checkbox;
+ QAbstractButton *checkbox;
+ void finish();
+};
+
+class ColorConfigControl : public VIntConfigControl
+{
+Q_OBJECT
+public:
+ ColorConfigControl( vlc_object_t *, module_config_t *, QWidget * );
+ ColorConfigControl( vlc_object_t *, module_config_t *,
+ QLabel *, QAbstractButton* );
+ virtual ~ColorConfigControl() { delete color_px; }
+ virtual int getValue() const;
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ color_but->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
+private:
+ QLabel *label;
+ QAbstractButton *color_but;
+ QPixmap *color_px;
+ int i_color;
void finish();
+private slots:
+ void selectColor();
};
/*******************************************************
{
Q_OBJECT
public:
- VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
- ConfigControl(a,b,c) {};
+ virtual float getValue() const = 0;
+ virtual int getType() const;
+ virtual void doApply();
+protected:
VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
- virtual ~VFloatConfigControl() {};
- virtual float getValue() = 0;
- virtual int getType() { return CONFIG_ITEM_FLOAT; }
};
class FloatConfigControl : public VFloatConfigControl
{
Q_OBJECT
public:
- FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int& );
+ FloatConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FloatConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
- virtual ~FloatConfigControl() {};
- virtual float getValue();
- virtual void show() { spin->show(); if( label ) label->show(); }
- virtual void hide() { spin->hide(); if( label ) label->hide(); }
+ virtual float getValue() const;
protected:
+ virtual void changeVisibility( bool b )
+ {
+ spin->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
QDoubleSpinBox *spin;
private:
{
Q_OBJECT
public:
- FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int& );
+ FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FloatRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
private:
{
Q_OBJECT
public:
- VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
- ConfigControl(a,b,c) {};
+ virtual QString getValue() const = 0;
+ virtual int getType() const;
+ virtual void doApply();
+protected:
VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
- virtual ~VStringConfigControl() {};
- virtual QString getValue() = 0;
- virtual int getType() { return CONFIG_ITEM_STRING; }
};
class StringConfigControl : public VStringConfigControl
{
Q_OBJECT
public:
- StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int&, bool pwd );
+ StringConfigControl( vlc_object_t *, module_config_t *,
+ QWidget *, bool pwd );
StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit*, bool pwd );
- virtual ~StringConfigControl() {};
- virtual QString getValue() { return text->text(); };
- virtual void show() { text->show(); if( label ) label->show(); }
- virtual void hide() { text->hide(); if( label ) label->hide(); }
+ virtual QString getValue() const { return text->text(); };
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ text->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
private:
void finish();
QLineEdit *text;
class FileConfigControl : public VStringConfigControl
{
- Q_OBJECT;
+ Q_OBJECT
public:
- FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int&, bool pwd );
+ FileConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
- QLineEdit *, QPushButton *, bool pwd );
- virtual ~FileConfigControl() {};
- virtual QString getValue() { return text->text(); };
- virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
- virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
+ QLineEdit *, QPushButton * );
+ virtual QString getValue() const { return text->text(); };
public slots:
virtual void updateField();
protected:
+ virtual void changeVisibility( bool b )
+ {
+ text->setVisible( b );
+ browse->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
void finish();
QLineEdit *text;
QLabel *label;
class DirectoryConfigControl : public FileConfigControl
{
- Q_OBJECT;
+ Q_OBJECT
public:
- DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int&, bool pwd );
+ DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget * );
DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
- QLineEdit *, QPushButton *, bool pwd );
- virtual ~DirectoryConfigControl() {};
+ QLineEdit *, QPushButton * );
public slots:
virtual void updateField();
};
-#if 0
-class FontConfigControl : public FileConfigControl
+class FontConfigControl : public VStringConfigControl
{
- Q_OBJECT;
+ Q_OBJECT
public:
- FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout *, int&, bool pwd );
+ FontConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
- QLineEdit *, QPushButton *, bool pwd );
- virtual ~FontConfigControl() {};
-public slots:
- virtual void updateField();
+ QFontComboBox *);
+ virtual QString getValue() const { return font->currentFont().family(); }
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ font->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
+ QLabel *label;
+ QFontComboBox *font;
};
-#endif
class ModuleConfigControl : public VStringConfigControl
{
+ Q_OBJECT
public:
- ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
- QGridLayout*, int& );
+ ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget * );
ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
- QComboBox*, bool );
- virtual ~ModuleConfigControl() {};
- virtual QString getValue();
- virtual void hide() { combo->hide(); if( label ) label->hide(); }
- virtual void show() { combo->show(); if( label ) label->show(); }
+ QComboBox* );
+ virtual QString getValue() const;
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ combo->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
private:
- void finish( bool );
+ void finish( );
QLabel *label;
QComboBox *combo;
};
class ModuleListConfigControl : public VStringConfigControl
{
- Q_OBJECT;
+ Q_OBJECT
+ friend class ConfigControl;
public:
- ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- bool, QGridLayout*, int& );
+ ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
// ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
// QComboBox*, bool );
virtual ~ModuleListConfigControl();
- virtual QString getValue();
- virtual void hide();
- virtual void show();
+ virtual QString getValue() const;
public slots:
- void onUpdate( int value );
+ void onUpdate();
+protected:
+ virtual void changeVisibility( bool );
+ virtual void fillGrid( QGridLayout*, int );
private:
void finish( bool );
- QVector<checkBoxListItem*> modules;
+ void checkbox_lists(module_t*);
+ void checkbox_lists( QString, QString, const char* );
+ QList<checkBoxListItem*> modules;
QGroupBox *groupBox;
QLineEdit *text;
};
class StringListConfigControl : public VStringConfigControl
{
- Q_OBJECT;
+ Q_OBJECT
public:
- StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
- bool, QGridLayout*, int& );
+ StringListConfigControl( vlc_object_t *, module_config_t *, QWidget * );
StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
- virtual ~StringListConfigControl() {};
- virtual QString getValue();
- virtual void hide() { combo->hide(); if( label ) label->hide(); }
- virtual void show() { combo->show(); if( label ) label->show(); }
- QComboBox *combo;
+ virtual QString getValue() const;
+protected:
+ virtual void changeVisibility( bool b )
+ {
+ combo->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
+ QComboBox *combo;
private:
- void finish(module_config_t *, bool );
+ void finish(module_config_t * );
QLabel *label;
+ QList<QPushButton *> buttons;
private slots:
- void actionRequested( int );
-
+ void comboIndexChanged( int );
};
void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
- QComboBox *combo, QWidget *parent = 0 );
+ QComboBox *combo );
#if 0
struct ModuleCheckBox {
class ModuleListConfigControl : public ConfigControl
{
+ Q_OBJECT
public:
StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
bycat );
virtual ~StringConfigControl();
virtual QString getValue();
private:
- std::vector<ModuleCheckBox> checkboxes;
+ QVector<ModuleCheckBox> checkboxes;
QLineEdit *text;
private slot:
void OnUpdate();
/**********************************************************************
* Key selector widget
**********************************************************************/
-class KeyShortcutEdit: public QLineEdit
+class KeySelectorControl : public ConfigControl
{
Q_OBJECT
-public:
- void setValue( int _value ){ value = _value; }
- int getValue(){ return value; }
-private:
- int value;
- virtual void mousePressEvent( QMouseEvent *event );
-signals:
- void pressed();
-};
-class KeySelectorControl : public ConfigControl
-{
- Q_OBJECT;
public:
- KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
- QGridLayout*, int& );
- virtual int getType() { return CONFIG_ITEM_KEY; }
- virtual ~KeySelectorControl() {};
- virtual void hide() { table->hide(); if( label ) label->hide(); }
- virtual void show() { table->show(); if( label ) label->show(); }
- void doApply();
+ KeySelectorControl( vlc_object_t *, module_config_t *, QWidget * );
+ virtual int getType() const;
+ virtual void doApply();
+
+protected:
+ virtual bool eventFilter( QObject *, QEvent * );
+ virtual void changeVisibility( bool b )
+ {
+ table->setVisible( b );
+ if ( label ) label->setVisible( b );
+ }
+ virtual void fillGrid( QGridLayout*, int );
+
private:
+ void buildAppHotkeysList( QWidget *rootWidget );
void finish();
QLabel *label;
+ QLabel *searchLabel;
+ SearchLineEdit *actionSearch;
+ QComboBox *searchOption;
+ QLabel *searchOptionLabel;
QTreeWidget *table;
- KeyShortcutEdit *shortcutValue;
QList<module_config_t *> values;
+ QSet<QString> existingkeys;
+ enum
+ {
+ ACTION_COL = 0,
+ HOTKEY_COL = 1,
+ GLOBAL_HOTKEY_COL = 2,
+ ANY_COL = 3 // == count()
+ };
+
private slots:
- void setTheKey();
- void selectKey( QTreeWidgetItem * = NULL );
- void select1Key( QTreeWidgetItem *);
+ void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
+ void filter( const QString & );
};
class KeyInputDialog : public QDialog
{
+ Q_OBJECT
+
public:
- KeyInputDialog( QTreeWidget *, QString, QWidget * );
+ KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false );
int keyValue;
bool conflicts;
+ void setExistingkeysSet( const QSet<QString> *keyset = NULL );
+
private:
QTreeWidget *table;
- void checkForConflicts( int i_vlckey );
+ QLabel *selected, *warning;
+ QPushButton *ok, *unset;
+
+ void checkForConflicts( int i_vlckey, const QString &sequence );
void keyPressEvent( QKeyEvent *);
void wheelEvent( QWheelEvent *);
- QLabel *selected;
- QVBoxLayout *vLayout;
- QDialogButtonBox *buttonBox;
+ bool b_global;
+ const QSet<QString> *existingkeys;
+
+private slots:
+ void unsetAction();
};
#endif