summaryrefslogtreecommitdiffstats
path: root/src/styles/qwindowsstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/styles/qwindowsstyle.cpp')
-rw-r--r--src/styles/qwindowsstyle.cpp104
1 files changed, 28 insertions, 76 deletions
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;