From 69429dcfc35d449c78b346bdce536f17d926c755 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 30 Oct 2012 22:41:50 -0500 Subject: [PATCH 1/3] Add new style primatives for enhanced third party style compatibility --- src/kernel/qapplication.cpp | 31 ++++++++++++ src/kernel/qapplication.h | 1 + src/kernel/qstyle.h | 7 +++ src/styles/qcommonstyle.cpp | 3 ++ src/styles/qcompactstyle.cpp | 74 ++++++++++++++++++++------- src/styles/qcompactstyle.h | 9 ++++ src/styles/qmotifplusstyle.cpp | 41 +++++++++++---- src/styles/qmotifstyle.cpp | 46 +++++++++++------ src/styles/qsgistyle.cpp | 36 +++++++++----- src/styles/qwindowsstyle.cpp | 91 +++++++++++++++++++++++----------- 10 files changed, 254 insertions(+), 85 deletions(-) diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 0478cf1..51aa247 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -1847,6 +1847,37 @@ QPalette QApplication::palette(const QWidget* w) return *app_pal; } +QPalette QApplication::palette(QStringList objectTypeList) +{ +#if defined(QT_CHECK_STATE) + if ( !qApp ) + qWarning( "QApplication::palette: This function can only be " + "called after the QApplication object has been created" ); +#endif + if ( !app_pal ) { + if ( !qt_std_pal ) + qt_create_std_palette(); + app_pal = new QPalette( *qt_std_pal ); + qt_fix_tooltips(); + } + + if ( (objectTypeList.count() > 0) && app_palettes ) { + QPalette* wp = app_palettes->find( objectTypeList[objectTypeList.count()-1] ); + if ( wp ) { + return *wp; + } + QAsciiDictIterator it( *app_palettes ); + const char* name; + while ( (name=it.currentKey()) != 0 ) { + if ( objectTypeList.contains(name) ) { + return *it.current(); + } + ++it; + } + } + return *app_pal; +} + /*! Changes the default application palette to \a palette. If \a informWidgets is TRUE, then existing widgets are informed about the diff --git a/src/kernel/qapplication.h b/src/kernel/qapplication.h index 39f7858..c34ff45 100644 --- a/src/kernel/qapplication.h +++ b/src/kernel/qapplication.h @@ -113,6 +113,7 @@ public: static void setGlobalMouseTracking( bool enable ); #ifndef QT_NO_PALETTE static QPalette palette( const QWidget* = 0 ); + static QPalette palette( QStringList ); static void setPalette( const QPalette &, bool informWidgets=FALSE, const char* className = 0 ); #endif diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 27dbb07..5731f8f 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -458,6 +458,11 @@ public: PE_HeaderSectionMenu, + PE_PanelScrollBar, + PE_MenuItemIndicatorFrame, + PE_MenuItemIndicatorIconFrame, + PE_MenuItemIndicatorCheck, + // do not add any values below/greater this PE_CustomBase = 0xf000000 }; @@ -830,6 +835,8 @@ public: PM_MenuBarItemSpacing, PM_ToolBarItemSpacing, + PM_ArrowSize, + // do not add any values below/greater than this PM_CustomBase = 0xf0000000 }; diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 2614bbf..3a1a8d8 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -2870,6 +2870,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co case PM_TabBarScrollButtonWidth: ret = 16; break; + case PM_ArrowSize: + ret = 7; + break; default: ret = 0; break; diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp index 7c7e0f5..5b83f0e 100644 --- a/src/styles/qcompactstyle.cpp +++ b/src/styles/qcompactstyle.cpp @@ -189,13 +189,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont return; if ( mi->isChecked() ) { - if ( act && !dis ) { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Button ) ); - } else { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); - } + drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); } else if ( !act ) { p->fillRect(x, y, checkcol , h, g.brush( QColorGroup::Button )); @@ -214,7 +208,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont int pixh = pixmap.height(); if ( act && !dis ) { if ( !mi->isChecked() ) - qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); + drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); } QRect cr( x, y, checkcol, h ); QRect pmr( 0, 0, pixw, pixh ); @@ -226,18 +220,8 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont g.brush( QColorGroup::Button ); p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); } else if ( checkable ) { // just "checking"... - int mw = checkcol + motifItemFrame; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, - mw, mh), itemg, cflags, opt ); + drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); } } @@ -319,4 +303,56 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont } } +/*! \reimp */ +void QCompactStyle::drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + switch (pe) { + case PE_MenuItemIndicatorFrame: + { + if ( act && !dis ) { + qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } else { + qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + } + } + break; + case PE_MenuItemIndicatorIconFrame: + { + qDrawShadePanel( p, x, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + case PE_MenuItemIndicatorCheck: + { + int mw = w + motifItemFrame; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) { + cflags |= Style_Enabled; + } + if (act) { + cflags |= Style_On; + } + + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, mw, mh), cg, cflags, opt ); + } + break; + default: + break; + } +} + #endif diff --git a/src/styles/qcompactstyle.h b/src/styles/qcompactstyle.h index 2f9748b..3b209cf 100644 --- a/src/styles/qcompactstyle.h +++ b/src/styles/qcompactstyle.h @@ -60,6 +60,15 @@ public: int pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget = 0 ); + void drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags = Style_Default, + const QStyleOption& = QStyleOption::Default ) const; + void drawControl( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default, const QWidget *w = 0 ); diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 72e28a8..86db691 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -282,6 +282,9 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch (pe) { case PE_HeaderSection: @@ -638,6 +641,28 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, break; } + case PE_PanelScrollBar: + { + drawMotifPlusShade(p, r, cg, TRUE, FALSE, &cg.brush(QColorGroup::Mid)); + break; + } + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + QRect vrect = visualRect( QRect( x+2, y+2, w, h-2 ), r ); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + break; + } + default: QMotifStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); break; @@ -828,13 +853,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, } else if (checkable) { if (mi->isChecked()) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); } } @@ -1147,8 +1166,12 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control, if (controls == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - drawMotifPlusShade(p, widget->rect(), cg, TRUE, FALSE, - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((maxedOut) ? Style_Default : Style_Enabled) | + ((active == SC_ScrollBarLast) ? + Style_Down : Style_Default) | + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); if ((controls & SC_ScrollBarSubLine) && subline.isValid()) drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index e91e0d0..422dacb 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -211,6 +211,9 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch( pe ) { #ifndef QT_NO_LISTVIEW case PE_CheckListExclusiveIndicator: { @@ -761,6 +764,30 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, r.height() - 4, cg.brush(QColorGroup::Highlight)); break; + case PE_PanelScrollBar: + qDrawShadePanel(p, r, cg, TRUE, + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags), + &cg.brush(QColorGroup::Mid)); + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, w, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + int mw = w; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, QRect(xvis, y+motifItemFrame, mw, mh), cg, cflags); + } + default: QCommonStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -1076,18 +1103,8 @@ void QMotifStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else if ( checkable ) { // just "checking"... - int mw = checkcol; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - QRect(xvis, y+motifItemFrame, mw, mh), - cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); } } @@ -1339,9 +1356,10 @@ void QMotifStyle::drawComplexControl( ComplexControl control, if (sub == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - qDrawShadePanel(p, ceData.rect, cg, TRUE, - pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget), - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); + QCommonStyle::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget); break; diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index a66fcda..b65100c 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -567,6 +567,9 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags ); bool hot = ( flags & Style_MouseOver ) && ( flags & Style_Enabled ); + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch ( pe ) { case PE_ButtonCommand: { @@ -878,6 +881,25 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); + er.addCoords( 0, 1, 1, 1 ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + } + break; + default: QMotifStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -1018,20 +1040,8 @@ void QSGIStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else { if ( checkable ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - if ( mi->isChecked() ) { - QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, - pixelMetric(PM_IndicatorWidth, ceData, elementFlags), - pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); - er.addCoords( 1, 1, -1, -1 ); - drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); - er.addCoords( 0, 1, 1, 1 ); - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, w, h), cg, flags); } } } diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 4bdb421..578b32f 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -225,6 +225,9 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + QRect rr( r ); switch (pe) { case PE_ButtonCommand: @@ -568,6 +571,60 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + QRect vrect = visualRect( QRect( x, y, w, h ), r ); + int xvis = vrect.x(); + + if ( act && !dis ) { + qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } + else { + QBrush fill( cg.light(), Dense4Pattern ); + // set the brush origin for the hash pattern to the x/y coordinate + // of the menu item's checkmark... this way, the check marks have + // a consistent look + QPoint origin = p->brushOrigin(); + p->setBrushOrigin( xvis, y ); + qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &fill ); + // restore the previous brush origin + p->setBrushOrigin( origin ); + } + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + QRect vrect = visualRect( QRect( x, y, w, h ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + int xp = x + windowsItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, w - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); + } + break; + default: if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) { QPointArray a; @@ -809,21 +866,7 @@ void QWindowsStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r ); int xvis = vrect.x(); if ( mi->isChecked() ) { - if ( act && !dis ) - qDrawShadePanel( p, xvis, y, checkcol, h, - cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); - else { - QBrush fill( cg.light(), Dense4Pattern ); - // set the brush origin for the hash pattern to the x/y coordinate - // of the menu item's checkmark... this way, the check marks have - // a consistent look - QPoint origin = p->brushOrigin(); - p->setBrushOrigin( xvis, y ); - qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, - &fill ); - // restore the previous brush origin - p->setBrushOrigin( origin ); - } + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); } else if (! act) p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button )); @@ -839,8 +882,7 @@ void QWindowsStyle::drawControl( ControlElement element, int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis && !mi->isChecked() ) - qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1, - &cg.brush( QColorGroup::Button ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); QRect pmr( 0, 0, pixw, pixh ); pmr.moveCenter( vrect.center() ); p->setPen( cg.text() ); @@ -851,20 +893,9 @@ void QWindowsStyle::drawControl( ControlElement element, cg.brush( QColorGroup::Button )); int xp = xpos + checkcol + 1; p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill); - } else if ( checkable ) { // just "checking"... + } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - int xp = xpos + windowsItemFrame; - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - visualRect( QRect(xp, y + windowsItemFrame, - checkcol - 2*windowsItemFrame, - h - 2*windowsItemFrame), r ), cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); } } From a5ced706e9295f4f3c1e95c829750dff0d808935 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 31 Oct 2012 12:39:27 -0500 Subject: [PATCH 2/3] Add new style hints for enhanced third party style compatibility --- src/kernel/qstyle.h | 8 +++++ src/styles/qcompactstyle.cpp | 51 ++++++++++++++++++++++---- src/styles/qcompactstyle.h | 2 ++ src/styles/qmotifplusstyle.cpp | 44 ++++++++++++++++++++--- src/styles/qmotifstyle.cpp | 60 +++++++++++++++++++++++++------ src/styles/qsgistyle.cpp | 66 +++++++++++++++++++++++++++++++--- src/styles/qsgistyle.h | 2 ++ src/styles/qwindowsstyle.cpp | 43 +++++++++++++++++----- 8 files changed, 243 insertions(+), 33 deletions(-) diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 5731f8f..341473e 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -835,6 +835,11 @@ public: PM_MenuBarItemSpacing, PM_ToolBarItemSpacing, + PM_MenuIndicatorFrameHBorder, + PM_MenuIndicatorFrameVBorder, + PM_MenuIconIndicatorFrameHBorder, + PM_MenuIconIndicatorFrameVBorder, + PM_ArrowSize, // do not add any values below/greater than this @@ -1036,6 +1041,9 @@ public: // bool - hide underlined accelerators uless Alt key is currently down SH_HideUnderlineAcceleratorWhenAltUp, + // int - width of menu check column + SH_MenuIndicatorColumnWidth, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp index 5b83f0e..63c5be5 100644 --- a/src/styles/qcompactstyle.cpp +++ b/src/styles/qcompactstyle.cpp @@ -67,6 +67,12 @@ int QCompactStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceD case PM_MaximumDragDistance: ret = -1; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 0; + break; default: ret = QWindowsStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -189,7 +195,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont return; if ( mi->isChecked() ) { - drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } else if ( !act ) { p->fillRect(x, y, checkcol , h, g.brush( QColorGroup::Button )); @@ -208,7 +214,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont int pixh = pixmap.height(); if ( act && !dis ) { if ( !mi->isChecked() ) - drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } QRect cr( x, y, checkcol, h ); QRect pmr( 0, 0, pixw, pixh ); @@ -221,7 +227,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, itemg, flags, opt ); } } @@ -322,21 +328,27 @@ void QCompactStyle::drawPrimitive( PrimitiveElement pe, switch (pe) { case PE_MenuItemIndicatorFrame: { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + if ( act && !dis ) { - qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); } else { - qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); } } break; case PE_MenuItemIndicatorIconFrame: { - qDrawShadePanel( p, x, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + qDrawShadePanel( p, x, y, checkcol, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); } break; case PE_MenuItemIndicatorCheck: { - int mw = w + motifItemFrame; + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int mw = checkcol + motifItemFrame; int mh = h - 2*motifItemFrame; SFlags cflags = Style_Default; @@ -355,4 +367,29 @@ void QCompactStyle::drawPrimitive( PrimitiveElement pe, } } +/*! \reimp */ +int QCompactStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks + + ret = maxpmw; + } + break; + default: + ret = QWindowsStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif diff --git a/src/styles/qcompactstyle.h b/src/styles/qcompactstyle.h index 3b209cf..6002055 100644 --- a/src/styles/qcompactstyle.h +++ b/src/styles/qcompactstyle.h @@ -72,6 +72,8 @@ public: void drawControl( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default, const QWidget *w = 0 ); + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + private: // Disabled copy constructor and operator= #if defined(Q_DISABLE_COPY) QCompactStyle( const QCompactStyle & ); diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 86db691..113716c 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -263,6 +263,13 @@ int QMotifPlusStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ce ret = 11; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 2; + break; + default: ret = QMotifStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -647,11 +654,30 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, break; } + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); + + qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + case PE_MenuItemIndicatorCheck: { int x, y, w, h; r.rect(&x, &y, &w, &h); - QRect vrect = visualRect( QRect( x+2, y+2, w, h-2 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); SFlags cflags = Style_Default; if (! dis) @@ -820,8 +846,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(vrect, @@ -853,7 +878,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, } else if (checkable) { if (mi->isChecked()) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1582,6 +1607,17 @@ int QMotifPlusStyle::styleHint(StyleHint hint, case SH_PopupMenu_MouseTracking: ret = 1; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if (checkable) + maxpmw = QMAX(maxpmw, 15); + + ret = maxpmw; + break; + } default: ret = QMotifStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index 422dacb..826cd16 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -770,22 +770,44 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, &cg.brush(QColorGroup::Mid)); break; + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + case PE_MenuItemIndicatorCheck: { int x, y, w, h; r.rect( &x, &y, &w, &h ); - QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, w, h-2*motifItemFrame ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); int xvis = vrect.x(); - int mw = w; + int mw = checkcol; int mh = h - 2*motifItemFrame; SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, QRect(xvis, y+motifItemFrame, mw, mh), cg, cflags); + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, QRect(xvis, y+motifItemFrame, mw, mh), cg, cflags); + break; } default: @@ -1077,8 +1099,7 @@ void QMotifStyle::drawControl( ControlElement element, int xvis = vrect.x(); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, @@ -1104,7 +1125,7 @@ void QMotifStyle::drawControl( ControlElement element, } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1556,6 +1577,13 @@ int QMotifStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceDat ret = 13; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = motifItemFrame; + break; + default: ret = QCommonStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -2364,6 +2392,18 @@ int QMotifStyle::styleHint(StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, motifCheckMarkSpace ); + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index b65100c..eb59d11 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -398,6 +398,14 @@ int QSGIStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, case PM_SplitterWidth: return QMAX( 10, QApplication::globalStrut().width() ); + case PM_MenuIndicatorFrameHBorder: + return (sgiItemFrame+2); + case PM_MenuIndicatorFrameVBorder: + return (sgiItemFrame+4); + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return sgiItemFrame; + default: break; } @@ -881,7 +889,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, } break; - case PE_MenuItemIndicatorCheck: + case PE_MenuItemIndicatorFrame: { int x, y, w, h; r.rect(&x, &y, &w, &h); @@ -895,6 +903,32 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); er.addCoords( 1, 1, -1, -1 ); drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); er.addCoords( 0, 1, 1, 1 ); drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); } @@ -1012,8 +1046,7 @@ void QSGIStyle::drawControl( ControlElement element, if ( mi->isChecked() ) { if ( mi->iconSet() ) { - drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else { if ( !act ) @@ -1041,7 +1074,8 @@ void QSGIStyle::drawControl( ControlElement element, } else { if ( checkable ) { if ( mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, w, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } } @@ -1477,4 +1511,28 @@ QRect QSGIStyle::querySubControlMetrics( ComplexControl control, return QMotifStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); } +/*! \reimp */ +int QSGIStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) + maxpmw = QMAX( maxpmw, sgiCheckMarkSpace ); + ret = maxpmw; + } + break; + default: + ret = QMotifStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif // QT_NO_STYLE_SGI diff --git a/src/styles/qsgistyle.h b/src/styles/qsgistyle.h index 0afacd6..17bdb05 100644 --- a/src/styles/qsgistyle.h +++ b/src/styles/qsgistyle.h @@ -124,6 +124,8 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 578b32f..f93e31a 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -575,12 +575,13 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); - QRect vrect = visualRect( QRect( x, y, w, h ), r ); + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); int xvis = vrect.x(); if ( act && !dis ) { - qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); } else { QBrush fill( cg.light(), Dense4Pattern ); @@ -589,7 +590,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, // a consistent look QPoint origin = p->brushOrigin(); p->setBrushOrigin( xvis, y ); - qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &fill ); + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill ); // restore the previous brush origin p->setBrushOrigin( origin ); } @@ -600,8 +601,9 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); - QRect vrect = visualRect( QRect( x, y, w, h ), r ); + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); int xvis = vrect.x(); qDrawShadePanel( p, xvis, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); @@ -612,6 +614,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); int xp = x + windowsItemFrame; @@ -621,7 +624,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, if (act) cflags |= Style_On; - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, w - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, checkcol - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); } break; @@ -866,7 +869,7 @@ void QWindowsStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r ); int xvis = vrect.x(); if ( mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); } else if (! act) p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button )); @@ -882,7 +885,7 @@ void QWindowsStyle::drawControl( ControlElement element, int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis && !mi->isChecked() ) - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); QRect pmr( 0, 0, pixw, pixh ); pmr.moveCenter( vrect.center() ); p->setPen( cg.text() ); @@ -895,7 +898,7 @@ void QWindowsStyle::drawControl( ControlElement element, p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill); } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1073,6 +1076,13 @@ int QWindowsStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ceDa ret = QMAX( 6, QApplication::globalStrut().width() ); break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = windowsItemFrame; + break; + default: ret = QCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -1996,6 +2006,23 @@ int QWindowsStyle::styleHint( StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) { + // space for the checkmarks + if (use2000style) + maxpmw = QMAX( maxpmw, 20 ); + else + maxpmw = QMAX( maxpmw, 12 ); + } + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; From 289363b959ac4720ee604f1dfba54c624f0098c0 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 31 Oct 2012 15:33:40 -0500 Subject: [PATCH 3/3] Add public set methods to QMenuItem --- src/widgets/qmenudata.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/widgets/qmenudata.h b/src/widgets/qmenudata.h index 13f26c3..ee6f9f9 100644 --- a/src/widgets/qmenudata.h +++ b/src/widgets/qmenudata.h @@ -90,6 +90,20 @@ public: void setVisible( bool visible ) { is_visible = visible; } void setWhatsThis( const QString &text ) { whatsthis_data = text; } + // Do not use these methods unless you know exactly what you are doing! + void setSeparator( bool separator ) { is_separator = separator; } + void setEnabled( bool enabled ) { is_enabled = enabled; } + void setChecked( bool checked ) { is_checked = checked; } + void setIdent( int identifier ) { ident = identifier; } + void setIconSet( QIconSet* iconset ) { iconset_data = iconset; } + void setPixmap( QPixmap* pixmap ) { pixmap_data = pixmap; } + void setPopup( QPopupMenu* popup ) { popup_menu = popup; } + void setWidget( QWidget* widget ) { widget_item = widget; } +#ifndef QT_NO_ACCEL + void setKey( QKeySequence key ) { accel_key = key; } +#endif + void setSignal( QSignal* signal ) { signal_data = signal; } + private: int ident; // item identifier QIconSet *iconset_data; // icons