[vlc-commits] gui/qt: extended_panels: refactor OptionFromWidgetName

Filip Roséen git at videolan.org
Sat Feb 25 15:22:14 CET 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Sat Feb 25 07:31:44 2017 +0100| [8a961e000682d252ed727cd838c46e6dd9076c3b] | committer: Jean-Baptiste Kempf

gui/qt: extended_panels: refactor OptionFromWidgetName

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8a961e000682d252ed727cd838c46e6dd9076c3b
---

 modules/gui/qt/components/extended_panels.cpp | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 837932e..6a9c947 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -39,6 +39,7 @@
 #include <QFileDialog>
 #include <QGraphicsScene>
 #include <QPainter>
+#include <QRegExp>
 
 #include "components/extended_panels.hpp"
 #include "dialogs/preferences.hpp"
@@ -64,18 +65,10 @@ static const QString ModuleFromWidgetName( QObject *obj )
 static QString OptionFromWidgetName( QObject *obj )
 {
     /* Gruik ? ... nah */
-    QString option = obj->objectName().replace( "Slider", "" )
-                                      .replace( "Combo" , "" )
-                                      .replace( "Dial"  , "" )
-                                      .replace( "Check" , "" )
-                                      .replace( "Spin"  , "" )
-                                      .replace( "Text"  , "" );
-    for( char a = 'A'; a <= 'Z'; a++ )
-    {
-        option = option.replace( QString( a ),
-                                 QString( '-' ) + QString( a + 'a' - 'A' ) );
-    }
-    return option;
+    return obj->objectName()
+        .remove( QRegExp( "Slider|Combo|Dial|Check|Spin|Text" ) )
+        .replace( QRegExp( "([A-Z])" ), "-\\1" )
+        .toLower();
 }
 
 static inline void setup_vfilter( intf_thread_t *p_intf, const char* psz_name, QWidget *widget )



More information about the vlc-commits mailing list