From 8071564e17af2ef0e4c8bb093862fe3b5c37caf6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Tue, 23 Oct 2007 06:23:27 +0000 Subject: [PATCH] Qt4 - initial actions support for StringListConfigs in preferences... To be tested a lot more... --- .../qt4/components/preferences_widgets.cpp | 38 ++++++++++++++++++- .../qt4/components/preferences_widgets.hpp | 4 ++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index 46682f44c0..d6286639ed 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -44,7 +44,7 @@ #include #include #include - +#include QString formatTooltip(const QString & tooltip) { QString formatted = @@ -364,6 +364,42 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, l->addWidget( label, line, 0 ); l->addWidget( combo, line, 1, Qt::AlignRight ); } + + if( p_item->i_action ) + { + QSignalMapper *signalMapper = new QSignalMapper(this); + + /* Some stringLists like Capture listings have action associated */ + for( int i = 0; i < p_item->i_action; i++ ) + { + QPushButton *button = + new QPushButton( qfu( p_item->ppsz_action_text[i] )); + CONNECT( button, clicked(), signalMapper, map() ); + signalMapper->setMapping( button, i ); + l->addWidget( button, line, 2 + i, Qt::AlignRight ); + } + CONNECT( signalMapper, mapped( int ), + this, actionRequested( int ) ); + } +} + +void StringListConfigControl::actionRequested( int i_action ) +{ + /* Supplementary check for boundaries */ + if( i_action < 0 || i_action >= p_item->i_action ) return; + + vlc_value_t val; + val.psz_string = qtu( (combo->itemData( combo->currentIndex() ).toString() ) ); + + p_item->ppf_action[i_action]( p_this, getName(), val, val, 0 ); + + if( p_item->b_dirty ) + { + combo->clear(); + finish( true ); + p_item->b_dirty = VLC_FALSE; + + } } StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, module_config_t *_p_item, QLabel *_label, QComboBox *_combo, diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp index 836e66f7bc..605dabbffa 100644 --- a/modules/gui/qt4/components/preferences_widgets.hpp +++ b/modules/gui/qt4/components/preferences_widgets.hpp @@ -360,6 +360,7 @@ private: class StringListConfigControl : public VStringConfigControl { + Q_OBJECT; public: StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool, QGridLayout*, int& ); @@ -373,6 +374,9 @@ private: void finish( bool ); QLabel *label; QComboBox *combo; +private slots: + void actionRequested( int ); + }; #if 0 struct ModuleCheckBox { -- 2.39.2