preferences_widgets.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * preferences_widgets.hpp : Widgets for preferences panels
00003  ****************************************************************************
00004  * Copyright (C) 2006-2007 the VideoLAN team
00005  * $Id: 412f21e81e6f400855f1aeed615d0c6cac65edf8 $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Antoine Cellerier <dionoea@videolan.org>
00009  *          Jean-Baptiste Kempf <jb@videolan.org>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef _PREFERENCESWIDGETS_H_
00027 #define _PREFERENCESWIDGETS_H_
00028 
00029 #ifdef HAVE_CONFIG_H
00030 # include "config.h"
00031 #endif
00032 
00033 #include "qt4.hpp"
00034 #include <assert.h>
00035 
00036 #include <QWidget>
00037 
00038 #include <QCheckBox>
00039 #include <QComboBox>
00040 #include <QLineEdit>
00041 #include <QTreeWidget>
00042 #include <QSpinBox>
00043 #include <QLabel>
00044 #include <QDoubleSpinBox>
00045 #include <QPushButton>
00046 #include <QVector>
00047 #include <QDialog>
00048 #include <QFontComboBox>
00049 
00050 class QTreeWidget;
00051 class QTreeWidgetItem;
00052 class QGroupBox;
00053 class QGridLayout;
00054 class QDialogButtonBox;
00055 class QVBoxLayout;
00056 
00057 /*******************************************************
00058  * Simple widgets
00059  *******************************************************/
00060 
00061 class InterfacePreviewWidget : public QLabel
00062 {
00063     Q_OBJECT
00064 public:
00065     InterfacePreviewWidget( QWidget * );
00066     enum enum_style {
00067                  COMPLETE, // aka MPC
00068                  MINIMAL,  // aka WMP12 minimal
00069                  SKINS };
00070 public slots:
00071     void setPreview( enum_style );
00072     void setNormalPreview( bool b_minimal );
00073 };
00074 
00075 /*******************************************************
00076  * Variable controls
00077  *******************************************************/
00078 
00079 class ConfigControl : public QObject
00080 {
00081     Q_OBJECT
00082 public:
00083     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
00084                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
00085     {
00086         widget = new QWidget( p );
00087     }
00088     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
00089                             p_this (_p_this ), p_item( _p_conf )
00090     {
00091         widget = NULL;
00092     }
00093     virtual ~ConfigControl() {};
00094     virtual int getType() = 0;
00095     const char * getName() { return  p_item->psz_name; }
00096     QWidget *getWidget() { assert( widget ); return widget; }
00097     bool isAdvanced() { return p_item->b_advanced; }
00098     virtual void hide() { getWidget()->hide(); };
00099     virtual void show() { getWidget()->show(); };
00100 
00101     static ConfigControl * createControl( vlc_object_t*,
00102                                           module_config_t*,QWidget* );
00103     static ConfigControl * createControl( vlc_object_t*,
00104                                           module_config_t*,QWidget*,
00105                                           QGridLayout *, int& );
00106     void doApply( intf_thread_t *);
00107 protected:
00108     vlc_object_t *p_this;
00109     module_config_t *p_item;
00110     QString _name;
00111     QWidget *widget;
00112     bool _advanced;
00113 #if 0
00114 /* You shouldn't use that now..*/
00115 signals:
00116     void Updated();
00117 #endif
00118 };
00119 
00120 /*******************************************************
00121  * Integer-based controls
00122  *******************************************************/
00123 class VIntConfigControl : public ConfigControl
00124 {
00125 Q_OBJECT
00126 public:
00127     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
00128             ConfigControl(a,b,c) {};
00129     VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
00130                 ConfigControl(a,b) {};
00131     virtual ~VIntConfigControl() {};
00132     virtual int getValue() = 0;
00133     virtual int getType() { return CONFIG_ITEM_INTEGER; }
00134 };
00135 
00136 class IntegerConfigControl : public VIntConfigControl
00137 {
00138 Q_OBJECT
00139 public:
00140     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00141                           QGridLayout *, int& );
00142     IntegerConfigControl( vlc_object_t *, module_config_t *,
00143                           QLabel*, QSpinBox* );
00144     IntegerConfigControl( vlc_object_t *, module_config_t *,
00145                           QLabel*, QSlider* );
00146     virtual ~IntegerConfigControl() {};
00147     virtual int getValue();
00148     virtual void show() { spin->show(); if( label ) label->show(); }
00149     virtual void hide() { spin->hide(); if( label ) label->hide(); }
00150 
00151 protected:
00152     QSpinBox *spin;
00153 private:
00154     QLabel *label;
00155     void finish();
00156 };
00157 
00158 class IntegerRangeConfigControl : public IntegerConfigControl
00159 {
00160 public:
00161     IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00162                                QGridLayout *, int& );
00163     IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
00164                                QLabel*, QSpinBox* );
00165 private:
00166     void finish();
00167 };
00168 
00169 class IntegerRangeSliderConfigControl : public VIntConfigControl
00170 {
00171 public:
00172     IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
00173                                 QLabel *, QSlider * );
00174     virtual ~IntegerRangeSliderConfigControl() {};
00175     virtual int getValue();
00176 protected:
00177          QSlider *slider;
00178 private:
00179          QLabel *label;
00180          void finish();
00181 };
00182 
00183 class IntegerListConfigControl : public VIntConfigControl
00184 {
00185 Q_OBJECT
00186 public:
00187     IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00188                               bool, QGridLayout*, int& );
00189     IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00190                               QComboBox*, bool );
00191     virtual ~IntegerListConfigControl() {};
00192     virtual int getValue();
00193     virtual void hide() { combo->hide(); if( label ) label->hide(); }
00194     virtual void show() { combo->show(); if( label ) label->show(); }
00195 private:
00196     void finish(module_config_t *, bool );
00197     QLabel *label;
00198     QComboBox *combo;
00199 private slots:
00200     void actionRequested( int );
00201 
00202 };
00203 
00204 class BoolConfigControl : public VIntConfigControl
00205 {
00206 public:
00207     BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00208                        QGridLayout *, int& );
00209     BoolConfigControl( vlc_object_t *, module_config_t *,
00210                        QLabel *, QAbstractButton*, bool );
00211     virtual ~BoolConfigControl() {};
00212     virtual int getValue();
00213     virtual void show() { checkbox->show(); }
00214     virtual void hide() { checkbox->hide(); }
00215     virtual int getType() { return CONFIG_ITEM_BOOL; }
00216 private:
00217     QAbstractButton *checkbox;
00218     void finish();
00219 };
00220 
00221 /*******************************************************
00222  * Float-based controls
00223  *******************************************************/
00224 class VFloatConfigControl : public ConfigControl
00225 {
00226     Q_OBJECT
00227 public:
00228     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
00229                 ConfigControl(a,b,c) {};
00230     VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
00231                 ConfigControl(a,b) {};
00232     virtual ~VFloatConfigControl() {};
00233     virtual float getValue() = 0;
00234     virtual int getType() { return CONFIG_ITEM_FLOAT; }
00235 };
00236 
00237 class FloatConfigControl : public VFloatConfigControl
00238 {
00239     Q_OBJECT
00240 public:
00241     FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00242                         QGridLayout *, int& );
00243     FloatConfigControl( vlc_object_t *, module_config_t *,
00244                         QLabel*, QDoubleSpinBox* );
00245     virtual ~FloatConfigControl() {};
00246     virtual float getValue();
00247     virtual void show() { spin->show(); if( label ) label->show(); }
00248     virtual void hide() { spin->hide(); if( label ) label->hide(); }
00249 
00250 protected:
00251     QDoubleSpinBox *spin;
00252 
00253 private:
00254     QLabel *label;
00255     void finish();
00256 };
00257 
00258 class FloatRangeConfigControl : public FloatConfigControl
00259 {
00260     Q_OBJECT
00261 public:
00262     FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00263                              QGridLayout *, int& );
00264     FloatRangeConfigControl( vlc_object_t *, module_config_t *,
00265                              QLabel*, QDoubleSpinBox* );
00266 private:
00267     void finish();
00268 };
00269 
00270 /*******************************************************
00271  * String-based controls
00272  *******************************************************/
00273 class VStringConfigControl : public ConfigControl
00274 {
00275     Q_OBJECT
00276 public:
00277     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
00278                 ConfigControl(a,b,c) {};
00279     VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
00280                 ConfigControl(a,b) {};
00281     virtual ~VStringConfigControl() {};
00282     virtual QString getValue() = 0;
00283     virtual int getType() { return CONFIG_ITEM_STRING; }
00284 };
00285 
00286 class StringConfigControl : public VStringConfigControl
00287 {
00288     Q_OBJECT
00289 public:
00290     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00291                          QGridLayout *, int&,  bool pwd );
00292     StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00293                          QLineEdit*,  bool pwd );
00294     virtual ~StringConfigControl() {};
00295     virtual QString getValue() { return text->text(); };
00296     virtual void show() { text->show(); if( label ) label->show(); }
00297     virtual void hide() { text->hide(); if( label ) label->hide(); }
00298 private:
00299     void finish();
00300     QLineEdit *text;
00301     QLabel *label;
00302 };
00303 
00304 class FileConfigControl : public VStringConfigControl
00305 {
00306     Q_OBJECT
00307 public:
00308     FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00309                        QGridLayout *, int& );
00310     FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00311                        QLineEdit *, QPushButton * );
00312     virtual ~FileConfigControl() {};
00313     virtual QString getValue() { return text->text(); };
00314     virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
00315     virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
00316 public slots:
00317     virtual void updateField();
00318 protected:
00319     void finish();
00320     QLineEdit *text;
00321     QLabel *label;
00322     QPushButton *browse;
00323 };
00324 
00325 class DirectoryConfigControl : public FileConfigControl
00326 {
00327     Q_OBJECT
00328 public:
00329     DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00330                             QGridLayout *, int& );
00331     DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00332                             QLineEdit *, QPushButton * );
00333     virtual ~DirectoryConfigControl() {};
00334 public slots:
00335     virtual void updateField();
00336 };
00337 
00338 class FontConfigControl : public VStringConfigControl
00339 {
00340     Q_OBJECT
00341 public:
00342     FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00343                        QGridLayout *, int&);
00344     FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00345                        QFontComboBox *);
00346     virtual ~FontConfigControl() {};
00347     virtual QString getValue(){ return font->currentFont().family(); }
00348 protected:
00349     QLabel *label;
00350     QFontComboBox *font;
00351 };
00352 
00353 class ModuleConfigControl : public VStringConfigControl
00354 {
00355 public:
00356     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
00357                          QGridLayout*, int& );
00358     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00359                          QComboBox*, bool );
00360     virtual ~ModuleConfigControl() {};
00361     virtual QString getValue();
00362     virtual void hide() { combo->hide(); if( label ) label->hide(); }
00363     virtual void show() { combo->show(); if( label ) label->show(); }
00364 private:
00365     void finish( bool );
00366     QLabel *label;
00367     QComboBox *combo;
00368 };
00369 
00370 struct checkBoxListItem {
00371     QCheckBox *checkBox;
00372     char *psz_module;
00373 };
00374 
00375 class ModuleListConfigControl : public VStringConfigControl
00376 {
00377     Q_OBJECT
00378     friend class ConfigControl;
00379 public:
00380     ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00381                              bool, QGridLayout*, int& );
00382 //    ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00383 //                         QComboBox*, bool );
00384     virtual ~ModuleListConfigControl();
00385     virtual QString getValue();
00386     virtual void hide();
00387     virtual void show();
00388 public slots:
00389     void onUpdate();
00390 private:
00391     void finish( bool );
00392     QVector<checkBoxListItem*> modules;
00393     QGroupBox *groupBox;
00394     QLineEdit *text;
00395 };
00396 
00397 class StringListConfigControl : public VStringConfigControl
00398 {
00399     Q_OBJECT
00400 public:
00401     StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
00402                              bool, QGridLayout*, int& );
00403     StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
00404                              QComboBox*, bool );
00405     virtual ~StringListConfigControl() {};
00406     virtual QString getValue();
00407     virtual void hide() { combo->hide(); if( label ) label->hide(); }
00408     virtual void show() { combo->show(); if( label ) label->show(); }
00409     QComboBox *combo;
00410 private:
00411     void finish(module_config_t *, bool );
00412     QLabel *label;
00413 private slots:
00414     void actionRequested( int );
00415 
00416 };
00417 
00418 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
00419                         QComboBox *combo );
00420 
00421 #if 0
00422 struct ModuleCheckBox {
00423     QCheckBox *checkbox;
00424     QString module;
00425 };
00426 
00427 class ModuleListConfigControl : public ConfigControl
00428 {
00429 public:
00430     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
00431                          bycat );
00432     virtual ~StringConfigControl();
00433     virtual QString getValue();
00434 private:
00435     std::vector<ModuleCheckBox> checkboxes;
00436     QLineEdit *text;
00437 private slot:
00438     void OnUpdate();
00439 };
00440 #endif
00441 
00442 /**********************************************************************
00443  * Key selector widget
00444  **********************************************************************/
00445 class KeyShortcutEdit: public QLineEdit
00446 {
00447     Q_OBJECT
00448 public:
00449     void setValue( int _value ){ value = _value; }
00450     int getValue() const { return value; }
00451 
00452     void setGlobal( bool _value ) { b_global = _value; }
00453     bool getGlobal()  const { return b_global; }
00454 public slots:
00455     virtual void clear(void) { value = 0; QLineEdit::clear(); }
00456 private:
00457     int value;
00458     bool b_global;
00459     virtual void mousePressEvent( QMouseEvent *event );
00460 signals:
00461     void pressed();
00462 };
00463 
00464 class SearchLineEdit;
00465 class KeySelectorControl : public ConfigControl
00466 {
00467     Q_OBJECT
00468 public:
00469     KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
00470                         QGridLayout*, int& );
00471     virtual int getType() { return CONFIG_ITEM_KEY; }
00472     virtual ~KeySelectorControl() {};
00473     virtual void hide() { table->hide(); if( label ) label->hide(); }
00474     virtual void show() { table->show(); if( label ) label->show(); }
00475     void doApply();
00476 private:
00477     void finish();
00478     QLabel *label;
00479     QTreeWidget *table;
00480     KeyShortcutEdit *shortcutValue;
00481     QList<module_config_t *> values;
00482     SearchLineEdit *actionSearch;
00483 private slots:
00484     void setTheKey();
00485     void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
00486     void select( QTreeWidgetItem * = NULL, int column = 1 );
00487     void select1Key();
00488     void filter( const QString & );
00489 };
00490 
00491 class KeyInputDialog : public QDialog
00492 {
00493 public:
00494     KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
00495     int keyValue;
00496     bool conflicts;
00497 private:
00498     QTreeWidget *table;
00499     void checkForConflicts( int i_vlckey );
00500     void keyPressEvent( QKeyEvent *);
00501     void wheelEvent( QWheelEvent *);
00502     QLabel *selected, *warning;
00503     QVBoxLayout *vLayout;
00504     QDialogButtonBox *buttonBox;
00505     bool b_global;
00506 };
00507 #endif

Generated on Tue May 25 08:04:57 2010 for VLC by  doxygen 1.5.6