]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.hpp
Fix configure hotkeys behaviour on keyboard seection.
[vlc] / modules / gui / qt4 / components / preferences_widgets.hpp
index 56a455f2f1367504dbabbab76fe30faef4a11704..715f26afd1204206f0be6cb832a32dce7ed094b3 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#ifndef _INFOPANELS_H_
-#define _INFOPANELS_H_
-#include <vlc/vlc.h>
+#ifndef _PREFERENCESWIDGETS_H_
+#define _PREFERENCESWIDGETS_H_
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.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 <QLabel>
-#include <QFile>
-#include <QPushButton>
-#include <QGroupBox>
 
-#include "qt4.hpp"
-#include <assert.h>
 
+class QFile;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QGroupBox;
 class QGridLayout;
+class QDialogButtonBox;
+class QVBoxLayout;
 
 class ConfigControl : public QObject
 {
@@ -79,8 +91,11 @@ protected:
     QString _name;
     QWidget *widget;
     bool _advanced;
+#if 0
+/* You shouldn't use that now..*/
 signals:
     void Updated();
+#endif
 };
 
 /*******************************************************
@@ -96,7 +111,7 @@ public:
                 ConfigControl(a,b) {};
     virtual ~VIntConfigControl() {};
     virtual int getValue() = 0;
-    virtual int getType() { return 1; }
+    virtual int getType() { return CONFIG_ITEM_INTEGER; }
 };
 
 class IntegerConfigControl : public VIntConfigControl
@@ -111,8 +126,8 @@ public:
                           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;
@@ -148,6 +163,7 @@ private:
 
 class IntegerListConfigControl : public VIntConfigControl
 {
+Q_OBJECT
 public:
     IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
                               bool, QGridLayout*, int& );
@@ -155,12 +171,15 @@ 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 );
+    void finish(module_config_t *, bool );
     QLabel *label;
     QComboBox *combo;
+private slots:
+    void actionRequested( int );
+
 };
 
 class BoolConfigControl : public VIntConfigControl
@@ -174,6 +193,7 @@ public:
     virtual int getValue();
     virtual void show() { checkbox->show(); }
     virtual void hide() { checkbox->hide(); }
+    virtual int getType() { return CONFIG_ITEM_BOOL; }
 private:
     QCheckBox *checkbox;
     void finish();
@@ -192,7 +212,7 @@ public:
                 ConfigControl(a,b) {};
     virtual ~VFloatConfigControl() {};
     virtual float getValue() = 0;
-    virtual int getType() { return 2; }
+    virtual int getType() { return CONFIG_ITEM_FLOAT; }
 };
 
 class FloatConfigControl : public VFloatConfigControl
@@ -205,8 +225,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;
@@ -241,7 +261,7 @@ public:
                 ConfigControl(a,b) {};
     virtual ~VStringConfigControl() {};
     virtual QString getValue() = 0;
-    virtual int getType() { return 3; }
+    virtual int getType() { return CONFIG_ITEM_STRING; }
 };
 
 class StringConfigControl : public VStringConfigControl
@@ -254,8 +274,8 @@ 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;
@@ -272,8 +292,8 @@ public:
                        QLineEdit *, QPushButton *, bool pwd );
     virtual ~FileConfigControl() {};
     virtual QString getValue() { return text->text(); };
-    virtual void show() { text->show(); label->show(); browse->show(); }
-    virtual void hide() { text->hide(); label->hide(); browse->hide(); }
+    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:
@@ -296,6 +316,7 @@ public slots:
     virtual void updateField();
 };
 
+#if 0
 class FontConfigControl : public FileConfigControl
 {
     Q_OBJECT;
@@ -308,6 +329,7 @@ public:
 public slots:
     virtual void updateField();
 };
+#endif
 
 class ModuleConfigControl : public VStringConfigControl
 {
@@ -318,14 +340,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;
@@ -339,16 +366,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;
+    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& );
@@ -356,13 +384,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(); }
+       QComboBox *combo;
 private:
-    void finish( bool );
+    void finish(module_config_t *, 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;
@@ -387,20 +422,19 @@ private slot:
 /**********************************************************************
  * Key selector widget
  **********************************************************************/
-class KeyInputDialog : public QDialog
+class KeyShortcutEdit: public QLineEdit
 {
+    Q_OBJECT
 public:
-    KeyInputDialog( QList<module_config_t *> &, const char * );
-    int keyValue;
-    bool conflicts;
+    void setValue( int _value ){ value = _value; }
+    int getValue() const { return value; }
+public slots:
+    virtual void clear(void) { value = 0; QLineEdit::clear(); }
 private:
-    void checkForConflicts( int i_vlckey );
-    void keyPressEvent( QKeyEvent *);
-    void wheelEvent( QWheelEvent *);
-    QLabel *selected;
-    QLabel *warning;
-    const char * keyToChange;
-    QList<module_config_t*> values;
+    int value;
+    virtual void mousePressEvent( QMouseEvent *event );
+signals:
+    void pressed();
 };
 
 class KeySelectorControl : public ConfigControl
@@ -409,18 +443,36 @@ class KeySelectorControl : public ConfigControl
 public:
     KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
                         QGridLayout*, int& );
-    virtual int getType() { return 4; }
+    virtual int getType() { return CONFIG_ITEM_KEY; }
     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();
 };
 
+class KeyInputDialog : public QDialog
+{
+public:
+    KeyInputDialog( QTreeWidget *, QString, QWidget * );
+    int keyValue;
+    bool conflicts;
+private:
+    QTreeWidget *table;
+    void checkForConflicts( int i_vlckey );
+    void keyPressEvent( QKeyEvent *);
+    void wheelEvent( QWheelEvent *);
+    QLabel *selected;
+    QVBoxLayout *vLayout;
+    QDialogButtonBox *buttonBox;
+};
 #endif