diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/qstyle.cpp | 391 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 152 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 47 | ||||
-rw-r--r-- | src/styles/qcommonstyle.h | 9 | ||||
-rw-r--r-- | src/styles/qmotifplusstyle.cpp | 78 | ||||
-rw-r--r-- | src/styles/qmotifplusstyle.h | 11 | ||||
-rw-r--r-- | src/styles/qmotifstyle.cpp | 8 | ||||
-rw-r--r-- | src/styles/qmotifstyle.h | 4 | ||||
-rw-r--r-- | src/styles/qsgistyle.cpp | 124 | ||||
-rw-r--r-- | src/styles/qsgistyle.h | 11 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 104 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.h | 9 | ||||
-rw-r--r-- | src/tools/qglobal.h | 4 | ||||
-rw-r--r-- | src/widgets/qgroupbox.cpp | 3 | ||||
-rw-r--r-- | src/widgets/qlabel.cpp | 3 | ||||
-rw-r--r-- | src/widgets/qtoolbox.cpp | 3 |
16 files changed, 713 insertions, 248 deletions
diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index f8c0fd9..01c09d1 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -44,6 +44,10 @@ #include "qpainter.h" #include "qbitmap.h" #include "qpixmapcache.h" +#include "qframe.h" +#include "qlayout.h" +#include "qobjectlist.h" +#include "qwidgetlist.h" #include <limits.h> @@ -394,6 +398,10 @@ public: */ QStyle::QStyle() { + m_eventHandlerInstallationHook = NULL; + m_eventHandlerRemovalHook = NULL; + m_widgetActionRequestHook = NULL; + conditionalAcceleratorsEnabled = false; d = new QStylePrivate; } @@ -414,8 +422,6 @@ QStyle::~QStyle() style. Current supported values are Qt::WindowsStyle and Qt::MotifStyle. */ - - /*! Initializes the appearance of a widget. @@ -439,8 +445,9 @@ QStyle::~QStyle() \sa unPolish() */ -void QStyle::polish( QWidget*) -{ +void QStyle::polish( QWidget *widget ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + polish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); } /*! @@ -453,10 +460,62 @@ void QStyle::polish( QWidget*) \sa polish() */ -void QStyle::unPolish( QWidget*) -{ +void QStyle::unPolish( QWidget *widget ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +/*! + Initializes the appearance of a widget. + + This function is called for every widget at some point after it + has been fully created but just \e before it is shown the very + first time. + + Reasonable actions in this function might be to install a widget + event handler for the style. An example of highly unreasonable + use would be setting the geometry! With Qt 3.0's style engine + you will rarely need to write your own polish(); instead reimplement + drawItem(), drawPrimitive(), etc. + + The \a objectTypes object may provide enough information to + allow class-specific customizations. But be careful not to + hard-code things too much because new QStyle subclasses are + expected to work reasonably with all current and \e future + widgets. + + You may specify either a QWidget pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void QStyle::polish( QStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + // Enable dynamic hide/show of accelerator shortcuts + QWidget* widget = reinterpret_cast<QWidget*>(ptr); + widget->installEventFilter(this); + } } +/*! + Undoes the initialization of a widget's appearance. + + This function is the counterpart to polish. It is called for every + polished widget when the style is dynamically changed. The former + style has to unpolish its settings before the new style can polish + them again. + + \sa polish() +*/ +void QStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + // Disable dynamic hide/show of accelerator shortcuts + QWidget* widget = reinterpret_cast<QWidget*>(ptr); + widget->installEventFilter(this); + } +} /*! \overload @@ -464,8 +523,10 @@ void QStyle::unPolish( QWidget*) \sa unPolish() */ -void QStyle::polish( QApplication*) -{ +void QStyle::polish( QApplication *app ) { + QStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); } /*! @@ -475,8 +536,41 @@ void QStyle::polish( QApplication*) \sa polish() */ -void QStyle::unPolish( QApplication*) -{ +void QStyle::unPolish( QApplication *app ) { + QStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); +} + +/*! + \overload + Late initialization of the QApplication object or other global application object. + + You may specify either a QApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void QStyle::applicationPolish( QStyleControlElementData, ControlElementFlags, void * ) { + // +} + +/*! + \overload + + Undoes the application polish. + + You may specify either a QApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa polish() +*/ +void QStyle::applicationUnPolish( QStyleControlElementData, ControlElementFlags, void * ) { + // } /*! @@ -1958,6 +2052,283 @@ QRect QStyle::visualRect( const QRect &logical, const QRect &boundingRect ) } /*! + \fn void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + + Intercepts events generated by \a source and sends them to \a handler via + the bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) virtual method. + + \sa void QStyle::removeObjectEventHandler( QObject* source, QStyle* handler ) + \sa bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) +*/ +void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) { + bool cbret = false; + if (m_eventHandlerInstallationHook) { + cbret = (*m_eventHandlerInstallationHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QObject")) { + QObject* o = reinterpret_cast<QObject*>(source); + o->installEventFilter(this); + m_objectEventSourceToHandlerMap[source] = handler; + m_objectEventSourceDataToHandlerMap[source] = ceData; + m_objectEventSourceFlagsToHandlerMap[source] = elementFlags; + } + } +} + +/*! + \fn void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + + Stops intercepting events generated by \a source. + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) { + bool cbret = false; + if (m_eventHandlerRemovalHook) { + cbret = (*m_eventHandlerRemovalHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QObject")) { + QObject* o = reinterpret_cast<QObject*>(source); + m_objectEventSourceToHandlerMap.remove(source); + m_objectEventSourceDataToHandlerMap.remove(source); + m_objectEventSourceFlagsToHandlerMap.remove(source); + o->removeEventFilter(this); + } + } +} + +/*! + \fn void QStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept request + is made via the QStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ) { + m_eventHandlerInstallationHook = hook; +} + +/*! + \fn void QStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept deactivation request + is made via the QStyle::removeObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ) { + m_eventHandlerRemovalHook = hook; +} + +/*! + \fn bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); + + Override this virtual function to intercept events requested by a previous call to + QStyle::installObjectEventHandler. + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) + \sa void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) { + Q_UNUSED(ceData); + Q_UNUSED(elementFlags); + Q_UNUSED(source); + Q_UNUSED(e); + return false; +} + +/*! + \fn bool QStyle::eventFilter(QObject *o, QEvent *e); + \internal +*/ +bool QStyle::eventFilter(QObject *o, QEvent *e) { + acceleratorKeypressEventMonitor(o, e); + + if (m_objectEventSourceToHandlerMap.contains(o)) { + QStyle* handler = m_objectEventSourceToHandlerMap[o]; + QStyleControlElementData ceData = m_objectEventSourceDataToHandlerMap[o]; + ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; + bool ret = handler->objectEventHandler(ceData, elementFlags, o, e); + if (ret) { + return ret; + } + else { + return QObject::eventFilter(o, e); + } + } + else { + return QObject::eventFilter(o, e); + } +} + +/*! + \fn void QStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new widget action request + is made via the QStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ) { + m_widgetActionRequestHook = hook; +} + +/*! + \fn bool widgetActionRequestHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request ); + + Handles widget action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData ) { + bool cbret = false; + if (m_widgetActionRequestHook) { + cbret = (*m_widgetActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + QWidget* widget = reinterpret_cast<QWidget*>(source); + if (request == WAR_Repaint) { + widget->repaint(FALSE); + } + else if (request == WAR_RepaintRect) { + widget->repaint(requestData.rect, FALSE); + } + else if (request == WAR_EnableMouseTracking) { + widget->setMouseTracking(TRUE); + } + else if (request == WAR_DisableMouseTracking) { + widget->setMouseTracking(FALSE); + } + else if (request == WAR_FrameSetStyle) { + QFrame* frame = dynamic_cast<QFrame*>(widget); + if (frame) { + frame->setFrameStyle(requestData.metric1); + } + } + else if (request == WAR_FrameSetLineWidth) { + QFrame* frame = dynamic_cast<QFrame*>(widget); + if (frame) { + frame->setLineWidth(requestData.metric1); + } + } + else if (request == WAR_SetLayoutMargin) { + QLayout* layout = widget->layout(); + if (layout) { + layout->setMargin(requestData.metric1); + } + } + else if (request == WAR_SetPalette) { + widget->setPalette(requestData.palette); + } + else if (request == WAR_SetBackgroundMode) { + widget->setBackgroundMode((Qt::BackgroundMode)requestData.metric1); + } + else if (request == WAR_SetFont) { + widget->setFont(requestData.font); + } + else if (request == WAR_RepaintAllAccelerators) { + QWidgetList *list = QApplication::topLevelWidgets(); + QWidgetListIt it( *list ); + QWidget * widget; + while ((widget=it.current()) != 0) { + ++it; + + QObjectList *l = widget->queryList("QWidget"); + QObjectListIt it2( *l ); + QWidget *w; + while ( (w = (QWidget*)it2.current()) != 0 ) { + ++it2; + if (w->isTopLevel() || !w->isVisible() || w->style().styleHint(SH_UnderlineAccelerator, QStyleControlElementData(), CEF_None, w)) { + l->removeRef(w); + } + } + + // Repaint all relevant widgets + it2.toFirst(); + while ( (w = (QWidget*)it2.current()) != 0 ) { + ++it2; + w->repaint(FALSE); + } + delete l; + } + delete list; + } + return true; + } + } + return true; +} + +void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) { + // RAJA FIXME + // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the QWindowsStyle::styleHint overridden method + // Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint + + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { + QWidget *widget = dynamic_cast<QWidget*>(o); + if (widget) { + switch(e->type()) { + case QEvent::KeyPress: + if (((QKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = true; + widgetActionRequest(QStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + case QEvent::KeyRelease: + if (((QKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = false; + widgetActionRequest(QStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + default: + break; + } + } + } + else { + conditionalAcceleratorsEnabled = false; + } +} + +bool QStyle::acceleratorsShown() const { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { + return conditionalAcceleratorsEnabled; + } + else { + return true; + } +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData() { + // +} +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(int param1, int param2) { + metric1 = param1; + metric2 = param2; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param) { + palette = param; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param) { + font = param; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QRect param) { + rect = param; +} + +QStyleWidgetActionRequestData::~QStyleWidgetActionRequestData() { + // +} + +/*! \fn int QStyle::defaultFrameWidth() const \obsolete */ diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 9a10b7f..6978deb 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -177,6 +177,7 @@ class QStyleControlElementDockWidgetData { class QStyleControlElementGenericWidgetData { public: QStringList widgetObjectTypes; + bool allDataPopulated; Qt::WFlags wflags; QPixmap bgPixmap; QBrush bgBrush; @@ -196,6 +197,7 @@ class QStyleControlElementGenericWidgetData { class QStyleControlElementData { public: QStringList widgetObjectTypes; + bool allDataPopulated; Qt::WFlags wflags; QPixmap bgPixmap; QBrush bgBrush; @@ -239,6 +241,24 @@ class QStyleControlElementData { QStyleControlElementListViewData listViewData; QStyleControlElementTabBarData tabBarData; Q_UINT32 comboBoxLineEditFlags; + Q_UINT32 frameStyle; + QRect sliderRect; +}; + +class QStyleWidgetActionRequestData { + public: + QStyleWidgetActionRequestData(); + QStyleWidgetActionRequestData(int metric1, int metric2=0); + QStyleWidgetActionRequestData(QPalette palette); + QStyleWidgetActionRequestData(QFont font); + QStyleWidgetActionRequestData(QRect rect); + ~QStyleWidgetActionRequestData(); + public: + int metric1; + int metric2; + QPalette palette; + QFont font; + QRect rect; }; class Q_EXPORT QStyle: public QObject @@ -249,28 +269,6 @@ public: QStyle(); virtual ~QStyle(); - // New QStyle API - most of these should probably be pure virtual - - virtual void polish( QWidget * ); - virtual void unPolish( QWidget * ); - - virtual void polish( QApplication * ); - virtual void unPolish( QApplication * ); - - virtual void polish( QPalette & ); - - virtual void polishPopupMenu( QPopupMenu* ) = 0; - - virtual QRect itemRect( QPainter *p, const QRect &r, - int flags, bool enabled, - const QPixmap *pixmap, - const QString &text, int len = -1 ) const; - - virtual void drawItem( QPainter *p, const QRect &r, - int flags, const QColorGroup &g, bool enabled, - const QPixmap *pixmap, const QString &text, - int len = -1, const QColor *penColor = 0 ) const; - enum ControlElementFlags { CEF_None = 0x00000000, CEF_IsDefault = 0x00000001, @@ -293,9 +291,68 @@ public: CEF_IsCheckable = 0x00020000, CEF_HasFocusProxy = 0x00040000, CEF_IsEditable = 0x00080000, - CEF_IsFlat = 0x00100000 + CEF_IsFlat = 0x00100000, + CEF_IsActiveWindow = 0x00200000, + CEF_IsTopLevel = 0x00400000, + CEF_IsVisible = 0x00800000, }; + // New QStyle API - most of these should probably be pure virtual + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void polish( QWidget * ); + + // New API + virtual void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void unPolish( QWidget * ); + + // New API + virtual void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void polish( QApplication * ); + + // New API + virtual void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void unPolish( QApplication * ); + + // New API + virtual void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + virtual void polish( QPalette & ); + + virtual void polishPopupMenu( QPopupMenu* ) = 0; + + virtual QRect itemRect( QPainter *p, const QRect &r, + int flags, bool enabled, + const QPixmap *pixmap, + const QString &text, int len = -1 ) const; + + virtual void drawItem( QPainter *p, const QRect &r, + int flags, const QColorGroup &g, bool enabled, + const QPixmap *pixmap, const QString &text, + int len = -1, const QColor *penColor = 0 ) const; + enum PrimitiveElement { PE_ButtonCommand, PE_ButtonDefault, @@ -967,6 +1024,9 @@ public: // when the mouse is over the button SH_ToolButton_Uses3D, + // bool - hide underlined accelerators uless Alt key is currently down + SH_HideUnderlineAcceleratorWhenAltUp, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; @@ -1038,7 +1098,35 @@ public: static QRect visualRect( const QRect &logical, const QRect &bounding ); + // Object event handling API + typedef QMap<void*, QStyle*> ObjectEventSourceToHandlerMap; + typedef QMap<void*, QStyleControlElementData> ObjectEventSourceDataToHandlerMap; + typedef QMap<void*, ControlElementFlags> ObjectEventSourceFlagsToHandlerMap; + typedef bool (*EventHandlerInstallationHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler); + typedef bool (*EventHandlerRemovalHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler); + void installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + void removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + void setEventHandlerInstallationHook( EventHandlerInstallationHook ); + void setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + virtual bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); + + enum WidgetActionRequest { + WAR_Repaint, + WAR_RepaintRect, + WAR_EnableMouseTracking, + WAR_DisableMouseTracking, + WAR_FrameSetStyle, + WAR_FrameSetLineWidth, + WAR_SetLayoutMargin, + WAR_SetPalette, + WAR_SetBackgroundMode, + WAR_SetFont, + WAR_RepaintAllAccelerators + }; + typedef bool (*WidgetActionRequestHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData); + void setWidgetActionRequestHook( WidgetActionRequestHook ); + virtual bool widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData = QStyleWidgetActionRequestData() ); // Old 2.x QStyle API @@ -1061,6 +1149,12 @@ public: } #endif +public: + virtual bool eventFilter( QObject *, QEvent * ); + bool acceleratorsShown() const; + +protected: + void acceleratorKeypressEventMonitor( QObject *, QEvent * ); private: QStylePrivate * d; @@ -1069,10 +1163,22 @@ private: QStyle( const QStyle & ); QStyle& operator=( const QStyle & ); #endif + + EventHandlerInstallationHook m_eventHandlerInstallationHook; + EventHandlerRemovalHook m_eventHandlerRemovalHook; + WidgetActionRequestHook m_widgetActionRequestHook; + ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; + ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; + ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; + bool conditionalAcceleratorsEnabled; }; inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a, const QStyle::ControlElementFlags b) { return static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); } // inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; } +Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object); + #endif // QT_NO_STYLE #endif // QSTYLE_H diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 38ff35b..e46f264 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -156,7 +156,7 @@ QStringList getObjectTypeListForObject(const QObject* object) { return objectTypes; } -QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt) { +QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields) { QStyle::ControlElementFlags cef = (QStyle::ControlElementFlags)0; if (object) { @@ -226,6 +226,11 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget; if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy; if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus; + if (populateReliantFields) { + if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow; + if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel; + if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible; + } } } else { @@ -240,6 +245,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (widget) { ceData.widgetObjectTypes = getObjectTypeListForObject(widget); + ceData.allDataPopulated = populateReliantFields; const QPixmap* erasePixmap = widget->backgroundPixmap(); if (erasePixmap) { ceData.bgPixmap = *erasePixmap; @@ -373,8 +379,11 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.maxSteps = sb->maxValue(); ceData.currentStep = sb->value(); ceData.startStep = sb->sliderStart(); + ceData.lineStep = sb->lineStep(); ceData.pageStep = sb->pageStep(); - + if (populateReliantFields) { + ceData.sliderRect = sb->sliderRect(); + } } } if (ceData.widgetObjectTypes.contains("QSlider")) { @@ -387,6 +396,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.startStep = sl->sliderStart(); ceData.lineStep = sl->lineStep(); ceData.pageStep = sl->pageStep(); + if (populateReliantFields) { + ceData.sliderRect = sl->sliderRect(); + } } } if (ceData.widgetObjectTypes.contains("QDialogButtons")) { @@ -434,6 +446,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid QWidget* viewport = lv->viewport(); if (viewport) { ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport); + ceData.viewportData.allDataPopulated = populateReliantFields; const QPixmap* erasePixmap = viewport->backgroundPixmap(); if (erasePixmap) { ceData.viewportData.bgPixmap = *erasePixmap; @@ -470,10 +483,17 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid } } } + if (ceData.widgetObjectTypes.contains("QFrame")) { + const QFrame *frame = dynamic_cast<const QFrame*>(widget); + if (frame) { + ceData.frameStyle = frame->frameStyle(); + } + } const QWidget* parentWidget = widget->parentWidget(); if (parentWidget) { ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget); + ceData.parentWidgetData.allDataPopulated = populateReliantFields; const QPixmap* erasePixmap = parentWidget->backgroundPixmap(); if (erasePixmap) { ceData.parentWidgetData.bgPixmap = *erasePixmap; @@ -1111,7 +1131,7 @@ void QCommonStyle::drawControl( ControlElement element, } int tf=AlignVCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) tf |= NoAccel; #ifndef QT_NO_ICONSET @@ -1164,7 +1184,7 @@ void QCommonStyle::drawControl( ControlElement element, { #ifndef QT_NO_CHECKBOX int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, @@ -1186,7 +1206,7 @@ void QCommonStyle::drawControl( ControlElement element, { #ifndef QT_NO_RADIOBUTTON int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text); @@ -1253,7 +1273,7 @@ void QCommonStyle::drawControl( ControlElement element, pixelMetric( QStyle::PM_DefaultFrameWidth, ceData, elementFlags, widget ) ); int alignment = AlignCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem( p, tr, alignment, cg, flags & Style_Enabled, 0, t->text() ); @@ -1386,7 +1406,7 @@ void QCommonStyle::drawControl( ControlElement element, QMenuItem *mi = opt.menuItem(); int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem( p, r, alignment, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, @@ -1428,7 +1448,7 @@ void QCommonStyle::drawControl( ControlElement element, ! ceData.text.isNull() && ! (elementFlags & CEF_UsesTextLabel)) { int alignment = AlignCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; rect.moveBy(shiftX, shiftY); @@ -1455,7 +1475,7 @@ void QCommonStyle::drawControl( ControlElement element, p->setFont( ceData.font ); QRect pr = rect, tr = rect; int alignment = ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; if ( ceData.toolButtonTextPosition == QToolButton::Under ) { @@ -2379,7 +2399,7 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control, } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false); return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget); } @@ -3126,7 +3146,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents, int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const { QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption(), false); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, shr, w); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w); } /*! \reimp */ @@ -3200,6 +3220,10 @@ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, Contr ret = 1; break; + case SH_HideUnderlineAcceleratorWhenAltUp: + ret = 0; + break; + default: ret = 0; break; @@ -3221,5 +3245,4 @@ QPixmap QCommonStyle::stylePixmap(StylePixmap, QStyleControlElementData, Control return QPixmap(); } - #endif // QT_NO_STYLE diff --git a/src/styles/qcommonstyle.h b/src/styles/qcommonstyle.h index 7cb406f..22b241b 100644 --- a/src/styles/qcommonstyle.h +++ b/src/styles/qcommonstyle.h @@ -38,6 +38,11 @@ ** **********************************************************************/ +// RAJA FIXME +// QMotifPlusStyle +// QSGIStyle +// QWindowsStyle + #ifndef QCOMMONSTYLE_H #define QCOMMONSTYLE_H @@ -241,7 +246,6 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - private: // Disabled copy constructor and operator= #if defined(Q_DISABLE_COPY) @@ -250,9 +254,6 @@ private: #endif }; -Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true); -Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt); - #endif // QT_NO_STYLE #endif // QCOMMONSTYLE_H diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 9245e65..86a2558 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -69,7 +69,9 @@ struct QMotifPlusStylePrivate scrollbarElement(0), lastElement(0), ref(1) { ; } - QGuardedPtr<QWidget> hoverWidget; + void* hoverWidget; + QStyleControlElementData hoverWidgetData; + QStyle::ControlElementFlags hoverWidgetFlags; bool hovering, sliderActive, mousePressed; int scrollbarElement, lastElement, ref; QPoint mousePos; @@ -176,52 +178,58 @@ void QMotifPlusStyle::polish(QPalette &) /*! \reimp */ -void QMotifPlusStyle::polish(QWidget *widget) +void QMotifPlusStyle::polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { + if (ceData.widgetObjectTypes.contains("QWidget")) { #ifndef QT_NO_FRAME - if (::qt_cast<QFrame*>(widget) && ((QFrame *) widget)->frameStyle() == QFrame::Panel) - ((QFrame *) widget)->setFrameStyle(QFrame::WinPanel); + if ((ceData.widgetObjectTypes.contains("QFrame")) && (ceData.frameStyle == QFrame::Panel)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::WinPanel)); + } #endif #ifndef QT_NO_MENUBAR - if (::qt_cast<QMenuBar*>(widget) && ((QMenuBar *) widget)->frameStyle() != QFrame::NoFrame) - ((QMenuBar *) widget)->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); + if ((ceData.widgetObjectTypes.contains("QMenuBar")) && (ceData.frameStyle != QFrame::NoFrame)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::StyledPanel | QFrame::Raised)); + } #endif #ifndef QT_NO_TOOLBAR - if (::qt_cast<QToolBar*>(widget)) - widget->layout()->setMargin(2); + if (ceData.widgetObjectTypes.contains("QToolBar")) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetLayoutMargin, QStyleWidgetActionRequestData(2)); + } #endif + } if (useHoveringHighlight) { - if (::qt_cast<QButton*>(widget) || ::qt_cast<QComboBox*>(widget)) - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QComboBox"))) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } - if (::qt_cast<QScrollBar*>(widget) || ::qt_cast<QSlider*>(widget)) { - widget->setMouseTracking(TRUE); - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("QScrollBar")) || (ceData.widgetObjectTypes.contains("QSlider"))) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); + installObjectEventHandler(ceData, elementFlags, ptr, this); } } - QMotifStyle::polish(widget); + QMotifStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ -void QMotifPlusStyle::unPolish(QWidget *widget) +void QMotifPlusStyle::unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - widget->removeEventFilter(this); - QMotifStyle::unPolish(widget); + removeObjectEventHandler(ceData, elementFlags, ptr, this); + QMotifStyle::unPolish(ceData, elementFlags, ptr); } /*! \reimp */ -void QMotifPlusStyle::polish(QApplication *) +void QMotifPlusStyle::applicationPolish(QStyleControlElementData, ControlElementFlags, void *) { } /*! \reimp */ -void QMotifPlusStyle::unPolish(QApplication *) +void QMotifPlusStyle::applicationUnPolish(QStyleControlElementData, ControlElementFlags, void *) { } @@ -1477,14 +1485,14 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control, /*! \reimp */ -bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) +bool QMotifPlusStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *event ) { switch(event->type()) { case QEvent::MouseButtonPress: { singleton->mousePressed = TRUE; - if (!::qt_cast<QSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("QSlider")) break; singleton->sliderActive = TRUE; @@ -1495,50 +1503,52 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) { singleton->mousePressed = FALSE; - if (!::qt_cast<QSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("QSlider")) break; singleton->sliderActive = FALSE; - ((QWidget *) object)->repaint(FALSE); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; } case QEvent::Enter: { - if (! object->isWidgetType()) + if (!ceData.widgetObjectTypes.contains("QWidget")) break; - singleton->hoverWidget = (QWidget *) object; - if (! singleton->hoverWidget->isEnabled()) { + singleton->hoverWidget = source; + singleton->hoverWidgetData = ceData; + singleton->hoverWidgetFlags = elementFlags; + if (!(singleton->hoverWidgetFlags & CEF_IsEnabled)) { singleton->hoverWidget = 0; break; } - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); break; } case QEvent::Leave: { - if (object != singleton->hoverWidget) + if (source != singleton->hoverWidget) break; - QWidget *w = singleton->hoverWidget; + void *w = singleton->hoverWidget; singleton->hoverWidget = 0; - w->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, w, WAR_Repaint); break; } case QEvent::MouseMove: { - if (! object->isWidgetType() || object != singleton->hoverWidget) + if ((!ceData.widgetObjectTypes.contains("QWidget")) || source != singleton->hoverWidget) break; - if (!::qt_cast<QScrollBar*>(object) && ! ::qt_cast<QSlider*>(object)) + if ((!ceData.widgetObjectTypes.contains("QScrollBar")) && (!ceData.widgetObjectTypes.contains("QSlider"))) break; singleton->mousePos = ((QMouseEvent *) event)->pos(); if (! singleton->mousePressed) { singleton->hovering = TRUE; - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); singleton->hovering = FALSE; } @@ -1549,7 +1559,7 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) break; } - return QMotifStyle::eventFilter(object, event); + return QMotifStyle::objectEventHandler(ceData, elementFlags, source, event); } diff --git a/src/styles/qmotifplusstyle.h b/src/styles/qmotifplusstyle.h index beb8ae6..24de609 100644 --- a/src/styles/qmotifplusstyle.h +++ b/src/styles/qmotifplusstyle.h @@ -63,11 +63,11 @@ public: virtual ~QMotifPlusStyle(); void polish(QPalette &pal); - void polish(QWidget *widget); - void unPolish(QWidget*widget); + void polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); - void polish(QApplication *app); - void unPolish(QApplication *app); + void applicationPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void applicationUnPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void drawPrimitive( PrimitiveElement pe, QPainter *p, @@ -118,8 +118,7 @@ public: int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption & = QStyleOption::Default, QStyleHintReturn* = 0, const QWidget * = 0) const; -protected: - bool eventFilter(QObject *, QEvent *); + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index 1fc7bd0..4c6a0c8 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -171,9 +171,9 @@ void QMotifStyle::polish( QPalette& pal ) \internal Keep QStyle::polish() visible. */ -void QMotifStyle::polish( QWidget* w ) +void QMotifStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - QStyle::polish(w); + QStyle::polish(ceData, elementFlags, ptr); } /*! @@ -181,9 +181,9 @@ void QMotifStyle::polish( QWidget* w ) \internal Keep QStyle::polish() visible. */ -void QMotifStyle::polish( QApplication* a ) +void QMotifStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - QStyle::polish(a); + QStyle::applicationPolish(ceData, elementFlags, ptr); } static void rot(QPointArray& a, int n) diff --git a/src/styles/qmotifstyle.h b/src/styles/qmotifstyle.h index 969064c..213795f 100644 --- a/src/styles/qmotifstyle.h +++ b/src/styles/qmotifstyle.h @@ -67,8 +67,8 @@ public: bool useHighlightColors() const; void polish( QPalette& ); - void polish( QWidget* ); - void polish( QApplication* ); + void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void polishPopupMenu( QPopupMenu* ); diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index 5695348..a66fcda 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -65,7 +65,7 @@ struct SliderLastPosition { SliderLastPosition() : rect(0,-1,0,-1), slider(0) {} QRect rect; - const QSlider* slider; + const void* slider; }; #endif @@ -74,7 +74,7 @@ struct ScrollbarLastPosition { ScrollbarLastPosition() : rect( 0,-1, 0,-1 ), scrollbar(0) {} QRect rect; - const QScrollBar *scrollbar; + const void* scrollbar; }; #endif @@ -86,7 +86,7 @@ public: { } - const QWidget *hotWidget; + const void* hotWidget; QPoint mousePos; #ifndef QT_NO_SCROLLBAR ScrollbarLastPosition lastScrollbarRect; @@ -136,10 +136,10 @@ QSGIStyle::~QSGIStyle() bold italic font for menu options. */ void -QSGIStyle::polish( QApplication* app) +QSGIStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { isApplicationStyle = 1; - QMotifStyle::polish( app ); + QMotifStyle::polish( ceData, elementFlags, ptr ); QPalette pal = QApplication::palette(); // check this on SGI-Boxes @@ -181,7 +181,7 @@ QSGIStyle::polish( QApplication* app) /*! \reimp */ void -QSGIStyle::unPolish( QApplication* /* app */ ) +QSGIStyle::applicationUnPolish( QStyleControlElementData, ControlElementFlags, void * ) { QFont f = QApplication::font(); QApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes @@ -194,9 +194,9 @@ QSGIStyle::unPolish( QApplication* /* app */ ) hovering. */ void -QSGIStyle::polish( QWidget* w ) +QSGIStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - QMotifStyle::polish(w); + QMotifStyle::polish(ceData, elementFlags, ptr); if ( !isApplicationStyle ) { QPalette sgiPal = QApplication::palette(); @@ -214,7 +214,7 @@ QSGIStyle::polish( QWidget* w ) sgiPal.setColor( QPalette::Disabled, QColorGroup::HighlightedText, sgiPal.disabled().base() ); } - if ( ::qt_cast<QLineEdit*>(w) || ::qt_cast<QTextEdit*>(w) ) { + if ( (ceData.widgetObjectTypes.contains("QLineEdit")) || (ceData.widgetObjectTypes.contains("QTextEdit")) ) { // different basecolor and highlighting in Q(Multi)LineEdit sgiPal.setColor( QColorGroup::Base, QColor(211,181,181) ); sgiPal.setColor( QPalette::Active, QColorGroup::Highlight, sgiPal.active().midlight() ); @@ -224,89 +224,89 @@ QSGIStyle::polish( QWidget* w ) sgiPal.setColor( QPalette::Disabled, QColorGroup::Highlight, sgiPal.disabled().midlight() ); sgiPal.setColor( QPalette::Disabled, QColorGroup::HighlightedText, sgiPal.disabled().text() ); - } else if ( ::qt_cast<QMenuBar*>(w) || ::qt_cast<QToolBar*>(w) ) { + } else if ( (ceData.widgetObjectTypes.contains("QMenuBar")) || (ceData.widgetObjectTypes.contains("QToolBar")) ) { sgiPal.setColor( QColorGroup::Button, sgiPal.active().midlight() ); } - w->setPalette( sgiPal ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetPalette, QStyleWidgetActionRequestData(sgiPal)); } - if ( ::qt_cast<QButton*>(w) || ::qt_cast<QSlider*>(w) || ::qt_cast<QScrollBar*>(w) ) { - w->installEventFilter( this ); - w->setMouseTracking( TRUE ); + if ( (ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QSlider")) || (ceData.widgetObjectTypes.contains("QScrollBar")) ) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); #ifndef QT_NO_SCROLLBAR - if ( ::qt_cast<QScrollBar*>(w) ) - w->setBackgroundMode( QWidget::NoBackground ); + if ( ceData.widgetObjectTypes.contains("QScrollBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::NoBackground)); + } #endif - } else if ( ::qt_cast<QComboBox*>(w) ) { + } else if ( ceData.widgetObjectTypes.contains("QComboBox") ) { QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #ifndef QT_NO_MENUBAR - } else if ( ::qt_cast<QMenuBar*>(w) ) { - ((QFrame*) w)->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - w->setBackgroundMode( QWidget::PaletteBackground ); + } else if ( ceData.widgetObjectTypes.contains("QMenuBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::StyledPanel | QFrame::Raised)); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::PaletteBackground)); QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #endif #ifndef QT_NO_POPUPMENU - } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) + 1 ); + } else if ( ceData.widgetObjectTypes.contains("QPopupMenu") ) { + QStyleWidgetActionRequestData requestData; + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, QStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) + 1)); QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #endif - } else if ( ::qt_cast<QToolBar*>(w) || w->inherits("QToolBarSeparator") ) { - w->setBackgroundMode( QWidget::PaletteBackground ); + } else if ( (ceData.widgetObjectTypes.contains("QToolBar")) || (ceData.widgetObjectTypes.contains("QToolBarSeparator")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::PaletteBackground)); } } /*! \reimp */ void -QSGIStyle::unPolish( QWidget* w ) +QSGIStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if ( ::qt_cast<QButton*>(w) || ::qt_cast<QSlider*>(w) || ::qt_cast<QScrollBar*>(w) ) { - w->removeEventFilter( this ); + if ( (ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QSlider")) || (ceData.widgetObjectTypes.contains("QScrollBar")) ) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); #ifndef QT_NO_POPUPMENU - } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) ); - w->setFont( QApplication::font() ); + } else if ( ceData.widgetObjectTypes.contains("QPopupMenu") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, QStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ))); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(QApplication::font())); #endif #if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX) - } else if ( ::qt_cast<QMenuBar*>(w) || ::qt_cast<QComboBox*>(w) ) { - w->setFont( QApplication::font() ); + } else if ( (ceData.widgetObjectTypes.contains("QMenuBar")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(QApplication::font())); #endif } } /*! \reimp */ -bool QSGIStyle::eventFilter( QObject* o, QEvent* e ) +bool QSGIStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) { - if ( !o->isWidgetType() || e->type() == QEvent::Paint ) - return QMotifStyle::eventFilter( o, e ); - - QWidget *widget = (QWidget*)o; + if ( (!(ceData.widgetObjectTypes.contains("QWidget"))) || (e->type() == QEvent::Paint) ) + return QMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); switch ( e->type() ) { case QEvent::MouseButtonPress: { #ifndef QT_NO_SCROLLBAR - if ( ::qt_cast<QScrollBar*>(widget) ) { - d->lastScrollbarRect.rect = ((QScrollBar*)widget)->sliderRect(); - d->lastScrollbarRect.scrollbar = ((QScrollBar*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("QScrollBar")) { + d->lastScrollbarRect.rect = ceData.sliderRect; + d->lastScrollbarRect.scrollbar = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } else #endif { #ifndef QT_NO_SLIDER - if ( ::qt_cast<QSlider*>(widget) ) { - d->lastSliderRect.rect = ((QSlider*)widget)->sliderRect(); - d->lastSliderRect.slider = ((QSlider*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("QSlider")) { + d->lastSliderRect.rect = ceData.sliderRect; + d->lastSliderRect.slider = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } #endif } @@ -317,52 +317,52 @@ bool QSGIStyle::eventFilter( QObject* o, QEvent* e ) { if ( 0 ) { #ifndef QT_NO_SCROLLBAR - } else if ( ::qt_cast<QScrollBar*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("QScrollBar")) { QRect oldRect = d->lastScrollbarRect.rect; d->lastScrollbarRect.rect = QRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, QStyleWidgetActionRequestData(oldRect)); #endif #ifndef QT_NO_SLIDER - } else if ( ::qt_cast<QSlider*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("QSlider")) { QRect oldRect = d->lastSliderRect.rect; d->lastSliderRect.rect = QRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, QStyleWidgetActionRequestData(oldRect)); #endif } } break; case QEvent::MouseMove: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; if ( ((QMouseEvent*)e)->button() ) break; - d->hotWidget = widget; + d->hotWidget = source; d->mousePos = ((QMouseEvent*)e)->pos(); - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case QEvent::Enter: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - d->hotWidget = widget; - widget->repaint( FALSE ); + d->hotWidget = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case QEvent::Leave: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - if ( widget == d->hotWidget) { + if ( source == d->hotWidget) { d->hotWidget = 0; - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } break; default: break; } - return QMotifStyle::eventFilter( o, e ); + return QMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); } static const int sgiItemFrame = 2; // menu item frame width diff --git a/src/styles/qsgistyle.h b/src/styles/qsgistyle.h index 849d67c..0afacd6 100644 --- a/src/styles/qsgistyle.h +++ b/src/styles/qsgistyle.h @@ -67,10 +67,10 @@ public: #if !defined(Q_NO_USING_KEYWORD) using QMotifStyle::polish; #endif - void polish( QWidget* ); - void unPolish( QWidget* ); - void polish( QApplication* ); - void unPolish( QApplication* ); + void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void drawPrimitive( PrimitiveElement pe, QPainter *p, @@ -124,8 +124,7 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; -protected: - bool eventFilter( QObject*, QEvent*); + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: QSGIStylePrivate *d; diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 9514939..ec05b80 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -95,99 +95,42 @@ class QWindowsStyle::Private : public QObject public: Private(QWindowsStyle *parent); - bool hasSeenAlt(const QWidget *widget) const; - bool altDown() const { return alt_down; } - -protected: - bool eventFilter(QObject *o, QEvent *e); + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: - QPtrList<QWidget> seenAlt; - bool alt_down; int menuBarTimer; }; QWindowsStyle::Private::Private(QWindowsStyle *parent) -: QObject(parent, "QWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0) +: QObject(parent, "QWindowsStylePrivate"), menuBarTimer(0) { } -// Returns true if the toplevel parent of \a widget has seen the Alt-key -bool QWindowsStyle::Private::hasSeenAlt(const QWidget *widget) const -{ - widget = widget->topLevelWidget(); - return seenAlt.contains(widget); -} - // Records Alt- and Focus events -bool QWindowsStyle::Private::eventFilter(QObject *o, QEvent *e) +bool QWindowsStyle::Private::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags, void* source, QEvent *e ) { - if (!o->isWidgetType()) - return QObject::eventFilter(o, e); + if (!(ceData.widgetObjectTypes.contains("QWidget"))) { + return TRUE; + } - QWidget *widget = ::qt_cast<QWidget*>(o); + QWidget *widget = reinterpret_cast<QWidget*>(source); switch(e->type()) { - case QEvent::KeyPress: - if (((QKeyEvent*)e)->key() == Key_Alt) { - widget = widget->topLevelWidget(); - - // Alt has been pressed - find all widgets that care - QObjectList *l = widget->queryList("QWidget"); - QObjectListIt it( *l ); - QWidget *w; - while ( (w = (QWidget*)it.current()) != 0 ) { - ++it; - if (w->isTopLevel() || !w->isVisible() || - w->style().styleHint(SH_UnderlineAccelerator, QStyleControlElementData(), CEF_None, w)) - l->removeRef(w); - } - // Update states before repainting - seenAlt.append(widget); - alt_down = TRUE; - - // Repaint all relevant widgets - it.toFirst(); - while ( (w = (QWidget*)it.current()) != 0 ) { - ++it; - w->repaint(FALSE); - } - delete l; - } - break; - case QEvent::KeyRelease: - if (((QKeyEvent*)e)->key() == Key_Alt) { - widget = widget->topLevelWidget(); - - // Update state - alt_down = FALSE; - // Repaint only menubars - QObjectList *l = widget->queryList("QMenuBar"); - QObjectListIt it( *l ); - QMenuBar *menuBar; - while ( (menuBar = (QMenuBar*)it.current()) != 0) { - ++it; - menuBar->repaint(FALSE); - } - } - break; case QEvent::FocusIn: case QEvent::FocusOut: { // Menubars toggle based on focus - QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o); + QMenuBar *menuBar = ::qt_cast<QMenuBar*>(widget); if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker menuBarTimer = menuBar->startTimer(0); } break; case QEvent::Close: // Reset widget when closing - seenAlt.removeRef(widget); - seenAlt.removeRef(widget->topLevelWidget()); break; case QEvent::Timer: { - QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o); + QMenuBar *menuBar = ::qt_cast<QMenuBar*>(widget); QTimerEvent *te = (QTimerEvent*)e; if (menuBar && te->timerId() == menuBarTimer) { menuBar->killTimer(te->timerId()); @@ -201,7 +144,7 @@ bool QWindowsStyle::Private::eventFilter(QObject *o, QEvent *e) break; } - return QObject::eventFilter(o, e); + return TRUE; } /*! @@ -230,32 +173,40 @@ QWindowsStyle::~QWindowsStyle() } /*! \reimp */ -void QWindowsStyle::polish(QApplication *app) +bool QWindowsStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) { + if (d) { + return d->objectEventHandler(ceData, elementFlags, source, e); + } + return TRUE; +} + +/*! \reimp */ +void QWindowsStyle::applicationPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { // We only need the overhead when shortcuts are sometimes hidden - if (!styleHint(SH_UnderlineAccelerator, QStyleControlElementData(), CEF_None, 0)) { + if (styleHint(SH_UnderlineAccelerator, QStyleControlElementData(), CEF_None, 0) && styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, 0)) { d = new Private(this); - app->installEventFilter(d); + installObjectEventHandler(ceData, elementFlags, ptr, this); } } /*! \reimp */ -void QWindowsStyle::unPolish(QApplication *) +void QWindowsStyle::applicationUnPolish(QStyleControlElementData, ControlElementFlags, void *) { delete d; d = 0; } /*! \reimp */ -void QWindowsStyle::polish(QWidget *widget) +void QWindowsStyle::polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - QCommonStyle::polish(widget); + QCommonStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ -void QWindowsStyle::unPolish(QWidget *widget) +void QWindowsStyle::unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - QCommonStyle::polish(widget); + QCommonStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ @@ -946,8 +897,9 @@ void QWindowsStyle::drawControl( ControlElement element, if ( !s.isNull() ) { // draw text int t = s.find( '\t' ); int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) { text_flags |= NoAccel; + } text_flags |= (QApplication::reverseLayout() ? AlignRight : AlignLeft ); if ( t >= 0 ) { // draw tab text int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1; diff --git a/src/styles/qwindowsstyle.h b/src/styles/qwindowsstyle.h index d0b400c..d768a04 100644 --- a/src/styles/qwindowsstyle.h +++ b/src/styles/qwindowsstyle.h @@ -61,11 +61,11 @@ public: QWindowsStyle(); ~QWindowsStyle(); - void polish(QApplication*); - void unPolish(QApplication*); + void applicationPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void applicationUnPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); - void polish(QWidget*); - void unPolish(QWidget*); + void polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void polish( QPalette & ); @@ -130,6 +130,7 @@ public: QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const; + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: class Private; diff --git a/src/tools/qglobal.h b/src/tools/qglobal.h index 44e6bbf..a62d19a 100644 --- a/src/tools/qglobal.h +++ b/src/tools/qglobal.h @@ -41,11 +41,11 @@ #ifndef QGLOBAL_H #define QGLOBAL_H -#define QT_VERSION_STR "3.4.0" +#define QT_VERSION_STR "3.5.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x030400 +#define QT_VERSION 0x030500 /* The operating system, must be one of: (Q_OS_x) diff --git a/src/widgets/qgroupbox.cpp b/src/widgets/qgroupbox.cpp index 6097ece..7ffcb2a 100644 --- a/src/widgets/qgroupbox.cpp +++ b/src/widgets/qgroupbox.cpp @@ -364,8 +364,9 @@ void QGroupBox::paintEvent( QPaintEvent *event ) if(va & AlignTop) r.moveBy(0, fm.descent()); QColor pen( (QRgb) style().styleHint(QStyle::SH_GroupBox_TextLabelColor, this ) ); - if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) + if ((!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) || ((style().styleHint(QStyle::SH_HideUnderlineAcceleratorWhenAltUp, this)) && (!style().acceleratorsShown()))) { va |= NoAccel; + } style().drawItem( &paint, r, ShowPrefix | AlignHCenter | va, colorGroup(), isEnabled(), 0, str, -1, ownPalette() ? 0 : &pen ); paint.setClipRegion( event->region().subtract( r ) ); // clip everything but title diff --git a/src/widgets/qlabel.cpp b/src/widgets/qlabel.cpp index 40f2b38..ff2e7bc 100644 --- a/src/widgets/qlabel.cpp +++ b/src/widgets/qlabel.cpp @@ -838,8 +838,9 @@ void QLabel::drawContents( QPainter *p ) } #endif int alignment = align; - if ((align & ShowPrefix) && !style().styleHint(QStyle::SH_UnderlineAccelerator, this)) + if ((align & ShowPrefix) && ((!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) || ((style().styleHint(QStyle::SH_HideUnderlineAcceleratorWhenAltUp, this)) && (!style().acceleratorsShown())))) { alignment |= NoAccel; + } // ordinary text or pixmap label style().drawItem( p, cr, alignment, colorGroup(), isEnabled(), pix, ltext ); diff --git a/src/widgets/qtoolbox.cpp b/src/widgets/qtoolbox.cpp index 64fc148..b48f416 100644 --- a/src/widgets/qtoolbox.cpp +++ b/src/widgets/qtoolbox.cpp @@ -240,8 +240,9 @@ void QToolBoxButton::drawButton( QPainter *p ) fill = &cg.color( QPalette::foregroundRoleFromMode( tb->backgroundMode() ) ); int alignment = AlignLeft | AlignVCenter | ShowPrefix; - if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) + if ((!style().styleHint(QStyle::SH_UnderlineAccelerator, this)) || ((style().styleHint(QStyle::SH_HideUnderlineAcceleratorWhenAltUp, this)) && (!style().acceleratorsShown()))) { alignment |= NoAccel; + } style().drawItem( p, tr, alignment, cg, isEnabled(), 0, txt, -1, fill ); |