diff options
Diffstat (limited to 'src/gui')
35 files changed, 260 insertions, 295 deletions
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index a7dccd8..a97aedd 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -343,8 +343,8 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, { bool modern = ((info.wizStyle == QWizard::ModernStyle) #if !defined(QT_NO_STYLE_WINDOWSVISTA) - || ((info.wizStyle == QWizard::AeroStyle) - && (QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) + || ((info.wizStyle == QWizard::AeroStyle + && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) #endif ); diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index 840149b..1def47f 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -616,7 +616,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q // Set up a memory DC and bitmap that we'll draw into HDC dcMem; HBITMAP bmp; - BITMAPINFO dib = {0}; + BITMAPINFO dib = {{0}}; dcMem = CreateCompatibleDC(hdc); dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -662,7 +662,7 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc) // Set up a memory DC and bitmap that we'll draw into HDC dcMem; HBITMAP bmp; - BITMAPINFO dib = {0}; + BITMAPINFO dib = {{0}}; dcMem = CreateCompatibleDC(hdc); dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 03014d8..cb0418c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -650,6 +650,10 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch // For root items only. This is the item that has either enabled or // disabled \a childFlag, or has been reparented. switch (int(childFlag)) { + case -2: + flag = AncestorFiltersChildEvents; + enabled = q->filtersChildEvents(); + break; case -1: flag = AncestorHandlesChildEvents; enabled = q->handlesChildEvents(); @@ -670,7 +674,8 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch // Inherit the enabled-state from our parents. if ((parent && ((parent->d_ptr->ancestorFlags & flag) || (int(parent->d_ptr->flags & childFlag) == childFlag) - || (childFlag == -1 && parent->d_ptr->handlesChildEvents)))) { + || (childFlag == -1 && parent->d_ptr->handlesChildEvents) + || (childFlag == -2 && parent->d_ptr->filtersDescendantEvents)))) { enabled = true; ancestorFlags |= flag; } @@ -691,7 +696,9 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch ancestorFlags &= ~flag; // Don't process children if the item has the main flag set on itself. - if ((childFlag != -1 && int(flags & childFlag) == childFlag) || (int(childFlag) == -1 && handlesChildEvents)) + if ((childFlag != -1 && int(flags & childFlag) == childFlag) + || (int(childFlag) == -1 && handlesChildEvents) + || (int(childFlag) == -2 && filtersDescendantEvents)) return; } @@ -953,6 +960,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Inherit ancestor flags from the new parent. + updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); @@ -969,6 +977,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } else { // Inherit ancestor flags from the new parent. + updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); @@ -2352,6 +2361,40 @@ void QGraphicsItem::setAcceptTouchEvents(bool enabled) } /*! + Returns true if this item filters child events (i.e., all events + intended for any of its children are instead sent to this item); + otherwise, false is returned. + + The default value is false; child events are not filtered. + + \sa setFiltersChildEvents() +*/ +bool QGraphicsItem::filtersChildEvents() const +{ + return d_ptr->filtersDescendantEvents; +} + +/*! + If \a enabled is true, this item is set to filter all events for + all its children (i.e., all events intented for any of its + children are instead sent to this item); otherwise, if \a enabled + is false, this item will only handle its own events. The default + value is false. + + \sa filtersChildEvents() +*/ +void QGraphicsItem::setFiltersChildEvents(bool enabled) +{ + if (d_ptr->filtersDescendantEvents == enabled) + return; + + d_ptr->filtersDescendantEvents = enabled; + d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); +} + +/*! + \obsolete + Returns true if this item handles child events (i.e., all events intended for any of its children are instead sent to this item); otherwise, false is returned. @@ -2372,6 +2415,8 @@ bool QGraphicsItem::handlesChildEvents() const } /*! + \obsolete + If \a enabled is true, this item is set to handle all events for all its children (i.e., all events intented for any of its children are instead sent to this item); otherwise, if \a enabled diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 72c4830..a307622 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -216,6 +216,9 @@ public: bool acceptTouchEvents() const; void setAcceptTouchEvents(bool enabled); + bool filtersChildEvents() const; + void setFiltersChildEvents(bool enabled); + bool handlesChildEvents() const; void setHandlesChildEvents(bool enabled); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 9bdd273..4729634 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -109,7 +109,8 @@ public: NoFlag = 0, AncestorHandlesChildEvents = 0x1, AncestorClipsChildren = 0x2, - AncestorIgnoresTransformations = 0x4 + AncestorIgnoresTransformations = 0x4, + AncestorFiltersChildEvents = 0x8 }; inline QGraphicsItemPrivate() @@ -157,6 +158,7 @@ public: ignoreOpacity(0), acceptTouchEvents(0), acceptedTouchBeginEvent(0), + filtersDescendantEvents(0), sceneTransformTranslateOnly(0), globalStackingOrder(-1), q_ptr(0) @@ -421,7 +423,7 @@ public: quint32 handlesChildEvents : 1; quint32 itemDiscovered : 1; quint32 hasCursor : 1; - quint32 ancestorFlags : 3; + quint32 ancestorFlags : 4; quint32 cacheMode : 2; quint32 hasBoundingRegionGranularity : 1; quint32 isWidget : 1; @@ -433,13 +435,13 @@ public: quint32 inSetPosHelper : 1; quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; - quint32 fullUpdatePending : 1; // New 32 bits - quint32 flags : 13; + quint32 fullUpdatePending : 1; + quint32 flags : 12; quint32 dirtyChildrenBoundingRect : 1; quint32 paintedViewBoundingRectsNeedRepaint : 1; - quint32 dirtySceneTransform : 1; + quint32 dirtySceneTransform : 1; quint32 geometryChanged : 1; quint32 inDestructor : 1; quint32 isObject : 1; @@ -447,8 +449,9 @@ public: quint32 ignoreOpacity : 1; quint32 acceptTouchEvents : 1; quint32 acceptedTouchBeginEvent : 1; + quint32 filtersDescendantEvents : 1; quint32 sceneTransformTranslateOnly : 1; - quint32 unused : 8; // feel free to use + quint32 unused : 7; // feel free to use // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index c8e178a..06333ae 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -357,6 +357,9 @@ void QGraphicsScenePrivate::_q_emitUpdated() updateAll = false; for (int i = 0; i < views.size(); ++i) views.at(i)->d_func()->processPendingUpdates(); + // It's important that we update all views before we dispatch, hence two for-loops. + for (int i = 0; i < views.size(); ++i) + views.at(i)->d_func()->dispatchPendingUpdateRequests(); return; } @@ -447,13 +450,8 @@ void QGraphicsScenePrivate::_q_processDirtyItems() } // Immediately dispatch all pending update requests on the views. - for (int i = 0; i < views.size(); ++i) { - QWidget *viewport = views.at(i)->d_func()->viewport; - if (qt_widget_private(viewport)->paintOnScreen()) - QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest); - else - QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); - } + for (int i = 0; i < views.size(); ++i) + views.at(i)->d_func()->dispatchPendingUpdateRequests(); } /*! @@ -853,6 +851,24 @@ void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGrap } /*! + \internal +*/ +bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event) +{ + if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) { + QGraphicsItem *parent = item->parentItem(); + while (parent) { + if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event)) + return true; + if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) + return false; + parent = parent->parentItem(); + } + } + return false; +} + +/*! \internal */ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) @@ -884,7 +900,9 @@ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) { if (filterEvent(item, event)) return false; - return (item && item->isEnabled()) ? item->sceneEvent(event) : false; + if (filterDescendantEvent(item, event)) + return false; + return (item && item->isEnabled() ? item->sceneEvent(event) : false); } /*! @@ -2730,7 +2748,7 @@ void QGraphicsScene::update(const QRectF &rect) if (directUpdates) { // Update all views. for (int i = 0; i < d->views.size(); ++i) - d->views.at(i)->d_func()->updateAll(); + d->views.at(i)->d_func()->fullUpdatePending = true; } } else { if (directUpdates) { diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index ffd62d5..9a91acc 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -172,6 +172,7 @@ public: QMultiMap<QGraphicsItem *, QGraphicsItem *> sceneEventFilters; void installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); void removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); + bool filterDescendantEvent(QGraphicsItem *item, QEvent *event); bool filterEvent(QGraphicsItem *item, QEvent *event); bool sendEvent(QGraphicsItem *item, QEvent *event); diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 2e02458..ed5fa8e 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -1,9 +1,9 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index 8cf0294..37dffb8 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -1,9 +1,9 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h index 56dde3a..3dbbc63 100644 --- a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h @@ -1,9 +1,9 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index bcfd68c..1cea8db 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -821,13 +821,9 @@ void QGraphicsViewPrivate::processPendingUpdates() if (!scene) return; - if (fullUpdatePending) { // We have already called viewport->update() - dirtyBoundingRect = QRect(); - dirtyRegion = QRegion(); - return; - } - - if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) { + if (fullUpdatePending) { + viewport->update(); + } else if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) { if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) viewport->update(dirtyBoundingRect.adjusted(-1, -1, 1, 1)); else diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 0fa8b34..62a2b84 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -58,6 +58,7 @@ #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW #include <QtGui/qevent.h> +#include <QtCore/qcoreapplication.h> #include "qgraphicssceneevent.h" #include <QtGui/qstyleoption.h> #include <private/qabstractscrollarea_p.h> @@ -168,6 +169,15 @@ public: dirtyBoundingRect = QRect(); dirtyRegion = QRegion(); } + + inline void dispatchPendingUpdateRequests() + { + if (qt_widget_private(viewport)->paintOnScreen()) + QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest); + else + QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); + } + bool updateRect(const QRect &rect); bool updateRegion(const QRegion ®ion); bool updateSceneSlotReimplementedChecked; diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 164a228..243e361 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -275,6 +275,8 @@ extern HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) #define XBUTTON1 0x0001 #define XBUTTON2 0x0002 +#endif +#ifndef MK_XBUTTON1 #define MK_XBUTTON1 0x0020 #define MK_XBUTTON2 0x0040 #endif @@ -807,9 +809,10 @@ void qt_init(QApplicationPrivate *priv, int) ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect; // Notify Vista and Windows 7 that we support highter DPI settings - if (ptrSetProcessDPIAware = (PtrSetProcessDPIAware) - QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware")) - ptrSetProcessDPIAware(); + ptrSetProcessDPIAware = (PtrSetProcessDPIAware) + QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware"); + if (ptrSetProcessDPIAware) + ptrSetProcessDPIAware(); #endif priv->lastGestureId = 0; @@ -1351,13 +1354,13 @@ static int inputcharset = CP_ACP; static bool qt_is_translatable_mouse_event(UINT message) { - return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST || - message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK) + return (((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) || + (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)) && message != WM_MOUSEWHEEL - && message != WM_MOUSEHWHEEL + && message != WM_MOUSEHWHEEL) #ifndef Q_WS_WINCE - || message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK + || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK) #endif ; } @@ -2601,7 +2604,7 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret) bool block_event = false; #ifndef Q_WS_WINCE - if (type != WM_NCHITTEST) + if (type != WM_NCHITTEST) { #endif if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) || type == WM_MOUSEWHEEL || type == WM_MOUSEHWHEEL || @@ -2631,17 +2634,18 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret) block_event = true; } #ifndef Q_WS_WINCE - else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){ - if (!top->isActiveWindow()) { - top->activateWindow(); - } else { - QApplication::beep(); - } - block_event = true; - ret = MA_NOACTIVATEANDEAT; - } else if (type == WM_SYSCOMMAND) { - if (!(msg->wParam == SC_RESTORE && widget->isMinimized())) + else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){ + if (!top->isActiveWindow()) { + top->activateWindow(); + } else { + QApplication::beep(); + } block_event = true; + ret = MA_NOACTIVATEANDEAT; + } else if (type == WM_SYSCOMMAND) { + if (!(msg->wParam == SC_RESTORE && widget->isMinimized())) + block_event = true; + } } #endif @@ -2843,7 +2847,7 @@ void qt_win_eatMouseMove() // remove all those messages (usually 1) and post the last one with a // reset button state - MSG msg = {0, 0, 0, 0, 0, 0, 0}; + MSG msg = {0, 0, 0, 0, 0, {0, 0} }; while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ; if (msg.message == WM_MOUSEMOVE) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 52685ca..3e5bfb6 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -550,15 +550,7 @@ extern "C" { qwidget->objectName().local8Bit().data()); #endif QPainter p(qwidget); - QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(qwidget->parent()); - QPoint scrollAreaOffset; - if (scrollArea && scrollArea->viewport() == qwidget) { - QAbstractScrollAreaPrivate *priv - = static_cast<QAbstractScrollAreaPrivate *>(qt_widget_private(scrollArea)); - scrollAreaOffset = priv->contentsOffset(); - p.translate(-scrollAreaOffset); - } - qwidgetprivate->paintBackground(&p, qrgn, scrollAreaOffset, + qwidgetprivate->paintBackground(&p, qrgn, qwidget->isWindow() ? QWidgetPrivate::DrawAsRoot : 0); p.end(); } diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index db00835..26e395c 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -476,7 +476,11 @@ void QCursorData::update() qWarning("QCursor::update: Invalid cursor shape %d", cshape); return; } +#ifdef Q_WS_WINCE + hcurs = LoadCursor(0, sh); +#else hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED); +#endif } QT_END_NAMESPACE diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/gui/kernel/qkeymapper_win.cpp index b13e622..0998631 100644 --- a/src/gui/kernel/qkeymapper_win.cpp +++ b/src/gui/kernel/qkeymapper_win.cpp @@ -851,8 +851,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool } } else if (msgType == WM_KEYUP) { if (dirStatus == VK_LSHIFT - && (msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL) - || msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT))) { + && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) + || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { k0 = q->sendKeyEvent(widget, grab, QEvent::KeyPress, Qt::Key_Direction_L, 0, QString(), false, 0, scancode, msg.wParam, nModifiers); @@ -861,8 +861,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool scancode, msg.wParam, nModifiers); dirStatus = 0; } else if (dirStatus == VK_RSHIFT - && (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL) - || msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT))) { + && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) + || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { k0 = q->sendKeyEvent(widget, grab, QEvent::KeyPress, Qt::Key_Direction_R, 0, QString(), false, 0, scancode, msg.wParam, nModifiers); diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp index c7559d8..acd7cfc 100644 --- a/src/gui/kernel/qmime_win.cpp +++ b/src/gui/kernel/qmime_win.cpp @@ -170,7 +170,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj) if (pDataObj->GetData(&formatetc, &s) == S_OK) { char szBuffer[4096]; ULONG actualRead = 0; - LARGE_INTEGER pos = {0, 0}; + LARGE_INTEGER pos = {{0, 0}}; //Move to front (can fail depending on the data model implemented) HRESULT hr = s.pstm->Seek(pos, STREAM_SEEK_SET, NULL); while(SUCCEEDED(hr)){ diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5f076ff..7026525 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1966,10 +1966,9 @@ void QPixmap::fill( const QWidget *widget, const QPoint &off ) QPainter p(this); p.translate(-off); widget->d_func()->paintBackground(&p, QRect(off, size())); - } -static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush) +static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) { Q_ASSERT(painter); @@ -1978,26 +1977,39 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin // Optimize pattern filling on mac by using HITheme directly // when filling with the standard widget background. // Defined in qmacstyle_mac.cpp - extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush); - qt_mac_fill_background(painter, rgn, offset, brush); + extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); + qt_mac_fill_background(painter, rgn, brush); #else - const QRegion translated = rgn.translated(offset); - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); + const QRect rect(rgn.boundingRect()); + painter->setClipRegion(rgn); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); #endif } else { const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) - painter->fillRect(rects.at(i).translated(offset), brush); + painter->fillRect(rects.at(i), brush); } } - -void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, const QPoint &offset, int flags) const +void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const { Q_Q(const QWidget); +#ifndef QT_NO_SCROLLAREA + bool resetBrushOrigin = false; + QPointF oldBrushOrigin; + //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture + QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); + if (scrollArea && scrollArea->viewport() == q) { + QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr; + QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); + oldBrushOrigin = painter->brushOrigin(); + resetBrushOrigin = true; + painter->setBrushOrigin(-priv->contentsOffset()); + + } +#endif // QT_NO_SCROLLAREA + const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) { @@ -2006,18 +2018,24 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, cons if (!(flags & DontSetCompositionMode) && painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) painter->setCompositionMode(QPainter::CompositionMode_Source); //copy alpha straight in #endif - fillRegion(painter, rgn, offset, bg); + fillRegion(painter, rgn, bg); } if (q->autoFillBackground()) - fillRegion(painter, rgn, offset, autoFillBrush); + fillRegion(painter, rgn, autoFillBrush); + if (q->testAttribute(Qt::WA_StyledBackground)) { - painter->setClipRegion(rgn.translated(offset)); + painter->setClipRegion(rgn); QStyleOption opt; opt.initFrom(q); q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); } + +#ifndef QT_NO_SCROLLAREA + if (resetBrushOrigin) + painter->setBrushOrigin(oldBrushOrigin); +#endif // QT_NO_SCROLLAREA } /* @@ -4998,19 +5016,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) { QPainter p(q); - QPoint scrollAreaOffset; - -#ifndef QT_NO_SCROLLAREA - QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); - if (scrollArea && scrollArea->viewport() == q) { - QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr; - QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); - scrollAreaOffset = priv->contentsOffset(); - p.translate(-scrollAreaOffset); - } -#endif // QT_NO_SCROLLAREA - - paintBackground(&p, toBePainted, scrollAreaOffset, (asRoot || onScreen) ? flags | DrawAsRoot : 0); + paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); } if (!sharedPainter) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5577224..1717fbd 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1198,22 +1198,13 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event, p.setClipping(false); if(was_unclipped) widget->setAttribute(Qt::WA_PaintUnclipped); - - QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(widget->parent()); - QPoint scrollAreaOffset; - if (scrollArea && scrollArea->viewport() == widget) { - QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr); - scrollAreaOffset = priv->contentsOffset(); - p.translate(-scrollAreaOffset); - } - - widget->d_func()->paintBackground(&p, qrgn, scrollAreaOffset, widget->isWindow() ? DrawAsRoot : 0); + widget->d_func()->paintBackground(&p, qrgn, widget->isWindow() ? DrawAsRoot : 0); if (widget->testAttribute(Qt::WA_TintedBackground)) { QColor tint = widget->palette().window().color(); tint.setAlphaF(.6); const QVector<QRect> &rects = qrgn.rects(); for (int i = 0; i < rects.size(); ++i) - p.fillRect(rects.at(i).translated(scrollAreaOffset), tint); + p.fillRect(rects.at(i), tint); } p.end(); if (!redirectionOffset.isNull()) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 626950e..998181e 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -295,7 +295,7 @@ public: void setUpdatesEnabled_helper(bool ); - void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const; + void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const; bool isAboutToShow() const; QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags); void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index a3ae102..602b991 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1008,8 +1008,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, ; #ifndef QT_NO_IMAGE_HEURISTIC_MASK } else { // color pixmap, no mask - QString k; - k.sprintf("$qt-drawitem-%llx", pm.cacheKey()); + QString k = QString::fromLatin1("$qt-drawitem-%1").arg(pm.cacheKey()); if (!QPixmapCache::find(k, pm)) { pm = pm.createHeuristicMask(); pm.setMask((QBitmap&)pm); diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h index 8f6797c..ce07c1f 100644 --- a/src/gui/painting/qdrawutil.h +++ b/src/gui/painting/qdrawutil.h @@ -133,7 +133,7 @@ Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GU const QPalette &pal, bool enabled); #endif -struct Q_GUI_EXPORT QMargins +struct QMargins { inline QMargins(int margin = 0) : top(margin), @@ -151,7 +151,7 @@ struct Q_GUI_EXPORT QMargins int right; }; -struct Q_GUI_EXPORT QTileRules +struct QTileRules { inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule = Qt::Stretch) : horizontal(horizontalRule), vertical(verticalRule) {} @@ -168,8 +168,7 @@ Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules = QTileRules()); - -Q_GUI_EXPORT inline void qDrawBorderPixmap(QPainter *painter, +inline void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4c35004..e9ff752 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -110,10 +110,6 @@ extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // #define qt_swap_int(x, y) { int tmp = (x); (x) = (y); (y) = tmp; } #define qt_swap_qreal(x, y) { qreal tmp = (x); (x) = (y); (y) = tmp; } -#ifdef Q_WS_WIN -static bool qt_enable_16bit_colors = false; -#endif - // #define QT_DEBUG_DRAW #ifdef QT_DEBUG_DRAW void dumpClip(int width, int height, QClipData *clip); @@ -4661,104 +4657,6 @@ static int qt_intersect_spans(QT_FT_Span *spans, int numSpans, return n; } -/* - \internal - Clip spans to \a{clip}-region. - Returns number of unclipped spans -*/ -static int qt_intersect_spans(QT_FT_Span *spans, int numSpans, - int *currSpan, - QT_FT_Span *outSpans, int maxOut, - const QRegion &clip) -{ - const QVector<QRect> rects = clip.rects(); - const int numRects = rects.size(); - - int r = 0; - short miny, minx, maxx, maxy; - { - const QRect &rect = rects[0]; - miny = rect.top(); - minx = rect.left(); - maxx = rect.right(); - maxy = rect.bottom(); - } - - // TODO: better mapping of currY and startRect - - int n = 0; - int i = *currSpan; - int currY = spans[i].y; - while (i < numSpans) { - - if (spans[i].y != currY && r != 0) { - currY = spans[i].y; - r = 0; - const QRect &rect = rects[r]; - miny = rect.top(); - minx = rect.left(); - maxx = rect.right(); - maxy = rect.bottom(); - } - - if (spans[i].y < miny) { - ++i; - continue; - } - - if (spans[i].y > maxy || spans[i].x > maxx) { - if (++r >= numRects) { - ++i; - continue; - } - - const QRect &rect = rects[r]; - miny = rect.top(); - minx = rect.left(); - maxx = rect.right(); - maxy = rect.bottom(); - continue; - } - - if (spans[i].x + spans[i].len <= minx) { - ++i; - continue; - } - - outSpans[n].y = spans[i].y; - outSpans[n].coverage = spans[i].coverage; - - if (spans[i].x < minx) { - const ushort cutaway = minx - spans[i].x; - outSpans[n].len = qMin(spans[i].len - cutaway, maxx - minx + 1); - outSpans[n].x = minx; - if (outSpans[n].len == spans[i].len - cutaway) { - ++i; - } else { - // span wider than current rect - spans[i].len -= outSpans[n].len + cutaway; - spans[i].x = maxx + 1; - } - } else { // span starts inside current rect - outSpans[n].x = spans[i].x; - outSpans[n].len = qMin(spans[i].len, - ushort(maxx - spans[i].x + 1)); - if (outSpans[n].len == spans[i].len) { - ++i; - } else { - // span wider than current rect - spans[i].len -= outSpans[n].len; - spans[i].x = maxx + 1; - } - } - - if (++n >= maxOut) - break; - } - - *currSpan = i; - return n; -} static void qt_span_fill_clipRect(int count, const QSpan *spans, void *userData) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 67586ac..9d5a3bc 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -70,6 +70,7 @@ #include <qpixmapcache.h> #undef signals // Collides with GTK stymbols #include "qgtkpainter_p.h" +#include "qstylehelper_p.h" #include <private/qcleanlooksstyle_p.h> @@ -208,17 +209,6 @@ static GdkColor fromQColor(const QColor &color) return retval; } -// Note this is different from uniqueName as used in QGtkPainter -static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) -{ - QString tmp; - const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state), - option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height()); - return tmp; -} - /*! \class QGtkStyle \brief The QGtkStyle class provides a widget style rendered by GTK+ diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index c08009b..5d75392 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -1871,24 +1871,23 @@ QPixmap QMacStylePrivate::generateBackgroundPattern() const Fills the given \a rect with the pattern stored in \a brush. As an optimization, HIThemeSetFill us used directly if we are filling with the standard background. */ -void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush) +void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) { QPoint dummy; const QPaintDevice *target = painter->device(); const QPaintDevice *redirected = QPainter::redirected(target, &dummy); const bool usePainter = redirected && redirected != target; - const QRegion translated = rgn.translated(offset); if (!usePainter && qt_mac_backgroundPattern && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) { - painter->setClipRegion(translated); + painter->setClipRegion(rgn); CGContextRef cg = qt_mac_cg_context(target); CGContextSaveGState(cg); HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted); - const QVector<QRect> &rects = translated.rects(); + const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) { const QRect rect(rects.at(i)); // Anchor the pattern to the top so it stays put when the window is resized. @@ -1899,8 +1898,8 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint CGContextRestoreGState(cg); } else { - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); + const QRect rect(rgn.boundingRect()); + painter->setClipRegion(rgn); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); } } diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 12aa679..cd0bd0a 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -730,16 +730,6 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto return tmp; } -static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) -{ - QString tmp; - const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state), - option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height()); - return tmp; -} - static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop) { @@ -1512,7 +1502,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption rect.adjust(2, 0, -2, 0); } #endif - QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(rect.size()); cache.fill(Qt::transparent); @@ -2777,7 +2767,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // contents painter->setPen(QPen()); - QString progressBarName = uniqueName(QLatin1String("progressBarContents"), + QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"), option, rect.size()); QPixmap cache; if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { @@ -2837,7 +2827,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); pixmapName += QString::number(- int(header->position)); pixmapName += QString::number(- int(header->orientation)); @@ -3084,7 +3074,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // Draws a menu bar item; File, Edit, Help etc.. if ((option->state & State_Selected)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); @@ -3447,7 +3437,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op bool reverse = scrollBar->direction == Qt::RightToLeft; bool sunken = scrollBar->state & State_Sunken; - QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); + QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); QPixmap cache; if (!QPixmapCache::find(addLinePixmapName, cache)) { cache = QPixmap(option->rect.size()); @@ -3519,7 +3509,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op bool sunken = scrollBar->state & State_Sunken; bool horizontal = scrollBar->orientation == Qt::Horizontal; - QString groovePixmapName = uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); + QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); if (sunken) groovePixmapName += QLatin1String("-sunken"); if (element == CE_ScrollBarAddPage) @@ -3578,7 +3568,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op button2.setRect(scrollBarSubLine.left(), scrollBarSubLine.bottom() - (scrollBarExtent - 1), scrollBarSubLine.width(), scrollBarExtent); } - QString subLinePixmapName = uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); + QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); QPixmap cache; if (!QPixmapCache::find(subLinePixmapName, cache)) { cache = QPixmap(button1.size()); @@ -3653,7 +3643,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // The slider if (option->rect.isValid()) { - QString sliderPixmapName = uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); + QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); if (horizontal) sliderPixmapName += QLatin1String("-horizontal"); @@ -3873,7 +3863,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } if ((option->subControls & SC_SliderHandle) && handle.isValid()) { - QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size()); + QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); if (ticksAbove && !ticksBelow) handlePixmapName += QLatin1String("-flipped"); if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h index 854874f..2d6ef22 100644 --- a/src/gui/styles/qstyle_p.h +++ b/src/gui/styles/qstyle_p.h @@ -43,6 +43,7 @@ #define QSTYLE_P_H #include "private/qobject_p.h" +#include "private/qstylehelper_p.h" #include <QtGui/qstyle.h> QT_BEGIN_NAMESPACE @@ -78,7 +79,7 @@ public: QPixmap internalPixmapCache; \ QImage imageCache; \ QPainter *p = painter; \ - QString unique = uniqueName((a), option, option->rect.size()); \ + QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ bool doPixmapCache = txType <= QTransform::TxTranslate; \ if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \ diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index f9010e8..4877ec4 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -60,11 +60,10 @@ namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { - QString tmp; const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%lld-%dx%d-%d", key.toLatin1().constData(), uint(option->state), - complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height(), option->direction); + QString tmp = QString::fromLatin1("%1-%2-%3-%4-%5-%6x%7").arg(key).arg(uint(option->state)).arg(option->direction) + .arg(complexOption ? uint(complexOption->activeSubControls) : uint(0)) + .arg(option->palette.cacheKey()).arg(size.width()).arg(size.height()); #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { tmp.append(QLatin1Char('-')); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 01d8aad..2efa4a7 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4171,7 +4171,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op if (!rule.hasDrawable()) { QWidget *container = containerWidget(w); if (autoFillDisabledWidgets->contains(container) - && (container == w || !renderRule(container, opt).hasDrawable())) { + && (container == w || !renderRule(container, opt).hasBackground())) { //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now. // (this may happen if we have rules like :focus) p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole())); diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 4f25e68..4c66bbb 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -1061,6 +1061,8 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl } } break; + default: + break; } if (!desktopIcon.isNull()) { return desktopIcon; @@ -1375,11 +1377,8 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QRect r = opt->rect; int size = qMin(r.height(), r.width()); QPixmap pixmap; - QString pixmapName; - pixmapName.sprintf("%s-%s-%d-%d-%d-%lld", - "$qt_ia", metaObject()->className(), - uint(opt->state), pe, - size, opt->palette.cacheKey()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size)) + + QLatin1Char('-') + QString::number(pe); if (!QPixmapCache::find(pixmapName, pixmap)) { int border = size/5; int sqsize = 2*(size/2); diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 3e65eef..f3d0f04 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -735,7 +735,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt if (const QListView *listview = qobject_cast<const QListView *>(widget)) { if (listview->viewMode() == QListView::IconMode) newStyle = true; - } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) { + } else if (qobject_cast<const QTreeView *>(widget)) { newStyle = true; } if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { @@ -1093,7 +1093,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL); theme.rect = option->rect; - bool reverse = bar->direction == Qt::LeftToRight && inverted || bar->direction == Qt::RightToLeft && !inverted; + bool reverse = bar->direction == (Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); QTime current = QTime::currentTime(); if (isIndeterminate) { @@ -1271,7 +1271,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption int yoff = y-2 + h / 2; QPoint p1 = QPoint(x + checkcol, yoff); QPoint p2 = QPoint(x + w + 6 , yoff); - int stateId = stateId = MBI_HOT; + stateId = MBI_HOT; QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6); subRect = QStyle::visualRect(option->direction, option->rect, subRect ); XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPSEPARATOR, stateId, subRect); @@ -1283,7 +1283,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption menuitem->rect.y(), checkcol - 6, menuitem->rect.height())); if (act) { - int stateId = stateId = MBI_HOT; + stateId = MBI_HOT; XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect); d->drawBackground(theme2); } @@ -1403,7 +1403,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption break; case CE_MenuBarEmptyArea: { - int stateId = MBI_NORMAL; + stateId = MBI_NORMAL; if (!(state & State_Enabled)) stateId = MBI_DISABLED; XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, stateId, option->rect); @@ -1500,7 +1500,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QListView *listview = qobject_cast<const QListView *>(widget)) { if (listview->viewMode() == QListView::IconMode) newStyle = true; - } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) { + } else if (qobject_cast<const QTreeView *>(widget)) { newStyle = true; } if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { @@ -2014,7 +2014,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption MARGINS borderSize; HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button"); if (theme) { - int stateId; + int stateId = PBS_NORMAL; if (!(option->state & State_Enabled)) stateId = PBS_DISABLED; else if (option->state & State_Sunken) @@ -2023,8 +2023,6 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption stateId = PBS_HOT; else if (btn->features & QStyleOptionButton::DefaultButton) stateId = PBS_DEFAULTED; - else - stateId = PBS_NORMAL; int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); rect = option->rect.adjusted(border, border, -border, -border); @@ -2097,7 +2095,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget); break; case SE_ItemViewItemDecoration: - if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) + if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) rect.adjust(-2, 0, 2, 0); break; case SE_ItemViewItemFocusRect: @@ -2303,6 +2301,8 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt rect = visualRect(option->direction, option->rect, rect); } break; + default: + break; } } break; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 9c4afee..4d1fb7a 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -1918,8 +1918,8 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op { name = QLatin1String("BUTTON"); partId = BP_PUSHBUTTON; - bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken)) - || (btn->features & QStyleOptionButton::CommandLinkButton + bool justFlat = ((btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken))) + || ((btn->features & QStyleOptionButton::CommandLinkButton) && !(flags & State_MouseOver) && !(btn->features & QStyleOptionButton::DefaultButton)); if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat)) @@ -3244,7 +3244,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_IndicatorWidth ? size.cx : res = size.cy); + res = (pm == PM_IndicatorWidth) ? size.cx : size.cy; } } break; @@ -3256,7 +3256,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_ExclusiveIndicatorWidth ? size.cx : res = size.cy); + res = (pm == PM_ExclusiveIndicatorWidth) ? size.cx : size.cy; } } break; @@ -3536,6 +3536,8 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height()); } break; + default: + break; } } break; @@ -3562,6 +3564,9 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl case SC_ComboBoxListBoxPopup: rect = cmb->rect; break; + + default: + break; } } break; @@ -3802,6 +3807,8 @@ QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QSt } } break; + default: + break; } return QWindowsStyle::standardPixmap(standardPixmap, option, widget); } @@ -3923,6 +3930,8 @@ QIcon QWindowsXPStyle::standardIconImplementation(StandardPixmap standardIcon, } break; + default: + break; } return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index f4adc9a..c6717e3 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -125,8 +125,6 @@ HDC shared_dc() } #endif -static HFONT stock_sysfont = 0; - typedef BOOL (WINAPI *PtrGetCharWidthI)(HDC, UINT, UINT, LPWORD, LPINT); static PtrGetCharWidthI ptrGetCharWidthI = 0; static bool resolvedGetCharWidthI = false; @@ -542,13 +540,6 @@ glyph_metrics_t QFontEngineWin::boundingBox(const QGlyphLayout &glyphs) } - - -#ifndef Q_WS_WINCE -typedef HRESULT (WINAPI *pGetCharABCWidthsFloat)(HDC, UINT, UINT, LPABCFLOAT); -static pGetCharABCWidthsFloat qt_GetCharABCWidthsFloat = 0; -#endif - glyph_metrics_t QFontEngineWin::boundingBox(glyph_t glyph, const QTransform &t) { #ifndef Q_WS_WINCE @@ -1143,8 +1134,7 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin memset(&mat, 0, sizeof(mat)); mat.eM11.value = mat.eM22.value = 1; - int error = GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat); - if (error == GDI_ERROR) { + if (GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat) == GDI_ERROR) { qWarning("QWinFontEngine: unable to query transformed glyph metrics..."); return 0; } diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index 5fbc36d..ccb4e6b 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -56,13 +56,23 @@ #if defined(Q_OS_WIN) #undef S_IFREG #define S_IFREG 0100000 -# define S_ISDIR(x) ((x) & 0040000) > 0 -# define S_ISREG(x) ((x) & 0170000) == S_IFREG +# ifndef S_ISDIR +# define S_ISDIR(x) ((x) & 0040000) > 0 +# endif +# ifndef S_ISREG +# define S_ISREG(x) ((x) & 0170000) == S_IFREG +# endif # define S_IFLNK 020000 # define S_ISLNK(x) ((x) & S_IFLNK) > 0 -# define S_IRUSR 0400 -# define S_IWUSR 0200 -# define S_IXUSR 0100 +# ifndef S_IRUSR +# define S_IRUSR 0400 +# endif +# ifndef S_IWUSR +# define S_IWUSR 0200 +# endif +# ifndef S_IXUSR +# define S_IXUSR 0100 +# endif # define S_IRGRP 0040 # define S_IWGRP 0020 # define S_IXGRP 0010 diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index dea9264..85eae26 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -314,7 +314,6 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) emit q->activated(QSystemTrayIcon::Trigger); break; -#if !defined(Q_WS_WINCE) case WM_LBUTTONDBLCLK: emit q->activated(QSystemTrayIcon::DoubleClick); break; @@ -322,20 +321,30 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) case WM_RBUTTONUP: if (q->contextMenu()) { q->contextMenu()->popup(gpos); +#if defined(Q_WS_WINCE) + // We must ensure that the popup menu doesn't show up behind the task bar. + QRect desktopRect = qApp->desktop()->availableGeometry(); + int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height(); + if (gpos.y() > maxY) { + gpos.ry() = maxY; + q->contextMenu()->move(gpos); + } +#endif q->contextMenu()->activateWindow(); //Must be activated for proper keyboardfocus and menu closing on windows: } emit q->activated(QSystemTrayIcon::Context); break; +#if !defined(Q_WS_WINCE) case NIN_BALLOONUSERCLICK: emit q->messageClicked(); break; +#endif case WM_MBUTTONUP: emit q->activated(QSystemTrayIcon::MiddleClick); break; -#endif default: break; } |