]> git.sesse.net Git - vlc/commitdiff
Qt: messages dialog: new verbosity spinbox
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 25 Sep 2010 20:20:45 +0000 (22:20 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 25 Sep 2010 20:23:07 +0000 (22:23 +0200)
modules/gui/qt4/ui/messages_panel.ui
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.hpp

index 5832847e847e7beba7347e3f6f725a2b0846c44b..9efc353e095af818c6846085f1b6e6ecbb746dde 100644 (file)
         </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">
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>DebugLevelSpinBox</class>
+   <extends>QSpinBox</extends>
+   <header>util/customwidgets.hpp</header>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>
index a83d94dbd9e44510cdcda725238805069f0e4fa7..3a661a2f8f8133195527bd7844a2e9beca89dd21 100644 (file)
@@ -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
  ***************************************************************************/
index 64d08dda335b06e6fd31c6c4d3ad4aad65dda367..e2338c6baa7eef8899bfc4e45dfc0063267acc0d 100644 (file)
@@ -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;