summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-05-07 13:07:34 +0200
committerLiang Qi <liang.qi@qt.io>2017-05-07 13:08:18 +0200
commitd1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch)
tree3bdc16da993e5de56b669e6774fb0748075ddd90 /src/widgets/widgets
parent1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff)
parent0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/network/access/qnetworkreply.cpp tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp18
-rw-r--r--src/widgets/widgets/qcombobox.cpp16
-rw-r--r--src/widgets/widgets/qdockwidget.cpp1
-rw-r--r--src/widgets/widgets/qdockwidget_p.h1
-rw-r--r--src/widgets/widgets/qmenu.cpp46
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp19
-rw-r--r--src/widgets/widgets/qsplitter.cpp25
-rw-r--r--src/widgets/widgets/qsplitter_p.h8
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp2
9 files changed, 84 insertions, 52 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index c0bd8bce5a..77fb203b82 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -396,8 +396,7 @@ void QAbstractButtonPrivate::click()
}
blockRefresh = false;
refresh();
- q->repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ q->repaint();
if (guard)
emitReleased();
if (guard)
@@ -834,8 +833,7 @@ void QAbstractButton::animateClick(int msec)
if (d->checkable && focusPolicy() & Qt::ClickFocus)
setFocus();
setDown(true);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
if (!d->animateTimer.isActive())
d->emitPressed();
d->animateTimer.start(msec, this);
@@ -977,8 +975,7 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e)
if (hitButton(e->pos())) {
setDown(true);
d->pressed = true;
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitPressed();
e->accept();
} else {
@@ -1025,8 +1022,7 @@ void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
if (hitButton(e->pos()) != d->down) {
setDown(!d->down);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
if (d->down)
d->emitPressed();
else
@@ -1051,8 +1047,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
case Qt::Key_Space:
if (!e->isAutoRepeat()) {
setDown(true);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitPressed();
}
break;
@@ -1103,8 +1098,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_SHORTCUT
if (e->matches(QKeySequence::Cancel) && d->down) {
setDown(false);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitReleased();
return;
}
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 272032d76f..0dde839629 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2741,6 +2741,22 @@ void QComboBox::showPopup()
bool startTimer = !container->isVisible();
container->raise();
+ container->create();
+ QWindow *containerWindow = container->window()->windowHandle();
+ if (containerWindow) {
+ QWindow *win = window()->windowHandle();
+ if (win) {
+ QScreen *currentScreen = win->screen();
+ if (currentScreen && !currentScreen->virtualSiblings().contains(containerWindow->screen())) {
+ containerWindow->setScreen(currentScreen);
+
+ // This seems to workaround an issue in xcb+multi GPU+multiscreen
+ // environment where the window might not always show up when screen
+ // is changed.
+ container->hide();
+ }
+ }
+ }
container->show();
container->updateScrollers();
view()->setFocus();
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 59a1e99398..15f79638c8 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -49,7 +49,6 @@
#include <qwindow.h>
#include <qscreen.h>
#include <qmainwindow.h>
-#include <qrubberband.h>
#include <qstylepainter.h>
#include <qtoolbutton.h>
#include <qdebug.h>
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 84bf8efacf..2d62cf5acd 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
class QGridLayout;
class QWidgetResizeHandler;
-class QRubberBand;
class QDockWidgetTitleButton;
class QSpacerItem;
class QDockWidgetItem;
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 8498835a34..4567f7c2a3 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -72,6 +72,7 @@
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformtheme.h>
QT_BEGIN_NAMESPACE
@@ -127,9 +128,9 @@ public:
setParent(parentWidget, Qt::Window | Qt::Tool);
setAttribute(Qt::WA_DeleteOnClose, true);
setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
- setWindowTitle(p->windowTitle());
+ updateWindowTitle();
setEnabled(p->isEnabled());
-#if QT_CONFIG(cssparser)
+#if QT_CONFIG(style_stylesheet)
setStyleSheet(p->styleSheet());
#endif
if (style() != p->style())
@@ -165,6 +166,15 @@ public:
}
}
+ void updateWindowTitle()
+ {
+ Q_D(QTornOffMenu);
+ if (!d->causedMenu)
+ return;
+ const QString &cleanTitle = QPlatformTheme::removeMnemonics(d->causedMenu->title()).trimmed();
+ setWindowTitle(cleanTitle);
+ }
+
public slots:
void onTrigger(QAction *action) { d_func()->activateAction(action, QAction::Trigger, false); }
void onHovered(QAction *action) { d_func()->activateAction(action, QAction::Hover, false); }
@@ -183,6 +193,10 @@ void QMenuPrivate::init()
q->setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu);
defaultMenuAction = menuAction = new QAction(q);
menuAction->d_func()->menu = q;
+ QObject::connect(menuAction, &QAction::changed, [=] {
+ if (!tornPopup.isNull())
+ tornPopup->updateWindowTitle();
+ });
q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q));
if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) {
scroll = new QMenuPrivate::QMenuScroller;
@@ -313,8 +327,8 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + tearoffHeight;
+ const int column_max_y = screen.height() - 2 * deskFw - (vmargin + bottommargin + fw);
int max_column_width = 0;
- int dh = screen.height();
int y = base_y;
//for compatibility now - will have to refactor this away
@@ -392,8 +406,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
if (!sz.isEmpty()) {
max_column_width = qMax(max_column_width, sz.width());
//wrapping
- if (!scroll &&
- y + sz.height() + vmargin + bottommargin + fw > dh - (deskFw * 2)) {
+ if (!scroll && y + sz.height() > column_max_y) {
ncols++;
y = base_y;
} else {
@@ -419,8 +432,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
QRect &rect = actionRects[i];
if (rect.isNull())
continue;
- if (!scroll &&
- y + rect.height() + vmargin + bottommargin + fw > dh - deskFw * 2) {
+ if (!scroll && y + rect.height() > column_max_y) {
x += max_column_width + hmargin;
y = base_y;
}
@@ -2310,16 +2322,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
ensurePolished(); // Get the right font
emit aboutToShow();
const bool actionListChanged = d->itemsDirty;
- d->updateActionRects();
- QPoint pos;
- QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
- if (actionListChanged && causedButton)
- pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
- else
- pos = p;
- const QSize menuSizeHint(sizeHint());
- QSize size = menuSizeHint;
QRect screen;
#ifndef QT_NO_GRAPHICSVIEW
bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
@@ -2328,6 +2331,17 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
else
#endif
screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
+ d->updateActionRects(screen);
+
+ QPoint pos;
+ QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
+ if (actionListChanged && causedButton)
+ pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
+ else
+ pos = p;
+
+ const QSize menuSizeHint(sizeHint());
+ QSize size = menuSizeHint;
const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this);
bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 4ad2b83582..2758af53ef 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -164,15 +164,14 @@ void QSplashScreen::mousePressEvent(QMouseEvent *)
}
/*!
- This overrides QWidget::repaint(). It differs from the standard
- repaint function in that it also calls QApplication::flush() to
- ensure the updates are displayed, even when there is no event loop
- present.
+ This overrides QWidget::repaint(). It differs from the standard repaint
+ function in that it also calls QApplication::processEvents() to ensure
+ the updates are displayed, even when there is no event loop present.
*/
void QSplashScreen::repaint()
{
QWidget::repaint();
- QApplication::flush();
+ QApplication::processEvents();
}
/*!
@@ -190,13 +189,9 @@ void QSplashScreen::repaint()
/*!
Draws the \a message text onto the splash screen with color \a
color and aligns the text according to the flags in \a alignment.
-
- To make sure the splash screen is repainted immediately, you can
- call \l{QCoreApplication}'s
- \l{QCoreApplication::}{processEvents()} after the call to
- showMessage(). You usually want this to make sure that the message
- is kept up to date with what your application is doing (e.g.,
- loading files).
+ This function calls repaint() to make sure the splash screen is
+ repainted immediately. As a result the message is kept up
+ to date with what your application is doing (e.g. loading files).
\sa Qt::Alignment, clearMessage(), message()
*/
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 1676c188a6..0c98c3875a 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -975,7 +975,9 @@ QSplitter::QSplitter(Qt::Orientation orientation, QWidget *parent)
QSplitter::~QSplitter()
{
Q_D(QSplitter);
+#if QT_CONFIG(rubberband)
delete d->rubberBand;
+#endif
while (!d->list.isEmpty())
delete d->list.takeFirst();
}
@@ -1296,18 +1298,19 @@ void QSplitter::childEvent(QChildEvent *c)
qWarning("Adding a QLayout to a QSplitter is not supported.");
return;
}
- QWidget *w = static_cast<QWidget*>(c->child());
- if (w->isWindow())
- return;
- if (c->added() && !d->blockChildAdd && !d->findWidget(w)) {
- d->insertWidget_helper(d->list.count(), w, false);
- } else if (c->polished() && !d->blockChildAdd) {
- if (d->shouldShowWidget(w))
+ if (c->added()) {
+ QWidget *w = static_cast<QWidget*>(c->child());
+ if (!d->blockChildAdd && !w->isWindow() && !d->findWidget(w))
+ d->insertWidget_helper(d->list.count(), w, false);
+ } else if (c->polished()) {
+ QWidget *w = static_cast<QWidget*>(c->child());
+ if (!d->blockChildAdd && !w->isWindow() && d->shouldShowWidget(w))
w->show();
- } else if (c->type() == QEvent::ChildRemoved) {
+ } else if (c->removed()) {
+ QObject *child = c->child();
for (int i = 0; i < d->list.size(); ++i) {
QSplitterLayoutStruct *s = d->list.at(i);
- if (s->widget == w) {
+ if (s->widget == child) {
d->list.removeAt(i);
delete s;
d->recalc(isVisible());
@@ -1325,6 +1328,7 @@ void QSplitter::childEvent(QChildEvent *c)
void QSplitter::setRubberBand(int pos)
{
+#if QT_CONFIG(rubberband)
Q_D(QSplitter);
if (pos < 0) {
if (d->rubberBand)
@@ -1345,6 +1349,9 @@ void QSplitter::setRubberBand(int pos)
: QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord));
d->rubberBand->setGeometry(newGeom);
d->rubberBand->show();
+#else
+ Q_UNUSED(pos);
+#endif
}
/*!
diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index 07b43e56b8..0730fab824 100644
--- a/src/widgets/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
@@ -81,11 +81,17 @@ class QSplitterPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QSplitter)
public:
- QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
+ QSplitterPrivate() :
+#if QT_CONFIG(rubberband)
+ rubberBand(0),
+#endif
+ opaque(true), firstShow(true),
childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {}
~QSplitterPrivate();
+#if QT_CONFIG(rubberband)
QPointer<QRubberBand> rubberBand;
+#endif
mutable QList<QSplitterLayoutStruct *> list;
Qt::Orientation orient;
bool opaque : 8;
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 363e7157ac..905bc0f586 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1704,7 +1704,9 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
}
bool unknown = false;
+#if QT_CONFIG(shortcut)
bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
+#endif
if (false) {
}