summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp2
-rw-r--r--src/widgets/dialogs/qdialog.cpp2
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp17
-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.cpp27
-rw-r--r--src/widgets/kernel/qwidget_p.h4
-rw-r--r--src/widgets/styles/qcommonstyle.cpp36
-rw-r--r--src/widgets/styles/qstylefactory.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp47
-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/qplaintextedit.cpp7
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp57
27 files changed, 190 insertions, 98 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 93e49466cb..7132bb3297 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -1887,7 +1887,7 @@ bool QColorDialogPrivate::canBeNativeDialog() const
}
static const Qt::WindowFlags DefaultWindowFlags =
- Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint
+ Qt::Dialog | Qt::WindowTitleHint
| Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
/*!
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 1fb5e61301..c9093095a7 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -969,7 +969,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/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 5a7d6edddf..3cfe8367e0 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -168,6 +168,18 @@ private:
}
};
+class QInputDialogListView : public QListView
+{
+public:
+ QInputDialogListView(QWidget *parent = 0) : QListView(parent) {}
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
+ {
+ if (query == Qt::ImEnabled)
+ return false;
+ return QListView::inputMethodQuery(query);
+ }
+};
+
class QInputDialogPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QInputDialog)
@@ -201,7 +213,7 @@ public:
mutable QSpinBox *intSpinBox;
mutable QDoubleSpinBox *doubleSpinBox;
mutable QComboBox *comboBox;
- mutable QListView *listView;
+ mutable QInputDialogListView *listView;
mutable QWidget *inputWidget;
mutable QVBoxLayout *mainLayout;
QInputDialog::InputDialogOptions opts;
@@ -298,8 +310,7 @@ void QInputDialogPrivate::ensureListView()
Q_Q(QInputDialog);
if (!listView) {
ensureComboBox();
-
- listView = new QListView(q);
+ listView = new QInputDialogListView(q);
listView->hide();
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
listView->setSelectionMode(QAbstractItemView::SingleSelection);
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 4bf78e2115..e1fb1055ae 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -397,7 +397,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 7bc0ece4b3..9508aed3d3 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 72e0a67a64..b9c0e0a4b7 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -1375,7 +1375,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()
*/
@@ -1442,7 +1442,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 2d539e10ba..eee3e91ac3 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -1936,7 +1936,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()
*/
@@ -2029,7 +2029,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
{
@@ -2435,7 +2435,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 a0af27115d..9fbfb50029 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -2688,7 +2688,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 f9db6155af..ebab87b193 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)
@@ -2194,7 +2177,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,
@@ -4508,6 +4491,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 66e8858e21..600934b8a1 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1825,7 +1825,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 fef07cfe0d..19599cc008 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -247,6 +247,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#ifndef QT_NO_TOOLTIP
, toolTipDuration(-1)
#endif
+ , directFontResolveMask(0)
, inheritedFontResolveMask(0)
, inheritedPaletteResolveMask(0)
, leftmargin(0)
@@ -4508,8 +4509,7 @@ void QWidget::setForegroundRole(QPalette::ColorRole role)
style, depend on third party APIs to render the content of widgets,
and these styles typically do not follow the palette. Because of this,
assigning roles to a widget's palette is not guaranteed to change the
- appearance of the widget. Instead, you may choose to apply a \l
- styleSheet.
+ appearance of the widget. Instead, you may choose to apply a \l {styleSheet}.
\warning Do not use this function in conjunction with \l{Qt Style Sheets}.
When using style sheets, the palette of a widget can be customized using
@@ -4754,6 +4754,18 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
/*!
\internal
+ Returns a font suitable for inheritance, where only locally set attributes are considered resolved.
+*/
+QFont QWidgetPrivate::localFont() const
+{
+ QFont localfont = data.fnt;
+ localfont.resolve(directFontResolveMask);
+ return localfont;
+}
+
+/*!
+ \internal
+
Determine which font is implicitly imposed on this widget by its ancestors
and QApplication::font, resolve this against its own font (attributes from
the implicit font are copied over). Then propagate this font to this
@@ -4762,7 +4774,7 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
void QWidgetPrivate::resolveFont()
{
QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask);
- QFont resolvedFont = data.fnt.resolve(naturalFont);
+ QFont resolvedFont = localFont().resolve(naturalFont);
setFont_helper(resolvedFont);
}
@@ -4801,6 +4813,11 @@ void QWidgetPrivate::updateFont(const QFont &font)
inheritedFontResolveMask = 0;
}
uint newMask = data.fnt.resolve() | inheritedFontResolveMask;
+ // Set the font as also having resolved inherited traits, so the result of reading QWidget::font()
+ // isn't all weak information, but save the original mask to be able to let new changes on the
+ // parent widget font propagate correctly.
+ directFontResolveMask = data.fnt.resolve();
+ data.fnt.resolve(newMask);
for (int i = 0; i < children.size(); ++i) {
QWidget *w = qobject_cast<QWidget*>(children.at(i));
@@ -10409,7 +10426,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.
*/
/*!
@@ -12373,7 +12390,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/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 6f1ce67c4c..0d7e9e26ba 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -383,10 +383,11 @@ public:
void updateFont(const QFont &);
inline void setFont_helper(const QFont &font) {
- if (data.fnt.resolve() == font.resolve() && data.fnt == font)
+ if (directFontResolveMask == font.resolve() && data.fnt == font)
return;
updateFont(font);
}
+ QFont localFont() const;
void resolveFont();
QFont naturalWidgetFont(uint inheritedMask) const;
@@ -729,6 +730,7 @@ public:
#endif
// Other variables.
+ uint directFontResolveMask;
uint inheritedFontResolveMask;
uint inheritedPaletteResolveMask;
short leftmargin;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 9fbbe1893a..3d626a57fa 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -943,17 +943,20 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
const QRectF boundingRect = textLayout.boundingRect();
const QRect layoutRect = QStyle::alignedRect(option->direction, option->displayAlignment,
boundingRect.size().toSize(), textRect);
- const QPointF position = layoutRect.topLeft();
- const int lineCount = textLayout.lineCount();
+ QPointF paintPosition = QPointF(textRect.x(), layoutRect.top());
+ QString newText;
qreal height = 0;
+ const int lineCount = textLayout.lineCount();
for (int i = 0; i < lineCount; ++i) {
const QTextLine line = textLayout.lineAt(i);
height += line.height();
// above visible rect
- if (height + layoutRect.top() <= textRect.top())
+ if (height + layoutRect.top() <= textRect.top()) {
+ paintPosition.ry() += line.height();
continue;
+ }
const int start = line.textStart();
const int length = line.textLength();
@@ -968,26 +971,33 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
elideLastVisibleLine = true;
}
+ QString text = textLayout.text().mid(start, length);
if (drawElided || elideLastVisibleLine) {
- QString text = textLayout.text().mid(start, length);
- if (elideLastVisibleLine)
+ if (elideLastVisibleLine) {
+ if (text.endsWith(QChar::LineSeparator))
+ text.chop(1);
text += QChar(0x2026);
+ }
const QStackTextEngine engine(text, option->font);
- const QString elidedText = engine.elidedText(option->textElideMode, textRect.width());
- const QPointF pos(position.x() + line.x(),
- position.y() + line.y() + line.ascent());
- p->save();
- p->setFont(option->font);
- p->drawText(pos, elidedText);
- p->restore();
+ newText += engine.elidedText(option->textElideMode, textRect.width());
+ // sometimes drawElided is true but no eliding is done so the text ends
+ // with QChar::LineSeparator - don't add another one. This happened with
+ // arabic text in the testcase for QTBUG-72805
+ if (i < lineCount - 1 &&
+ !newText.endsWith(QChar::LineSeparator))
+ newText += QChar::LineSeparator;
} else {
- line.draw(p, position);
+ newText += text;
}
// below visible text, can stop
if (height + layoutRect.top() >= textRect.bottom())
break;
}
+
+ textLayout.setText(newText);
+ viewItemTextLayout(textLayout, textRect.width());
+ textLayout.draw(p, paintPosition);
}
/*! \internal
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/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 96c6fdf2e2..79fa20851f 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2642,7 +2642,7 @@ void QStyleSheetStyle::setPalette(QWidget *w)
QRenderRule rule = renderRule(w, PseudoElement_None, map[i].state | extendedPseudoClass(w));
if (i == 0) {
if (!w->property("_q_styleSheetWidgetFont").isValid()) {
- saveWidgetFont(w, w->font());
+ saveWidgetFont(w, w->d_func()->localFont());
}
updateStyleSheetFont(w);
if (ew != w)
@@ -3705,21 +3705,17 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
QStyleOptionMenuItem newMi = mi;
newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
- checkableOffset = newMi.rect.width();
+ // align with icons if there are some
+ checkableOffset = std::max(m->maxIconWidth, newMi.rect.width());
if (subSubRule.hasDrawable() || checked)
drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
}
- int iconOffset = 0;
if (!mi.icon.isNull()) {
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
if (act && !dis)
mode = QIcon::Active;
- QPixmap pixmap;
- if (checked)
- pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
- else
- pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
+ const QPixmap pixmap(mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, checked ? QIcon::On : QIcon::Off));
const int pixw = pixmap.width() / pixmap.devicePixelRatio();
const int pixh = pixmap.height() / pixmap.devicePixelRatio();
QRenderRule iconRule = renderRule(w, opt, PseudoElement_MenuIcon);
@@ -3738,15 +3734,20 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(iconRect.center());
p->drawPixmap(pmr.topLeft(), pixmap);
- iconOffset = iconRule.geo->width;
}
+ int textOffset = 0;
+ // padding overrules it all
+ if (!subRule.hasBox() || subRule.box()->paddings[LeftEdge] == 0) {
+ textOffset = checkableOffset;
+ if (!m->icon.isNull() || !checkable)
+ textOffset += m->maxIconWidth;
+ }
QRect textRect = subRule.contentsRect(opt->rect);
- if (opt->direction == Qt::LeftToRight)
- textRect.setLeft(textRect.left() + checkableOffset + iconOffset);
- else
- textRect.setRight(textRect.right() - checkableOffset - iconOffset);
+ textRect.setLeft(textRect.left() + textOffset);
textRect.setWidth(textRect.width() - mi.tabWidth);
+ const QRect vTextRect = visualRect(opt->direction, m->rect, textRect);
+
QStringRef s(&mi.text);
p->setPen(mi.palette.buttonText().color());
if (!s.isEmpty()) {
@@ -3760,7 +3761,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
p->drawText(vShortcutRect, text_flags, s.mid(t + 1).toString());
s = s.left(t);
}
- p->drawText(textRect, text_flags, s.left(t).toString());
+ p->drawText(vTextRect, text_flags, s.left(t).toString());
}
if (mi.menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
@@ -5084,15 +5085,22 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
if (mi->text.contains(QLatin1Char('\t')))
width += 12; //as in QCommonStyle
bool checkable = mi->checkType != QStyleOptionMenuItem::NotCheckable;
+ int checkableWidth = 0;
if (checkable) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
QRect checkmarkRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
- width += checkmarkRect.width();
+ checkableWidth = std::max(mi->maxIconWidth, checkmarkRect.width());
}
if (!mi->icon.isNull()) {
QPixmap pixmap = mi->icon.pixmap(pixelMetric(PM_SmallIconSize));
width += pixmap.width();
}
+ // padding overrules it all
+ if (!subRule.hasBox() || subRule.box()->paddings[LeftEdge] == 0) {
+ width += checkableWidth;
+ if (!mi->icon.isNull() || !checkable)
+ width += mi->maxIconWidth;
+ }
return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height())));
}
}
@@ -6025,7 +6033,7 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
unsetStyleSheetFont(w);
if (rule.font.resolve()) {
- QFont wf = w->font();
+ QFont wf = w->d_func()->localFont();
styleSheetCaches->customFontWidgets.insert(w, {wf, rule.font.resolve()});
QFont font = rule.font.resolve(wf);
@@ -6033,7 +6041,9 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
w->setFont(font);
}
} else {
- QFont font = rule.font.resolve(w->font());
+ QFont wf = w->d_func()->localFont();
+ QFont font = rule.font.resolve(wf);
+ font.resolve(wf.resolve() | rule.font.resolve());
if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
&& isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
@@ -6041,10 +6051,11 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
font = font.resolve(static_cast<QWidget *>(w->parent())->font());
}
- if (w->data->fnt == font)
+ if (wf.resolve() == font.resolve() && wf == font)
return;
w->data->fnt = font;
+ w->d_func()->directFontResolveMask = font.resolve();
QEvent e(QEvent::FontChange);
QApplication::sendEvent(w, &e);
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 e3c29ff6ee..48253b52b0 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2283,7 +2283,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/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index d6f6a364a8..57f2dec8f7 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -312,10 +312,11 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
QTextBlock block = changeStartBlock;
do {
block.clearLayout();
- const int lineCount = block.isVisible() ? 1 : 0;
- if (block.lineCount() != lineCount) {
+ if (block.isVisible()
+ ? (block.lineCount() == 0)
+ : (block.lineCount() > 0)) {
blockVisibilityChanged = true;
- block.setLineCount(lineCount);
+ block.setLineCount(block.isVisible() ? 1 : 0);
}
if (block == changeEndBlock)
break;
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();
}
/*!