From: Yoann Peronneau Date: Tue, 27 Mar 2007 21:54:16 +0000 (+0000) Subject: * qt: add a FontConfigControl X-Git-Tag: 0.9.0-test0~7974 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=42980ccc071d8a2b6655e3ec857b36af90c67ee3;p=vlc * qt: add a FontConfigControl --- diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h index 1212aacaf6..33b052f261 100644 --- a/include/vlc_configuration.h +++ b/include/vlc_configuration.h @@ -61,6 +61,7 @@ extern "C" { #define CONFIG_ITEM_MODULE_CAT 0x0090 /* Module option */ #define CONFIG_ITEM_MODULE_LIST 0x00A0 /* Module option */ #define CONFIG_ITEM_MODULE_LIST_CAT 0x00B0 /* Module option */ +#define CONFIG_ITEM_FONT 0x00C0 /* Font option */ #define CONFIG_ITEM 0x00F0 diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index aea238411d..0760c74a80 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -110,6 +111,10 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, p_control = new DirectoryConfigControl( p_this, p_item, parent, l, line, false ); break; + case CONFIG_ITEM_FONT: + p_control = new FontConfigControl( p_this, p_item, parent, l, + line, false ); + break; case CONFIG_ITEM_KEY: p_control = new KeySelectorControl( p_this, p_item, parent, l, line ); break; @@ -273,7 +278,6 @@ void FileConfigControl::finish() } /********* String / Directory **********/ - DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this, module_config_t *_p_item, QWidget *_p_widget, QGridLayout *_p_layout, int& _int, bool _pwd ) : @@ -286,7 +290,6 @@ DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this, FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd) {} - void DirectoryConfigControl::updateField() { QString dir = QFileDialog::getExistingDirectory( NULL, @@ -297,6 +300,27 @@ void DirectoryConfigControl::updateField() text->setText( dir ); } +/********* String / Font **********/ +FontConfigControl::FontConfigControl( vlc_object_t *_p_this, + module_config_t *_p_item, QWidget *_p_widget, + QGridLayout *_p_layout, int& _int, bool _pwd ) : + FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd) +{} + +FontConfigControl::FontConfigControl( vlc_object_t *_p_this, + module_config_t *_p_item, QLabel *_p_label, + QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ): + FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd) +{} + +void FontConfigControl::updateField() +{ + bool ok; + QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL ); + if( !ok ) return; + text->setText( font.family() ); +} + /********* String / choice list **********/ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, module_config_t *_p_item, QWidget *_parent, bool bycat, diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp index d27d7f16fc..76e5b5b5f3 100644 --- a/modules/gui/qt4/components/preferences_widgets.hpp +++ b/modules/gui/qt4/components/preferences_widgets.hpp @@ -266,9 +266,9 @@ class FileConfigControl : public VStringConfigControl Q_OBJECT; public: FileConfigControl( vlc_object_t *, module_config_t *, QWidget *, - QGridLayout *, int&, bool pwd ); + QGridLayout *, int&, bool pwd ); FileConfigControl( vlc_object_t *, module_config_t *, QLabel *, - QLineEdit *, QPushButton *, bool pwd ); + QLineEdit *, QPushButton *, bool pwd ); virtual ~FileConfigControl() {}; virtual QString getValue() { return text->text(); }; virtual void show() { text->show(); label->show(); browse->show(); } @@ -287,14 +287,27 @@ class DirectoryConfigControl : public FileConfigControl Q_OBJECT; public: DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *, - QGridLayout *, int&, bool pwd ); + QGridLayout *, int&, bool pwd ); DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *, - QLineEdit *, QPushButton *, bool pwd ); + 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: