summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 13:03:09 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 13:03:09 +0100
commitf94ca82e0ff6345648b499911411f2dcc1849267 (patch)
treebc5acac8bfecaf5bccc612f5b009bf249bc69ef1 /src/widgets
parentfe29a6a6ebbf28505df7cdf1de24fa540fd3745e (diff)
parentb1092a7d4240d419cc2b5f3f5c326a1cb680bbdd (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: .qmake.conf Change-Id: Ibfcb30053f3aacb8ec2ec480e146538c9bf440ea
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qdialog.cpp2
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp2
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.cpp2
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp2
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp4
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp6
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp42
-rw-r--r--src/widgets/kernel/qapplication_p.h3
-rw-r--r--src/widgets/kernel/qformlayout.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp4
-rw-r--r--src/widgets/styles/qstylefactory.cpp2
-rw-r--r--src/widgets/util/qundogroup.cpp2
-rw-r--r--src/widgets/util/qundoview.cpp2
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp2
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp2
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenubar.cpp2
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp57
21 files changed, 96 insertions, 56 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 5e64503f27..ebbd2fa9ea 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -988,7 +988,7 @@ Qt::Orientation QDialog::orientation() const
Sets the widget, \a extension, to be the dialog's extension,
deleting any previous extension. The dialog takes ownership of the
- extension. Note that if 0 is passed any existing extension will be
+ extension. Note that if \nullptr is passed, any existing extension will be
deleted. This function must only be called while the dialog is hidden.
Instead of using this functionality, we recommend that you simply call
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 854043e48f..078dd6463b 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -393,7 +393,7 @@ void QProgressDialog::setLabelText(const QString &text)
Sets the cancel button to the push button, \a cancelButton. The
progress dialog takes ownership of this button which will be deleted
when necessary, so do not pass the address of an object that is on
- the stack, i.e. use new() to create the button. If 0 is passed then
+ the stack, i.e. use new() to create the button. If \nullptr is passed,
no cancel button will be shown.
\sa setCancelButtonText()
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index 028010d3dd..94188f3485 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -178,7 +178,7 @@ QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
/*!
Returns a pointer to the item if this source is a QGraphicsItem; otherwise
- returns 0.
+ returns \nullptr.
\sa widget()
*/
@@ -189,7 +189,7 @@ const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const
/*!
Returns a pointer to the widget if this source is a QWidget; otherwise
- returns 0.
+ returns \nullptr.
\sa graphicsItem()
*/
@@ -200,7 +200,7 @@ const QWidget *QGraphicsEffectSource::widget() const
/*!
Returns a pointer to the style options (used when drawing the source) if
- available; otherwise returns 0.
+ available; otherwise returns \nullptr.
\sa graphicsItem(), widget()
*/
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 3a9bfab298..86f3d6a2f0 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1726,8 +1726,8 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const
/*!
\since 4.6
- Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
- is not a QGraphicsObject.
+ Returns a pointer to the item's parent, cast to a QGraphicsObject. Returns
+ \nullptr if the parent item is not a QGraphicsObject.
\sa parentItem(), childItems()
*/
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
index 9951fc0383..aed154a95f 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
@@ -369,7 +369,7 @@ bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
protected constructor, or by calling setParentLayoutItem(). The
parentLayoutItem() function returns a pointer to the item's layoutItem
parent. If the item's parent is 0 or if the parent does not inherit
- from QGraphicsItem, the parentLayoutItem() function then returns 0.
+ from QGraphicsItem, the parentLayoutItem() function then returns \nullptr.
isLayout() returns \c true if the QGraphicsLayoutItem subclass is itself a
layout, or false otherwise.
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 6e46eefa38..4bdc318566 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -240,7 +240,7 @@ QAbstractItemDelegate::~QAbstractItemDelegate()
model being used. The editor's parent widget is specified by \a parent,
and the item options by \a option.
- The base implementation returns 0. If you want custom editing you
+ The base implementation returns \nullptr. If you want custom editing you
will need to reimplement this function.
The returned editor widget should have Qt::StrongFocus;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 3b3a72cd4f..a9899983c2 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -1454,7 +1454,7 @@ void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel)
/*!
Returns the item that occupies the given \a row in the list if one has been
- set; otherwise returns 0.
+ set; otherwise returns \nullptr.
\sa row()
*/
@@ -1521,7 +1521,7 @@ void QListWidget::insertItems(int row, const QStringList &labels)
/*!
Removes and returns the item from the given \a row in the list widget;
- otherwise returns 0.
+ otherwise returns \nullptr.
Items removed from a list widget will not be managed by Qt, and will need
to be deleted manually.
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 0916079cfc..f99d69d37c 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -1983,7 +1983,7 @@ int QTableWidget::column(const QTableWidgetItem *item) const
/*!
Returns the item for the given \a row and \a column if one has been set; otherwise
- returns 0.
+ returns \nullptr.
\sa setItem()
*/
@@ -2076,7 +2076,7 @@ QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row)
/*!
Returns the horizontal header item for column, \a column, if one has been
- set; otherwise returns 0.
+ set; otherwise returns \nullptr.
*/
QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const
{
@@ -2481,7 +2481,7 @@ int QTableWidget::visualColumn(int logicalColumn) const
/*!
\fn QTableWidgetItem *QTableWidget::itemAt(const QPoint &point) const
- Returns a pointer to the item at the given \a point, or returns 0 if
+ Returns a pointer to the item at the given \a point, or returns \nullptr if
\a point is not covered by an item in the table widget.
\sa item()
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 1923f5edc1..6050bcd616 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -2779,7 +2779,7 @@ void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item)
/*!
Removes the top-level item at the given \a index in the tree and
- returns it, otherwise returns 0;
+ returns it, otherwise returns \nullptr;
\sa insertTopLevelItem(), topLevelItem(), topLevelItemCount()
*/
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 595bdf621d..53e1d13455 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -360,7 +360,7 @@ void QApplicationPrivate::createEventDispatcher()
/*!
\fn QWidget *QApplication::topLevelAt(const QPoint &point)
- Returns the top-level widget at the given \a point; returns 0 if
+ Returns the top-level widget at the given \a point; returns \nullptr if
there is no such widget.
*/
QWidget *QApplication::topLevelAt(const QPoint &pos)
@@ -1226,7 +1226,7 @@ void QApplication::setStyle(QStyle *style)
"windows", "windowsvista", "fusion", or "macintosh". Style
names are case insensitive.
- Returns 0 if an unknown \a style is passed, otherwise the QStyle object
+ Returns \nullptr if an unknown \a style is passed, otherwise the QStyle object
returned is set as the application's GUI style.
\warning To ensure that the application's style is set correctly, it is
@@ -1420,24 +1420,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
// Send ApplicationPaletteChange to qApp itself, and to the widgets.
- QEvent e(QEvent::ApplicationPaletteChange);
- QApplication::sendEvent(QApplication::instance(), &e);
-
- QWidgetList wids = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) {
- QWidget *w = *it;
- if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
- QApplication::sendEvent(w, &e);
- }
-
- // Send to all scenes as well.
-#if QT_CONFIG(graphicsview)
- QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
- for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
- it != scenes.constEnd(); ++it) {
- QApplication::sendEvent(*it, &e);
- }
-#endif // QT_CONFIG(graphicsview)
+ qApp->d_func()->sendApplicationPaletteChange(all, className);
}
if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {
if (!QApplicationPrivate::set_pal)
@@ -2195,7 +2178,7 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
/*!internal
* Helper function that returns the new focus widget, but does not set the focus reason.
- * Returns 0 if a new focus widget could not be found.
+ * Returns \nullptr if a new focus widget could not be found.
* Shared with QGraphicsProxyWidgetPrivate::findFocusChild()
*/
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next,
@@ -4511,6 +4494,23 @@ void QApplicationPrivate::notifyThemeChanged()
qt_init_tooltip_palette();
}
+void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className)
+{
+ QGuiApplicationPrivate::sendApplicationPaletteChange();
+
+ QEvent event(QEvent::ApplicationPaletteChange);
+ const QWidgetList widgets = QApplication::allWidgets();
+ for (auto widget : widgets) {
+ if (toAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className)))
+ QApplication::sendEvent(widget, &event);
+ }
+
+#if QT_CONFIG(graphicsview)
+ for (auto scene : qAsConst(scene_list))
+ QApplication::sendEvent(scene, &event);
+#endif // QT_CONFIG(graphicsview)
+}
+
#if QT_CONFIG(draganddrop)
void QApplicationPrivate::notifyDragStarted(const QDrag *drag)
{
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 05bc2468c1..133279f977 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -177,6 +177,9 @@ public:
protected:
void notifyThemeChanged() override;
+ void sendApplicationPaletteChange(bool toAllWidgets = false,
+ const char *className = nullptr) override;
+
#if QT_CONFIG(draganddrop)
void notifyDragStarted(const QDrag *) override;
#endif // QT_CONFIG(draganddrop)
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 7cdddf3133..bd0ea2598a 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1827,7 +1827,7 @@ int QFormLayout::rowCount() const
/*!
Returns the layout item in the given \a row with the specified \a
- role (column). Returns 0 if there is no such item.
+ role (column). Returns \nullptr if there is no such item.
\sa QLayout::itemAt(), setItem()
*/
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 396a3bcf07..6616cb6de3 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -10412,7 +10412,7 @@ bool QWidget::hasHeightForWidth() const
Returns the visible child widget at the position (\a{x}, \a{y})
in the widget's coordinate system. If there is no visible child
- widget at the specified position, the function returns 0.
+ widget at the specified position, the function returns \nullptr.
*/
/*!
@@ -12376,7 +12376,7 @@ Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
\since 4.5
Returns the proxy widget for the corresponding embedded widget in a graphics
- view; otherwise returns 0.
+ view; otherwise returns \nullptr.
\sa QGraphicsProxyWidget::createProxyForChildWidget(),
QGraphicsScene::addWidget()
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index c959994d2c..b0ce5e52cf 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -77,7 +77,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
/*!
Creates and returns a QStyle object that matches the given \a key, or
- returns 0 if no matching style is found.
+ returns \nullptr if no matching style is found.
Both built-in styles and styles from style plugins are queried for a
matching style.
diff --git a/src/widgets/util/qundogroup.cpp b/src/widgets/util/qundogroup.cpp
index f9605c7a2f..9bd63d4232 100644
--- a/src/widgets/util/qundogroup.cpp
+++ b/src/widgets/util/qundogroup.cpp
@@ -242,7 +242,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack)
Returns the active stack of this group.
If none of the stacks are active, or if the group is empty, this function
- returns 0.
+ returns \nullptr.
\sa setActiveStack(), QUndoStack::setActive()
*/
diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp
index 31f6c0dff2..c862cbcea5 100644
--- a/src/widgets/util/qundoview.cpp
+++ b/src/widgets/util/qundoview.cpp
@@ -412,7 +412,7 @@ void QUndoView::setGroup(QUndoGroup *group)
/*!
Returns the group displayed by this view.
- If the view is not looking at group, this function returns 0.
+ If the view is not looking at group, this function returns \nullptr.
\sa setGroup(), setStack()
*/
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index 5854472ff0..f30a3bc7b8 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -805,7 +805,7 @@ bool QAbstractButton::autoExclusive() const
Returns the group that this button belongs to.
If the button is not a member of any QButtonGroup, this function
- returns 0.
+ returns \nullptr.
\sa QButtonGroup
*/
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 4e1aa51b4b..00ac5034e9 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -692,7 +692,7 @@ QLineEdit *QAbstractSpinBox::lineEdit() const
QAbstractSpinBox takes ownership of the new lineEdit
- If QLineEdit::validator() for the \a lineEdit returns 0, the internal
+ If QLineEdit::validator() for the \a lineEdit returns \nullptr, the internal
validator of the spinbox will be set on the line edit.
*/
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 5927331305..9b30ec4619 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2255,7 +2255,7 @@ int QMenu::columnCount() const
}
/*!
- Returns the item at \a pt; returns 0 if there is no item there.
+ Returns the item at \a pt; returns \nullptr if there is no item there.
*/
QAction *QMenu::actionAt(const QPoint &pt) const
{
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index ce74a4c2ff..e7984078de 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1581,7 +1581,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
}
/*!
- Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if
+ Returns the QAction at \a pt. Returns \nullptr if there is no action at \a pt or if
the location has a separator.
\sa addAction(), addSeparator()
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 277d2fd99f..4af4f90119 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -46,6 +46,7 @@
#include "qpixmap.h"
#include "qtextdocument.h"
#include "qtextcursor.h"
+#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
#include <QtCore/qdebug.h>
#include <QtCore/qelapsedtimer.h>
@@ -69,6 +70,10 @@ public:
int currAlign;
inline QSplashScreenPrivate();
+
+ void setPixmap(const QPixmap &p, const QScreen *screen = nullptr);
+
+ static const QScreen *screenFor(const QWidget *w);
};
/*!
@@ -143,8 +148,9 @@ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)
: QWidget(*new QSplashScreenPrivate, parent, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
- d_func()->pixmap = pixmap;
- setPixmap(d_func()->pixmap); // Does an implicit repaint
+ // Does an implicit repaint. Explicitly pass parent as QObject::parent()
+ // is still 0 here due to QWidget's special handling.
+ d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(parent));
}
/*!
@@ -276,16 +282,47 @@ void QSplashScreen::finish(QWidget *mainWin)
*/
void QSplashScreen::setPixmap(const QPixmap &pixmap)
{
- Q_D(QSplashScreen);
+ d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(this));
+}
+
+// In setPixmap(), resize and try to position on a screen according to:
+// 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on
+// QSplashScreen(QWidget *, QPixmap).
+// 2) If a widget with associated QWindow is found, use that
+// 3) When nothing can be found, do not position the widget, allowing for
+// QPlatformWindow::initialGeometry() to center it over the cursor
+
+static inline int screenNumberOf(const QDesktopScreenWidget *dsw)
+{
+ auto desktopWidgetPrivate =
+ static_cast<QDesktopWidgetPrivate *>(qt_widget_private(QApplication::desktop()));
+ return desktopWidgetPrivate->screens.indexOf(const_cast<QDesktopScreenWidget *>(dsw));
+}
+
+const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w)
+{
+ for (const QWidget *p = w; p !=nullptr ; p = p->parentWidget()) {
+ if (auto dsw = qobject_cast<const QDesktopScreenWidget *>(p))
+ return QGuiApplication::screens().value(screenNumberOf(dsw));
+ if (QWindow *window = p->windowHandle())
+ return window->screen();
+ }
+ return nullptr;
+}
+
+void QSplashScreenPrivate::setPixmap(const QPixmap &p, const QScreen *screen)
+{
+ Q_Q(QSplashScreen);
- d->pixmap = pixmap;
- setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
+ pixmap = p;
+ q->setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
- QRect r(QPoint(), d->pixmap.size() / d->pixmap.devicePixelRatio());
- resize(r.size());
- move(QDesktopWidgetPrivate::screenGeometry().center() - r.center());
- if (isVisible())
- repaint();
+ QRect r(QPoint(), pixmap.size() / pixmap.devicePixelRatio());
+ q->resize(r.size());
+ if (screen)
+ q->move(screen->geometry().center() - r.center());
+ if (q->isVisible())
+ q->repaint();
}
/*!