Commit 1beb0074 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Qt: QProxyStyle is the new way to extend styles in Qt5

parent 1c9516cf
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include "util/input_slider.hpp" #include "util/input_slider.hpp"
#include "adapters/seekpoints.hpp" #include "adapters/seekpoints.hpp"
#include <QWindowsStyle> #include <QProxyStyle>
#include <QStyleFactory>
#include <QStyleOptionSlider> #include <QStyleOptionSlider>
#include <QPainter> #include <QPainter>
#include <QDebug> #include <QDebug>
...@@ -32,6 +33,11 @@ ...@@ -32,6 +33,11 @@
#define RADIUS 3 #define RADIUS 3
#define CHAPTERSSPOTSIZE 3 #define CHAPTERSSPOTSIZE 3
SeekStyle::SeekStyle() : QProxyStyle( QStyleFactory::create( QLatin1String("Windows") ) )
{
}
int SeekStyle::pixelMetric( PixelMetric metric, const QStyleOption *option, const QWidget *widget ) const int SeekStyle::pixelMetric( PixelMetric metric, const QStyleOption *option, const QWidget *widget ) const
{ {
const QStyleOptionSlider *slider; const QStyleOptionSlider *slider;
...@@ -39,7 +45,7 @@ int SeekStyle::pixelMetric( PixelMetric metric, const QStyleOption *option, cons ...@@ -39,7 +45,7 @@ int SeekStyle::pixelMetric( PixelMetric metric, const QStyleOption *option, cons
if ( metric == PM_SliderLength && ( slider = qstyleoption_cast<const QStyleOptionSlider *>( option ) ) ) if ( metric == PM_SliderLength && ( slider = qstyleoption_cast<const QStyleOptionSlider *>( option ) ) )
return slider->rect.height(); return slider->rect.height();
else else
return QWindowsStyle::pixelMetric( metric, option, widget ); return QProxyStyle::pixelMetric( metric, option, widget );
} }
void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget ) const void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget ) const
...@@ -121,7 +127,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex ...@@ -121,7 +127,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
if ( slider->subControls & SC_SliderTickmarks ) { if ( slider->subControls & SC_SliderTickmarks ) {
QStyleOptionSlider tmpSlider = *slider; QStyleOptionSlider tmpSlider = *slider;
tmpSlider.subControls = SC_SliderTickmarks; tmpSlider.subControls = SC_SliderTickmarks;
QWindowsStyle::drawComplexControl(cc, &tmpSlider, painter, widget); QProxyStyle::drawComplexControl(cc, &tmpSlider, painter, widget);
} }
if ( slider->subControls & SC_SliderHandle && handle.isValid() ) if ( slider->subControls & SC_SliderHandle && handle.isValid() )
...@@ -202,6 +208,6 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex ...@@ -202,6 +208,6 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
else else
{ {
qWarning() << "SeekStyle: Drawing an unmanaged control"; qWarning() << "SeekStyle: Drawing an unmanaged control";
QWindowsStyle::drawComplexControl( cc, option, painter, widget ); QProxyStyle::drawComplexControl( cc, option, painter, widget );
} }
} }
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
#ifndef SEEKSTYLE_HPP #ifndef SEEKSTYLE_HPP
#define SEEKSTYLE_HPP #define SEEKSTYLE_HPP
#include <QWindowsStyle> #include <QProxyStyle>
class SeekStyle : public QWindowsStyle class SeekStyle : public QProxyStyle
{ {
Q_OBJECT Q_OBJECT
public: public:
SeekStyle() { } SeekStyle();
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0) const; virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0) const;
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const; virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const;
}; };
......
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