[vlc-commits] Qt: QDial: show value on control (fix #8906)
Francois Cartegnie
git at videolan.org
Tue Jul 9 19:13:10 CEST 2013
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 9 19:12:19 2013 +0200| [ba5d2dc02ceb16da558fb1bf4fc37b9b65135bcf] | committer: Francois Cartegnie
Qt: QDial: show value on control (fix #8906)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ba5d2dc02ceb16da558fb1bf4fc37b9b65135bcf
---
modules/gui/qt4/components/extended_panels.cpp | 5 +++--
modules/gui/qt4/ui/video_effects.ui | 9 ++++++++-
modules/gui/qt4/util/customwidgets.cpp | 16 ++++++++++++++++
modules/gui/qt4/util/customwidgets.hpp | 10 ++++++++++
4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index 7c87b9c..d591001 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -47,6 +47,7 @@
#include "qt4.hpp"
#include "input_manager.hpp"
#include "util/qt_dirs.hpp"
+#include "util/customwidgets.hpp"
#include "../../audio_filter/equalizer_presets.h"
#include <vlc_intf_strings.h>
@@ -529,7 +530,7 @@ void ExtVideo::setWidgetValue( QObject *widget )
QCheckBox *checkbox = qobject_cast<QCheckBox*> ( widget );
QSpinBox *spinbox = qobject_cast<QSpinBox*> ( widget );
QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( widget );
- QDial *dial = qobject_cast<QDial*> ( widget );
+ VLCQDial *dial = qobject_cast<VLCQDial*> ( widget );
QLineEdit *lineedit = qobject_cast<QLineEdit*> ( widget );
QComboBox *combobox = qobject_cast<QComboBox*> ( widget );
@@ -605,7 +606,7 @@ void ExtVideo::updateFilterOptions()
QCheckBox *checkbox = qobject_cast<QCheckBox*> ( sender() );
QSpinBox *spinbox = qobject_cast<QSpinBox*> ( sender() );
QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
- QDial *dial = qobject_cast<QDial*> ( sender() );
+ VLCQDial *dial = qobject_cast<VLCQDial*> ( sender() );
QLineEdit *lineedit = qobject_cast<QLineEdit*> ( sender() );
QComboBox *combobox = qobject_cast<QComboBox*> ( sender() );
diff --git a/modules/gui/qt4/ui/video_effects.ui b/modules/gui/qt4/ui/video_effects.ui
index 88a231c..be07ad3 100644
--- a/modules/gui/qt4/ui/video_effects.ui
+++ b/modules/gui/qt4/ui/video_effects.ui
@@ -843,7 +843,7 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QDial" name="rotateAngleDial">
+ <widget class="VLCQDial" name="rotateAngleDial">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -1795,6 +1795,13 @@
</layout>
</widget>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>VLCQDial</class>
+ <extends>QDial</extends>
+ <header>util/customwidgets.hpp</header>
+ </customwidget>
+ </customwidgets>
<tabstops>
<tabstop>adjustEnable</tabstop>
<tabstop>hueSlider</tabstop>
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 1a00fe0..8d19631 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -87,6 +87,22 @@ QString QVLCDebugLevelSpinBox::textFromValue( int v ) const
return QString( "%1 (%2)" ).arg( v ).arg( texts[v] );
}
+VLCQDial::VLCQDial( QWidget *parent ) : QDial( parent )
+{
+
+}
+
+void VLCQDial::paintEvent( QPaintEvent *event )
+{
+ QDial::paintEvent( event );
+ QPainter painter( this );
+ QRect rect = geometry();
+ painter.setPen( QPen( palette().color( QPalette::WindowText ) ) );
+ painter.drawText( QRectF( 0, rect.height() * 0.66, rect.width(), rect.height() ),
+ Qt::AlignHCenter, QString::number( value() ), 0 );
+ painter.end();
+}
+
/***************************************************************************
* Hotkeys converters
***************************************************************************/
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index e7ccf46..9a15553 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -37,6 +37,7 @@
#include <QTimer>
#include <QToolButton>
#include <QAbstractAnimation>
+#include <QDial>
class QPixmap;
class QWidget;
@@ -51,6 +52,15 @@ protected:
virtual void paintEvent( QPaintEvent * event );
};
+class VLCQDial : public QDial
+{
+ Q_OBJECT
+public:
+ VLCQDial( QWidget *parent = NULL );
+protected:
+ virtual void paintEvent( QPaintEvent * event );
+};
+
class QToolButtonExt : public QToolButton
{
Q_OBJECT
More information about the vlc-commits
mailing list