[vlc-commits] commit: Qt: messages dialog: new verbosity spinbox (Francois Cartegnie )
git at videolan.org
git at videolan.org
Sat Sep 25 22:29:49 CEST 2010
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Sep 25 22:20:45 2010 +0200| [b3564a7d8180f0e72111a485aaf4d46ab0be868e] | committer: Francois Cartegnie
Qt: messages dialog: new verbosity spinbox
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3564a7d8180f0e72111a485aaf4d46ab0be868e
---
modules/gui/qt4/ui/messages_panel.ui | 15 ++++++++++++++-
modules/gui/qt4/util/customwidgets.cpp | 24 ++++++++++++++++++++++++
modules/gui/qt4/util/customwidgets.hpp | 11 +++++++++++
3 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/ui/messages_panel.ui b/modules/gui/qt4/ui/messages_panel.ui
index 5832847..9efc353 100644
--- a/modules/gui/qt4/ui/messages_panel.ui
+++ b/modules/gui/qt4/ui/messages_panel.ui
@@ -49,13 +49,19 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="verbosityBox">
+ <widget class="DebugLevelSpinBox" name="verbosityBox">
<property name="wrapping">
<bool>true</bool>
</property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
<property name="maximum">
<number>2</number>
</property>
+ <property name="value">
+ <number>0</number>
+ </property>
</widget>
</item>
<item row="1" column="2">
@@ -111,6 +117,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>DebugLevelSpinBox</class>
+ <extends>QSpinBox</extends>
+ <header>util/customwidgets.hpp</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index a83d94d..3a661a2 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 64d08dd..e2338c6 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -31,6 +31,7 @@
#include <QPushButton>
#include <QLabel>
#include <QStackedWidget>
+#include <QSpinBox>
/**
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;
More information about the vlc-commits
mailing list