]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.hpp
Qt4 - Hotkeys, correct some unicode problem and change the default behaviour.
[vlc] / modules / gui / qt4 / components / preferences_widgets.hpp
index 11e3877c8f5a31218d77b8b732433d7a57302601..1b9ff8173e7ed8e97f677c275598cc63b3c28c50 100644 (file)
@@ -1,11 +1,12 @@
 /*****************************************************************************
  * preferences_widgets.hpp : Widgets for preferences panels
  ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006-2007 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *          Antoine Cellerier <dionoea@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #ifndef _INFOPANELS_H_
 #define _INFOPANELS_H_
+
 #include <vlc/vlc.h>
+
+#include "qt4.hpp"
+#include <assert.h>
+
 #include <QWidget>
-#include <QTreeWidget>
+
+#include <QCheckBox>
+#include <QComboBox>
 #include <QLineEdit>
+#include <QTreeWidget>
 #include <QSpinBox>
+#include <QLabel>
 #include <QDoubleSpinBox>
-#include <QComboBox>
-#include <QCheckBox>
+#include <QPushButton>
 #include <QVector>
 #include <QDialog>
 
-#include "ui/input_stats.h"
-#include "qt4.hpp"
-#include <assert.h>
+
+class QFile;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QGroupBox;
+class QGridLayout;
+class QDialogButtonBox;
 
 class ConfigControl : public QObject
 {
-    Q_OBJECT;
+    Q_OBJECT
 public:
     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
@@ -55,7 +68,7 @@ public:
     }
     virtual ~ConfigControl() {};
     virtual int getType() = 0;
-    char * getName() { return  p_item->psz_name; }
+    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(); };
@@ -73,8 +86,11 @@ protected:
     QString _name;
     QWidget *widget;
     bool _advanced;
+#if 0
+/* You shouldn't use that now..*/
 signals:
     void Updated();
+#endif
 };
 
 /*******************************************************
@@ -82,6 +98,7 @@ signals:
  *******************************************************/
 class VIntConfigControl : public ConfigControl
 {
+Q_OBJECT
 public:
     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
             ConfigControl(a,b,c) {};
@@ -94,19 +111,21 @@ public:
 
 class IntegerConfigControl : public VIntConfigControl
 {
+Q_OBJECT
 public:
     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                           QGridLayout *, int& );
     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(); label->show(); }
-    virtual void hide() { spin->hide(); label->hide(); }
+    virtual void show() { spin->show(); if( label ) label->show(); }
+    virtual void hide() { spin->hide(); if( label ) label->hide(); }
 
 protected:
     QSpinBox *spin;
-
 private:
     QLabel *label;
     void finish();
@@ -123,6 +142,20 @@ private:
     void finish();
 };
 
+class IntegerRangeSliderConfigControl : public VIntConfigControl
+{
+public:
+    IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
+                                QLabel *, QSlider * );
+    virtual ~IntegerRangeSliderConfigControl() {};
+    virtual int getValue();
+protected:
+         QSlider *slider;
+private:
+         QLabel *label;
+         void finish();
+};
+
 class IntegerListConfigControl : public VIntConfigControl
 {
 public:
@@ -132,8 +165,8 @@ public:
                               QComboBox*, bool );
     virtual ~IntegerListConfigControl() {};
     virtual int getValue();
-    virtual void hide() { combo->hide(); label->hide(); }
-    virtual void show() { combo->show(); label->show(); }
+    virtual void hide() { combo->hide(); if( label ) label->hide(); }
+    virtual void show() { combo->show(); if( label ) label->show(); }
 private:
     void finish( bool );
     QLabel *label;
@@ -161,6 +194,7 @@ private:
  *******************************************************/
 class VFloatConfigControl : public ConfigControl
 {
+    Q_OBJECT
 public:
     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
                 ConfigControl(a,b,c) {};
@@ -173,6 +207,7 @@ public:
 
 class FloatConfigControl : public VFloatConfigControl
 {
+    Q_OBJECT
 public:
     FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                         QGridLayout *, int& );
@@ -180,8 +215,8 @@ public:
                         QLabel*, QDoubleSpinBox* );
     virtual ~FloatConfigControl() {};
     virtual float getValue();
-    virtual void show() { spin->show(); label->show(); }
-    virtual void hide() { spin->hide(); label->hide(); }
+    virtual void show() { spin->show(); if( label ) label->show(); }
+    virtual void hide() { spin->hide(); if( label ) label->hide(); }
 
 protected:
     QDoubleSpinBox *spin;
@@ -193,6 +228,7 @@ private:
 
 class FloatRangeConfigControl : public FloatConfigControl
 {
+    Q_OBJECT
 public:
     FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                              QGridLayout *, int& );
@@ -207,6 +243,7 @@ private:
  *******************************************************/
 class VStringConfigControl : public ConfigControl
 {
+    Q_OBJECT
 public:
     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
                 ConfigControl(a,b,c) {};
@@ -219,6 +256,7 @@ public:
 
 class StringConfigControl : public VStringConfigControl
 {
+    Q_OBJECT
 public:
     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                          QGridLayout *, int&,  bool pwd );
@@ -226,14 +264,61 @@ public:
                          QLineEdit*,  bool pwd );
     virtual ~StringConfigControl() {};
     virtual QString getValue() { return text->text(); };
