summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-11 17:19:29 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-11 17:19:29 (GMT)
commit8c13e18eb49ab9ab42db4359f0ccc91de5c72818 (patch)
tree17dbc029e37835594ad29d586f3fc7ec8013b65a /src
parentde76200652e05de34d99f111c64a051a49911034 (diff)
parent2d63f8fe5b77747014e1c5807c9d457611bd9304 (diff)
downloadQt-8c13e18eb49ab9ab42db4359f0ccc91de5c72818.zip
Qt-8c13e18eb49ab9ab42db4359f0ccc91de5c72818.tar.gz
Qt-8c13e18eb49ab9ab42db4359f0ccc91de5c72818.tar.bz2
Merge commit 'widget/4.6' into oslo-staging-2/4.6
Conflicts: src/gui/painting/qbrush.cpp
Diffstat (limited to 'src')
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp10
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp1
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp3
-rw-r--r--src/gui/kernel/qaction.cpp26
-rw-r--r--src/gui/kernel/qaction_p.h2
-rw-r--r--src/gui/kernel/qapplication.cpp3
-rw-r--r--src/gui/kernel/qgesturemanager.cpp1
-rw-r--r--src/gui/kernel/qkeysequence.cpp20
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/painting/qbrush.cpp2
-rw-r--r--src/gui/styles/qplastiquestyle.cpp10
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--src/gui/text/qfont.cpp4
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp11
-rw-r--r--src/gui/widgets/qabstractslider.cpp2
-rw-r--r--src/gui/widgets/qdockarealayout.cpp9
-rw-r--r--src/gui/widgets/qdockwidget.cpp5
-rw-r--r--src/gui/widgets/qfontcombobox.cpp11
-rw-r--r--src/gui/widgets/qmenu.cpp44
-rw-r--r--src/gui/widgets/qmenu_p.h1
-rw-r--r--src/gui/widgets/qmenubar.cpp4
-rw-r--r--src/gui/widgets/qtoolbar.cpp2
-rw-r--r--src/gui/widgets/qtoolbararealayout.cpp50
-rw-r--r--src/gui/widgets/qtoolbararealayout_p.h6
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp5
-rw-r--r--src/gui/widgets/qtoolbarlayout_p.h2
28 files changed, 140 insertions, 108 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 3065083..013ff7f 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 861e26e..5dbb8c3 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
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 182594e..594a205 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -903,7 +903,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));
QVector<AnchorVertex*> 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/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 9d495e9..4e5e5c8 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();
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 27fd09e..3ef311c 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();
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index 6f3cbaf..3eaf2e1 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 2527a02..f7b035b 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<QActionGroup> group;
QString text;
QString iconText;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 987aa26..4b8f6a0 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
}
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 3d4bb8c..192f9ac 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -601,6 +601,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &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/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 1a76083..89c18fb 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;
}
/*!
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 9f08dc6..9e4cf60 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
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index afe9986..7273c35 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
- const char *BRUSH_STYLES[] = {
+ static const char *BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
"Dense1Pattern",
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index f880351..be4fff2 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());
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index ce73fd8..59210c3 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:
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 447087c..f1cd6bb 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;
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index b0d0baf..35639b7 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<QWheelEvent*>(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 fec9fab..e0db9c2 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;
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index dffec11..953edab 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)
{
@@ -1933,6 +1931,9 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
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
@@ -1977,12 +1978,10 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
if (!testing) {
widget->setFloating(false);
widget->setVisible(flags & StateFlagVisible);
+ emit widget->dockLocationChanged(toDockWidgetArea(dockPos));
}
}
- if (!testing) {
- item_list.append(item);
- }
}
} else if (nextMarker == SequenceMarker) {
int dummy;
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index a8e2a37..9cf6af1 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<QDockWidgetLayout*>(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
diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp
index 806db59..d601f81 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();
@@ -420,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);
+ }
}
}
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index cc39b7f..54d1612 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<QMenu*>(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<QMenu *>(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<QMenu*>(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<QMenu *>(top))
- top = m->d_func()->causedPopup.widget;
- setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(top) != 0);
+ setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(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<QMenu*>(caused))
- caused = m->d_func()->causedPopup.widget;
#ifndef QT_NO_MENUBAR
- if (QMenuBar *mb = qobject_cast<QMenuBar*>(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<QMenuBar*>(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 a5bde7c..c021063 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);
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 689d2e1..b1ff662 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());
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index 5596ca4..58a3d28 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/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp
index de11625..b7e985c 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<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const
+QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) const
{
int p = pick(o, pos);
@@ -509,12 +509,19 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const
QList<int> 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 (dist >= 0 && *minDistance > dist) {
+ *minDistance = dist;
+
+ QList<int> result;
+ result << lines.count() << 0;
return result;
}
- } else if (appendLineDropRect().contains(pos)) {
- QList<int> result;
- result << lines.count() << 0;
- return result;
}
return QList<int>();
@@ -587,32 +594,20 @@ QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &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<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const
return result;
}
+//this functions returns the path to the possible gapindex for the position pos
QList<int> 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<int> 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<int> result = docks[i].gapIndex(p);
+ QList<int> result = docks[i].gapIndex(p, &minDistance);
if (!result.isEmpty()) {
result.prepend(i);
- return result;
+ ret = result;
}
}
- return QList<int>();
+ return ret;
}
QList<int> QToolBarAreaLayout::currentGapIndex() const
diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h
index 1e113b7..f0ab80c 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<QToolBarAreaLayoutLine> lines;
@@ -173,11 +171,11 @@ public:
void removeToolBarBreak(QToolBar *before);
void moveToolBar(QToolBar *toolbar, int pos);
- QList<int> gapIndex(const QPoint &pos) const;
+ QList<int> gapIndex(const QPoint &pos, int *maxDistance) const;
bool insertGap(const QList<int> &path, QLayoutItem *item);
void clear();
QRect itemRect(const QList<int> &path) const;
- QRect appendLineDropRect() const;
+ int distance(const QPoint &pos) const;
QRect rect;
Qt::Orientation o;
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index 7dc1e01..0afe5d8 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<QMainWindow*>(tb->parentWidget())) {
- animating = true;
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(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 d49a5df..afd0227 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<QToolBarItem*> items;