summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/CMakeLists.txt11
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp15
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp12
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp13
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.cpp2
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.h2
-rw-r--r--src/widgets/doc/snippets/customviewstyle/CMakeLists.txt11
-rw-r--r--src/widgets/doc/snippets/filedialogurls/CMakeLists.txt9
-rw-r--r--src/widgets/doc/snippets/graphicssceneadditem/CMakeLists.txt9
-rw-r--r--src/widgets/doc/snippets/graphicsview/CMakeLists.txt12
-rw-r--r--src/widgets/doc/snippets/mdiarea/CMakeLists.txt9
-rw-r--r--src/widgets/doc/snippets/myscrollarea/CMakeLists.txt9
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.cpp2
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.h2
-rw-r--r--src/widgets/doc/snippets/snippets.pro3
-rw-r--r--src/widgets/doc/src/qt6-changes.qdoc14
-rw-r--r--src/widgets/doc/src/qtwidgets-index.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp56
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp6
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp6
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp10
-rw-r--r--src/widgets/itemviews/qheaderview.cpp48
-rw-r--r--src/widgets/itemviews/qheaderview_p.h3
-rw-r--r--src/widgets/itemviews/qlistview.cpp4
-rw-r--r--src/widgets/itemviews/qtableview.cpp8
-rw-r--r--src/widgets/itemviews/qtreeview.cpp4
-rw-r--r--src/widgets/kernel/qgridlayout.cpp6
-rw-r--r--src/widgets/kernel/qwidget.cpp1
-rw-r--r--src/widgets/kernel/qwidget.h2
-rw-r--r--src/widgets/styles/qcommonstyle.cpp17
-rw-r--r--src/widgets/styles/qfusionstyle.cpp13
-rw-r--r--src/widgets/styles/qstyle.cpp3
-rw-r--r--src/widgets/styles/qstyle.h2
-rw-r--r--src/widgets/styles/qstylehelper.cpp8
-rw-r--r--src/widgets/styles/qstyleoption.cpp37
-rw-r--r--src/widgets/styles/qstyleoption.h22
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp28
-rw-r--r--src/widgets/util/qcompleter.cpp1
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp5
-rw-r--r--src/widgets/widgets/qcombobox.cpp8
-rw-r--r--src/widgets/widgets/qdial.cpp22
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp4
-rw-r--r--src/widgets/widgets/qlabel.cpp17
-rw-r--r--src/widgets/widgets/qlabel.h6
-rw-r--r--src/widgets/widgets/qlabel_p.h2
-rw-r--r--src/widgets/widgets/qlineedit.cpp22
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp16
-rw-r--r--src/widgets/widgets/qlineedit_p.h6
-rw-r--r--src/widgets/widgets/qmainwindow.cpp3
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp4
-rw-r--r--src/widgets/widgets/qmenu.cpp5
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp14
-rw-r--r--src/widgets/widgets/qsizegrip.cpp28
-rw-r--r--src/widgets/widgets/qsplitter.cpp13
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp11
-rw-r--r--src/widgets/widgets/qtextedit.cpp8
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp9
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h3
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp16
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h2
64 files changed, 476 insertions, 184 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 34c8d2bc1e..3c049c4061 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -824,3 +824,14 @@ qt_internal_add_docs(Widgets
doc/qtwidgets.qdocconf
)
+# include the snippet projects for developer-builds
+if(QT_FEATURE_private_tests)
+ add_subdirectory(doc/snippets/customviewstyle)
+ add_subdirectory(doc/snippets/filedialogurls)
+ add_subdirectory(doc/snippets/graphicssceneadditem)
+ if(QT_FEATURE_opengl AND QT_FEATURE_printdialog)
+ add_subdirectory(doc/snippets/graphicsview)
+ endif()
+ add_subdirectory(doc/snippets/mdiarea)
+ add_subdirectory(doc/snippets/myscrollarea)
+endif()
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index ad2a025090..931b8a69e3 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1335,21 +1335,14 @@ QList<QUrl> QFileDialog::selectedUrls() const
*/
QStringList qt_make_filter_list(const QString &filter)
{
- QString f(filter);
-
- if (f.isEmpty())
+ if (filter.isEmpty())
return QStringList();
QString sep(QLatin1String(";;"));
- int i = f.indexOf(sep, 0);
- if (i == -1) {
- if (f.indexOf(QLatin1Char('\n'), 0) != -1) {
- sep = QLatin1Char('\n');
- i = f.indexOf(sep, 0);
- }
- }
+ if (!filter.contains(sep) && filter.contains(QLatin1Char('\n')))
+ sep = QLatin1Char('\n');
- return f.split(sep);
+ return filter.split(sep);
}
/*!
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 6e7253b789..f1c844df5e 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -575,7 +575,7 @@ void QFontDialogPrivate::updateStyles()
QString cstyle = style;
redo:
- for (int i = 0; i < (int)styleList->count(); i++) {
+ for (int i = 0; i < static_cast<int>(styleList->count()); i++) {
if (cstyle == styleList->text(i)) {
styleList->setCurrentItem(i);
found = true;
@@ -591,6 +591,14 @@ void QFontDialogPrivate::updateStyles()
cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));
first = false;
goto redo;
+ } else if (cstyle.contains(QLatin1String("Regular"))) {
+ cstyle.replace(QLatin1String("Regular"), QLatin1String("Normal"));
+ first = false;
+ goto redo;
+ } else if (cstyle.contains(QLatin1String("Normal"))) {
+ cstyle.replace(QLatin1String("Normal"), QLatin1String("Regular"));
+ first = false;
+ goto redo;
}
}
if (!found)
@@ -804,7 +812,7 @@ void QFontDialog::changeEvent(QEvent *e)
void QFontDialog::setCurrentFont(const QFont &font)
{
Q_D(QFontDialog);
- d->family = font.families().first();
+ d->family = font.families().value(0);
d->style = QFontDatabase::styleString(font);
d->size = font.pointSize();
if (d->size == -1) {
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index d8d642c48c..1a8006944b 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -99,9 +99,10 @@ public:
#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent * e) override
{
- QMenu *menu = createStandardContextMenu();
- menu->setAttribute(Qt::WA_DeleteOnClose);
- menu->popup(e->globalPos());
+ if (QMenu *menu = createStandardContextMenu()) {
+ menu->setAttribute(Qt::WA_DeleteOnClose);
+ menu->popup(e->globalPos());
+ }
}
#endif // QT_NO_CONTEXTMENU
};
@@ -1891,7 +1892,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
"<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"
"<p>Qt is The Qt Company Ltd product developed as an open source "
"project. See <a href=\"http://%3/\">%3</a> for more information.</p>"
- ).arg(QStringLiteral("2020"),
+ ).arg(QStringLiteral("2021"),
QStringLiteral("qt.io/licensing"),
QStringLiteral("qt.io"));
QMessageBox *msgBox = new QMessageBox(parent);
@@ -2043,7 +2044,7 @@ int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon ico
void QMessageBoxPrivate::retranslateStrings()
{
#if QT_CONFIG(textedit)
- if (detailsButton)
+ if (detailsButton && detailsText)
detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
#endif
}
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.cpp b/src/widgets/doc/snippets/customstyle/customstyle.cpp
index 61a8ec5600..0f1d5f4b9b 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.cpp
+++ b/src/widgets/doc/snippets/customstyle/customstyle.cpp
@@ -52,7 +52,7 @@
#include "customstyle.h"
-CustomStyle::CustomStyle()
+CustomStyle::CustomStyle(const QWidget *widget)
{
//! [0]
const QSpinBox *spinBox = qobject_cast<const QSpinBox *>(widget);
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.h b/src/widgets/doc/snippets/customstyle/customstyle.h
index be9edf0bf4..3cadd84650 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.h
+++ b/src/widgets/doc/snippets/customstyle/customstyle.h
@@ -59,7 +59,7 @@ class CustomStyle : public QProxyStyle
Q_OBJECT
public:
- CustomStyle();
+ CustomStyle(const QWidget *widget);
~CustomStyle() {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
diff --git a/src/widgets/doc/snippets/customviewstyle/CMakeLists.txt b/src/widgets/doc/snippets/customviewstyle/CMakeLists.txt
new file mode 100644
index 0000000000..4e9f7ca210
--- /dev/null
+++ b/src/widgets/doc/snippets/customviewstyle/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_library(widgets_customviewstyle_snippets OBJECT
+ ../customstyle/customstyle.h
+ ../customstyle/customstyle.cpp
+ customviewstyle.cpp
+)
+
+target_link_libraries(widgets_customviewstyle_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+)
diff --git a/src/widgets/doc/snippets/filedialogurls/CMakeLists.txt b/src/widgets/doc/snippets/filedialogurls/CMakeLists.txt
new file mode 100644
index 0000000000..8fd3d7a4bb
--- /dev/null
+++ b/src/widgets/doc/snippets/filedialogurls/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(widgets_filedialogurl_snippets OBJECT
+ filedialogurls.cpp
+)
+
+target_link_libraries(widgets_filedialogurl_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+)
diff --git a/src/widgets/doc/snippets/graphicssceneadditem/CMakeLists.txt b/src/widgets/doc/snippets/graphicssceneadditem/CMakeLists.txt
new file mode 100644
index 0000000000..c9b2c7b377
--- /dev/null
+++ b/src/widgets/doc/snippets/graphicssceneadditem/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(widgets_graphicssceneadditem_snippets OBJECT
+ graphicssceneadditemsnippet.cpp
+)
+
+target_link_libraries(widgets_graphicssceneadditem_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+)
diff --git a/src/widgets/doc/snippets/graphicsview/CMakeLists.txt b/src/widgets/doc/snippets/graphicsview/CMakeLists.txt
new file mode 100644
index 0000000000..182709fcd4
--- /dev/null
+++ b/src/widgets/doc/snippets/graphicsview/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_library(widgets_graphicsview_snippets OBJECT
+ graphicsview.cpp
+)
+
+target_link_libraries(widgets_graphicsview_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+ Qt::OpenGL
+ Qt::OpenGLWidgets
+ Qt::PrintSupport
+)
diff --git a/src/widgets/doc/snippets/mdiarea/CMakeLists.txt b/src/widgets/doc/snippets/mdiarea/CMakeLists.txt
new file mode 100644
index 0000000000..e4c2dd93a5
--- /dev/null
+++ b/src/widgets/doc/snippets/mdiarea/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(widgets_mdiarea_snippets OBJECT
+ mdiareasnippets.cpp
+)
+
+target_link_libraries(widgets_mdiarea_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+)
diff --git a/src/widgets/doc/snippets/myscrollarea/CMakeLists.txt b/src/widgets/doc/snippets/myscrollarea/CMakeLists.txt
new file mode 100644
index 0000000000..49d7e1c81f
--- /dev/null
+++ b/src/widgets/doc/snippets/myscrollarea/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(widgets_myscrollarea_snippets OBJECT
+ myscrollarea.cpp
+)
+
+target_link_libraries(widgets_myscrollarea_snippets PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Widgets
+)
diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.cpp b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
index 6835479e7a..4f3ad8db4c 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/model.cpp
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
@@ -66,7 +66,7 @@ DragDropListModel::DragDropListModel(const QStringList &strings,
//! [0]
bool DragDropListModel::canDropMimeData(const QMimeData *data,
- Qt::DropAction action, int row, int column, const QModelIndex &parent)
+ Qt::DropAction action, int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(action);
Q_UNUSED(row);
diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.h b/src/widgets/doc/snippets/qlistview-dnd/model.h
index 3d723f9540..4d6867b384 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/model.h
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.h
@@ -64,7 +64,7 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent) override;
+ int row, int column, const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
diff --git a/src/widgets/doc/snippets/snippets.pro b/src/widgets/doc/snippets/snippets.pro
new file mode 100644
index 0000000000..6e5c07edf7
--- /dev/null
+++ b/src/widgets/doc/snippets/snippets.pro
@@ -0,0 +1,3 @@
+#! [qmake_use]
+QT += widgets
+#! [qmake_use]
diff --git a/src/widgets/doc/src/qt6-changes.qdoc b/src/widgets/doc/src/qt6-changes.qdoc
index 585021efeb..1f8e97a4ad 100644
--- a/src/widgets/doc/src/qt6-changes.qdoc
+++ b/src/widgets/doc/src/qt6-changes.qdoc
@@ -43,7 +43,7 @@
\section1 Kernel classes
- \section2 QWidget
+ \section2 The QWidget class
The virtual QWidget::enterEvent() handler now receives a QEnterEvent*
parameter which has information about the pointer position, rather than
@@ -71,15 +71,23 @@
\section1 Widgets
- \section2 QAbstractButton
+ \section2 The QAbstractButton class
The default timeout parameter for QAbstractButton::animateClick() is
removed to allow modern connection syntax without the need for qOverload.
- \section2 QComboBox
+ \section2 The QComboBox class
The QComboBox::setModel() function is now virtual.
+ \section1 ItemViews
+
+ \section2 The QAbstractItemView class
+
+ The virtual viewOptions() method that previously returned a QStyleOptionViewItem
+ object has been renamed to initViewItemOption, and initializes a
+ QStyleOptionViewItem object that's passed in through a pointer.
+
\section1 Styling Classes and related APIs
All versioned QStyleOption subclasses are consolidated, and the version
diff --git a/src/widgets/doc/src/qtwidgets-index.qdoc b/src/widgets/doc/src/qtwidgets-index.qdoc
index de7cb1084a..57ed0e69c1 100644
--- a/src/widgets/doc/src/qtwidgets-index.qdoc
+++ b/src/widgets/doc/src/qtwidgets-index.qdoc
@@ -119,7 +119,7 @@ interfaces
See also the \l {Build with CMake} overview.
\include module-use.qdocinc building with qmake
- \snippet snippets/snippets.pro qmake_use
+ \snippet snippets.pro qmake_use
\section1 Module Evolution
\l{Changes to Qt Widgets} lists important changes in the module API
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index be26b2785e..9da290974b 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -225,7 +225,7 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
if (anchorPrivate->hasSize) {
// Anchor has user-defined size
prefSizeHint = anchorPrivate->preferredSize;
- } else {
+ } else if (styleInfo) {
// Fetch size information from style
const Qt::Orientation orient = QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge);
qreal s = styleInfo->defaultSpacing(orient);
@@ -241,6 +241,8 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
s = 0;
}
prefSizeHint = s;
+ } else {
+ prefSizeHint = 0;
}
}
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index e426e09adf..7dcfd47dc0 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -2652,23 +2652,25 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
// Certain properties are dropped when an item is disabled.
if (!newEnabled) {
- if (scene && scene->mouseGrabberItem() == q_ptr)
- q_ptr->ungrabMouse();
- if (q_ptr->hasFocus()) {
- // Disabling the closest non-panel ancestor of the focus item
- // causes focus to pop to the next item, otherwise it's cleared.
- QGraphicsItem *focusItem = scene->focusItem();
- bool clear = true;
- if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
- do {
- if (focusItem == q_ptr) {
- clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
- break;
- }
- } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
+ if (scene) {
+ if (scene->mouseGrabberItem() == q_ptr)
+ q_ptr->ungrabMouse();
+ if (q_ptr->hasFocus()) {
+ // Disabling the closest non-panel ancestor of the focus item
+ // causes focus to pop to the next item, otherwise it's cleared.
+ QGraphicsItem *focusItem = scene->focusItem();
+ bool clear = true;
+ if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
+ do {
+ if (focusItem == q_ptr) {
+ clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
+ break;
+ }
+ } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
+ }
+ if (clear)
+ q_ptr->clearFocus();
}
- if (clear)
- q_ptr->clearFocus();
}
if (q_ptr->isSelected())
q_ptr->setSelected(false);
@@ -7149,14 +7151,14 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
QPointF currentParentPos;
QPointF buttonDownParentPos;
- if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
+ if (view && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations)) {
// Items whose ancestors ignore transformations need to
// map screen coordinates to local coordinates, then map
// those to the parent.
QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();
currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));
buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));
- } else if (item->flags() & ItemIgnoresTransformations) {
+ } else if (view && (item->flags() & ItemIgnoresTransformations)) {
// Root items that ignore transformations need to
// calculate their diff by mapping viewport coordinates
// directly to parent coordinates.
@@ -10309,14 +10311,16 @@ QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
v = int(inputMethodHints());
else if (dd->control)
v = dd->control->inputMethodQuery(query, QVariant());
- if (v.userType() == QMetaType::QRectF)
- v = v.toRectF().translated(-dd->controlOffset());
- else if (v.userType() == QMetaType::QPointF)
- v = v.toPointF() - dd->controlOffset();
- else if (v.userType() == QMetaType::QRect)
- v = v.toRect().translated(-dd->controlOffset().toPoint());
- else if (v.userType() == QMetaType::QPoint)
- v = v.toPoint() - dd->controlOffset().toPoint();
+ if (dd->control) {
+ if (v.userType() == QMetaType::QRectF)
+ v = v.toRectF().translated(-dd->controlOffset());
+ else if (v.userType() == QMetaType::QPointF)
+ v = v.toPointF() - dd->controlOffset();
+ else if (v.userType() == QMetaType::QRect)
+ v = v.toRect().translated(-dd->controlOffset().toPoint());
+ else if (v.userType() == QMetaType::QPoint)
+ v = v.toPoint() - dd->controlOffset().toPoint();
+ }
return v;
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 2e65effb1a..dd54a4bffa 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4821,7 +4821,7 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
qreal opacity, const QTransform *effectTransform,
bool wasDirtyParentSceneTransform, bool drawItem)
{
- const auto children = item->d_ptr->children;
+ const auto &children = item->d_ptr->children;
const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index fea9e18b9c..a4b1b8ea6c 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -2143,7 +2143,7 @@ void QGraphicsWidget::setTabOrder(QGraphicsWidget *first, QGraphicsWidget *secon
return;
}
QGraphicsScene *scene = first ? first->scene() : second->scene();
- if (!scene && (!first || !second)) {
+ if (!scene) {
qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
" scene requires the item to be in a scene.");
return;
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 0580c6d938..d989455596 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -784,7 +784,8 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new
// detach from current focus chain; skip this widget subtree.
focusBefore->d_func()->focusNext = focusAfter;
- focusAfter->d_func()->focusPrev = focusBefore;
+ if (focusAfter)
+ focusAfter->d_func()->focusPrev = focusBefore;
if (newParent) {
// attach to new parent's focus chain as the last element
@@ -800,7 +801,8 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new
newFocusLast->d_func()->focusNext = q;
focusLast->d_func()->focusNext = newFocusAfter;
- newFocusAfter->d_func()->focusPrev = focusLast;
+ if (newFocusAfter)
+ newFocusAfter->d_func()->focusPrev = focusLast;
focusPrev = newFocusLast;
} else {
// no new parent, so just link up our own prev->last widgets.
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 3b2d1a80ff..f675092bd0 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -369,10 +369,12 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
{
if (!event || !view)
return false;
- Q_D(QAbstractItemDelegate);
+ Q_UNUSED(index);
+ Q_UNUSED(option);
switch (event->type()) {
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
+ Q_D(QAbstractItemDelegate);
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
const QString tooltip = index.isValid() ?
@@ -393,6 +395,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
event->setAccepted(index.data(Qt::WhatsThisRole).isValid());
break;
case QEvent::WhatsThis: {
+ Q_D(QAbstractItemDelegate);
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
const QString whatsthis = index.isValid() ?
@@ -403,6 +406,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
break;
}
#endif
+ case QEvent::None:
default:
break;
}
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index d0bd4bc9a5..0530621cae 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -172,17 +172,9 @@ QIcon QFileIconProvider::icon(IconType type) const
return QIcon();
}
-static inline QPlatformTheme::IconOptions toThemeIconOptions(QFileIconProvider::Options options)
-{
- QPlatformTheme::IconOptions result;
- if (options & QFileIconProvider::DontUseCustomDirectoryIcons)
- result |= QPlatformTheme::DontUseCustomDirectoryIcons;
- return result;
-}
-
QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const
{
- return QGuiApplicationPrivate::platformTheme()->fileIcon(fi, toThemeIconOptions(options));
+ return getPlatformThemeIcon(fi);
}
/*!
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 8ddbbd903a..27866ecbb0 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2362,7 +2362,7 @@ void QHeaderView::initializeSections(int start, int end)
d->contentsSections = newSectionCount;
if (newSectionCount > oldCount)
- d->createSectionItems(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode);
+ d->createSectionItems(start, end, d->defaultSectionSize, d->globalResizeMode);
//Q_ASSERT(d->headerLength() == d->length);
if (d->sectionCount() != oldCount)
@@ -2572,7 +2572,8 @@ void QHeaderView::mousePressEvent(QMouseEvent *e)
acceptMoveSection = false; // Do not allow moving the tree nod
if (acceptMoveSection) {
- d->section = d->target = d->pressed;
+ d->target = -1;
+ d->section = d->pressed;
if (d->section == -1)
return;
d->state = QHeaderViewPrivate::MoveSection;
@@ -2645,6 +2646,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
const int posThreshold = d->headerSectionPosition(visual) - d->offset + d->headerSectionSize(visual) / 2;
const int checkPos = d->reverse() ? d->viewport->width() - pos : pos;
int moving = visualIndex(d->section);
+ int oldTarget = d->target;
if (visual < moving) {
if (checkPos < posThreshold)
d->target = d->logicalIndex(visual);
@@ -2658,6 +2660,8 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
} else {
d->target = d->section;
}
+ if (oldTarget != d->target || oldTarget == -1)
+ d->updateSectionsBeforeAfter(d->target);
d->updateSectionIndicator(d->section, pos);
}
return;
@@ -2729,6 +2733,8 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
moveSection(from, to);
d->section = d->target = -1;
d->updateSectionIndicator(d->section, pos);
+ if (from == to)
+ d->updateSectionsBeforeAfter(from);
break;
} // not moving
Q_FALLTHROUGH();
@@ -2904,6 +2910,7 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica
if (!option)
return;
QStyleOptionHeader &opt = *option;
+ QStyleOptionHeaderV2 *optV2 = qstyleoption_cast<QStyleOptionHeaderV2*>(option);
QStyle::State state = QStyle::State_None;
if (window()->isActiveWindow())
@@ -2947,7 +2954,8 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica
Qt::FontRole);
if (var.isValid() && var.canConvert<QFont>())
opt.fontMetrics = QFontMetrics(qvariant_cast<QFont>(var));
- opt.textElideMode = d->textElideMode;
+ if (optV2)
+ optV2->textElideMode = d->textElideMode;
QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation,
Qt::ForegroundRole);
@@ -2986,6 +2994,8 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica
opt.selectedPosition = QStyleOptionHeader::NextIsSelected;
else
opt.selectedPosition = QStyleOptionHeader::NotAdjacent;
+ if (optV2)
+ optV2->isSectionDragTarget = d->target == logicalIndex;
}
/*!
@@ -3000,7 +3010,7 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
if (!rect.isValid())
return;
- QStyleOptionHeader opt;
+ QStyleOptionHeaderV2 opt;
QPointF oldBO = painter->brushOrigin();
initStyleOption(&opt);
@@ -3045,7 +3055,7 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const
return qvariant_cast<QSize>(variant);
// otherwise use the contents
- QStyleOptionHeader opt;
+ QStyleOptionHeaderV2 opt;
initStyleOption(&opt);
opt.section = logicalIndex;
QVariant var = d->model->headerData(logicalIndex, d->orientation,
@@ -3674,8 +3684,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
//Q_ASSERT(newSectionLength > 0);
if ((previousSectionResizeMode != newSectionResizeMode
|| previousSectionLength != newSectionLength) && i > 0) {
- int spanLength = (i - spanStartSection) * previousSectionLength;
- createSectionItems(spanStartSection, i - 1, spanLength, previousSectionResizeMode);
+ createSectionItems(spanStartSection, i - 1, previousSectionLength, previousSectionResizeMode);
//Q_ASSERT(headerLength() == length);
spanStartSection = i;
}
@@ -3688,16 +3697,14 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
}
createSectionItems(spanStartSection, sectionCount() - 1,
- (sectionCount() - spanStartSection) * previousSectionLength,
- previousSectionResizeMode);
+ previousSectionLength, previousSectionResizeMode);
//Q_ASSERT(headerLength() == length);
resizeRecursionBlock = false;
viewport->update();
}
-void QHeaderViewPrivate::createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode)
+void QHeaderViewPrivate::createSectionItems(int start, int end, int sizePerSection, QHeaderView::ResizeMode mode)
{
- int sizePerSection = size / (end - start + 1);
if (end >= sectionItems.count()) {
sectionItems.resize(end + 1);
sectionStartposRecalc = true;
@@ -4047,6 +4054,25 @@ void QHeaderViewPrivate::setScrollOffset(const QScrollBar *scrollBar, QAbstractI
}
}
+void QHeaderViewPrivate::updateSectionsBeforeAfter(int logical)
+{
+ Q_Q(QHeaderView);
+ const int visual = visualIndex(logical);
+ int from = logicalIndex(visual > 1 ? visual - 1 : 0);
+ int to = logicalIndex(visual + 1 >= sectionCount() ? visual : visual + 1);
+ QRect updateRect;
+ if (orientation == Qt::Horizontal) {
+ if (reverse())
+ std::swap(from, to);
+ updateRect = QRect(QPoint(q->sectionViewportPosition(from), 0),
+ QPoint(q->sectionViewportPosition(to) + headerSectionSize(to), viewport->height()));
+ } else {
+ updateRect = QRect(QPoint(0, q->sectionViewportPosition(from)),
+ QPoint(viewport->width(), q->sectionViewportPosition(to) + headerSectionSize(to)));
+ }
+ viewport->update(updateRect);
+}
+
#ifndef QT_NO_DATASTREAM
void QHeaderViewPrivate::write(QDataStream &out) const
{
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index 7c1ff94646..130220523f 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -341,7 +341,7 @@ public:
};
QList<LayoutChangeItem> layoutChangePersistentSections;
- void createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode);
+ void createSectionItems(int start, int end, int sectionSize, QHeaderView::ResizeMode mode);
void removeSectionsFromSectionItems(int start, int end);
void resizeSectionItem(int visualIndex, int oldSize, int newSize);
void setDefaultSectionSize(int size);
@@ -385,6 +385,7 @@ public:
int viewSectionSizeHint(int logical) const;
int adjustedVisualIndex(int visualIndex) const;
void setScrollOffset(const QScrollBar *scrollBar, QAbstractItemView::ScrollMode scrollMode);
+ void updateSectionsBeforeAfter(int logical);
#ifndef QT_NO_DATASTREAM
void write(QDataStream &out) const;
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 27b4402e88..216f44fd9c 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -683,7 +683,7 @@ void QListView::reset()
}
/*!
- \internal
+ \reimp
*/
void QListView::setRootIndex(const QModelIndex &index)
{
@@ -696,7 +696,7 @@ void QListView::setRootIndex(const QModelIndex &index)
}
/*!
- \internal
+ \reimp
Scroll the view contents by \a dx and \a dy.
*/
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 05d8807e10..4dcd92f29f 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1431,7 +1431,7 @@ void QTableView::setVerticalHeader(QHeaderView *header)
}
/*!
- \internal
+ \reimp
Scroll the contents of the table view by (\a dx, \a dy).
*/
@@ -2069,7 +2069,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
}
/*!
- \internal
+ \reimp
Returns the rectangle from the viewport of the items in the given
\a selection.
@@ -2812,7 +2812,7 @@ bool QTableView::isCornerButtonEnabled() const
#endif
/*!
- \internal
+ \reimp
Returns the rectangle on the viewport occupied by the given \a
index.
@@ -2842,7 +2842,7 @@ QRect QTableView::visualRect(const QModelIndex &index) const
}
/*!
- \internal
+ \reimp
Makes sure that the given \a item is visible in the table view,
scrolling if necessary.
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index c0b0ee4f2d..49585d8b26 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1486,7 +1486,8 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, c
void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
{
Q_D(const QTreeView);
- const QList<QTreeViewItem> viewItems = d->viewItems;
+ // d->viewItems changes when posted layouts are executed in itemDecorationAt, so don't copy
+ const QList<QTreeViewItem> &viewItems = d->viewItems;
QStyleOptionViewItem option;
initViewItemOption(&option);
@@ -3484,6 +3485,7 @@ int QTreeViewPrivate::indentationForItem(int item) const
int QTreeViewPrivate::itemHeight(int item) const
{
+ Q_ASSERT(item < viewItems.count());
if (uniformRowHeights)
return defaultItemHeight;
if (viewItems.isEmpty())
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 121bae0352..336a68cd80 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -149,14 +149,14 @@ public:
QRect cellRect(int row, int col) const;
inline QLayoutItem *itemAt(int index) const {
- if (index < things.count())
+ if (index >= 0 && index < things.count())
return things.at(index)->item();
else
return nullptr;
}
inline QLayoutItem *takeAt(int index) {
Q_Q(QGridLayout);
- if (index < things.count()) {
+ if (index >= 0 && index < things.count()) {
if (QGridBox *b = things.takeAt(index)) {
QLayoutItem *item = b->takeItem();
if (QLayout *l = item->layout()) {
@@ -184,7 +184,7 @@ public:
}
void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const {
- if (index < things.count()) {
+ if (index >= 0 && index < things.count()) {
const QGridBox *b = things.at(index);
int toRow = b->toRow(rr);
int toCol = b->toCol(cc);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index b4be9bbfe7..99a6a24aff 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1246,6 +1246,7 @@ void QWidgetPrivate::create()
// in case the extra was already valid.
if (!win) {
createTLSysExtra();
+ Q_ASSERT(topData()->window);
win = topData()->window;
}
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 11d143d0e4..75fefb8ffd 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -230,7 +230,7 @@ public:
void setStyle(QStyle *);
// Widget types and states
-#if QT_DEPRECATED_SINCE(6, 2)
+#if QT_DEPRECATED_SINCE(6, 1)
QT_DEPRECATED_VERSION_X_6_1("Use isWindow()")
bool isTopLevel() const;
#endif
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 3bdababe2c..358edc230b 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1682,11 +1682,11 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
p->setFont(fnt);
fm = QFontMetrics((p->font()));
}
- QString text;
- if (header->textElideMode != Qt::ElideNone)
- text = fm.elidedText(header->text, header->textElideMode, rect.width());
- else
- text = header->text;
+ QString text = header->text;
+ if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
+ if (headerV2->textElideMode != Qt::ElideNone)
+ text = fm.elidedText(header->text, headerV2->textElideMode, rect.width());
+ }
proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
header->state.testFlag(State_Enabled), text, QPalette::ButtonText);
}
@@ -3230,8 +3230,8 @@ static StaticPolygonF<3> calcArrow(const QStyleOptionSlider *dial, qreal &a)
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
/ (dial->maximum - dial->minimum)) / 6;
- int xc = width / 2;
- int yc = height / 2;
+ int xc = width / 2 + dial->rect.left();
+ int yc = height / 2 + dial->rect.top();
int len = r - QStyleHelper::calcBigLineSize(r) - 5;
if (len < 5)
@@ -4828,6 +4828,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_IconViewIconSize:
ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
break;
+ case PM_LineEditIconSize:
+ ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
+ break;
case PM_LargeIconSize:
ret = int(QStyleHelper::dpiScaled(32, opt));
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index ab5cb80843..5772c7d4c4 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1280,9 +1280,12 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
painter->save();
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
+ const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(option);
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
pixmapName += QString::number(- int(header->position));
pixmapName += QString::number(- int(header->orientation));
+ if (headerV2)
+ pixmapName += QString::number(- int(headerV2->isSectionDragTarget));
QPixmap cache;
if (!QPixmapCache::find(pixmapName, &cache)) {
@@ -1291,9 +1294,12 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QRect pixmapRect(0, 0, rect.width(), rect.height());
QPainter cachePainter(&cache);
QColor buttonColor = d->buttonColor(option->palette);
- QColor gradientStopColor;
QColor gradientStartColor = buttonColor.lighter(104);
- gradientStopColor = buttonColor.darker(102);
+ QColor gradientStopColor = buttonColor.darker(102);
+ if (headerV2 && headerV2->isSectionDragTarget) {
+ gradientStopColor = gradientStartColor.darker(130);
+ gradientStartColor = gradientStartColor.darker(130);
+ }
QLinearGradient gradient(pixmapRect.topLeft(), pixmapRect.bottomLeft());
if (option->palette.window().gradient()) {
@@ -1723,12 +1729,13 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
font.setBold(true);
p->setFont(font);
- const QString textToDraw = s.left(t).toString();
+ QString textToDraw = s.left(t).toString();
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
p->setPen(menuitem->palette.light().color());
p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
p->setPen(discol);
}
+ textToDraw = menuitem->fontMetrics.elidedText(textToDraw, Qt::ElideMiddle, vTextRect.width());
p->drawText(vTextRect, text_flags, textToDraw);
p->restore();
}
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 8aa423c224..9c4e66b0ba 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1516,6 +1516,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value PM_TitleBarButtonSize The size of buttons on a title bar.
This enum value has been introduced in Qt 5.8.
+ \value PM_LineEditIconSize The default size for icons in a line edit.
+ This enum value has been introduced in Qt 6.2.
+
\value PM_CustomBase Base value for custom pixel metrics. Custom
values must be greater than this value.
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index ba64a6b1bf..c3c99d9974 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -567,6 +567,8 @@ public:
PM_TitleBarButtonIconSize,
PM_TitleBarButtonSize,
+ PM_LineEditIconSize,
+
// do not add any values below/greater than this
PM_CustomBase = 0xf0000000
};
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index d8e0495b37..377df7705b 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -181,7 +181,7 @@ static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
qreal back = offset * len;
QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
- return pos;
+ return pos + dial->rect.topLeft();
}
qreal angle(const QPointF &p1, const QPointF &p2)
@@ -254,7 +254,7 @@ QPolygonF calcLines(const QStyleOptionSlider *dial)
poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
}
}
- return poly;
+ return poly.translated(dial->rect.topLeft());
}
// This will draw a nice and shiny QDial for us. We don't want
@@ -291,8 +291,8 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
p->setRenderHint(QPainter::Antialiasing);
const qreal d_ = r / 6;
- const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
- const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
+ const qreal dx = d_ + (width - 2 * r) / 2 + 1;
+ const qreal dy = d_ + (height - 2 * r) / 2 + 1;
QRectF br = QRectF(dx + 0.5, dy + 0.5,
int(r * 2 - 2 * d_ - 2),
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 6e994dc8dc..fba7bd071d 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -748,7 +748,7 @@ QStyleOptionHeader::QStyleOptionHeader(int version)
section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
position(QStyleOptionHeader::Beginning),
selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
- orientation(Qt::Horizontal), textElideMode(Qt::ElideNone), unused(0)
+ orientation(Qt::Horizontal)
{
}
@@ -892,7 +892,31 @@ QStyleOptionHeader::QStyleOptionHeader(int version)
*/
/*!
- \variable QStyleOptionHeader::textElideMode
+ \class QStyleOptionHeaderV2
+ \brief The QStyleOptionHeaderV2 class is used to describe the
+ parameters for drawing a header.
+
+ \inmodule QtWidgets
+*/
+
+/*!
+ Constructs a QStyleOptionHeaderV2, initializing the members
+ variables to their default values.
+*/
+QStyleOptionHeaderV2::QStyleOptionHeaderV2()
+ : QStyleOptionHeaderV2(QStyleOptionHeaderV2::Version)
+{
+}
+
+/*!
+ \internal
+*/
+QStyleOptionHeaderV2::QStyleOptionHeaderV2(int version)
+: QStyleOptionHeader(version), textElideMode(Qt::ElideNone), isSectionDragTarget(false), unused(0)
+{}
+
+/*!
+ \variable QStyleOptionHeaderV2::textElideMode
\brief where ellipsis should be added for text that is too long to fit
into an item
@@ -902,6 +926,15 @@ QStyleOptionHeader::QStyleOptionHeader(int version)
*/
/*!
+ \variable QStyleOptionHeaderV2::isSectionDragTarget
+
+ \brief whether the section is the location at which a dragged section
+ will be inserted
+
+ \sa QHeaderView::setSectionsMovable
+*/
+
+/*!
\class QStyleOptionButton
\brief The QStyleOptionButton class is used to describe the
parameters for drawing buttons.
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 4998d8cf14..0f41211521 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -219,9 +219,7 @@ public:
SectionPosition position;
SelectedPosition selectedPosition;
SortIndicator sortIndicator;
- Qt::Orientation orientation:2;
- Qt::TextElideMode textElideMode:2;
- int unused:28;
+ Qt::Orientation orientation;
QStyleOptionHeader();
QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
@@ -231,6 +229,24 @@ protected:
QStyleOptionHeader(int version);
};
+class Q_WIDGETS_EXPORT QStyleOptionHeaderV2 : public QStyleOptionHeader
+{
+public:
+ enum StyleOptionType { Type = SO_Header };
+ enum StyleOptionVersion { Version = 2 };
+
+ QStyleOptionHeaderV2();
+ QStyleOptionHeaderV2(const QStyleOptionHeaderV2 &other) : QStyleOptionHeader(Version) { *this = other; }
+ QStyleOptionHeaderV2 &operator=(const QStyleOptionHeaderV2 &) = default;
+
+ Qt::TextElideMode textElideMode:2;
+ bool isSectionDragTarget:1;
+ int unused:29;
+
+protected:
+ QStyleOptionHeaderV2(int version);
+};
+
class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption
{
public:
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index a200cc0cd1..068cc95ffe 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -60,6 +60,7 @@
#if QT_CONFIG(textedit)
#include <qtextedit.h>
#endif
+#include <qplaintextedit.h>
#include <private/qwindowsstyle_p.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
@@ -863,9 +864,9 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget
info.rule = subRule;
info.offset = offsets[where];
info.where = where;
- infos.append(std::move(info));
-
offsets[where] += info.width;
+
+ infos.append(std::move(info));
}
}
@@ -2106,6 +2107,9 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
}
#endif
+ else if (const QPlainTextEdit *edit = qobject_cast<const QPlainTextEdit *>(obj)) {
+ extraClass |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
+ }
#if QT_CONFIG(textedit)
else if (const QTextEdit *edit = qobject_cast<const QTextEdit *>(obj)) {
extraClass |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
@@ -2541,7 +2545,9 @@ static quint64 extendedPseudoClass(const QWidget *w)
pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
} else
#endif
- { } // required for the above ifdef'ery to work
+ if (const QPlainTextEdit *edit = qobject_cast<const QPlainTextEdit *>(w)) {
+ pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
+ }
return pc;
}
@@ -3542,7 +3548,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (btn->features & QStyleOptionButton::HasMenu) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator);
- QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction);
+ QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator,
+ baseStyle()->subElementRect(SE_PushButtonBevel, btn, w), opt->direction);
if (subRule.hasDrawable()) {
subRule.drawRule(p, ir);
} else {
@@ -3569,8 +3576,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight;
const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignBottom;
- const Qt::Alignment textAlignment = rule.position()->textAlignment;
- if (rule.hasPosition() && textAlignment != 0) {
+ if (rule.hasPosition() && rule.position()->textAlignment != 0) {
+ Qt::Alignment textAlignment = rule.position()->textAlignment;
tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) : Qt::AlignHCenter;
if (!styleHint(SH_UnderlineShortcut, button, w))
@@ -3629,8 +3636,6 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
pixelMetric(PM_ButtonShiftVertical, opt, w));
p->drawPixmap(iconRect, pixmap);
- }else {
- tf |= textAlignment;
}
if (button->state & (State_On | State_Sunken))
@@ -5857,6 +5862,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_PushButtonBevel:
case SE_PushButtonFocusRect:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ if (btn->features & QStyleOptionButton::HasMenu
+ && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator)) {
+ QStyleOptionButton btnOpt(*btn);
+ btnOpt.features &= ~QStyleOptionButton::HasMenu;
+ return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
+ : QWindowsStyle::subElementRect(se, &btnOpt, w);
+ }
if (rule.hasBox() || !rule.hasNativeBorder()) {
return visualRect(opt->direction, opt->rect, se == SE_PushButtonBevel
? rule.borderRect(opt->rect)
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 7bfd112f5c..13a28b628c 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -1329,6 +1329,7 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e)
if (o != d->popup)
return QObject::eventFilter(o, e);
+ Q_ASSERT(d->popup);
switch (e->type()) {
case QEvent::KeyPress: {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 4ceb85e9bf..5f35b85044 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -1111,16 +1111,17 @@ QTextCharFormat QCalendarModel::formatForCell(int row, int col) const
{
QPalette pal;
QPalette::ColorGroup cg = QPalette::Active;
+ QTextCharFormat format;
+
if (m_view) {
pal = m_view->palette();
if (!m_view->isEnabled())
cg = QPalette::Disabled;
else if (!m_view->isActiveWindow())
cg = QPalette::Inactive;
+ format.setFont(m_view->font());
}
- QTextCharFormat format;
- format.setFont(m_view->font());
bool header = (m_weekNumbersShown && col == HeaderColumn)
|| (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader && row == HeaderRow);
format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base));
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 65017be384..4f626f7428 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -1704,7 +1704,7 @@ void QComboBox::setPlaceholderText(const QString &placeholderText)
d->placeholderText = placeholderText;
if (currentIndex() == -1) {
- if (d->placeholderText.isEmpty() && currentIndex() == -1)
+ if (d->placeholderText.isEmpty())
setCurrentIndex(0);
else
update();
@@ -3028,8 +3028,10 @@ void QComboBox::paintEvent(QPaintEvent *)
initStyleOption(&opt);
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
- if (currentIndex() < 0)
- opt.palette.setBrush(QPalette::ButtonText, opt.palette.brush(QPalette::ButtonText).color().lighter());
+ if (currentIndex() < 0 && !placeholderText().isEmpty()) {
+ opt.palette.setBrush(QPalette::ButtonText, opt.palette.placeholderText());
+ opt.currentText = placeholderText();
+ }
// draw the icon and text
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp
index 934be4fb6e..594fe0a779 100644
--- a/src/widgets/widgets/qdial.cpp
+++ b/src/widgets/widgets/qdial.cpp
@@ -370,12 +370,10 @@ bool QDial::wrapping() const
\property QDial::notchSize
\brief the current notch size
- The notch size is in range control units, not pixels, and if
- possible it is a multiple of singleStep() that results in an
+ The notch size is in range control units, not pixels, and is
+ calculated to be a multiple of singleStep() that results in an
on-screen notch size near notchTarget().
- By default, this property has a value of 1.
-
\sa notchTarget(), singleStep()
*/
@@ -383,21 +381,17 @@ int QDial::notchSize() const
{
Q_D(const QDial);
// radius of the arc
- int r = qMin(width(), height())/2;
+ qreal r = qMin(width(), height())/2.0;
// length of the whole arc
- int l = (int)(r * (d->wrapping ? 6 : 5) * Q_PI / 6);
+ int l = qRound(r * (d->wrapping ? 6.0 : 5.0) * Q_PI / 6.0);
// length of the arc from minValue() to minValue()+pageStep()
if (d->maximum > d->minimum + d->pageStep)
- l = (int)(0.5 + l * d->pageStep / (d->maximum - d->minimum));
+ l = qRound(l * d->pageStep / double(d->maximum - d->minimum));
// length of a singleStep arc
- l = l * d->singleStep / (d->pageStep ? d->pageStep : 1);
- if (l < 1)
- l = 1;
+ l = qMax(l * d->singleStep / (d->pageStep ? d->pageStep : 1), 1);
// how many times singleStep can be draw in d->target pixels
- l = (int)(0.5 + d->target / l);
- // we want notchSize() to be a non-zero multiple of lineStep()
- if (!l)
- l = 1;
+ l = qMax(qRound(d->target / l), 1);
+ // we want notchSize() to be a non-zero multiple of singleStep()
return d->singleStep * l;
}
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 2654341505..7776ae6613 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -182,7 +182,11 @@ QSize QDockAreaLayoutItem::sizeHint() const
QDockAreaLayoutItem
&QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other)
{
+ if (this == &other)
+ return *this;
+
widgetItem = other.widgetItem;
+ delete subinfo;
if (other.subinfo == nullptr)
subinfo = nullptr;
else
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 2d7b7f79b1..377f2967cf 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -1429,7 +1429,7 @@ void QLabel::setTextFormat(Qt::TextFormat format)
Returns the resource provider for rich text of this label.
*/
-QUrlResourceProvider *QLabel::resourceProvider() const
+QTextDocument::ResourceProvider QLabel::resourceProvider() const
{
Q_D(const QLabel);
return d->control ? d->control->document()->resourceProvider() : d->resourceProvider;
@@ -1442,7 +1442,7 @@ QUrlResourceProvider *QLabel::resourceProvider() const
\note The label \e{does not} take ownership of the \a provider.
*/
-void QLabel::setResourceProvider(QUrlResourceProvider *provider)
+void QLabel::setResourceProvider(const QTextDocument::ResourceProvider &provider)
{
Q_D(QLabel);
d->resourceProvider = provider;
@@ -1694,14 +1694,13 @@ QPoint QLabelPrivate::layoutPoint(const QPoint& p) const
#ifndef QT_NO_CONTEXTMENU
QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos)
{
- QString linkToCopy;
- QPoint p;
- if (control && effectiveTextFormat != Qt::PlainText) {
- p = layoutPoint(pos);
- linkToCopy = control->document()->documentLayout()->anchorAt(p);
- }
+ if (!control || effectiveTextFormat == Qt::PlainText)
+ return nullptr;
+
+ const QPoint p = layoutPoint(pos);
+ QString linkToCopy = control->document()->documentLayout()->anchorAt(p);
- if (linkToCopy.isEmpty() && !control)
+ if (linkToCopy.isEmpty())
return nullptr;
return control->createStandardContextMenu(p, q_func());
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 69aea6d57a..05fb39e0fa 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -43,13 +43,13 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtGui/qpicture.h>
+#include <QtGui/qtextdocument.h>
QT_REQUIRE_CONFIG(label);
QT_BEGIN_NAMESPACE
-class QUrlResourceProvider;
class QLabelPrivate;
class Q_WIDGETS_EXPORT QLabel : public QFrame
@@ -93,8 +93,8 @@ public:
Qt::TextFormat textFormat() const;
void setTextFormat(Qt::TextFormat);
- QUrlResourceProvider *resourceProvider() const;
- void setResourceProvider(QUrlResourceProvider *provider);
+ QTextDocument::ResourceProvider resourceProvider() const;
+ void setResourceProvider(const QTextDocument::ResourceProvider &provider);
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment);
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 80243239d2..d26bbf6a7f 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -154,7 +154,7 @@ public:
#endif
uint openExternalLinks : 1;
// <-- space for more bit field values here
- QUrlResourceProvider *resourceProvider;
+ QTextDocument::ResourceProvider resourceProvider;
friend class QMessageBoxPrivate;
};
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 4a877c7596..a308f92f9d 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1806,7 +1806,7 @@ QRect QLineEdit::cursorRect() const
void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
{
Q_D(QLineEdit);
- if (d->control->isReadOnly()) {
+ if (!d->shouldEnableInputMethod()) {
e->ignore();
return;
}
@@ -1874,6 +1874,20 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant arg
return QVariant(d->control->selectionEnd());
else
return QVariant(d->control->selectionStart());
+ case Qt::ImReadOnly:
+ return isReadOnly();
+ case Qt::ImTextBeforeCursor: {
+ const QPointF pt = argument.toPointF();
+ if (!pt.isNull())
+ return d->textBeforeCursor(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
+ else
+ return d->textBeforeCursor(d->control->cursor()); }
+ case Qt::ImTextAfterCursor: {
+ const QPointF pt = argument.toPointF();
+ if (!pt.isNull())
+ return d->textAfterCursor(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
+ else
+ return d->textAfterCursor(d->control->cursor()); }
default:
return QWidget::inputMethodQuery(property);
}
@@ -2073,8 +2087,10 @@ void QLineEdit::paintEvent(QPaintEvent *)
// Asian users see an IM selection text as cursor on candidate
// selection phase of input method, so the ordinary cursor should be
- // invisible if we have a preedit string.
- if (d->cursorVisible && !d->control->isReadOnly())
+ // invisible if we have a preedit string. another condition is when inputmask
+ // isn't empty,we don't need draw cursor,because cursor and character overlaping
+ // area is white.
+ if (d->cursorVisible && !d->control->isReadOnly() && d->control->inputMask().isEmpty())
flags |= QWidgetLineControl::DrawCursor;
d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth, &panel));
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 1839941036..a5ac6a2211 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -86,6 +86,18 @@ int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
return control->xToPos(x, betweenOrOn);
}
+QString QLineEditPrivate::textBeforeCursor(int curPos) const
+{
+ const QString &text = control->text();
+ return text.mid(0, curPos);
+}
+
+QString QLineEditPrivate::textAfterCursor(int curPos) const
+{
+ const QString &text = control->text();
+ return text.mid(curPos);
+}
+
bool QLineEditPrivate::inSelection(int x) const
{
x -= adjustedContentsRect().x() - hscroll + horizontalMargin;
@@ -479,7 +491,7 @@ void QLineEditPrivate::_q_clearButtonClicked()
Q_Q(QLineEdit);
if (!q->text().isEmpty()) {
q->clear();
- emit q->textEdited(QString());
+ _q_textEdited(QString());
}
}
@@ -495,7 +507,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters()
{
Q_Q(const QLineEdit);
SideWidgetParameters result;
- result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q);
+ result.iconSize = q->style()->pixelMetric(QStyle::PM_LineEditIconSize, nullptr, q);
result.margin = result.iconSize / 4;
result.widgetWidth = result.iconSize + 6;
result.widgetHeight = result.iconSize + 2;
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 936cf2d088..de9b9c1636 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -179,13 +179,19 @@ public:
void setCursorVisible(bool visible);
void setText(const QString& text);
+ QString textBeforeCursor(int curPos) const;
+ QString textAfterCursor(int curPos) const;
void updatePasswordEchoEditing(bool);
void resetInputMethod();
inline bool shouldEnableInputMethod() const
{
+#if defined (Q_OS_ANDROID)
+ return !control->isReadOnly() || control->isSelectableByMouse();
+#else
return !control->isReadOnly();
+#endif
}
inline bool shouldShowPlaceholderText() const
{
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 9c7b1d6aab..4e7f04de6c 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1306,6 +1306,7 @@ bool QMainWindow::event(QEvent *event)
#if QT_CONFIG(toolbar)
case QEvent::ToolBarChange: {
+ Q_ASSERT(d->layout);
d->layout->toggleToolBarsVisible();
return true;
}
@@ -1314,6 +1315,7 @@ bool QMainWindow::event(QEvent *event)
#if QT_CONFIG(statustip)
case QEvent::StatusTip:
#if QT_CONFIG(statusbar)
+ Q_ASSERT(d->layout);
if (QStatusBar *sb = d->layout->statusBar())
sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip());
else
@@ -1324,6 +1326,7 @@ bool QMainWindow::event(QEvent *event)
case QEvent::StyleChange:
#if QT_CONFIG(dockwidget)
+ Q_ASSERT(d->layout);
d->layout->layoutState.dockAreaLayout.styleChangedEvent();
#endif
if (!d->explicitIconSize)
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 1b61868868..89d77574f0 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -399,7 +399,7 @@ ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)
Q_UNUSED(subWindow);
setFocusPolicy(Qt::NoFocus);
updateWindowIcon();
- setFixedSize(label.size());
+ setFixedSize(label.size() / label.devicePixelRatio());
}
/*
@@ -407,7 +407,7 @@ ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)
*/
QSize ControlLabel::sizeHint() const
{
- return label.size();
+ return label.size() / label.devicePixelRatio();
}
/*
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index d704aac525..3f349cf8a0 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -472,7 +472,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
}
max_column_width += tabWidth; //finally add in the tab width
- if (!tornoff || (tornoff && scroll)) { // exclude non-scrollable tear-off menu since the tear-off menu has a fixed size
+ if (!tornoff || scroll) { // exclude non-scrollable tear-off menu since the tear-off menu has a fixed size
const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QSize(0, 0), q).width();
const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
max_column_width = qMax(min_column_width, max_column_width);
@@ -3003,8 +3003,7 @@ void QMenu::changeEvent(QEvent *e)
/*!
\reimp
*/
-bool
-QMenu::event(QEvent *e)
+bool QMenu::event(QEvent *e)
{
Q_D(QMenu);
switch (e->type()) {
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 00fe383e1d..20fdbcd6a8 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -71,9 +71,14 @@
QT_BEGIN_NAMESPACE
-static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit)
+static inline bool shouldEnableInputMethod(QPlainTextEdit *control)
{
- return !plaintextedit->isReadOnly();
+#if defined(Q_OS_ANDROID)
+ Q_UNUSED(control);
+ return !control->isReadOnly() || (control->textInteractionFlags() & Qt::TextSelectableByMouse);
+#else
+ return !control->isReadOnly();
+#endif
}
class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivate
@@ -962,7 +967,7 @@ void QPlainTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCurso
}
if (moveCursor) {
- control->setTextCursor(cursor);
+ control->setTextCursor(cursor, moveMode == QTextCursor::KeepAnchor);
pageUpDownLastCursorYIsValid = true;
}
}
@@ -2238,6 +2243,8 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
case Qt::ImHints:
case Qt::ImInputItemClipRectangle:
return QWidget::inputMethodQuery(query);
+ case Qt::ImReadOnly:
+ return isReadOnly();
default:
break;
}
@@ -2306,6 +2313,7 @@ void QPlainTextEdit::showEvent(QShowEvent *)
d->showCursorOnInitialShow = false;
ensureCursorVisible();
}
+ d->_q_adjustScrollbars();
}
/*! \reimp
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 946839c373..92042f31df 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -50,6 +50,8 @@
#include "qdebug.h"
#include <private/qwidget_p.h>
+#include "private/qapplication_p.h"
+#include <qpa/qplatformtheme.h>
#include <QtWidgets/qabstractscrollarea.h>
QT_BEGIN_NAMESPACE
@@ -268,6 +270,18 @@ static Qt::Edges edgesFromCorner(Qt::Corner corner)
return Qt::Edges{};
}
+static bool usePlatformSizeGrip(const QWidget *tlw)
+{
+ const QString &platformName = QGuiApplication::platformName();
+ if (platformName.contains(u"xcb")) // ### FIXME QTBUG-69716
+ return false;
+ if (tlw->testAttribute(Qt::WA_TranslucentBackground)
+ && platformName == u"windows") {
+ return false; // QTBUG-90628, flicker when using translucency
+ }
+ return true;
+}
+
void QSizeGrip::mousePressEvent(QMouseEvent * e)
{
if (e->button() != Qt::LeftButton) {
@@ -287,11 +301,11 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
&& tlw->windowHandle()
&& !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen)
- && !tlw->hasHeightForWidth()) {
+ && !tlw->hasHeightForWidth()
+ && usePlatformSizeGrip(tlw)) {
QPlatformWindow *platformWindow = tlw->windowHandle()->handle();
const Qt::Edges edges = edgesFromCorner(d->m_corner);
- if (!QGuiApplication::platformName().contains(QStringLiteral("xcb"))) // ### FIXME QTBUG-69716
- d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(edges);
+ d->m_platformSizeGrip = platformWindow->startSystemResize(edges);
}
if (d->m_platformSizeGrip)
@@ -301,8 +315,12 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
QRect availableGeometry;
bool hasVerticalSizeConstraint = true;
bool hasHorizontalSizeConstraint = true;
- if (tlw->isWindow())
- availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw);
+ if (tlw->isWindow()) {
+ if (QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::InteractiveResizeAcrossScreens).toBool())
+ availableGeometry = tlw->screen()->availableVirtualGeometry();
+ else
+ availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw);
+ }
else {
const QWidget *tlwParent = tlw->parentWidget();
// Check if tlw is inside QAbstractScrollArea/QScrollArea.
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 619b3788c8..1c04f02422 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -1404,10 +1404,10 @@ void QSplitter::moveSplitter(int pos, int index)
{
Q_D(QSplitter);
QSplitterLayoutStruct *s = d->list.at(index);
- int farMin;
- int min;
- int max;
- int farMax;
+ int farMin = 0;
+ int min = 0;
+ int max = 0;
+ int farMax = 0;
#ifdef QSPLITTER_DEBUG
int debugp = pos;
@@ -1471,7 +1471,10 @@ void QSplitter::getRange(int index, int *min, int *max) const
int QSplitter::closestLegalPosition(int pos, int index)
{
Q_D(QSplitter);
- int x, i, n, u;
+ int x = 0;
+ int i = 0;
+ int n = 0;
+ int u = 0;
return d->adjustPos(pos, index, &u, &n, &i, &x);
}
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 99ebaa93bf..6b05156ea3 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -57,6 +57,15 @@
QT_BEGIN_NAMESPACE
+static inline bool shouldEnableInputMethod(QTextBrowser *texbrowser)
+{
+#if defined (Q_OS_ANDROID)
+ return !texbrowser->isReadOnly() || (texbrowser->textInteractionFlags() & Qt::TextSelectableByMouse);
+#else
+ return !texbrowser->isReadOnly();
+#endif
+}
+
Q_LOGGING_CATEGORY(lcBrowser, "qt.text.browser")
class QTextBrowserPrivate : public QTextEditPrivate
@@ -692,7 +701,7 @@ void QTextBrowserPrivate::init()
#ifndef QT_NO_CURSOR
viewport->setCursor(oldCursor);
#endif
- q->setAttribute(Qt::WA_InputMethodEnabled, !q->isReadOnly());
+ q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(q));
q->setUndoRedoEnabled(false);
viewport->setMouseTracking(true);
QObject::connect(q->document(), SIGNAL(contentsChanged()), q, SLOT(_q_documentModified()));
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 25e973d90f..2d3f98b4b9 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -79,7 +79,11 @@ QT_BEGIN_NAMESPACE
static inline bool shouldEnableInputMethod(QTextEdit *textedit)
{
+#if defined (Q_OS_ANDROID)
+ return !textedit->isReadOnly() || (textedit->textInteractionFlags() & Qt::TextSelectableByMouse);
+#else
return !textedit->isReadOnly();
+#endif
}
class QTextEditControl : public QWidgetTextControl
@@ -270,7 +274,7 @@ void QTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::Mo
vbar->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
}
- control->setTextCursor(cursor);
+ control->setTextCursor(cursor, moveMode == QTextCursor::KeepAnchor);
}
#if QT_CONFIG(scrollbar)
@@ -1832,6 +1836,8 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
case Qt::ImHints:
case Qt::ImInputItemClipRectangle:
return QWidget::inputMethodQuery(query);
+ case Qt::ImReadOnly:
+ return isReadOnly();
default:
break;
}
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 1b04f3df72..b9d31bd657 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -244,7 +244,6 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
Q_D(const QToolButton);
option->initFrom(this);
- bool forceNoText = false;
option->iconSize = iconSize(); //default value
#if QT_CONFIG(toolbar)
@@ -255,8 +254,7 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
}
#endif // QT_CONFIG(toolbar)
- if (!forceNoText)
- option->text = d->text;
+ option->text = d->text;
option->icon = d->icon;
option->arrowType = d->arrowType;
if (d->down)
@@ -308,7 +306,7 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
option->toolButtonStyle = Qt::ToolButtonIconOnly;
}
- if (d->icon.isNull() && d->arrowType == Qt::NoArrow && !forceNoText) {
+ if (d->icon.isNull() && d->arrowType == Qt::NoArrow) {
if (!d->text.isEmpty())
option->toolButtonStyle = Qt::ToolButtonTextOnly;
else if (option->toolButtonStyle != Qt::ToolButtonTextOnly)
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 29ac32cadc..77c62b106b 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1944,10 +1944,15 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
return;
}
- if (unknown)
+ if (unknown) {
event->ignore();
- else
+ } else {
+#ifndef QT_NO_CLIPBOARD
+ if (QApplication::clipboard()->supportsSelection())
+ copy(QClipboard::Selection);
+#endif
event->accept();
+ }
}
bool QWidgetLineControl::isUndoAvailable() const
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index f906165c20..bb24fe4d5b 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -164,6 +164,9 @@ public:
int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
+#if defined (Q_OS_ANDROID)
+ bool isSelectableByMouse() const { return true; }
+#endif
bool inSelection(int x) const
{
if (m_selstart >= m_selend)
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index ef1be67975..c9c4c848fc 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -923,7 +923,7 @@ QTextDocument *QWidgetTextControl::document() const
return d->doc;
}
-void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
+void QWidgetTextControl::setTextCursor(const QTextCursor &cursor, bool selectionClipboard)
{
Q_D(QWidgetTextControl);
d->cursorIsFocusIndicator = false;
@@ -937,6 +937,11 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
d->repaintOldAndNewSelection(oldSelection);
if (posChanged)
emit cursorPositionChanged();
+
+#ifndef QT_NO_CLIPBOARD
+ if (selectionClipboard)
+ d->setClipboardSelection();
+#endif
}
QTextCursor QWidgetTextControl::textCursor() const
@@ -1226,6 +1231,9 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
if (e == QKeySequence::SelectAll) {
e->accept();
q->selectAll();
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
return;
}
#ifndef QT_NO_CLIPBOARD
@@ -1377,6 +1385,10 @@ process:
accept:
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
+
e->accept();
cursorOn = true;
@@ -2027,7 +2039,7 @@ bool QWidgetTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPoin
void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QWidgetTextControl);
- if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
+ if (!(interactionFlags & (Qt::TextEditable | Qt::TextSelectableByMouse)) || cursor.isNull()) {
e->ignore();
return;
}
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 54cb136621..54428e542b 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -105,7 +105,7 @@ public:
void setDocument(QTextDocument *document);
QTextDocument *document() const;
- void setTextCursor(const QTextCursor &cursor);
+ void setTextCursor(const QTextCursor &cursor, bool selectionClipboard = false);
QTextCursor textCursor() const;
void setTextInteractionFlags(Qt::TextInteractionFlags flags);