From: Francois Cartegnie Date: Sat, 25 Sep 2010 20:20:45 +0000 (+0200) Subject: Qt: messages dialog: new verbosity spinbox X-Git-Tag: 1.2.0-pre1~5225 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b3564a7d8180f0e72111a485aaf4d46ab0be868e;p=vlc Qt: messages dialog: new verbosity spinbox --- diff --git a/modules/gui/qt4/ui/messages_panel.ui b/modules/gui/qt4/ui/messages_panel.ui index 5832847e84..9efc353e09 100644 --- a/modules/gui/qt4/ui/messages_panel.ui +++ b/modules/gui/qt4/ui/messages_panel.ui @@ -49,13 +49,19 @@ - + true + + 0 + 2 + + 0 + @@ -111,6 +117,13 @@ + + + DebugLevelSpinBox + QSpinBox +
util/customwidgets.hpp
+
+
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp index a83d94dbd9..3a661a2f8f 100644 --- a/modules/gui/qt4/util/customwidgets.cpp +++ b/modules/gui/qt4/util/customwidgets.cpp @@ -227,6 +227,30 @@ void QVLCElidingLabel::paintEvent( QPaintEvent * event ) p.drawText( r, fontMetrics().elidedText( text(), elideMode, r.width() ), alignment() ); } +QString DebugLevelSpinBox::textFromValue( int v ) const +{ + QString const texts[] = { + /* Note that min level 0 is 'errors' in Qt Ui + FIXME: fix debug levels accordingly to documentation */ + /* qtr("infos"),*/ + qtr("errors"), + qtr("warnings"), + qtr("debug") + }; + if ( v < 0 ) v = 0; + if ( v >= 2 ) v = 2; + + return QString( "%1 (%2)" ).arg( v ).arg( texts[v] ); +} + +int DebugLevelSpinBox::mapTextToValue ( bool *ok ) +{ + int parsedvalue = cleanText().toInt(); + /* fix range */ + *ok = ( parsedvalue < 0 || parsedvalue > 2 )? FALSE : TRUE; + return parsedvalue; +} + /*************************************************************************** * Hotkeys converters ***************************************************************************/ diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp index 64d08dda33..e2338c6baa 100644 --- a/modules/gui/qt4/util/customwidgets.hpp +++ b/modules/gui/qt4/util/customwidgets.hpp @@ -31,6 +31,7 @@ #include #include #include +#include /** This class provides a QLineEdit which contains a greyed-out hinting @@ -112,6 +113,16 @@ public: } }; +class DebugLevelSpinBox : public QSpinBox +{ + Q_OBJECT +public: + DebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { }; +protected: + QString textFromValue( int ) const; + int mapTextToValue ( bool * ); +}; + /* VLC Key/Wheel hotkeys interactions */ class QKeyEvent;