diff options
author | Timothy Pearson <[email protected]> | 2014-08-07 13:08:29 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2014-08-07 13:08:29 -0500 |
commit | 93b3efa8902c19e9b67114652dc84c463f8c219a (patch) | |
tree | aa0f907f2c1c2f2dd6da5b8ca9c09f41c56be11b | |
parent | 71a6d7870f609df603d9520a8d292055ea5928c3 (diff) | |
download | qt3-93b3efa8902c19e9b67114652dc84c463f8c219a.tar.gz qt3-93b3efa8902c19e9b67114652dc84c463f8c219a.zip |
Refresh control element data structures before executing style object event handlers
This resolves Bug 1816
Fix FTBFS in style examples
-rw-r--r-- | examples/themes/metal.cpp | 16 | ||||
-rw-r--r-- | examples/themes/metal.h | 16 | ||||
-rw-r--r-- | examples/themes/wood.cpp | 22 | ||||
-rw-r--r-- | examples/themes/wood.h | 22 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 21 |
5 files changed, 53 insertions, 44 deletions
diff --git a/examples/themes/metal.cpp b/examples/themes/metal.cpp index 636e562..4a8bac8 100644 --- a/examples/themes/metal.cpp +++ b/examples/themes/metal.cpp @@ -41,7 +41,7 @@ MetalStyle::MetalStyle() : QWindowsStyle() { } /*! Reimplementation from QStyle */ -void MetalStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void MetalStyle::applicationPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { oldPalette = ceData.palette; @@ -99,7 +99,7 @@ void MetalStyle::applicationPolish( QStyleControlElementData ceData, ControlElem /*! Reimplementation from QStyle */ -void MetalStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void MetalStyle::applicationUnPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(oldPalette, TRUE)); applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, QStyleApplicationActionRequestData(ceData.font, TRUE)); @@ -108,7 +108,7 @@ void MetalStyle::applicationUnPolish( QStyleControlElementData ceData, ControlEl /*! Reimplementation from QStyle */ -void MetalStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void MetalStyle::polish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full @@ -126,7 +126,7 @@ void MetalStyle::polish( QStyleControlElementData ceData, ControlElementFlags el } } -void MetalStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void MetalStyle::unPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full @@ -145,7 +145,7 @@ void MetalStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags void MetalStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -191,7 +191,7 @@ void MetalStyle::drawPrimitive( PrimitiveElement pe, void MetalStyle::drawControl( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -292,7 +292,7 @@ void MetalStyle::drawControl( ControlElement element, } void MetalStyle::drawComplexControl( ComplexControl cc, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -468,7 +468,7 @@ void MetalStyle::drawMetalGradient( QPainter *p, int x, int y, int w, int h, -int MetalStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *w ) const +int MetalStyle::pixelMetric( PixelMetric metric, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QWidget *w ) const { switch ( metric ) { case PM_MenuBarFrameWidth: diff --git a/examples/themes/metal.h b/examples/themes/metal.h index 46257f6..5e20657 100644 --- a/examples/themes/metal.h +++ b/examples/themes/metal.h @@ -26,14 +26,14 @@ class MetalStyle : public QWindowsStyle { public: MetalStyle(); - void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void applicationUnPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void polish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void unPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); void drawPrimitive( PrimitiveElement pe, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -42,7 +42,7 @@ public: void drawControl( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -52,7 +52,7 @@ public: void drawComplexControl( ComplexControl cc, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -61,7 +61,7 @@ public: SCFlags subActive = SC_None, const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - int pixelMetric( PixelMetric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget * = 0 ) const; + int pixelMetric( PixelMetric, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QWidget * = 0 ) const; private: diff --git a/examples/themes/wood.cpp b/examples/themes/wood.cpp index 085fdea..11af503 100644 --- a/examples/themes/wood.cpp +++ b/examples/themes/wood.cpp @@ -769,7 +769,7 @@ NorwegianWoodStyle::NorwegianWoodStyle() : QWindowsStyle() /*! Reimplementation from QStyle */ -void NorwegianWoodStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void NorwegianWoodStyle::applicationPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { oldPalette = ceData.palette; @@ -871,7 +871,7 @@ void NorwegianWoodStyle::applicationPolish( QStyleControlElementData ceData, Con applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(QPalette(active, disabled, active), TRUE)); } -void NorwegianWoodStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void NorwegianWoodStyle::applicationUnPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(oldPalette, TRUE)); } @@ -879,7 +879,7 @@ void NorwegianWoodStyle::applicationUnPolish( QStyleControlElementData ceData, C /*! Reimplementation from QStyle */ -void NorwegianWoodStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void NorwegianWoodStyle::polish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full @@ -896,7 +896,7 @@ void NorwegianWoodStyle::polish( QStyleControlElementData ceData, ControlElement } } -void NorwegianWoodStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) +void NorwegianWoodStyle::unPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full @@ -915,7 +915,7 @@ void NorwegianWoodStyle::unPolish( QStyleControlElementData ceData, ControlEleme void NorwegianWoodStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -986,7 +986,7 @@ void NorwegianWoodStyle::drawPrimitive( PrimitiveElement pe, void NorwegianWoodStyle::drawControl( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -1095,7 +1095,7 @@ void NorwegianWoodStyle::drawControl( ControlElement element, void NorwegianWoodStyle::drawControlMask( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QStyleOption& opt, @@ -1118,7 +1118,7 @@ void NorwegianWoodStyle::drawControlMask( ControlElement element, void NorwegianWoodStyle::drawComplexControl( ComplexControl cc, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -1192,7 +1192,7 @@ void NorwegianWoodStyle::drawComplexControlMask( ComplexControl control, } QRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, SubControl sc, const QStyleOption& opt, @@ -1250,7 +1250,7 @@ QRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control, return rect; } -QRect NorwegianWoodStyle::subRect( SubRect sr, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget * widget ) const +QRect NorwegianWoodStyle::subRect( SubRect sr, const QStyleControlElementData &ceData, const ControlElementFlags elementFlags, const QWidget * widget ) const { QRect r; switch ( sr ) { @@ -1355,7 +1355,7 @@ static void get_combo_parameters( const QRect &r, static inline int buttonthickness( int d ) { return d > 20 ? 5 : ( d < 10 ? 2: 3 ); } -void NorwegianWoodStyle::drawSemicircleButton( QPainter *p, QStyleControlElementData ceData, +void NorwegianWoodStyle::drawSemicircleButton( QPainter *p, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, int dir, bool sunken, const QColorGroup &g ) const diff --git a/examples/themes/wood.h b/examples/themes/wood.h index 3d7b0e6..c5f6720 100644 --- a/examples/themes/wood.h +++ b/examples/themes/wood.h @@ -26,14 +26,14 @@ class NorwegianWoodStyle : public QWindowsStyle { public: NorwegianWoodStyle(); - void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void polish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void unPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void applicationUnPolish( const QStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); void drawPrimitive( PrimitiveElement pe, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -42,7 +42,7 @@ public: void drawControl( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -52,7 +52,7 @@ public: void drawControlMask( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QStyleOption& = QStyleOption::Default, @@ -60,7 +60,7 @@ public: void drawComplexControl( ComplexControl cc, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -79,17 +79,17 @@ public: const QWidget *widget = 0 ) const; QRect querySubControlMetrics( ComplexControl control, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, SubControl sc, const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const; + QRect subRect( SubRect r, const QStyleControlElementData &ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const; private: - void drawSemicircleButton(QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, int dir, + void drawSemicircleButton(QPainter *p, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, int dir, bool sunken, const QColorGroup &g ) const; QPalette oldPalette; QPixmap *sunkenDark; diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 3e8350a..e0b39b6 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -2355,12 +2355,21 @@ bool QStyle::eventFilter(QObject *o, QEvent *e) { ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; bool ret; QWidget* w = dynamic_cast<QWidget*>(o); - if ((w) && (e->type() == QEvent::Paint)) { - QPainter p(w); - QPainter* activePainterOrig = ceData.activePainter; - const_cast<QStyleControlElementData&>(ceData).activePainter = &p; - ret = handler->objectEventHandler(ceData, elementFlags, o, e); - const_cast<QStyleControlElementData&>(ceData).activePainter = activePainterOrig; + if (w) { + // Update ceData as widget parameters may have changed + // If not done glitches may appear such as those present in Bug 1816 + populateControlElementDataFromWidget(w, QStyleOption()); + const QStyleControlElementData &widgetCEData = *(w->controlElementDataObject()); + if (e->type() == QEvent::Paint) { + QPainter p(w); + QPainter* activePainterOrig = widgetCEData.activePainter; + const_cast<QStyleControlElementData&>(widgetCEData).activePainter = &p; + ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); + const_cast<QStyleControlElementData&>(widgetCEData).activePainter = activePainterOrig; + } + else { + ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); + } } else { ret = handler->objectEventHandler(ceData, elementFlags, o, e); |