Commit b3564a7d authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: messages dialog: new verbosity spinbox

parent 0ab13a3a
......@@ -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>
......@@ -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
***************************************************************************/
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment