From 445e8af844ef6f120a5e406271dbeabad34ed47a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 9 Nov 2009 13:46:37 +0100 Subject: Fix warnings Reviewed-by: Trust Me --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 2 +- src/gui/kernel/qgesturemanager.cpp | 1 + src/gui/painting/qbrush.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 182594e55b..594a205149 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -903,7 +903,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP QStack > stack; stack.push(qMakePair(static_cast(0), layoutFirstVertex[orientation])); QVector candidates; - bool candidatesForward; + bool candidatesForward = true; // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence) // and the vertex to be visited. diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index abd2128318..dfa5e524d0 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -599,6 +599,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, Qt::GestureType gestureType = gesture->gestureType(); Q_ASSERT(gestureType != Qt::CustomGesture); + Q_UNUSED(gestureType); if (target) { if (gesture->state() == Qt::GestureStarted) { diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 6f5d89208c..7273c35cee 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -970,7 +970,7 @@ bool QBrush::operator==(const QBrush &b) const QDebug operator<<(QDebug dbg, const QBrush &b) { #ifndef Q_BROKEN_DEBUG_STREAM - char *BRUSH_STYLES[] = { + static const char *BRUSH_STYLES[] = { "NoBrush", "SolidPattern", "Dense1Pattern", -- cgit v1.2.1 From 0d2f1562d63cf51d254a5761bf37ce36120cfcfd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Nov 2009 15:26:45 +0100 Subject: QPlastiqueStyle: Fix painting QTreeView with gradient When setting a gradian brush as a base for a QTreeWidget (with stylesheet), the branch decoration would be plain black. This is because the color() of a gradient brush is always black. Fix it by using the base brush itself to paint the decoration if the brush is not solid color. Task-number: QTBUG-3816 Reviewed-by: Thierry --- src/gui/styles/qplastiquestyle.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index f88035153c..be4fff25be 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -1094,8 +1094,6 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption QColor borderColor = option->palette.background().color().darker(178); QColor gradientStartColor = option->palette.button().color().lighter(104); QColor gradientStopColor = option->palette.button().color().darker(105); - QColor baseGradientStartColor = option->palette.base().color().darker(101); - QColor baseGradientStopColor = option->palette.base().color().darker(106); QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); QColor highlightedBaseGradientStartColor = option->palette.base().color(); @@ -1978,7 +1976,13 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption QRect gradientRect(adjustedRect.left() + 1, adjustedRect.top() + 1, adjustedRect.right() - adjustedRect.left() - 1, adjustedRect.bottom() - adjustedRect.top() - 1); - qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); + if (option->palette.base().style() == Qt::SolidPattern) { + QColor baseGradientStartColor = option->palette.base().color().darker(101); + QColor baseGradientStopColor = option->palette.base().color().darker(106); + qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); + } else { + painter->fillRect(gradientRect, option->palette.base()); + } // draw "+" or "-" painter->setPen(alphaTextColor); painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); -- cgit v1.2.1 From 0b7a5ebb7c4a65a931d2c69b9d3780cdc6ece893 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 9 Nov 2009 16:41:18 +0100 Subject: Now looking for the closer dock area for toolbutton Previously, we were looking for the 1st one that fit or was not too far (ie 80px) away. Now we really take the closest one. Task-number: QTBUG-2598 Reviewed-by: ogoffart --- src/gui/widgets/qtoolbararealayout.cpp | 50 ++++++++++++++++------------------ src/gui/widgets/qtoolbararealayout_p.h | 6 ++-- 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index de11625dd5..39d5c66074 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -480,7 +480,7 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) } -QList QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const +QList QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) const { int p = pick(o, pos); @@ -509,12 +509,19 @@ QList QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const QList result; result << j << k; + *minDistance = 0; //we found a perfect match + return result; + } + } else { + const int dist = distance(pos); + //it will only return a path if the minDistance is higher than the current distance + if (*minDistance > dist) { + *minDistance = dist; + + QList result; + result << lines.count() << 0; return result; } - } else if (appendLineDropRect().contains(pos)) { - QList result; - result << lines.count() << 0; - return result; } return QList(); @@ -587,32 +594,20 @@ QRect QToolBarAreaLayoutInfo::itemRect(const QList &path) const return result; } -QRect QToolBarAreaLayoutInfo::appendLineDropRect() const +int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const { - QRect result; - switch (dockPos) { case QInternal::LeftDock: - result = QRect(rect.right(), rect.top(), - EmptyDockAreaSize, rect.height()); - break; + return pos.x() - rect.right(); case QInternal::RightDock: - result = QRect(rect.left() - EmptyDockAreaSize, rect.top(), - EmptyDockAreaSize, rect.height()); - break; + return rect.left() - pos.x(); case QInternal::TopDock: - result = QRect(rect.left(), rect.bottom() + 1, - rect.width(), EmptyDockAreaSize); - break; + return pos.y() - rect.bottom(); case QInternal::BottomDock: - result = QRect(rect.left(), rect.top() - EmptyDockAreaSize, - rect.width(), EmptyDockAreaSize); - break; + return rect.top() - pos.y(); default: - break; + return -1; } - - return result; } /****************************************************************************** @@ -1022,21 +1017,24 @@ QList QToolBarAreaLayout::indexOf(QWidget *toolBar) const return result; } +//this functions returns the path to the possible gapindex for the position pos QList QToolBarAreaLayout::gapIndex(const QPoint &pos) const { Qt::LayoutDirection dir = mainWindow->layoutDirection(); + int minDistance = 80; // when a dock area is empty, how "wide" is it? + QList ret; //return value for (int i = 0; i < QInternal::DockCount; ++i) { QPoint p = pos; if (docks[i].o == Qt::Horizontal) p = QStyle::visualPos(dir, docks[i].rect, p); - QList result = docks[i].gapIndex(p); + QList result = docks[i].gapIndex(p, &minDistance); if (!result.isEmpty()) { result.prepend(i); - return result; + ret = result; } } - return QList(); + return ret; } QList QToolBarAreaLayout::currentGapIndex() const diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h index 1e113b7c74..f0ab80c350 100644 --- a/src/gui/widgets/qtoolbararealayout_p.h +++ b/src/gui/widgets/qtoolbararealayout_p.h @@ -155,8 +155,6 @@ public: class QToolBarAreaLayoutInfo { public: - enum { EmptyDockAreaSize = 80 }; // when a dock area is empty, how "wide" is it? - QToolBarAreaLayoutInfo(QInternal::DockPosition pos = QInternal::TopDock); QList lines; @@ -173,11 +171,11 @@ public: void removeToolBarBreak(QToolBar *before); void moveToolBar(QToolBar *toolbar, int pos); - QList gapIndex(const QPoint &pos) const; + QList gapIndex(const QPoint &pos, int *maxDistance) const; bool insertGap(const QList &path, QLayoutItem *item); void clear(); QRect itemRect(const QList &path) const; - QRect appendLineDropRect() const; + int distance(const QPoint &pos) const; QRect rect; Qt::Orientation o; -- cgit v1.2.1 From 963d42fbf1fb68c2bd09b12dedbad000d8001b94 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 9 Nov 2009 17:25:49 +0100 Subject: Make sure the dock widget is updated when changing closable property Task-number: QTBUG-1665 Reviewed-by: ogoffart --- src/gui/widgets/qdockwidget.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index a8e2a37978..9cf6af1245 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1225,6 +1225,7 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) features &= DockWidgetFeatureMask; if (d->features == features) return; + const bool closableChanged = (d->features ^ features) & DockWidgetClosable; d->features = features; QDockWidgetLayout *layout = qobject_cast(this->layout()); @@ -1233,6 +1234,10 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable); emit featuresChanged(d->features); update(); + if (closableChanged && layout->nativeWindowDeco()) { + //this ensures the native decoration is drawn + d->setWindowState(true /*floating*/, true /*unplug*/); + } } QDockWidget::DockWidgetFeatures QDockWidget::features() const -- cgit v1.2.1 From ecdecf7a628aa1c9eb953984c89fc65ffa767a24 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Mon, 9 Nov 2009 17:44:54 +0100 Subject: Fix docs for animation api All animation api code snippets should use references instead of local variables. Task-number: QTBUG-5616 Reviewed-by: thierry --- src/corelib/animation/qpropertyanimation.cpp | 10 +++++----- src/corelib/animation/qsequentialanimationgroup.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 30650831bc..013ff7fe54 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -58,12 +58,12 @@ an example: \code - QPropertyAnimation animation(myWidget, "geometry"); - animation.setDuration(10000); - animation.setStartValue(QRect(0, 0, 100, 30)); - animation.setEndValue(QRect(250, 250, 100, 30)); + QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry"); + animation->setDuration(10000); + animation->setStartValue(QRect(0, 0, 100, 30)); + animation->setEndValue(QRect(250, 250, 100, 30)); - animation.start(); + animation->start(); \endcode The property name and the QObject instance of which property diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 861e26e78f..5dbb8c3d10 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -63,12 +63,12 @@ pause to a sequential animation group. \code - QSequentialAnimationGroup group; + QSequentialAnimationGroup *group = new QSequentialAnimationGroup; - group.addAnimation(anim1); - group.addAnimation(anim2); + group->addAnimation(anim1); + group->addAnimation(anim2); - group.start(); + group->start(); \endcode In this example, \c anim1 and \c anim2 are two already set up -- cgit v1.2.1 From 327ef9127aba3aa6bf2238c0aa779613f8edf0b1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Nov 2009 18:20:51 +0100 Subject: QGraphicsTextItem: update when changing the color. Task-number: QTBUG-5418 Reviewed-by: Gabriel --- src/gui/graphicsview/qgraphicsitem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 723e49646c..87ed5b7933 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9606,6 +9606,7 @@ void QGraphicsTextItem::setDefaultTextColor(const QColor &col) QPalette pal = c->palette(); pal.setColor(QPalette::Text, col); c->setPalette(pal); + update(); } /*! -- cgit v1.2.1 From d845505fd57ad4b06499b5b125703e80bbae692a Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 10 Nov 2009 10:48:11 +0100 Subject: Avoid XSync-related runtime crashes on HP-UX due to C++ mangling. HP-UX is missing the extern "C" wrapper for its XSync function declarations. This caused applications to _build_ but not _run_ (i.e., all GUI apps crashed). Adding the wrapper should be harmless on all X11 platforms. Task-number: QTBUG-5524 Reviewed-by: Thiago --- src/gui/kernel/qt_x11_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 9f08dc63ae..9e4cf60b40 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -163,7 +163,9 @@ extern "C" { #endif // QT_NO_XRENDER #ifndef QT_NO_XSYNC +extern "C" { # include "X11/extensions/sync.h" +} #endif // #define QT_NO_XKB -- cgit v1.2.1 From 7429ff911e05c05fbdd986a5932545571ee4beef Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 13:17:29 +0100 Subject: Make the toolbar extension animated according to the main window Previously it would be always animated. Task-number: QTBUG-5623 Reviewed-by: Gabriel --- src/gui/widgets/qtoolbar.cpp | 2 +- src/gui/widgets/qtoolbarlayout.cpp | 5 ++--- src/gui/widgets/qtoolbarlayout_p.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 5596ca4fe9..58a3d280c1 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -396,7 +396,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) void QToolBarPrivate::unplug(const QRect &_r) { Q_Q(QToolBar); - layout->setExpanded(false, false); + layout->setExpanded(false); QRect r = _r; r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); setWindowState(true, true, r); diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index 7dc1e01949..0afe5d8e56 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -642,7 +642,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const return result; } -void QToolBarLayout::setExpanded(bool exp, bool animated) +void QToolBarLayout::setExpanded(bool exp) { if (exp == expanded) return; @@ -654,7 +654,6 @@ void QToolBarLayout::setExpanded(bool exp, bool animated) if (!tb) return; if (QMainWindow *win = qobject_cast(tb->parentWidget())) { - animating = true; QMainWindowLayout *layout = qobject_cast(win->layout()); if (expanded) { tb->raise(); @@ -665,7 +664,7 @@ void QToolBarLayout::setExpanded(bool exp, bool animated) layoutActions(rect.size()); } } - layout->layoutState.toolBarAreaLayout.apply(animated); + layout->layoutState.toolBarAreaLayout.apply(win->isAnimated()); } } diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h index d49a5dfffc..afd0227194 100644 --- a/src/gui/widgets/qtoolbarlayout_p.h +++ b/src/gui/widgets/qtoolbarlayout_p.h @@ -112,7 +112,7 @@ public: bool hasExpandFlag() const; public Q_SLOTS: - void setExpanded(bool b, bool animated = true); + void setExpanded(bool b); private: QList items; -- cgit v1.2.1 From 2a0c11e13ff1cba30f3be324dadd14f8d0a1baa6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 10 Nov 2009 12:56:23 +0100 Subject: PlatformPlugin: Do not load the plugin if there is no GUI Otherwise valgrind might complain we use uninitialized value (when using the X11 structure) Reviewed-by: Gabriel --- src/gui/kernel/qapplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 987aa26bcb..4b8f6a06ed 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -791,7 +791,8 @@ void QApplicationPrivate::construct( } //make sure the plugin is loaded - qt_guiPlatformPlugin(); + if (qt_is_gui_used) + qt_guiPlatformPlugin(); #endif } -- cgit v1.2.1 From b7ae1d97301dcb42997e09f996b103f3701b2139 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 13:44:28 +0100 Subject: Make sure that the toolbar is in the mainwinow rect for docking Task-number: QTBUG-2598 Reviewed-by: ogoffart --- src/gui/widgets/qtoolbararealayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 39d5c66074..b7e985cf3d 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -515,7 +515,7 @@ QList QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) } else { const int dist = distance(pos); //it will only return a path if the minDistance is higher than the current distance - if (*minDistance > dist) { + if (dist >= 0 && *minDistance > dist) { *minDistance = dist; QList result; -- cgit v1.2.1 From b6be1c595fa67ec034f04c8a93e57e593ceb97aa Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 14:43:19 +0100 Subject: Make sure the context menus also clear the status tip when needed Task-number: QTBUG-2700 Reviewed-by: ogoffart --- src/gui/kernel/qaction.cpp | 26 ++++++++++++++++---------- src/gui/kernel/qaction_p.h | 2 ++ src/gui/widgets/qmenu.cpp | 44 ++++++++++++++++++-------------------------- src/gui/widgets/qmenu_p.h | 1 + 4 files changed, 37 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 6f3cbafaf2..3eaf2e1ce1 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -100,6 +100,21 @@ QActionPrivate::~QActionPrivate() { } +bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) +{ +#ifdef QT_NO_STATUSTIP + Q_UNUSED(widget); + Q_UNUSED(str); +#else + if(QObject *object = widget ? widget : parent) { + QStatusTipEvent tip(str); + QApplication::sendEvent(object, &tip); + return true; + } +#endif + return false; +} + void QActionPrivate::sendDataChanged() { Q_Q(QAction); @@ -1206,16 +1221,7 @@ QAction::setData(const QVariant &data) bool QAction::showStatusText(QWidget *widget) { -#ifdef QT_NO_STATUSTIP - Q_UNUSED(widget); -#else - if(QObject *object = widget ? widget : parent()) { - QStatusTipEvent tip(statusTip()); - QApplication::sendEvent(object, &tip); - return true; - } -#endif - return false; + return d_func()->showStatusText(widget, statusTip()); } /*! diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h index 2527a02a13..f7b035b1f8 100644 --- a/src/gui/kernel/qaction_p.h +++ b/src/gui/kernel/qaction_p.h @@ -75,6 +75,8 @@ public: QActionPrivate(); ~QActionPrivate(); + bool showStatusText(QWidget *w, const QString &str); + QPointer group; QString text; QString iconText; diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index cc39b7f891..54d1612f15 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -602,14 +602,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } #ifndef QT_NO_STATUSTIP } else if (previousAction) { - QWidget *w = causedPopup.widget; - while (QMenu *m = qobject_cast(w)) - w = m->d_func()->causedPopup.widget; - if (w) { - QString empty; - QStatusTipEvent tip(empty); - QApplication::sendEvent(w, &tip); - } + previousAction->d_func()->showStatusText(topCausedWidget(), QString()); #endif } if (hideActiveMenu) { @@ -623,6 +616,15 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } } +//return the top causedPopup.widget that is not a QMenu +QWidget *QMenuPrivate::topCausedWidget() const +{ + QWidget* top = causedPopup.widget; + while (QMenu* m = qobject_cast(top)) + top = m->d_func()->causedPopup.widget; + return top; +} + QAction *QMenuPrivate::actionAt(QPoint p) const { if (!q_func()->rect().contains(p)) //sanity check @@ -1094,10 +1096,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e QAccessible::updateAccessibility(q, actionIndex, QAccessible::Selection); } #endif - QWidget *w = causedPopup.widget; - while (QMenu *m = qobject_cast(w)) - w = m->d_func()->causedPopup.widget; - action->showStatusText(w); + action->showStatusText(topCausedWidget()); } else { actionAboutToTrigger = 0; } @@ -1801,10 +1800,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #ifndef QT_NO_MENUBAR // if this menu is part of a chain attached to a QMenuBar, set the // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type - QWidget* top = this; - while (QMenu* m = qobject_cast(top)) - top = m->d_func()->causedPopup.widget; - setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast(top) != 0); + setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast(d->topCausedWidget()) != 0); #endif ensurePolished(); // Get the right font @@ -2752,18 +2748,14 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } if (!key_consumed) { - if (QWidget *caused = d->causedPopup.widget) { - while(QMenu *m = qobject_cast(caused)) - caused = m->d_func()->causedPopup.widget; #ifndef QT_NO_MENUBAR - if (QMenuBar *mb = qobject_cast(caused)) { - QAction *oldAct = mb->d_func()->currentAction; - QApplication::sendEvent(mb, e); - if (mb->d_func()->currentAction != oldAct) - key_consumed = true; - } -#endif + if (QMenuBar *mb = qobject_cast(d->topCausedWidget())) { + QAction *oldAct = mb->d_func()->currentAction; + QApplication::sendEvent(mb, e); + if (mb->d_func()->currentAction != oldAct) + key_consumed = true; } +#endif } #ifdef Q_OS_WIN32 diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index a5bde7c39c..c021063309 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -215,6 +215,7 @@ public: SelectedFromKeyboard, SelectedFromElsewhere }; + QWidget *topCausedWidget() const; QAction *actionAt(QPoint p) const; void setFirstActionActive(); void setCurrentAction(QAction *, int popup = -1, SelectionReason reason = SelectedFromElsewhere, bool activateFirst = false); -- cgit v1.2.1 From 642b0f063df1339bcef6e8f23d84536230131573 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 16:21:36 +0100 Subject: Menubars in dual screen mode now popup the menus on the correct screen If an item is split then its menu appears on the screen which contains most of it. Task-number: QTBUG-773 Reviewed-by: ogoffart --- src/gui/widgets/qmenubar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 689d2e1e90..b1ff662cb0 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -332,7 +332,9 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1))); QSize popup_size = activeMenu->sizeHint(); - QRect screenRect = QApplication::desktop()->screenGeometry(pos); + //we put the popup menu on the screen containing the bottom-center of the action rect + QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); + pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom()); -- cgit v1.2.1 From 6e6803540d50f14a2c4a6e1ee551310fa96d0cb6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 10 Nov 2009 17:17:44 +0100 Subject: Fixed: Stylesheet and background image issue in ScrollArea When using background-image and background-attachement: scroll and background-repeat: no-repeat The rectangle used to draw the image was not correctly computed. Reviewed-by: Thierry Task-number: QTBUG-3783 --- src/gui/styles/qstylesheetstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index ce73fd8db3..59210c3a95 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1180,7 +1180,7 @@ void QRenderRule::drawBackgroundImage(QPainter *p, const QRect &rect, QPoint off QRect r = originRect(rect, background()->origin); QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r); - QRect inter = aligned.intersected(r); + QRect inter = aligned.translated(-off).intersected(r); switch (background()->repeat) { case Repeat_Y: -- cgit v1.2.1 From 2321e8636d7436b70a8afcde16828f00c4b8590e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 17:55:14 +0100 Subject: Make it possible for QMainWindow to restore the geom of undocked widget Task-number: QTBUG-5663 Reviewed-by: ogoffart --- src/gui/widgets/qdockarealayout.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index dffec11c9c..27e145fbfc 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1933,6 +1933,9 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList item_list.append(item); } else { QDockAreaLayoutItem item(new QDockWidgetItem(widget)); + if (!testing) { + item_list.append(item); + } if (flags & StateFlagFloating) { bool drawer = false; #ifdef Q_WS_MAC // drawer support @@ -1980,9 +1983,6 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList } } - if (!testing) { - item_list.append(item); - } } } else if (nextMarker == SequenceMarker) { int dummy; -- cgit v1.2.1 From ba5fea372219000050715ecfac8fba9a6fd1b638 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 10 Nov 2009 18:01:27 +0100 Subject: QDockWidget also emits dockLocationChanged when the state is restored ...on the main window. Task-number: QTBUG-1304 Reviewed-by: ogoffart --- src/gui/widgets/qdockarealayout.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 27e145fbfc..953edab3a2 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1841,7 +1841,6 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const } } -#ifdef Q_WS_MAC static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos) { switch (pos) { @@ -1853,7 +1852,6 @@ static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos) } return Qt::NoDockWidgetArea; } -#endif static QRect constrainedRect(QRect rect, const QRect &desktop) { @@ -1980,6 +1978,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList if (!testing) { widget->setFloating(false); widget->setVisible(flags & StateFlagVisible); + emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); } } -- cgit v1.2.1 From 5e3f81237aae96181c9315b8e7c6c5368629a000 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 11 Nov 2009 07:09:07 +0100 Subject: Revert "Always set a clip on the painter in QGraphicsView." This reverts commit 4bf7f90a27377f439e86d6175e5e3cdebd131be0. The change is already reverted in kinetic-declarativeui. Reviewed-by: Warwick Allison Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsview.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 27fd09e165..3ef311cc2c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3275,13 +3275,10 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Determine the exposed region d->exposedRegion = event->region(); - if (d->exposedRegion.isEmpty()) - d->exposedRegion = viewport()->rect(); QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect(); // Set up the painter QPainter painter(viewport()); - painter.setClipRect(event->rect(), Qt::IntersectClip); #ifndef QT_NO_RUBBERBAND if (d->rubberBanding && !d->rubberBandRect.isEmpty()) painter.save(); -- cgit v1.2.1 From 2d97f299f5f25888656696c6dad0924b243ce4fd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Nov 2009 11:42:27 +0100 Subject: QKeySequence::mnemonic: add a warning if the text contains severals '&' Task-number: QTBUG-5667 Reviewed-by: Gabriel --- src/gui/kernel/qkeysequence.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 1a76083609..89c18fba1c 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1014,9 +1014,12 @@ bool QKeySequence::isEmpty() const */ QKeySequence QKeySequence::mnemonic(const QString &text) { + QKeySequence ret; + if(qt_sequence_no_mnemonics) - return QKeySequence(); + return ret; + bool found = false; int p = 0; while (p >= 0) { p = text.indexOf(QLatin1Char('&'), p) + 1; @@ -1025,13 +1028,22 @@ QKeySequence QKeySequence::mnemonic(const QString &text) if (text.at(p) != QLatin1Char('&')) { QChar c = text.at(p); if (c.isPrint()) { - c = c.toUpper(); - return QKeySequence(c.unicode() + Qt::ALT); + if (!found) { + c = c.toUpper(); + ret = QKeySequence(c.unicode() + Qt::ALT); +#ifdef QT_NO_DEBUG + return ret; +#else + found = true; + } else { + qWarning(qPrintable(QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurences of '&'").arg(text))); +#endif + } } } p++; } - return QKeySequence(); + return ret; } /*! -- cgit v1.2.1 From ad5f41c02daa0278902d0e8273c8cd34efd2d6da Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 11 Nov 2009 12:43:46 +0100 Subject: Fix Font combobox: one can set the current font without it being changed Task-number: QTBUG-5693 Reviewed-by: ogoffart --- src/gui/widgets/qfontcombobox.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp index 806db59ea3..a66657dbb9 100644 --- a/src/gui/widgets/qfontcombobox.cpp +++ b/src/gui/widgets/qfontcombobox.cpp @@ -247,7 +247,14 @@ void QFontComboBoxPrivate::_q_updateModel() } list = result; + //we need to block the signals so that the model doesn't emit reset + //this prevents the current index from changing + //it will be updated just after this + ///TODO: we should finda way to avoid blocking signals and have a real update of the model + const bool old = m->blockSignals(true); m->setStringList(list); + m->blockSignals(old); + if (list.isEmpty()) { if (currentFont != QFont()) { currentFont = QFont(); -- cgit v1.2.1 From 2b6fd0a7bdac686a41d7fbbe47ad3ded9e1d77b5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 11 Nov 2009 15:57:11 +0100 Subject: Small caps font variant wouldn't be used when defined through style sheets The font comparison (operator==) didn't check the capital attribute, which is the one responsible for this variant. Now it does. Auto-test updated. Reviewed-by: Samuel Reviewed-by: Olivier --- src/gui/text/qfont.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 447087c74f..f1cd6bbbf2 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1613,7 +1613,8 @@ bool QFont::operator==(const QFont &f) const && f.d->underline == d->underline && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut - && f.d->kerning == d->kerning)); + && f.d->kerning == d->kerning + && f.d->capital == d->capital)); } @@ -1645,6 +1646,7 @@ bool QFont::operator<(const QFont &f) const #ifdef Q_WS_X11 if (r1.addStyle != r2.addStyle) return r1.addStyle < r2.addStyle; #endif // Q_WS_X11 + if (f.d->capital != d->capital) return f.d->capital < d->capital; int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning; int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; -- cgit v1.2.1 From 46a3e518b3070cf7cb4cbbb2cb58254454cf169d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Nov 2009 16:28:24 +0100 Subject: QAbstractScrollArea: Wheel over a scrollarea that has only one horizontal scrollbar If the vertical scrollbar is hidden, scroll using the other scrollbar. Reviewed-by: Thierry Task-number: QTBUG-1760 --- src/gui/widgets/qabstractscrollarea.cpp | 11 +++++++---- src/gui/widgets/qabstractslider.cpp | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 48099ef399..c18664555f 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -1130,10 +1130,13 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e) void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); - if (static_cast(e)->orientation() == Qt::Horizontal) - QApplication::sendEvent(d->hbar, e); - else - QApplication::sendEvent(d->vbar, e); + QScrollBar *const bars[2] = { d->hbar, d->vbar }; + int idx = (e->orientation() == Qt::Vertical) ? 1 : 0; + int other = (idx + 1) % 2; + if (!bars[idx]->isVisible() && bars[other]->isVisible()) + idx = other; // If the scrollbar of the event orientation is hidden, fallback to the other. + + QApplication::sendEvent(bars[idx], e); } #endif diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index fec9fabcb9..e0db9c29e2 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -690,8 +690,6 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) { Q_D(QAbstractSlider); e->ignore(); - if (e->orientation() != d->orientation && !rect().contains(e->pos())) - return; int stepsToScroll = 0; qreal offset = qreal(e->delta()) / 120; -- cgit v1.2.1 From 2d63f8fe5b77747014e1c5807c9d457611bd9304 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Nov 2009 17:30:54 +0100 Subject: Fixed: QFontComboBox emits the currentFontChanged() signal twice Task-number: QTBUG-2438 Reviewed-by: Thierry --- src/gui/widgets/qfontcombobox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp index a66657dbb9..d601f81eb6 100644 --- a/src/gui/widgets/qfontcombobox.cpp +++ b/src/gui/widgets/qfontcombobox.cpp @@ -427,8 +427,10 @@ void QFontComboBox::setCurrentFont(const QFont &font) Q_D(QFontComboBox); if (font != d->currentFont) { d->currentFont = font; - emit currentFontChanged(d->currentFont); d->_q_updateModel(); + if (d->currentFont == font) { //else the signal has already be emitted by _q_updateModel + emit currentFontChanged(d->currentFont); + } } } -- cgit v1.2.1