-    virtual void show() { text->show(); label->show(); }
-    virtual void hide() { text->hide(); label->hide(); }
+    virtual void show() { text->show(); if( label ) label->show(); }
+    virtual void hide() { text->hide(); if( label ) label->hide(); }
 private:
     void finish();
     QLineEdit *text;
     QLabel *label;
 };
 
+class FileConfigControl : public VStringConfigControl
+{
+    Q_OBJECT;
+public:
+    FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
+                       QGridLayout *, int&, bool pwd );
+    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(); }
+public slots:
+    virtual void updateField();
+protected:
+    void finish();
+    QLineEdit *text;
+    QLabel *label;
+    QPushButton *browse;
+};
+
+class DirectoryConfigControl : public FileConfigControl
+{
+    Q_OBJECT;
+public:
+    DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
+                            QGridLayout *, int&, bool pwd );
+    DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
+                            QLineEdit *, QPushButton *, bool pwd );
+    virtual ~DirectoryConfigControl() {};
+public slots:
+    virtual void updateField();
+};
+
+class FontConfigControl : public FileConfigControl
+{
+    Q_OBJECT;
+public:
+    FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
+                       QGridLayout *, int&, bool pwd );
+    FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
+                       QLineEdit *, QPushButton *, bool pwd );
+    virtual ~FontConfigControl() {};
+public slots:
+    virtual void updateField();
+};
+
 class ModuleConfigControl : public VStringConfigControl
 {
 public:
@@ -243,14 +328,19 @@ public:
                          QComboBox*, bool );
     virtual ~ModuleConfigControl() {};
     virtual QString getValue();
-    virtual void hide() { combo->hide(); label->hide(); }
-    virtual void show() { combo->show(); label->show(); }
+    virtual void hide() { combo->hide(); if( label ) label->hide(); }
+    virtual void show() { combo->show(); if( label ) label->show(); }
 private:
     void finish( bool );
     QLabel *label;
     QComboBox *combo;
 };
 
+struct checkBoxListItem {
+    QCheckBox *checkBox;
+    char *psz_module;
+};
+
 class ModuleListConfigControl : public VStringConfigControl
 {
     Q_OBJECT;
@@ -264,16 +354,17 @@ public:
     virtual void hide();
     virtual void show();
 public slots:
-    void wakeUp_TheUserJustClickedOnSomething( int value );
+    void onUpdate( int value );
 private:
     void finish( bool );
-    QVector<QCheckBox*> modules;
-    QLabel *label;
+    QVector<checkBoxListItem*> modules;
+    QGroupBox *groupBox;
     QLineEdit *text;
 };
 
 class StringListConfigControl : public VStringConfigControl
 {
+    Q_OBJECT;
 public:
     StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                              bool, QGridLayout*, int& );
@@ -281,13 +372,20 @@ public:
                              QComboBox*, bool );
     virtual ~StringListConfigControl() {};
     virtual QString getValue();
-    virtual void hide() { combo->hide(); label->hide(); }
-    virtual void show() { combo->show(); label->show(); }
+    virtual void hide() { combo->hide(); if( label ) label->hide(); }
+    virtual void show() { combo->show(); if( label ) label->show(); }
 private:
     void finish( bool );
     QLabel *label;
     QComboBox *combo;
+private slots:
+    void actionRequested( int );
+
 };
+
+void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
+                        QComboBox *combo, QWidget *parent = 0 );
+
 #if 0
 struct ModuleCheckBox {
     QCheckBox *checkbox;
@@ -315,15 +413,27 @@ private slot:
 class KeyInputDialog : public QDialog
 {
 public:
-    KeyInputDialog( QList<module_config_t *> &, char * );
+    KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * );
     int keyValue;
     bool conflicts;
 private:
+    void checkForConflicts( int i_vlckey );
     void keyPressEvent( QKeyEvent *);
+    void wheelEvent( QWheelEvent *);
     QLabel *selected;
     QLabel *warning;
-    char * keyToChange;
+    const char * keyToChange;
     QList<module_config_t*> values;
+    QDialogButtonBox *buttonBox;
+};
+
+class KeyShortcutEdit: public QLineEdit
+{
+    Q_OBJECT
+private:
+    virtual void mousePressEvent( QMouseEvent *event );
+signals:
+    void pressed();
 };
 
 class KeySelectorControl : public ConfigControl
@@ -334,16 +444,19 @@ public:
                         QGridLayout*, int& );
     virtual int getType() { return 4; }
     virtual ~KeySelectorControl() {};
-    virtual void hide() { table->hide(); label->hide(); }
-    virtual void show() { table->show(); label->show(); }
+    virtual void hide() { table->hide(); if( label ) label->hide(); }
+    virtual void show() { table->show(); if( label ) label->show(); }
     void doApply();
 private:
     void finish();
     QLabel *label;
     QTreeWidget *table;
+    KeyShortcutEdit *shortcutValue;
     QList<module_config_t *> values;
 private slots:
-    void selectKey( QTreeWidgetItem *);
+    void setTheKey();
+    void selectKey( QTreeWidgetItem * = NULL );
+    void select1Key( QTreeWidgetItem *);
 };
 
 #endif