[vlc-commits] Qt: complete_preferences: toggle prefs for current modules.
Francois Cartegnie
git at videolan.org
Wed Dec 19 19:15:11 CET 2012
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 19 19:14:38 2012 +0100| [d02ebf63a7dbb1a17b720a53c4ca628beea63ab6] | committer: Francois Cartegnie
Qt: complete_preferences: toggle prefs for current modules.
Preferences set regarding loaded modules only is likely to contain what
the user is looking for.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d02ebf63a7dbb1a17b720a53c4ca628beea63ab6
---
.../gui/qt4/components/complete_preferences.cpp | 68 +++++++++++++++++++-
.../gui/qt4/components/complete_preferences.hpp | 10 ++-
modules/gui/qt4/dialogs/preferences.cpp | 13 ++++
modules/gui/qt4/dialogs/preferences.hpp | 2 +
4 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt4/components/complete_preferences.cpp b/modules/gui/qt4/components/complete_preferences.cpp
index f5c5b7a..43a8ec6 100644
--- a/modules/gui/qt4/components/complete_preferences.cpp
+++ b/modules/gui/qt4/components/complete_preferences.cpp
@@ -366,6 +366,8 @@ bool PrefsTree::filterItems( QTreeWidgetItem *item, const QString &text,
PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData *>();
bool filtered = sub_filtered && !data->contains( text, cs );
+ if ( b_show_only_loaded && sub_filtered && !data->b_loaded )
+ filtered = true;
item->setExpanded( !sub_filtered );
item->setHidden( filtered );
@@ -396,10 +398,59 @@ bool PrefsTree::collapseUnselectedItems( QTreeWidgetItem *item )
return collapsed;
}
+static void populateLoadedSet( QSet<QString> *loaded, vlc_object_t *p_node )
+{
+ Q_ASSERT( loaded );
+ char *name = vlc_object_get_name( p_node );
+ if ( !EMPTY_STR( name ) ) loaded->insert( QString( name ) );
+ free( name );
+
+ vlc_list_t *l = vlc_list_children( p_node );
+ for( int i=0; i < l->i_count; i++ )
+ populateLoadedSet( loaded, l->p_values[i].p_object );
+ vlc_list_release( l );
+}
+
+/* Updates the PrefsItemData loaded status to reflect currently
+ * running modules */
+void PrefsTree::updateLoadedStatus( QTreeWidgetItem *item = NULL,
+ QSet<QString> *loaded = NULL )
+{
+ bool b_release = false;
+
+ if( loaded == NULL )
+ {
+ vlc_object_t *p_root = VLC_OBJECT( p_intf->p_libvlc );
+ loaded = new QSet<QString>();
+ populateLoadedSet( loaded, p_root );
+ b_release = true;
+ }
+
+ if ( item == NULL )
+ {
+ for( int i = 0 ; i < topLevelItemCount(); i++ )
+ updateLoadedStatus( topLevelItem( i ), loaded );
+ }
+ else
+ {
+ PrefsItemData *data = item->data( 0, Qt::UserRole )
+ .value<PrefsItemData *>();
+ data->b_loaded = loaded->contains( QString( data->psz_name ) );
+
+ for( int i = 0; i < item->childCount(); i++ )
+ updateLoadedStatus( item->child( i ), loaded );
+ }
+
+ if ( b_release )
+ delete loaded;
+}
+
/* apply filter on tree */
void PrefsTree::filter( const QString &text )
{
- bool clear_filter = text.isEmpty();
+ bool clear_filter = text.isEmpty() && ! b_show_only_loaded;
+
+ updateLoadedStatus();
for( int i = 0 ; i < topLevelItemCount(); i++ )
{
@@ -415,11 +466,26 @@ void PrefsTree::filter( const QString &text )
}
}
+void PrefsTree::setLoadedOnly( bool b_only )
+{
+ b_show_only_loaded = b_only;
+ filter( "" );
+}
+
void PrefsTree::resizeColumns()
{
resizeColumnToContents( 0 );
}
+PrefsItemData::PrefsItemData()
+{
+ panel = NULL;
+ i_object_id = 0;
+ i_subcat_id = -1;
+ psz_name = NULL;
+ b_loaded = false;
+}
+
/* go over the module config items and search text in psz_text
* also search the module name and head */
bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
diff --git a/modules/gui/qt4/components/complete_preferences.hpp b/modules/gui/qt4/components/complete_preferences.hpp
index 7e23327..1d9ae84 100644
--- a/modules/gui/qt4/components/complete_preferences.hpp
+++ b/modules/gui/qt4/components/complete_preferences.hpp
@@ -32,6 +32,7 @@
#include <vlc_interface.h>
#include <QTreeWidget>
+#include <QSet>
enum
{
@@ -49,8 +50,7 @@ class PrefsItemData : public QObject
{
Q_OBJECT
public:
- PrefsItemData()
- { panel = NULL; i_object_id = 0; i_subcat_id = -1; psz_name = NULL; };
+ PrefsItemData();
virtual ~PrefsItemData() { free( psz_name ); };
bool contains( const QString &text, Qt::CaseSensitivity cs );
AdvPrefsPanel *panel;
@@ -58,6 +58,7 @@ public:
int i_subcat_id;
int i_type;
char *psz_name;
+ bool b_loaded;
QString name;
QString help;
};
@@ -67,18 +68,23 @@ Q_DECLARE_METATYPE( PrefsItemData* );
class PrefsTree : public QTreeWidget
{
Q_OBJECT
+ Q_PROPERTY( bool b_show_only_loaded WRITE setLoadedOnly )
+
public:
PrefsTree( intf_thread_t *, QWidget * );
void applyAll();
void cleanAll();
void filter( const QString &text );
+ void setLoadedOnly( bool );
private:
void doAll( bool );
bool filterItems( QTreeWidgetItem *item, const QString &text, Qt::CaseSensitivity cs );
bool collapseUnselectedItems( QTreeWidgetItem *item );
+ void updateLoadedStatus( QTreeWidgetItem *item , QSet<QString> *loaded );
intf_thread_t *p_intf;
+ bool b_show_only_loaded;
private slots:
void resizeColumns();
diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp
index d7fecf4..9875458 100644
--- a/modules/gui/qt4/dialogs/preferences.cpp
+++ b/modules/gui/qt4/dialogs/preferences.cpp
@@ -79,6 +79,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
/* Tree and panel initialisations */
advanced_tree = NULL;
tree_filter = NULL;
+ current_filter = NULL;
simple_tree = NULL;
simple_panels_stack = new QStackedWidget;
advanced_panels_stack = new QStackedWidget;
@@ -157,6 +158,13 @@ void PrefsDialog::setAdvanced()
this, advancedTreeFilterChanged( const QString & ) );
advanced_tree_panel->layout()->addWidget( tree_filter );
+
+ current_filter = new QCheckBox( qtr("Only show current") );
+ current_filter->setToolTip(
+ qtr("Only show modules related to current playback") );
+ CONNECT( current_filter, stateChanged(int),
+ this, onlyLoadedToggled() );
+ advanced_tree_panel->layout()->addWidget( current_filter );
}
/* If don't have already and advanced TREE, then create it */
@@ -328,3 +336,8 @@ void PrefsDialog::advancedTreeFilterChanged( const QString & text )
{
advanced_tree->filter( text );
}
+
+void PrefsDialog::onlyLoadedToggled()
+{
+ advanced_tree->setLoadedOnly( current_filter->isChecked() );
+}
diff --git a/modules/gui/qt4/dialogs/preferences.hpp b/modules/gui/qt4/dialogs/preferences.hpp
index 9273241..f4b8b2e 100644
--- a/modules/gui/qt4/dialogs/preferences.hpp
+++ b/modules/gui/qt4/dialogs/preferences.hpp
@@ -70,6 +70,7 @@ private:
SPrefsCatList *simple_tree;
PrefsTree *advanced_tree;
SearchLineEdit *tree_filter;
+ QCheckBox *current_filter;
QGroupBox *types;
QRadioButton *small,*all;
@@ -83,6 +84,7 @@ private slots:
void changeAdvPanel( QTreeWidgetItem * );
void changeSimplePanel( int );
void advancedTreeFilterChanged( const QString & );
+ void onlyLoadedToggled();
void save();
void cancel();
More information about the vlc-commits
mailing list