Commit c8986a40 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: Use a QFontComboBox instead of a QFontDialog.

parent 9f89ad42
...@@ -368,27 +368,37 @@ void DirectoryConfigControl::updateField() ...@@ -368,27 +368,37 @@ void DirectoryConfigControl::updateField()
text->setText( toNativeSepNoSlash( dir ) ); text->setText( toNativeSepNoSlash( dir ) );
} }
#include <QFontDialog> #include <QFontComboBox>
/********* String / Font **********/ /********* String / Font **********/
FontConfigControl::FontConfigControl( vlc_object_t *_p_this, FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_p_widget, module_config_t *_p_item, QWidget *_parent,
QGridLayout *_p_layout, int& _int) : QGridLayout *_p_layout, int& line) :
FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int) VStringConfigControl( _p_this, _p_item, _parent )
{} {
label = new QLabel( qtr(p_item->psz_text) );
font = new QFontComboBox( _parent );
if( !_p_layout )
{
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 );
layout->addWidget( font, 1 );
widget->setLayout( layout );
}
else
{
_p_layout->addWidget( label, line, 0 );
_p_layout->addWidget( font, line, 1 );
}
}
FontConfigControl::FontConfigControl( vlc_object_t *_p_this, FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_p_label, module_config_t *_p_item, QLabel *_p_label,
QLineEdit *_p_line, QPushButton *_p_button): QFontComboBox *_p_font):
FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button) VStringConfigControl( _p_this, _p_item)
{}
void FontConfigControl::updateField()
{ {
bool ok; label = _p_label;
QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL ); font = _p_font;
if( !ok ) return;
text->setText( font.family() );
} }
/********* String / choice list **********/ /********* String / choice list **********/
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QPushButton> #include <QPushButton>
#include <QVector> #include <QVector>
#include <QDialog> #include <QDialog>
#include <QFontComboBox>
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
...@@ -329,17 +330,19 @@ public slots: ...@@ -329,17 +330,19 @@ public slots:
virtual void updateField(); virtual void updateField();
}; };
class FontConfigControl : public FileConfigControl class FontConfigControl : public VStringConfigControl
{ {
Q_OBJECT; Q_OBJECT;
public: public:
FontConfigControl( vlc_object_t *, module_config_t *, QWidget *, FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int&); QGridLayout *, int&);
FontConfigControl( vlc_object_t *, module_config_t *, QLabel *, FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit *, QPushButton *); QFontComboBox *);
virtual ~FontConfigControl() {}; virtual ~FontConfigControl() {};
public slots: virtual QString getValue(){ return font->currentFont().toString(); }
virtual void updateField(); protected:
QLabel *label;
QFontComboBox *font;
}; };
class ModuleConfigControl : public VStringConfigControl class ModuleConfigControl : public VStringConfigControl
......
...@@ -576,8 +576,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -576,8 +576,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
encoding ); encoding );
CONFIG_GENERIC( "sub-language", String, ui.subLangLabel, CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
preferredLanguage ); preferredLanguage );
CONFIG_GENERIC_FILE( "freetype-font", Font, ui.fontLabel, ui.font, CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
ui.fontBrowse );
CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel, CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
fontColor ); fontColor );
CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>772</width> <width>772</width>
<height>444</height> <height>446</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -131,15 +131,8 @@ ...@@ -131,15 +131,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QPushButton" name="fontBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="font"/> <widget class="QFontComboBox" name="font"/>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="fontLabel"> <widget class="QLabel" name="fontLabel">
...@@ -187,7 +180,6 @@ ...@@ -187,7 +180,6 @@
<tabstop>preferredLanguage</tabstop> <tabstop>preferredLanguage</tabstop>
<tabstop>encoding</tabstop> <tabstop>encoding</tabstop>
<tabstop>font</tabstop> <tabstop>font</tabstop>
<tabstop>fontBrowse</tabstop>
<tabstop>fontSize</tabstop> <tabstop>fontSize</tabstop>
<tabstop>fontColor</tabstop> <tabstop>fontColor</tabstop>
<tabstop>effect</tabstop> <tabstop>effect</tabstop>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment