summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/itemviews.cpp23
-rw-r--r--src/widgets/accessible/itemviews_p.h2
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp37
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp14
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h3
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp8
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp4
-rw-r--r--src/widgets/dialogs/qwizard.cpp6
-rw-r--r--src/widgets/doc/src/guibooks.qdoc13
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery.qdoc2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc14
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp69
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h7
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp12
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp11
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp6
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp90
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h1
-rw-r--r--src/widgets/itemviews/qlistview.cpp10
-rw-r--r--src/widgets/itemviews/qtableview.cpp6
-rw-r--r--src/widgets/itemviews/qtreeview.cpp19
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp25
-rw-r--r--src/widgets/kernel/qaction.cpp6
-rw-r--r--src/widgets/kernel/qapplication.cpp36
-rw-r--r--src/widgets/kernel/qboxlayout.cpp4
-rw-r--r--src/widgets/kernel/qgesture.cpp2
-rw-r--r--src/widgets/kernel/qgridlayout.cpp6
-rw-r--r--src/widgets/kernel/qlayout.cpp5
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp20
-rw-r--r--src/widgets/kernel/qsizepolicy.h6
-rw-r--r--src/widgets/kernel/qtestsupport_widgets.cpp29
-rw-r--r--src/widgets/kernel/qtooltip.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp51
-rw-r--r--src/widgets/kernel/qwidget_p.h5
-rw-r--r--src/widgets/kernel/qwidgetrepaintmanager.cpp19
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp9
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-32.pngbin0 -> 305 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-down-32.pngbin0 -> 278 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-hover-32.pngbin0 -> 305 bytes
-rw-r--r--src/widgets/styles/qcommonstyle.cpp40
-rw-r--r--src/widgets/styles/qfusionstyle.cpp47
-rw-r--r--src/widgets/styles/qpixmapstyle.cpp2
-rw-r--r--src/widgets/styles/qstyle.cpp12
-rw-r--r--src/widgets/styles/qstyle.qrc3
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp95
-rw-r--r--src/widgets/util/qcompleter.cpp17
-rw-r--r--src/widgets/util/qscrollerproperties.cpp4
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp6
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qabstractslider.cpp2
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp2
-rw-r--r--src/widgets/widgets/qcombobox.cpp55
-rw-r--r--src/widgets/widgets/qcombobox_p.h1
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp2
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h2
-rw-r--r--src/widgets/widgets/qdial.cpp2
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp27
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp4
-rw-r--r--src/widgets/widgets/qframe.cpp6
-rw-r--r--src/widgets/widgets/qframe.h2
-rw-r--r--src/widgets/widgets/qlabel.cpp3
-rw-r--r--src/widgets/widgets/qlineedit.cpp25
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp21
-rw-r--r--src/widgets/widgets/qlineedit_p.h7
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm1
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm1
-rw-r--r--src/widgets/widgets/qmainwindow.cpp6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp14
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp35
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h1
-rw-r--r--src/widgets/widgets/qmenu.cpp4
-rw-r--r--src/widgets/widgets/qmenubar.cpp2
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp4
-rw-r--r--src/widgets/widgets/qpushbutton.cpp9
-rw-r--r--src/widgets/widgets/qpushbutton_p.h5
-rw-r--r--src/widgets/widgets/qscrollarea.cpp18
-rw-r--r--src/widgets/widgets/qscrollbar.cpp2
-rw-r--r--src/widgets/widgets/qsizegrip.cpp18
-rw-r--r--src/widgets/widgets/qslider.cpp2
-rw-r--r--src/widgets/widgets/qtabbar.cpp25
-rw-r--r--src/widgets/widgets/qtabwidget.cpp4
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp2
-rw-r--r--src/widgets/widgets/qtextedit.cpp2
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp10
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp55
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h7
93 files changed, 851 insertions, 377 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index a7b536ae54..e485744dc8 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -425,6 +425,15 @@ QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const
return nullptr;
}
+QAccessibleInterface *QAccessibleTable::focusChild() const
+{
+ QModelIndex index = view()->currentIndex();
+ if (!index.isValid())
+ return nullptr;
+
+ return child(logicalIndex(index));
+}
+
int QAccessibleTable::childCount() const
{
if (!view()->model())
@@ -692,6 +701,20 @@ QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const
return child(i);
}
+QAccessibleInterface *QAccessibleTree::focusChild() const
+{
+ QModelIndex index = view()->currentIndex();
+ if (!index.isValid())
+ return nullptr;
+
+ const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
+ int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
+ int column = index.column();
+
+ int i = row * view()->model()->columnCount() + column;
+ return child(i);
+}
+
int QAccessibleTree::childCount() const
{
const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h
index 683ae9c948..1fc6a3e521 100644
--- a/src/widgets/accessible/itemviews_p.h
+++ b/src/widgets/accessible/itemviews_p.h
@@ -79,6 +79,7 @@ public:
QRect rect() const override;
QAccessibleInterface *childAt(int x, int y) const override;
+ QAccessibleInterface *focusChild() const override;
int childCount() const override;
int indexOfChild(const QAccessibleInterface *) const override;
@@ -154,6 +155,7 @@ public:
QAccessibleInterface *childAt(int x, int y) const override;
+ QAccessibleInterface *focusChild() const override;
int childCount() const override;
QAccessibleInterface *child(int index) const override;
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 9c1f5d595d..5f5b325785 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -161,9 +161,10 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
By default, a platform-native file dialog will be used if the platform has
one. In that case, the widgets which would otherwise be used to construct the
dialog will not be instantiated, so related accessors such as layout() and
- itemDelegate() will return null. You can set the \l DontUseNativeDialog option to
- ensure that the widget-based implementation will be used instead of the
- native dialog.
+ itemDelegate() will return null. Also, not all platforms show file dialogs
+ with a title bar, so be aware that the caption text might not be visible to
+ the user. You can set the \l DontUseNativeDialog option to ensure that the
+ widget-based implementation will be used instead of the native dialog.
\sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example},
{Application Example}
@@ -224,12 +225,15 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
\value DontConfirmOverwrite Don't ask for confirmation if an
existing file is selected. By default confirmation is requested.
+ Note: This opption is not supported on macOS when using the
+ native file dialog.
+
\value DontUseNativeDialog Don't use the native file dialog. By
default, the native file dialog is used unless you use a subclass
of QFileDialog that contains the Q_OBJECT macro, or the platform
does not have a native dialog of the type that you require.
- \note This option must be set before changing dialog properties
+ \b{Note:} This option must be set before changing dialog properties
or showing the dialog.
\value ReadOnly Indicates that the model is readonly.
@@ -1253,8 +1257,9 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
QFileInfo info(name);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
- if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1)
+ if (!defaultSuffix.isEmpty() && !info.isDir() && !info.fileName().contains(u'.'))
name += QLatin1Char('.') + defaultSuffix;
+
if (info.isAbsolute()) {
files.append(name);
} else {
@@ -1280,8 +1285,12 @@ QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsTo
QUrl url = urlsToFix.at(i);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
- if (!defaultSuffix.isEmpty() && !url.path().endsWith(QLatin1Char('/')) && url.path().lastIndexOf(QLatin1Char('.')) == -1)
- url.setPath(url.path() + QLatin1Char('.') + defaultSuffix);
+ if (!defaultSuffix.isEmpty()) {
+ const QString urlPath = url.path();
+ const auto idx = urlPath.lastIndexOf(u'/');
+ if (idx != (urlPath.size() - 1) && !QStringView{urlPath}.mid(idx + 1).contains(u'.'))
+ url.setPath(urlPath + u'.' + defaultSuffix);
+ }
urls.append(url);
}
return urls;
@@ -2180,7 +2189,8 @@ QString QFileDialog::labelText(DialogLabel label) const
then a default caption will be used.
On Windows, and \macos, this static function will use the
- native file dialog and not a QFileDialog.
+ native file dialog and not a QFileDialog. Note that the \macos native file
+ dialog does not show a title bar.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not \nullptr then it will position
@@ -2291,7 +2301,8 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
then a default caption will be used.
On Windows, and \macos, this static function will use the
- native file dialog and not a QFileDialog.
+ native file dialog and not a QFileDialog. Note that the \macos native file
+ dialog does not show a title bar.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not \nullptr then it will position
@@ -2444,7 +2455,7 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
#else
QFileDialog *dialog = new QFileDialog();
dialog->setFileMode(QFileDialog::ExistingFile);
- dialog->selectNameFilter(nameFilter);
+ dialog->setNameFilter(nameFilter);
auto fileSelected = [=](const QString &fileName) {
QByteArray fileContent;
@@ -2458,7 +2469,7 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
auto dialogClosed = [=](int code) {
Q_UNUSED(code);
- delete dialog;
+ dialog->deleteLater();
};
connect(dialog, &QFileDialog::fileSelected, fileSelected);
@@ -2503,7 +2514,7 @@ void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &
auto dialogClosed = [=](int code) {
Q_UNUSED(code);
- delete dialog;
+ dialog->deleteLater();
};
connect(dialog, &QFileDialog::fileSelected, fileSelected);
@@ -2656,6 +2667,8 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
to pass \l{QFileDialog::}{DontUseNativeDialog} to display files using a
QFileDialog.
+ Note that the \macos native file dialog does not show a title bar.
+
On Unix/X11, the normal behavior of the file dialog is to resolve and
follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 0db06e9b71..1d23ffaadc 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -397,8 +397,11 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (absolutePath.endsWith(QLatin1Char('/')))
trailingSeparator = QLatin1String("\\");
int r = 0;
- QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
- if (!root.children.contains(host.toLower())) {
+ auto rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
+ auto it = root.children.constFind(host);
+ if (it != root.children.cend()) {
+ host = it.key(); // Normalize case for lookup in visibleLocation()
+ } else {
if (pathElements.count() == 1 && !absolutePath.endsWith(QLatin1Char('/')))
return rootNode;
QFileInfo info(host);
@@ -723,6 +726,9 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::EditRole:
+ if (index.column() == 0)
+ return d->name(index);
+ Q_FALLTHROUGH();
case Qt::DisplayRole:
switch (index.column()) {
case 0: return d->displayName(index);
@@ -2057,6 +2063,10 @@ QStringList QFileSystemModelPrivate::unwatchPathsAt(const QModelIndex &index)
}
#endif // filesystemwatcher && Q_OS_WIN
+QFileSystemModelPrivate::QFileSystemModelPrivate() = default;
+
+QFileSystemModelPrivate::~QFileSystemModelPrivate() = default;
+
/*!
\internal
*/
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index ad98b9ef44..0eec870016 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -213,7 +213,8 @@ public:
bool isVisible = false;
};
- QFileSystemModelPrivate() = default;
+ QFileSystemModelPrivate();
+ ~QFileSystemModelPrivate();
void init();
/*
\internal
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 8e42804943..5dd40eaa48 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -593,6 +593,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)
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 4e7a4a65e3..8aaab72239 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1894,7 +1894,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("2022"),
QStringLiteral("qt.io/licensing"),
QStringLiteral("qt.io"));
QMessageBox *msgBox = new QMessageBox(parent);
@@ -2046,7 +2046,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/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 00c5d5d426..d1639de232 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -256,11 +256,11 @@ public:
bool extension = false;
bool sideWidget = false;
- bool operator==(const QWizardLayoutInfo &other);
- inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); }
+ bool operator==(const QWizardLayoutInfo &other) const;
+ inline bool operator!=(const QWizardLayoutInfo &other) const { return !operator==(other); }
};
-bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other)
+bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other) const
{
return topLevelMarginLeft == other.topLevelMarginLeft
&& topLevelMarginRight == other.topLevelMarginRight
diff --git a/src/widgets/doc/src/guibooks.qdoc b/src/widgets/doc/src/guibooks.qdoc
index 30ffd0b5ec..b245e09b5d 100644
--- a/src/widgets/doc/src/guibooks.qdoc
+++ b/src/widgets/doc/src/guibooks.qdoc
@@ -88,17 +88,4 @@
recognize, find and activate them. This book explains these goals
from scratch and how to reach them, both with single icons and icon
families. Some 500 examples are scattered throughout the text.
-
-
- \section1 Buying these Books from Amazon.com
-
- These books are made available in association with Amazon.com, our
- favorite online bookstore. Here is more information about
- \link http://www.amazon.com/exec/obidos/subst/help/shipping-policy.html/t
- Amazon.com's shipping options\endlink and its
- \link http://www.amazon.com/exec/obidos/subst/help/desk.html/t
- customer service.\endlink When you buy a book by following one of these
- links, Amazon.com gives about 15% of the purchase price to
- \link http://www.amnesty.org/ Amnesty International.\endlink
-
*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
index a82462a432..d0673f207b 100644
--- a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
@@ -35,7 +35,7 @@
The widgets examples show how some of the widgets available in Qt might
appear when configured to use the a particular style. Each style is only
- available on the respective platfom, and provides native look and feel by
+ available on the respective platform, and provides native look and feel by
integrating to the platform theme. Thus, the final appearance varies
depending on the active theme.
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 3319b032cc..c4b77f42c4 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -1033,7 +1033,7 @@
The slider can be styled using the \l{#handle-sub}{::handle} subcontrol.
Setting the \l{#min-width-prop}{min-width} or \l{#min-height-prop}{min-height}
- provides size contraints for the slider depending on the orientation.
+ provides size constraints for the slider depending on the orientation.
The \l{add-line-sub}{::add-line} subcontrol can be used to style the
button to add a line. By default, the add-line subcontrol is placed in
@@ -1950,7 +1950,7 @@
The only widget currently supporting this property is QPushButton.
- \note It's the application's responsibilty to assign an icon to a
+ \note It's the application's responsibility to assign an icon to a
button (using the QAbstractButton API), and not the style's. So be
careful setting it unless your stylesheet is targeting a specific
application.
@@ -2167,7 +2167,7 @@
subclasses, QAbstractSpinBox subclasses, QCheckBox,
QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
- QSplitter, QStatusBar, QTextEdit, and QToolTip.
+ QSplitter, QStatusBar, QTextEdit, QToolButton, and QToolTip.
If this property is not specified, the minimum height is
derived based on the widget's contents and the style.
@@ -2179,6 +2179,9 @@
\snippet code/doc_src_stylesheet.qdoc 66
+ \note Setting this property might allow widgets to shrink
+ smaller than the space required for the contents.
+
See also \l{#min-width-prop}{min-width}.
\row
@@ -2190,7 +2193,7 @@
subclasses, QAbstractSpinBox subclasses, QCheckBox,
QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
- QSplitter, QStatusBar, QTextEdit, and QToolTip.
+ QSplitter, QStatusBar, QTextEdit, QToolButton, and QToolTip.
If this property is not specified, the minimum width is
derived based on the widget's contents and the style.
@@ -2202,6 +2205,9 @@
\snippet code/doc_src_stylesheet.qdoc 67
+ \note Setting this property might allow widgets to shrink
+ smaller than the space required for the contents.
+
See also \l{#min-height-prop}{min-height}.
\row
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index 2eb74ce2a8..235991b1df 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -86,7 +86,7 @@
any other existing effects) and reimplement the virtual function draw().
This function is called whenever the effect needs to redraw. The draw()
function takes the painter with which to draw as an argument. For more
- information, refer to the documenation for draw(). In the draw() function
+ information, refer to the documentation for draw(). In the draw() function
you can call sourcePixmap() to get a pixmap of the graphics effect source
which you can then process.
@@ -750,7 +750,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter)
at the potential cost of lower performance.
\value AnimationHint Indicates that the blur radius is going to be animated, hinting
- that the implementation can keep a cache of blurred verisons of the source.
+ that the implementation can keep a cache of blurred versions of the source.
Do not use this hint if the source is going to be dynamically changing.
\sa blurHints(), setBlurHints()
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index af0ee3d38c..7cc23339c2 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -2078,7 +2078,7 @@ QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints)
In a nutshell it should do:
1) Refresh anchor nominal sizes, that is, the size that each anchor would
- have if no other restrictions applied. This is done by quering the
+ have if no other restrictions applied. This is done by querying the
layout style and the sizeHints of the items belonging to the layout.
2) Simplify the graph by grouping together parallel and sequential anchors
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 38cab60fc2..b26b9c2f8e 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -244,7 +244,7 @@
\li keyPressEvent() and keyReleaseEvent() handle key press and release events
\li mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and
mouseDoubleClickEvent() handles mouse press, move, release, click and
- doubleclick events
+ double-click events
\endlist
You can filter events for any other item by installing event filters. This
@@ -2297,7 +2297,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
If no cursor has been set, the cursor of the item beneath is used.
\sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor,
- QApplication::overrideCursor()
+ QGuiApplication::overrideCursor()
*/
QCursor QGraphicsItem::cursor() const
{
@@ -2317,7 +2317,7 @@ QCursor QGraphicsItem::cursor() const
If no cursor has been set, the cursor of the item beneath is used.
\sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor,
- QApplication::overrideCursor()
+ QGuiApplication::overrideCursor()
*/
void QGraphicsItem::setCursor(const QCursor &cursor)
{
@@ -2738,7 +2738,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
If you disable a parent item, all its children will also be disabled. If
you enable a parent item, all children will be enabled, unless they have
been explicitly disabled (i.e., if you call setEnabled(false) on a child,
- it will not be reenabled if its parent is disabled, and then enabled
+ it will not be re-enabled if its parent is disabled, and then enabled
again).
Items are enabled by default.
@@ -3031,7 +3031,7 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const
Returns the effective bounding rect of the item.
If the item has no effect, this is the same as the item's bounding rect.
If the item has an effect, the effective rect can be larger than the item's
- bouding rect, depending on the effect.
+ bounding rect, depending on the effect.
\sa boundingRect()
*/
@@ -4357,7 +4357,8 @@ QMatrix QGraphicsItem::sceneMatrix() const
\snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4
Unlike transform(), which returns only an item's local transformation, this
- function includes the item's (and any parents') position, and all the transfomation properties.
+ function includes the item's (and any parents') position, and all the
+ transformation properties.
\sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations}
*/
@@ -4610,7 +4611,7 @@ QT_WARNING_POP
To simplify interaction with items using a transformed view, QGraphicsItem
provides mapTo... and mapFrom... functions that can translate between
items' and the scene's coordinates. For example, you can call mapToScene()
- to map an item coordiate to a scene coordinate, or mapFromScene() to map
+ to map an item coordinate to a scene coordinate, or mapFromScene() to map
from scene coordinates to item coordinates.
The transformation matrix is combined with the item's rotation(), scale()
@@ -5167,7 +5168,7 @@ bool QGraphicsItem::contains(const QPointF &point) const
The default implementation is based on shape intersection, and it calls
shape() on both items. Because the complexity of arbitrary shape-shape
intersection grows with an order of magnitude when the shapes are complex,
- this operation can be noticably time consuming. You have the option of
+ this operation can be noticeably time-consuming. You have the option of
reimplementing this function in a subclass of QGraphicsItem to provide a
custom algorithm. This allows you to make use of natural constraints in
the shapes of your own items, in order to improve the performance of the
@@ -7231,7 +7232,7 @@ void QGraphicsItem::keyReleaseEvent(QKeyEvent *event)
If you do reimplement this function, \a event will by default be
accepted (see QEvent::accept()), and this item is then the mouse
grabber. This allows the item to receive future move, release and
- doubleclick events. If you call QEvent::ignore() on \a event, this
+ double-click events. If you call QEvent::ignore() on \a event, this
item will lose the mouse grab, and \a event will propagate to any
topmost item beneath. No further mouse events will be delivered to
this item unless a new mouse press event is received.
@@ -7452,11 +7453,11 @@ void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
/*!
This event handler, for event \a event, can be reimplemented to
- receive mouse doubleclick events for this item.
+ receive mouse double-click events for this item.
When doubleclicking an item, the item will first receive a mouse
press event, followed by a release event (i.e., a click), then a
- doubleclick event, and finally a release event.
+ double-click event, and finally a release event.
Calling QEvent::ignore() or QEvent::accept() on \a event has no
effect.
@@ -8127,7 +8128,7 @@ void QGraphicsItemPrivate::resetHeight()
/*!
\fn QGraphicsObject::rotationChanged()
- This signal gets emitted whenever the roation of the item changes.
+ This signal gets emitted whenever the rotation of the item changes.
*/
/*!
@@ -8166,7 +8167,7 @@ void QGraphicsItemPrivate::resetHeight()
/*!
\fn void QGraphicsObject::enabledChanged()
- This signal gets emitted whenever the item get's enabled or disabled.
+ This signal gets emitted whenever the item gets enabled or disabled.
\sa isEnabled()
*/
@@ -8194,7 +8195,7 @@ void QGraphicsItemPrivate::resetHeight()
\property QGraphicsObject::transformOriginPoint
\brief the transformation origin
- This property sets a specific point in the items coordiante system as the
+ This property sets a specific point in the item's coordinate system as the
origin for scale and rotation.
\sa scale, rotation, QGraphicsItem::transformOriginPoint()
@@ -10297,6 +10298,7 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event)
case QEvent::GraphicsSceneMouseRelease:
case QEvent::KeyPress:
case QEvent::KeyRelease:
+ case QEvent::InputMethod:
// Reset the focus widget's input context, regardless
// of how this item gained or lost focus.
if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) {
@@ -10516,14 +10518,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;
}
@@ -10598,16 +10602,17 @@ QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const
control = new QWidgetTextControl(that);
control->setTextInteractionFlags(Qt::NoTextInteraction);
- QObject::connect(control, SIGNAL(updateRequest(QRectF)),
- qq, SLOT(_q_update(QRectF)));
- QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),
- qq, SLOT(_q_updateBoundingRect(QSizeF)));
- QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),
- qq, SLOT(_q_ensureVisible(QRectF)));
- QObject::connect(control, SIGNAL(linkActivated(QString)),
- qq, SIGNAL(linkActivated(QString)));
- QObject::connect(control, SIGNAL(linkHovered(QString)),
- qq, SIGNAL(linkHovered(QString)));
+ auto dd = that->dd;
+ QObject::connect(control, &QWidgetTextControl::updateRequest, qq,
+ [dd](const QRectF &rect) { dd->_q_update(rect); });
+ QObject::connect(control, &QWidgetTextControl::documentSizeChanged, qq,
+ [dd](QSizeF size) { dd->_q_updateBoundingRect(size); });
+ QObject::connect(control, &QWidgetTextControl::visibilityRequest, qq,
+ [dd](const QRectF &rect) { dd->_q_ensureVisible(rect); });
+ QObject::connect(control, &QWidgetTextControl::linkActivated, qq,
+ &QGraphicsTextItem::linkActivated);
+ QObject::connect(control, &QWidgetTextControl::linkHovered, qq,
+ &QGraphicsTextItem::linkHovered);
const QSizeF pgSize = control->document()->pageSize();
if (pgSize.height() != -1) {
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index d66a4917e5..047f29fdc4 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -964,9 +964,6 @@ protected:
private:
Q_DISABLE_COPY(QGraphicsTextItem)
- Q_PRIVATE_SLOT(dd, void _q_updateBoundingRect(const QSizeF &))
- Q_PRIVATE_SLOT(dd, void _q_update(QRectF))
- Q_PRIVATE_SLOT(dd, void _q_ensureVisible(QRectF))
QGraphicsTextItemPrivate *dd;
friend class QGraphicsTextItemPrivate;
};
@@ -1035,14 +1032,14 @@ template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item)
{
typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item;
return int(Item::Type) == int(QGraphicsItem::Type)
- || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0;
+ || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr;
}
template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item)
{
typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item;
return int(Item::Type) == int(QGraphicsItem::Type)
- || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0;
+ || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp
index 8b52b57580..f7987cdd23 100644
--- a/src/widgets/graphicsview/qgraphicslayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslayout.cpp
@@ -146,7 +146,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- Contructs a QGraphicsLayout object.
+ Constructs a QGraphicsLayout object.
\a parent is passed to QGraphicsLayoutItem's constructor and the
QGraphicsLayoutItem's isLayout argument is set to \e true.
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 36c6592012..e4253e9282 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -832,6 +832,10 @@ bool QGraphicsProxyWidget::event(QEvent *event)
return QGraphicsWidget::event(event);
switch (event->type()) {
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ QCoreApplication::sendEvent(d->widget, event);
+ break;
case QEvent::StyleChange:
// Propagate style changes to the embedded widget.
if (!d->styleChangeMode) {
@@ -1551,6 +1555,10 @@ void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsIt
if (exposedWidgetRect.isEmpty())
return;
+ // When rendering to pdf etc. painting may go outside widget boundaries unless clipped
+ if (painter->device()->devType() != QInternal::Widget && (flags() & ItemClipsChildrenToShape))
+ painter->setClipRect(d->widget->geometry(), Qt::IntersectClip);
+
d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index a428329a45..0db338550f 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -1852,7 +1852,7 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect
item discovery functions like items() and itemAt(). Indexing is most
efficient for static scenes (i.e., where items don't move around). For
dynamic scenes, or scenes with many animated items, the index bookkeeping
- can outweight the fast lookup speeds.
+ can outweigh the fast lookup speeds.
For the common case, the default index method BspTreeIndex works fine. If
your scene uses many animations and you are experiencing slowness, you can
@@ -2480,7 +2480,7 @@ void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group)
}
/*!
- Adds or moves the \a item and all its childen to this scene.
+ Adds or moves the \a item and all its children to this scene.
This scene takes ownership of the \a item.
If the item is visible (i.e., QGraphicsItem::isVisible() returns
@@ -4142,15 +4142,15 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
/*!
This event handler, for event \a mouseEvent, can be reimplemented
- in a subclass to receive mouse doubleclick events for the scene.
+ in a subclass to receive mouse double-click events for the scene.
If someone doubleclicks on the scene, the scene will first receive
a mouse press event, followed by a release event (i.e., a click),
- then a doubleclick event, and finally a release event. If the
- doubleclick event is delivered to a different item than the one
+ then a double-click event, and finally a release event. If the
+ double-click event is delivered to a different item than the one
that received the first press and release, it will be delivered as
a press event. However, tripleclick events are not delivered as
- doubleclick events in this case.
+ double-click events in this case.
The default implementation is similar to mousePressEvent().
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 90bddf6e84..e1ff2c932e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -107,7 +107,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
the events and reacts to them. For example, if you click on a selectable
item, the item will typically let the scene know that it has been
selected, and it will also redraw itself to display a selection
- rectangle. Similiary, if you click and drag the mouse to move a movable
+ rectangle. Similarly, if you click and drag the mouse to move a movable
item, it's the item that handles the mouse moves and moves itself. Item
interaction is enabled by default, and you can toggle it by calling
setInteractive().
@@ -3773,7 +3773,12 @@ void QGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
return;
}
+ const bool wasAa = painter->testRenderHint(QPainter::Antialiasing);
+ if (wasAa)
+ painter->setRenderHints(QPainter::Antialiasing, false);
painter->fillRect(rect, d->backgroundBrush);
+ if (wasAa)
+ painter->setRenderHints(QPainter::Antialiasing, true);
}
/*!
@@ -3877,7 +3882,7 @@ bool QGraphicsView::isTransformed() const
otherwise, \a matrix \e replaces the current matrix. \a combine is false
by default.
- The transformation matrix tranforms the scene into view coordinates. Using
+ The transformation matrix transforms the scene into view coordinates. Using
the default transformation, provided by the identity matrix, one pixel in
the view represents one unit in the scene (e.g., a 10x10 rectangular item
is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is
@@ -3891,7 +3896,7 @@ bool QGraphicsView::isTransformed() const
To simplify interation with items using a transformed view, QGraphicsView
provides mapTo... and mapFrom... functions that can translate between
scene and view coordinates. For example, you can call mapToScene() to map
- a view coordiate to a floating point scene coordinate, or mapFromScene()
+ a view coordinate to a floating point scene coordinate, or mapFromScene()
to map from floating point scene coordinates to view coordinates.
\sa transform(), rotate(), scale(), shear(), translate()
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index c5b22b5667..e120817edc 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -389,10 +389,12 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
{
if (!event || !view)
return false;
- Q_D(QAbstractItemDelegate);
+ Q_UNUSED(index);
+ Q_UNUSED(option);
switch (event->type()) {
#ifndef QT_NO_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() ?
@@ -413,6 +415,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() ?
@@ -423,6 +426,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
break;
}
#endif
+ case QEvent::None:
default:
break;
}
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index b8cc5621fb..93dc5ee80c 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -87,6 +87,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
pressedModifiers(Qt::NoModifier),
pressedPosition(QPoint(-1, -1)),
pressedAlreadySelected(false),
+ releaseFromDoubleClick(false),
viewportEnteredNeeded(false),
state(QAbstractItemView::NoState),
stateBeforeAnimation(QAbstractItemView::NoState),
@@ -1168,12 +1169,21 @@ QModelIndex QAbstractItemView::rootIndex() const
void QAbstractItemView::selectAll()
{
Q_D(QAbstractItemView);
- SelectionMode mode = d->selectionMode;
- if (mode == MultiSelection || mode == ExtendedSelection)
+ const SelectionMode mode = d->selectionMode;
+ switch (mode) {
+ case MultiSelection:
+ case ExtendedSelection:
d->selectAll(QItemSelectionModel::ClearAndSelect
- |d->selectionBehaviorFlags());
- else if (mode != SingleSelection)
- d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));
+ | d->selectionBehaviorFlags());
+ break;
+ case NoSelection:
+ case ContiguousSelection:
+ if (d->model->hasChildren(d->root))
+ d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));
+ break;
+ case SingleSelection:
+ break;
+ }
}
/*!
@@ -1754,6 +1764,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
void QAbstractItemView::mousePressEvent(QMouseEvent *event)
{
Q_D(QAbstractItemView);
+ d->releaseFromDoubleClick = false;
d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling
QPoint pos = event->pos();
QPersistentModelIndex index = indexAt(pos);
@@ -1899,6 +1910,8 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QAbstractItemView);
+ const bool releaseFromDoubleClick = d->releaseFromDoubleClick;
+ d->releaseFromDoubleClick = false;
QPoint pos = event->pos();
QPersistentModelIndex index = indexAt(pos);
@@ -1911,7 +1924,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
return;
}
- bool click = (index == d->pressedIndex && index.isValid());
+ bool click = (index == d->pressedIndex && index.isValid() && !releaseFromDoubleClick);
bool selectedClicked = click && (event->button() == Qt::LeftButton) && d->pressedAlreadySelected;
EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
const bool edited = click ? edit(index, trigger, event) : false;
@@ -1964,7 +1977,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
&& !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this))
emit activated(persistent);
- d->pressedIndex = QModelIndex();
+ d->releaseFromDoubleClick = true;
}
#if QT_CONFIG(draganddrop)
@@ -2334,11 +2347,12 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
if (event == QKeySequence::Copy) {
- QVariant variant;
- if (d->model)
- variant = d->model->data(currentIndex(), Qt::DisplayRole);
- if (variant.canConvert<QString>())
- QGuiApplication::clipboard()->setText(variant.toString());
+ const QModelIndex index = currentIndex();
+ if (index.isValid() && d->model) {
+ const QVariant variant = d->model->data(index, Qt::DisplayRole);
+ if (variant.canConvert<QString>())
+ QGuiApplication::clipboard()->setText(variant.toString());
+ }
event->accept();
}
#endif
@@ -3404,15 +3418,39 @@ void QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int star
} else {
int row = end + 1;
QModelIndex next;
- do { // find the next visible and enabled item
+ const int rowCount = d->model->rowCount(parent);
+ bool found = false;
+ // find the next visible and enabled item
+ while (row < rowCount && !found) {
next = d->model->index(row++, current.column(), current.parent());
- } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
- if (row > d->model->rowCount(parent)) {
+#ifdef QT_DEBUG
+ if (!next.isValid()) {
+ qWarning("Model unexpectedly returned an invalid index");
+ break;
+ }
+#endif
+ if (!isIndexHidden(next) && d->isIndexEnabled(next)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
row = start - 1;
- do { // find the previous visible and enabled item
+ // find the previous visible and enabled item
+ while (row >= 0) {
next = d->model->index(row--, current.column(), current.parent());
- } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
+#ifdef QT_DEBUG
+ if (!next.isValid()) {
+ qWarning("Model unexpectedly returned an invalid index");
+ break;
+ }
+#endif
+ if (!isIndexHidden(next) && d->isIndexEnabled(next))
+ break;
+ }
}
+
setCurrentIndex(next);
}
}
@@ -3490,9 +3528,19 @@ void QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &par
} else {
int column = end;
QModelIndex next;
- do { // find the next visible and enabled item
+ const int columnCount = model->columnCount(current.parent());
+ // find the next visible and enabled item
+ while (column < columnCount) {
next = model->index(current.row(), column++, current.parent());
- } while (next.isValid() && (q->isIndexHidden(next) || !isIndexEnabled(next)));
+#ifdef QT_DEBUG
+ if (!next.isValid()) {
+ qWarning("Model unexpectedly returned an invalid index");
+ break;
+ }
+#endif
+ if (!q->isIndexHidden(next) && isIndexEnabled(next))
+ break;
+ }
q->setCurrentIndex(next);
}
}
@@ -4301,7 +4349,7 @@ void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QMo
In DND if something has been moved then this is called.
Typically this means you should "remove" the selected item or row,
- but the behavior is view dependant (table just clears the selected indexes for example).
+ but the behavior is view-dependent (table just clears the selected indexes for example).
Either remove the selected rows or clear them
*/
@@ -4494,6 +4542,8 @@ void QAbstractItemViewPrivate::selectAll(QItemSelectionModel::SelectionFlags com
{
if (!selectionModel)
return;
+ if (!model->hasChildren(root))
+ return;
QItemSelection selection;
QModelIndex tl = model->index(0, 0, root);
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index 33924799fe..7532cf5789 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -385,6 +385,7 @@ public:
Qt::KeyboardModifiers pressedModifiers;
QPoint pressedPosition;
bool pressedAlreadySelected;
+ bool releaseFromDoubleClick;
//forces the next mouseMoveEvent to send the viewportEntered signal
//if the mouse is over the viewport and not over an item
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 2d33759d8c..5a88f1b1ef 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -572,6 +572,8 @@ void QListView::scrollTo(const QModelIndex &index, ScrollHint hint)
return;
const QRect rect = visualRect(index);
+ if (!rect.isValid())
+ return;
if (hint == EnsureVisible && d->viewport->rect().contains(rect)) {
d->viewport->update(rect);
return;
@@ -1539,12 +1541,14 @@ void QListView::doItemsLayout()
setState(ExpandingState);
if (d->model->columnCount(d->root) > 0) { // no columns means no contents
d->resetBatchStartRow();
- if (layoutMode() == SinglePass)
+ if (layoutMode() == SinglePass) {
d->doItemsLayout(d->model->rowCount(d->root)); // layout everything
- else if (!d->batchLayoutTimer.isActive()) {
+ } else if (!d->batchLayoutTimer.isActive()) {
if (!d->doItemsLayout(d->batchSize)) // layout is done
d->batchLayoutTimer.start(0, this); // do a new batch as fast as possible
}
+ } else { // clear the QBspTree generated by the last layout
+ d->clear();
}
QAbstractItemView::doItemsLayout();
setState(oldState); // restoring the oldState
@@ -2930,6 +2934,8 @@ bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
dd->stopAutoScroll();
draggedItems.clear();
dd->emitIndexesMoved(indexes);
+ // do not delete item on internal move, see filterStartDrag()
+ dd->dropEventMoved = true;
e->accept(); // we have handled the event
// if the size has not grown, we need to check if it has shrinked
if (contentsSize != contents) {
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 1b72536dcf..d120c41dc9 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1101,6 +1101,8 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
table can be found by using rowHeight(); similarly, the width of
columns can be found using columnWidth(). Since both of these are plain
widgets, you can hide either of them using their hide() functions.
+ Each header is configured with its \l{QHeaderView::}{highlightSections}
+ and \l{QHeaderView::}{sectionsClickable} properties set to \c true.
Rows and columns can be hidden and shown with hideRow(), hideColumn(),
showRow(), and showColumn(). They can be selected with selectRow()
@@ -2944,6 +2946,8 @@ void QTableView::timerEvent(QTimerEvent *event)
updateGeometries();
killTimer(d->columnResizeTimerID);
d->columnResizeTimerID = 0;
+ } else {
+ updateEditorGeometries();
}
QRect rect;
@@ -2972,6 +2976,8 @@ void QTableView::timerEvent(QTimerEvent *event)
updateGeometries();
killTimer(d->rowResizeTimerID);
d->rowResizeTimerID = 0;
+ } else {
+ updateEditorGeometries();
}
int viewportHeight = d->viewport->height();
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index b778ef9a47..6ab6576cbe 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1448,7 +1448,8 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, c
void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
{
Q_D(const QTreeView);
- const QVector<QTreeViewItem> viewItems = d->viewItems;
+ // d->viewItems changes when posted layouts are executed in itemDecorationAt, so don't copy
+ const QVector<QTreeViewItem> &viewItems = d->viewItems;
QStyleOptionViewItem option = d->viewOptionsV1();
const QStyle::State state = option.state;
@@ -1947,7 +1948,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this))
emit activated(persistent);
- d->pressedIndex = QModelIndex();
+ d->releaseFromDoubleClick = true;
d->executePostedLayout(); // we need to make sure viewItems is updated
if (d->itemsExpandable
&& d->expandsOnDoubleClick
@@ -2664,7 +2665,10 @@ QSize QTreeView::viewportSizeHint() const
\since 4.2
Expands all expandable items.
- \warning: if the model contains a large number of items,
+ \note This function will not try to \l{QAbstractItemModel::fetchMore}{fetch more}
+ data.
+
+ \warning If the model contains a large number of items,
this function will take some time to execute.
\sa collapseAll(), expand(), collapse(), setExpanded()
@@ -2686,7 +2690,10 @@ void QTreeView::expandAll()
A \a depth of -1 will expand all children, a \a depth of 0 will
only expand the given \a index.
- \warning: if the model contains a large number of items,
+ \note This function will not try to \l{QAbstractItemModel::fetchMore}{fetch more}
+ data.
+
+ \warning If the model contains a large number of items,
this function will take some time to execute.
\sa expandAll()
@@ -2751,6 +2758,9 @@ void QTreeView::collapseAll()
\since 4.3
Expands all expandable items to the given \a depth.
+ \note This function will not try to \l{QAbstractItemModel::fetchMore}{fetch more}
+ data.
+
\sa expandAll(), collapseAll(), expand(), collapse(), setExpanded()
*/
void QTreeView::expandToDepth(int depth)
@@ -3459,6 +3469,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/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 47b06a4138..713cb8e0d2 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -508,22 +508,18 @@ bool QTreeModel::insertColumns(int column, int count, const QModelIndex &parent)
bool QTreeModel::removeRows(int row, int count, const QModelIndex &parent) {
if (count < 1 || row < 0 || (row + count) > rowCount(parent))
return false;
-
- beginRemoveRows(parent, row, row + count - 1);
-
- QSignalBlocker blocker(this);
-
- QTreeWidgetItem *itm = item(parent);
+ QTreeWidgetItem *parentItem = item(parent);
+ // if parentItem is valid, begin/end RemoveRows is handled by takeChild below
+ if (!parentItem)
+ beginRemoveRows(parent, row, row + count - 1);
for (int i = row + count - 1; i >= row; --i) {
- QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i);
+ QTreeWidgetItem *child = parentItem ? parentItem->takeChild(i) : rootItem->children.takeAt(i);
Q_ASSERT(child);
child->view = nullptr;
delete child;
- child = nullptr;
}
- blocker.unblock();
-
- endRemoveRows();
+ if (!parentItem)
+ endRemoveRows();
return true;
}
@@ -1690,7 +1686,7 @@ QTreeWidgetItem *QTreeWidgetItem::clone() const
/*!
Sets the item indicator \a policy. This policy decides when the
tree branch expand/collapse indicator is shown.
- The default value is ShowForChildren.
+ The default value is DontShowIndicatorWhenChildless.
\sa childIndicatorPolicy()
*/
@@ -2601,9 +2597,6 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
This signal is emitted when the specified \a item is expanded so that
all of its children are displayed.
- \note This signal will not be emitted if an item changes its state when
- expandAll() is invoked.
-
\sa QTreeWidgetItem::isExpanded(), itemCollapsed(), expandItem()
*/
@@ -2702,7 +2695,7 @@ QTreeWidget::~QTreeWidget()
}
/*
- Retuns the number of header columns in the view.
+ Returns the number of header columns in the view.
\sa sortColumn(), currentColumn(), topLevelItemCount()
*/
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 64b0d69f6d..715a74438a 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -1304,8 +1304,7 @@ bool QAction::isIconVisibleInMenu() const
shown via a context menu, when it is false, it is not shown.
The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute
- is set for the application, falling back to the widget style hint.
- Explicitly setting this property overrides the presence (or abscence) of the attribute.
+ is set for the application. Explicitly setting this property overrides the attribute.
\sa QAction::shortcut, QCoreApplication::setAttribute()
*/
@@ -1327,8 +1326,7 @@ bool QAction::isShortcutVisibleInContextMenu() const
{
Q_D(const QAction);
if (d->shortcutVisibleInContextMenu == -1) {
- return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)
- && QGuiApplication::styleHints()->showShortcutsInContextMenus();
+ return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus);
}
return d->shortcutVisibleInContextMenu;
}
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 03e68217dd..1a0ac0cc3c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1432,9 +1432,11 @@ QFont QApplication::font()
/*!
\overload
- Returns the default font for the \a widget.
+ Returns the default font for the \a widget. If a default font was not
+ registered for the \a{widget}'s class, it returns the default font of
+ its nearest registered superclass.
- \sa fontMetrics(), QWidget::setFont()
+ \sa fontMetrics(), setFont(), QWidget::setFont()
*/
QFont QApplication::font(const QWidget *widget)
@@ -1452,14 +1454,16 @@ QFont QApplication::font(const QWidget *widget)
return hash->value(QByteArrayLiteral("QMiniFont"));
}
#endif
- FontHashConstIt it = hash->constFind(widget->metaObject()->className());
+ // Return the font for the nearest registered superclass
+ const QMetaObject *metaObj = widget->metaObject();
+ FontHashConstIt it = hash->constFind(metaObj->className());
const FontHashConstIt cend = hash->constEnd();
+ while (it == cend && metaObj != &QWidget::staticMetaObject) {
+ metaObj = metaObj->superClass();
+ it = hash->constFind(metaObj->className());
+ }
if (it != cend)
return it.value();
- for (it = hash->constBegin(); it != cend; ++it) {
- if (widget->inherits(it.key()))
- return it.value();
- }
}
return font();
}
@@ -2050,12 +2054,13 @@ void QApplication::setActiveWindow(QWidget* act)
if (w) {
w->setFocus(Qt::ActiveWindowFocusReason);
} else {
- // If the focus widget is not in the activate_window, clear the focus
w = QApplicationPrivate::focus_widget;
- if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
- QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
- else if (!QApplicationPrivate::active_window->isAncestorOf(w))
+ if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus) {
+ QApplicationPrivate::active_window->setFocus(Qt::ActiveWindowFocusReason);
+ } else if (!QApplicationPrivate::active_window->isAncestorOf(w)) {
+ // If the focus widget is not in the activate_window, clear the focus
QApplicationPrivate::setFocusWidget(nullptr, Qt::ActiveWindowFocusReason);
+ }
}
}
}
@@ -2130,7 +2135,10 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
// \a next). This is to ensure that we can tab in and out of compound widgets
// without getting stuck in a tab-loop between parent and child.
QWidget *focusProxy = test->d_func()->deepestFocusProxy();
- const bool canTakeFocus = ((focusProxy ? focusProxy->focusPolicy() : test->focusPolicy())
+ auto effectiveFocusPolicy = [](QWidget *widget) {
+ return widget->isEnabled() ? widget->focusPolicy() : Qt::NoFocus;
+ };
+ const bool canTakeFocus = (effectiveFocusPolicy(focusProxy ? focusProxy : test)
& focus_flag) == focus_flag;
const bool composites = focusProxy ? (next ? focusProxy->isAncestorOf(test)
: test->isAncestorOf(focusProxy))
@@ -2645,7 +2653,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
This function should only be called when the widget changes visibility, i.e.
when the \a widget is shown, hidden or deleted. This function does nothing
if the widget is a top-level or native, i.e. not an alien widget. In that
- case enter/leave events are genereated by the underlying windowing system.
+ case enter/leave events are generated by the underlying windowing system.
*/
extern QPointer<QWidget> qt_last_mouse_receiver;
extern Q_WIDGETS_EXPORT QWidget *qt_button_down;
@@ -3837,7 +3845,7 @@ bool QApplication::keypadNavigationEnabled()
\since 4.3
Causes an alert to be shown for \a widget if the window is not the active
- window. The alert is shown for \a msec miliseconds. If \a msec is zero (the
+ window. The alert is shown for \a msec milliseconds. If \a msec is zero (the
default), then the alert is shown indefinitely until the window becomes
active again.
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index c1052c5b9d..711510a623 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -1242,7 +1242,7 @@ QBoxLayout::Direction QBoxLayout::direction() const
layout. \c window will be the parent of the widgets that are
added to the layout.
- If you don't pass parent \c window in the constrcutor, you can
+ If you don't pass a parent \c window to the constructor, you can
at a later point use QWidget::setLayout() to install the QHBoxLayout
object onto \c window. At that point, the widgets in the layout are
reparented to have \c window as their parent.
@@ -1315,7 +1315,7 @@ QHBoxLayout::~QHBoxLayout()
layout. \c window will be the parent of the widgets that are
added to the layout.
- If you don't pass parent \c window in the constrcutor, you can
+ If you don't pass a parent \c window to the constructor, you can
at a later point use QWidget::setLayout() to install the QVBoxLayout
object onto \c window. At that point, the widgets in the layout are
reparented to have \c window as their parent.
diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp
index 84dbed7043..bde5484771 100644
--- a/src/widgets/kernel/qgesture.cpp
+++ b/src/widgets/kernel/qgesture.cpp
@@ -1033,7 +1033,7 @@ void QGestureEvent::accept(Qt::GestureType gestureType)
of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
Clearing the accept flag indicates that the event receiver does not
- want the gesture. Unwanted gestures may be propgated to the parent widget.
+ want the gesture. Unwanted gestures may be propagated to the parent widget.
\sa QGestureEvent::accept()
*/
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index b4e8541172..e2777b65d4 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/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index d4ff9083f1..09bc15da32 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1386,6 +1386,11 @@ QRect QLayout::alignmentRect(const QRect &r) const
*/
void QLayout::removeWidget(QWidget *widget)
{
+ if (Q_UNLIKELY(!widget)) {
+ qWarning("QLayout::removeWidget: Cannot remove a null widget.");
+ return;
+ }
+
int i = 0;
QLayoutItem *child;
while ((child = itemAt(i))) {
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 24e0c46032..b6b04795d5 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -453,6 +453,19 @@ QT_BEGIN_NAMESPACE
each frame. To restore the preserved behavior, call setUpdateBehavior() with
\c PartialUpdate.
+ \note Displaying a QOpenGLWidget requires an alpha channel in the associated
+ top-level window's backing store due to the way composition with other
+ QWidget-based content works. If there is no alpha channel, the content
+ rendered by the QOpenGLWidget will not be visible. This can become
+ particularly relevant on Linux/X11 in remote display setups (such as, with
+ Xvnc), when using a color depth lower than 24. For example, a color depth of
+ 16 will typically map to using a backing store image with the format
+ QImage::Format_RGB16 (RGB565), leaving no room for an alpha
+ channel. Therefore, if experiencing problems with getting the contents of a
+ QOpenGLWidget composited correctly with other the widgets in the window, make
+ sure the server (such as, vncserver) is configured with a 24 or 32 bit depth
+ instead of 16.
+
\section1 Alternatives
Adding a QOpenGLWidget into a window turns on OpenGL-based
@@ -1452,8 +1465,13 @@ bool QOpenGLWidget::event(QEvent *e)
}
if (!d->initialized && !size().isEmpty() && window()->windowHandle()) {
d->initialize();
- if (d->initialized)
+ if (d->initialized) {
d->recreateFbo();
+ // QTBUG-89812: generate a paint event, like resize would do,
+ // otherwise a QOpenGLWidget in a QDockWidget may not show the
+ // content upon (un)docking.
+ d->sendPaintEvent(QRect(QPoint(0, 0), size()));
+ }
}
break;
case QEvent::ScreenChangeInternal:
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index f26923eeb0..42623ee3a7 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -133,9 +133,10 @@ public:
Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) noexcept { bits.verPolicy = d; }
void setControlType(ControlType type) noexcept;
+ // ### Qt 7: consider making Policy a QFlags and removing these casts
QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const noexcept {
- return ( (verticalPolicy() & ExpandFlag) ? Qt::Vertical : Qt::Orientations() )
- | ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ;
+ return ( (verticalPolicy() & static_cast<Policy>(ExpandFlag)) ? Qt::Vertical : Qt::Orientations() )
+ | ( (horizontalPolicy() & static_cast<Policy>(ExpandFlag)) ? Qt::Horizontal : Qt::Orientations() ) ;
}
Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) noexcept { bits.hfw = b; }
@@ -232,6 +233,7 @@ Q_DECLARE_TYPEINFO(QSizePolicy, Q_RELOCATABLE_TYPE);
#endif
Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes)
+Q_DECLARE_MIXED_ENUM_OPERATORS(int, QSizePolicy::Policy, QSizePolicy::PolicyFlag)
#ifndef QT_NO_DATASTREAM
Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &);
diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp
index 0056bebdc6..530b9e1bc6 100644
--- a/src/widgets/kernel/qtestsupport_widgets.cpp
+++ b/src/widgets/kernel/qtestsupport_widgets.cpp
@@ -49,9 +49,16 @@ QT_BEGIN_NAMESPACE
/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a widget's window is active.
+ Returns \c true if \a widget is active within \a timeout milliseconds. Otherwise returns \c false.
- Returns \c true if \c widget's window is active within \a timeout milliseconds, otherwise returns \c false.
+ The method is useful in tests that call QWidget::show() and rely on the widget actually being
+ active (i.e. being visible and having focus) before proceeding.
+
+ \note The method will time out and return \c false if another window prevents \a widget from
+ becoming active.
+
+ \note Since focus is an exclusive property, \a widget may loose its focus to another window at
+ any time - even after the method has returned \c true.
\sa qWaitForWindowExposed(), QWidget::isActiveWindow()
*/
@@ -65,20 +72,16 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *wid
/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a widget's window is exposed.
- Returns \c true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns \c false.
-
- This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
- time after being asked to show itself on the screen.
+ Returns \c true if \a widget is exposed within \a timeout milliseconds. Otherwise returns \c false.
- Note that a window that is mapped to screen may still not be considered exposed if the window client
- area is completely covered by other windows, or if the window is otherwise not visible. This function
- will then time out when waiting for such a window.
+ The method is useful in tests that call QWidget::show() and rely on the widget actually being
+ being visible before proceeding.
- A specific configuration where this happens is when using QGLWidget as a viewport widget on macOS:
- The viewport widget gets the expose event, not the parent widget.
+ \note A window mapped to screen may still not be considered exposed, if the window client area is
+ not visible, e.g. because it is completely covered by other windows.
+ In such cases, the method will time out and return \c false.
- \sa qWaitForWindowActive()
+ \sa qWaitForWindowActive(), QWidget::isVisible(), QWindow::isExposed()
*/
Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout)
{
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 0c9db61f91..0f7bc97c1f 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -334,7 +334,7 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e)
break;
-#if defined (Q_OS_QNX) // On QNX the window activate and focus events are delayed and will appear
+#if defined (Q_OS_QNX) || defined (Q_OS_WASM) // On QNX the window activate and focus events are delayed and will appear
// after the window is shown.
case QEvent::WindowActivate:
case QEvent::FocusIn:
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 1eac50df81..e94520021e 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -783,6 +783,8 @@ void QWidget::setAutoFillBackground(bool enabled)
and a compositing window manager.
\li Windows: The widget needs to have the Qt::FramelessWindowHint window flag set
for the translucency to work.
+ \li \macos: The widget needs to have the Qt::FramelessWindowHint window flag set
+ for the translucency to work.
\endlist
@@ -2303,7 +2305,7 @@ void QWidgetPrivate::deactivateWidgetCleanup()
/*!
- Returns a pointer to the widget with window identifer/handle \a
+ Returns a pointer to the widget with window identifier/handle \a
id.
The window identifier type depends on the underlying window
@@ -2958,9 +2960,9 @@ bool QWidget::isFullScreen() const
Calling this function only affects \l{isWindow()}{windows}.
- To return from full-screen mode, call showNormal().
+ To return from full-screen mode, call showNormal() or close().
- Full-screen mode works fine under Windows, but has certain
+ \note Full-screen mode works fine under Windows, but has certain
problems under X. These problems are due to limitations of the
ICCCM protocol that specifies the communication between X11
clients and the window manager. ICCCM simply does not understand
@@ -2980,7 +2982,14 @@ bool QWidget::isFullScreen() const
X11 window managers that follow modern post-ICCCM specifications
support full-screen mode properly.
- \sa showNormal(), showMaximized(), show(), hide(), isVisible()
+ On macOS, showing a window full screen puts the entire application in
+ full-screen mode, providing it with a dedicated desktop. Showing another
+ window while the application runs in full-screen mode might automatically
+ make that window full screen as well. To prevent that, exit full-screen
+ mode by calling showNormal() or by close() on the full screen window
+ before showing another window.
+
+ \sa showNormal(), showMaximized(), show(), isVisible(), close()
*/
void QWidget::showFullScreen()
{
@@ -4682,7 +4691,9 @@ void QWidgetPrivate::resolveLayoutDirection()
/*!
\property QWidget::layoutDirection
- \brief the layout direction for this widget
+ \brief the layout direction for this widget.
+
+ \note This method no longer affects text layout direction since Qt 4.7.
By default, this property is set to Qt::LeftToRight.
@@ -4693,7 +4704,6 @@ void QWidgetPrivate::resolveLayoutDirection()
has been called for the parent do not inherit the parent's layout
direction.
- This method no longer affects text layout direction since Qt 4.7.
\sa QApplication::layoutDirection
*/
@@ -5286,10 +5296,11 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
(source->d_func());
if (!sourced->context) {
- QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, repaintManager);
+ const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+ QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
sourced->context = &context;
if (!sharedPainter) {
- setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), rgn.translated(offset));
+ setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), effectRgn.translated(offset));
QPainter p(pdev);
p.translate(offset);
context.painter = &p;
@@ -5303,7 +5314,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
}
sharedPainter->save();
sharedPainter->translate(offset);
- setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatioF(), rgn.translated(offset));
+ setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatioF(), effectRgn.translated(offset));
graphicsEffect->draw(sharedPainter);
setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
sharedPainter->restore();
@@ -5311,12 +5322,13 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
sourced->context = nullptr;
if (repaintManager)
- repaintManager->markNeedsFlush(q, rgn, offset);
+ repaintManager->markNeedsFlush(q, effectRgn, offset);
return;
}
}
#endif // QT_CONFIG(graphicseffect)
+ flags = flags & ~UseEffectRegionBounds;
const bool alsoOnScreen = flags & DrawPaintOnScreen;
const bool recursive = flags & DrawRecursive;
@@ -6745,8 +6757,21 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second)
lastFocusChild = target;
QWidget *focusProxy = target->d_func()->deepestFocusProxy();
- if (!focusProxy || !target->isAncestorOf(focusProxy))
+ if (!focusProxy || !target->isAncestorOf(focusProxy)) {
+ // QTBUG-81097: Another case is possible here. We can have a child
+ // widget, that sets its focusProxy() to the parent (target).
+ // An example of such widget is a QLineEdit, nested into
+ // a QAbstractSpinBox. In this case such widget should be considered
+ // the last focus child.
+ for (auto *object : target->children()) {
+ QWidget *w = qobject_cast<QWidget*>(object);
+ if (w && w->focusProxy() == target) {
+ lastFocusChild = w;
+ break;
+ }
+ }
return;
+ }
lastFocusChild = focusProxy;
@@ -12108,7 +12133,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
Q_D(QWidget);
- d->aboutToDestroy();
+ d->aboutToDestroy(destroyWindow);
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBackingStore(d->effectiveRectFor(geometry()));
d->deactivateWidgetCleanup();
@@ -12853,4 +12878,4 @@ QDebug operator<<(QDebug debug, const QWidget *widget)
QT_END_NAMESPACE
#include "moc_qwidget.cpp"
-
+#include "moc_qwidget_p.cpp"
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 6aadfe13f7..c432f4b5d5 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -229,7 +229,8 @@ public:
DontSubtractOpaqueChildren = 0x10,
DontDrawOpaqueChildren = 0x20,
DontDrawNativeChildren = 0x40,
- DontSetCompositionMode = 0x80
+ DontSetCompositionMode = 0x80,
+ UseEffectRegionBounds = 0x100
};
Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
Q_FLAG(DrawWidgetFlags)
@@ -464,7 +465,7 @@ public:
// aboutToDestroy() is called just before the contents of
// QWidget::destroy() is executed. It's used to signal QWidget
// sub-classes that their internals are about to be released.
- virtual void aboutToDestroy() {}
+ virtual void aboutToDestroy(bool destroyWindow) { Q_UNUSED(destroyWindow); }
inline QWidget *effectiveFocusWidget() {
QWidget *w = q_func();
diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp
index e7e85c39e7..6e72aae5b7 100644
--- a/src/widgets/kernel/qwidgetrepaintmanager.cpp
+++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp
@@ -801,6 +801,18 @@ bool QWidgetRepaintManager::syncAllowed()
return true;
}
+static bool isDrawnInEffect(const QWidget *w)
+{
+#if QT_CONFIG(graphicseffect)
+ do {
+ if (w->graphicsEffect())
+ return true;
+ w = w->parentWidget();
+ } while (w);
+#endif
+ return false;
+}
+
void QWidgetRepaintManager::paintAndFlush()
{
qCInfo(lcWidgetPainting) << "Painting and flushing dirty"
@@ -888,7 +900,8 @@ void QWidgetRepaintManager::paintAndFlush()
}
#endif
- if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
+ if (!isDrawnInEffect(w) && !hasDirtySiblingsAbove && wd->isOpaque
+ && !dirty.intersects(widgetDirty.boundingRect())) {
opaqueNonOverlappedWidgets.append(w);
} else {
resetWidget(w);
@@ -1005,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
// Paint the rest with composition.
if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
- QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
+ QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
+ | QWidgetPrivate::UseEffectRegionBounds;
tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
}
@@ -1396,3 +1410,4 @@ void QWidgetPrivate::invalidateBackingStore_resizeHelper(const QPoint &oldPos, c
QT_END_NAMESPACE
#include "qwidgetrepaintmanager.moc"
+#include "moc_qwidgetrepaintmanager_p.cpp"
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 51e484202d..4165232c47 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -634,7 +634,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
receiver = qt_button_down;
else if(popupChild)
receiver = popupChild;
- QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
+ const QPoint localPos = receiver->mapFromGlobal(event->globalPos());
+ QContextMenuEvent e(QContextMenuEvent::Mouse, localPos, event->globalPos(), event->modifiers());
QApplication::forwardEvent(receiver, &e, event);
}
#else
@@ -739,8 +740,12 @@ bool QWidgetWindow::updateSize()
void QWidgetWindow::updateMargins()
{
- const QMargins margins = frameMargins();
+ // QTBUG-79147 (Windows): Bail out on resize events after closing a dialog
+ // and destroying the platform window which would clear the margins.
QTLWExtra *te = m_widget->d_func()->topData();
+ if (te->window == nullptr || te->window->handle() == nullptr)
+ return;
+ const QMargins margins = frameMargins();
te->posIncludesFrame= false;
te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());
m_widget->data->fstrut_dirty = false;
diff --git a/src/widgets/styles/images/standardbutton-closetab-32.png b/src/widgets/styles/images/standardbutton-closetab-32.png
new file mode 100644
index 0000000000..93e1246b47
--- /dev/null
+++ b/src/widgets/styles/images/standardbutton-closetab-32.png
Binary files differ
diff --git a/src/widgets/styles/images/standardbutton-closetab-down-32.png b/src/widgets/styles/images/standardbutton-closetab-down-32.png
new file mode 100644
index 0000000000..343b72586e
--- /dev/null
+++ b/src/widgets/styles/images/standardbutton-closetab-down-32.png
Binary files differ
diff --git a/src/widgets/styles/images/standardbutton-closetab-hover-32.png b/src/widgets/styles/images/standardbutton-closetab-hover-32.png
new file mode 100644
index 0000000000..41ce0265c7
--- /dev/null
+++ b/src/widgets/styles/images/standardbutton-closetab-hover-32.png
Binary files differ
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 559ad913f8..a79c33005c 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -126,6 +126,30 @@ static QWindow *qt_getWindow(const QWidget *widget)
return widget ? widget->window()->windowHandle() : nullptr;
}
+static QIcon tabBarCloseButtonIcon()
+{
+ QIcon result;
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-16.png")),
+ QIcon::Normal, QIcon::Off);
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-32.png")),
+ QIcon::Normal, QIcon::Off);
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-down-16.png")),
+ QIcon::Normal, QIcon::On);
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-down-32.png")),
+ QIcon::Normal, QIcon::On);
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-hover-16.png")),
+ QIcon::Active, QIcon::Off);
+ result.addPixmap(QPixmap(
+ QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-hover-32.png")),
+ QIcon::Active, QIcon::Off);
+ return result;
+}
+
/*!
\class QCommonStyle
\brief The QCommonStyle class encapsulates the common Look and Feel of a GUI.
@@ -419,17 +443,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
break;
case PE_IndicatorTabClose: {
- if (d->tabBarcloseButtonIcon.isNull()) {
- d->tabBarcloseButtonIcon.addPixmap(QPixmap(
- QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-16.png")),
- QIcon::Normal, QIcon::Off);
- d->tabBarcloseButtonIcon.addPixmap(QPixmap(
- QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-down-16.png")),
- QIcon::Normal, QIcon::On);
- d->tabBarcloseButtonIcon.addPixmap(QPixmap(
- QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-hover-16.png")),
- QIcon::Active, QIcon::Off);
- }
+ if (d->tabBarcloseButtonIcon.isNull())
+ d->tabBarcloseButtonIcon = tabBarCloseButtonIcon();
const int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize, opt);
QIcon::Mode mode = opt->state & State_Enabled ?
@@ -1693,8 +1708,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
alignment |= Qt::TextHideMnemonic;
rect.translate(shiftX, shiftY);
p->setFont(toolbutton->font);
+ const QString text = d->toolButtonElideText(toolbutton, rect, alignment);
proxy()->drawItemText(p, rect, alignment, toolbutton->palette,
- opt->state & State_Enabled, toolbutton->text,
+ opt->state & State_Enabled, text,
QPalette::ButtonText);
} else {
QPixmap pm;
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 46e5b6dd17..a225d4b563 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1729,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();
}
@@ -2039,22 +2040,24 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
cachePainter.setPen(d->topShadow());
cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
- // Draw button gradient
- QColor buttonColor = d->buttonColor(option->palette);
- QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2);
- QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver ) ? buttonColor : buttonColor.darker(104));
+ if (!upRect.isNull()) {
+ // Draw button gradient
+ const QColor buttonColor = d->buttonColor(option->palette);
+ const QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2);
+ const QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver )
+ ? buttonColor : buttonColor.darker(104));
- // Draw button gradient
- cachePainter.setPen(Qt::NoPen);
- cachePainter.setBrush(gradient);
+ cachePainter.setPen(Qt::NoPen);
+ cachePainter.setBrush(gradient);
- cachePainter.save();
- cachePainter.setClipRect(updownRect);
- cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
- cachePainter.setPen(QPen(d->innerContrastLine()));
- cachePainter.setBrush(Qt::NoBrush);
- cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2);
- cachePainter.restore();
+ cachePainter.save();
+ cachePainter.setClipRect(updownRect);
+ cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
+ cachePainter.setPen(QPen(d->innerContrastLine()));
+ cachePainter.setBrush(Qt::NoBrush);
+ cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2);
+ cachePainter.restore();
+ }
if ((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) && upIsActive) {
if (sunken)
@@ -2082,12 +2085,14 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
cachePainter.restore();
}
- // outline the up/down buttons
- cachePainter.setPen(outline);
- if (spinBox->direction == Qt::RightToLeft) {
- cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
- } else {
- cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ // buttonSymbols == NoButtons results in 'null' rects
+ // and a tiny rect painted in the corner.
+ cachePainter.setPen(outline);
+ if (spinBox->direction == Qt::RightToLeft)
+ cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
+ else
+ cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
}
if (upIsActive && sunken) {
diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp
index 7cc32b2039..3ee68242de 100644
--- a/src/widgets/styles/qpixmapstyle.cpp
+++ b/src/widgets/styles/qpixmapstyle.cpp
@@ -1230,3 +1230,5 @@ QSize QPixmapStylePrivate::computeSize(const QPixmapStyleDescriptor &desc, int w
}
QT_END_NAMESPACE
+
+#include "moc_qpixmapstyle_p.cpp"
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index d80dafcce6..669f158b7b 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -91,7 +91,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
look of the different platforms supported by Qt (QWindowsStyle,
QMacStyle, etc.). These styles are built into the
Qt GUI module, other styles can be made available using Qt's
- plugin mechansim.
+ plugin mechanism.
Most functions for drawing style elements take four arguments:
@@ -697,7 +697,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value PE_IndicatorToolBarSeparator The separator in a toolbar.
\value PE_PanelToolBar The panel for a toolbar.
\value PE_PanelTipLabel The panel for a tip label.
- \value PE_FrameTabBarBase The frame that is drawn for a tab bar, ususally drawn for a tab bar that isn't part of a tab widget.
+ \value PE_FrameTabBarBase The frame that is drawn for a tab bar, usually drawn for a tab bar that isn't part of a tab widget.
\value PE_IndicatorTabTear Deprecated. Use \l{PE_IndicatorTabTearLeft} instead.
\value PE_IndicatorTabTearLeft An indicator that a tab is partially scrolled out on the left side of the visible tab bar when there are many tabs.
\value PE_IndicatorTabTearRight An indicator that a tab is partially scrolled out on the right side of the visible tab bar when there are many tabs.
@@ -1796,7 +1796,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
cause a list view expansion to be selected.
\value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size
- to prevent scoll arrows.
+ to prevent scroll arrows.
\value SH_ComboBox_Popup Allows popups as a combobox drop-down
menu.
@@ -2450,17 +2450,19 @@ QDebug operator<<(QDebug debug, QStyle::State state)
const QStyle * QStyle::proxy() const
{
Q_D(const QStyle);
- return d->proxyStyle;
+ return d->proxyStyle == this ? this : d->proxyStyle->proxy();
}
/* \internal
This function sets the base style that style calls will be
- redirected to. Note that ownership is not transferred.
+ redirected to. Note that ownership is not transferred. \a style
+ must be a valid pointer (not nullptr).
*/
void QStyle::setProxy(QStyle *style)
{
Q_D(QStyle);
+ Q_ASSERT(style);
d->proxyStyle = style;
}
diff --git a/src/widgets/styles/qstyle.qrc b/src/widgets/styles/qstyle.qrc
index d3511ee754..44090a54f0 100644
--- a/src/widgets/styles/qstyle.qrc
+++ b/src/widgets/styles/qstyle.qrc
@@ -104,8 +104,11 @@
<file>images/standardbutton-yes-128.png</file>
<file>images/standardbutton-yes-16.png</file>
<file>images/standardbutton-yes-32.png</file>
+ <file>images/standardbutton-closetab-32.png</file>
<file>images/standardbutton-closetab-16.png</file>
+ <file>images/standardbutton-closetab-down-32.png</file>
<file>images/standardbutton-closetab-down-16.png</file>
+ <file>images/standardbutton-closetab-hover-32.png</file>
<file>images/standardbutton-closetab-hover-16.png</file>
<file>images/refresh-24.png</file>
<file>images/refresh-32.png</file>
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 95232dd97b..7459a8d4e7 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -3481,7 +3481,7 @@ QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(int version)
/*!
Construct a QStyleOptionTabBarBase, initializing the members
- vaiables to their default values.
+ variables to their default values.
*/
QStyleOptionTabBarBase::QStyleOptionTabBarBase()
: QStyleOption(Version, SO_TabBarBase), shape(QTabBar::RoundedNorth),
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 72f7ad7455..11d6f4649f 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -57,6 +57,10 @@
#if QT_CONFIG(lineedit)
#include <qlineedit.h>
#endif
+#if QT_CONFIG(textedit)
+#include <qtextedit.h>
+#endif
+#include <qplaintextedit.h>
#include <private/qwindowsstyle_p.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
@@ -117,6 +121,9 @@
#if QT_CONFIG(toolbar)
#include <QtWidgets/qtoolbar.h>
#endif
+#if QT_CONFIG(pushbutton)
+#include <QtWidgets/qpushbutton.h>
+#endif
#include <QtGui/qpainterpath.h>
#include <QtGui/qscreen.h>
@@ -1458,6 +1465,11 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
p->setBrush(cg, w->foregroundRole(), pal->foreground);
p->setBrush(cg, QPalette::WindowText, pal->foreground);
p->setBrush(cg, QPalette::Text, pal->foreground);
+ QColor phColor(pal->foreground.color());
+ phColor.setAlpha((phColor.alpha() + 1) / 2);
+ QBrush placeholder = pal->foreground;
+ placeholder.setColor(phColor);
+ p->setBrush(cg, QPalette::PlaceholderText, placeholder);
}
if (pal->selectionBackground.style() != Qt::NoBrush)
p->setBrush(cg, QPalette::Highlight, pal->selectionBackground);
@@ -2085,6 +2097,14 @@ 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);
+ }
+#endif
#if QT_CONFIG(lineedit)
// LineEdit sets Sunken flag to indicate Sunken frame (argh)
if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(obj)) {
@@ -2425,11 +2445,12 @@ static QWidget *embeddedWidget(QWidget *w)
}
/** \internal
- in case w is an embedded widget, return the container widget
- (i.e, the widget for which the rules actualy apply)
- (exemple, if w is a lineedit embedded in a combobox, return the combobox)
+ Returns the widget whose style rules apply to \a w.
+
+ When \a w is an embedded widget, this is the container widget.
+ For example, if w is a line edit embedded in a combobox, this returns the combobox.
+ When \a w is not embedded, this function return \a w itself.
- if w is not embedded, return w itself
*/
static QWidget *containerWidget(const QWidget *w)
{
@@ -2511,7 +2532,14 @@ static quint64 extendedPseudoClass(const QWidget *w)
pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
} else
#endif
- { } // required for the above ifdef'ery to work
+#if QT_CONFIG(textedit)
+ if (const QTextEdit *edit = qobject_cast<const QTextEdit *>(w)) {
+ pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
+ } else
+#endif
+ if (const QPlainTextEdit *edit = qobject_cast<const QPlainTextEdit *>(w)) {
+ pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
+ }
return pc;
}
@@ -2626,6 +2654,9 @@ void QStyleSheetStyle::setProperties(QWidget *w)
default: v = decl.d->values.at(0).variant; break;
}
+ if (propertyL1 == "styleSheet" && value == v)
+ continue;
+
w->setProperty(propertyL1, v);
}
}
@@ -2908,6 +2939,12 @@ void QStyleSheetStyle::polish(QWidget *w)
if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
|| (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
w->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ if (rule.hasBox() || !rule.hasNativeBorder()
+#if QT_CONFIG(pushbutton)
+ || (qobject_cast<QPushButton *>(w))
+#endif
+ )
+ w->setAttribute(Qt::WA_MacShowFocusRect, false);
}
}
@@ -3513,7 +3550,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 {
@@ -3538,10 +3576,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QRect textRect = button->rect;
const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight;
- const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
+ 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))
@@ -3600,8 +3638,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))
@@ -3760,10 +3796,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(iconRect.center());
p->drawPixmap(pmr.topLeft(), pixmap);
- } else if (checkable) {
+ } else if (mi.menuHasCheckableItems) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
const QRect cmRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
- if (subSubRule.hasDrawable() || checked) {
+ if (checkable && (subSubRule.hasDrawable() || checked)) {
QStyleOptionMenuItem newMi = mi;
if (!dis)
newMi.state |= State_Enabled;
@@ -4421,14 +4457,17 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_PanelLineEdit:
if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
-#if QT_CONFIG(spinbox)
- if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
- QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
- if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
- return;
- rule = spinboxRule;
+ // Fall back to container widget's render rule
+ if (w) {
+ QWidget *container = containerWidget(w);
+ if (container && container != w) {
+ QRenderRule containerRule = renderRule(container, opt);
+ if (!containerRule.hasNativeBorder() || !containerRule.baseStyleCanDraw())
+ return;
+ rule = containerRule;
+ }
}
-#endif
+
if (rule.hasNativeBorder()) {
QStyleOptionFrame frmOpt(*frm);
rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
@@ -5143,18 +5182,19 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
QSize sz(csz);
if (mi->text.contains(QLatin1Char('\t')))
sz.rwidth() += 12; //as in QCommonStyle
- bool checkable = mi->checkType != QStyleOptionMenuItem::NotCheckable;
if (!mi->icon.isNull()) {
const int pmSmall = pixelMetric(PM_SmallIconSize);
const QSize pmSize = mi->icon.actualSize(QSize(pmSmall, pmSmall));
- sz.rwidth() += pmSize.width() + 4;
- } else if (checkable) {
+ sz.rwidth() += std::max(mi->maxIconWidth, pmSize.width()) + 4;
+ } else if (mi->menuHasCheckableItems) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
QRect checkmarkRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
sz.rwidth() += std::max(mi->maxIconWidth, checkmarkRect.width()) + 4;
+ } else {
+ sz.rwidth() += mi->maxIconWidth;
}
if (subRule.hasFont) {
- QFontMetrics fm(subRule.font);
+ QFontMetrics fm(subRule.font.resolve(mi->font));
const QRect r = fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, mi->text);
sz = sz.expandedTo(r.size());
}
@@ -5827,6 +5867,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 47fee68538..ef7207a8a3 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
{
Q_D(QCompleter);
QAbstractItemModel *oldModel = d->proxy->sourceModel();
+ if (oldModel == model)
+ return;
#if QT_CONFIG(filesystemmodel)
if (qobject_cast<const QFileSystemModel *>(oldModel))
setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
@@ -1208,7 +1210,7 @@ QCompleter::CompletionMode QCompleter::completionMode() const
/*!
\property QCompleter::filterMode
- \brief how the filtering is performed
+ \brief This property controls how filtering is performed.
\since 5.2
If filterMode is set to Qt::MatchStartsWith, only those entries that start
@@ -1216,11 +1218,14 @@ QCompleter::CompletionMode QCompleter::completionMode() const
the entries that contain the typed characters, and Qt::MatchEndsWith the
ones that end with the typed characters.
- Currently, only these three modes are implemented. Setting filterMode to
- any other Qt::MatchFlag will issue a warning, and no action will be
- performed.
+ Setting filterMode to any other Qt::MatchFlag will issue a warning, and no
+ action will be performed. Because of this, the \c Qt::MatchCaseSensitive
+ flag has no effect. Use the \l caseSensitivity property to control case
+ sensitivity.
The default mode is Qt::MatchStartsWith.
+
+ \sa caseSensitivity
*/
void QCompleter::setFilterMode(Qt::MatchFlags filterMode)
@@ -1747,9 +1752,9 @@ void QCompleter::setMaxVisibleItems(int maxItems)
\property QCompleter::caseSensitivity
\brief the case sensitivity of the matching
- The default is Qt::CaseSensitive.
+ The default value is \c Qt::CaseSensitive.
- \sa completionColumn, completionRole, modelSorting
+ \sa completionColumn, completionRole, modelSorting, filterMode
*/
void QCompleter::setCaseSensitivity(Qt::CaseSensitivity cs)
{
diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp
index be763f182e..4c87448a7d 100644
--- a/src/widgets/util/qscrollerproperties.cpp
+++ b/src/widgets/util/qscrollerproperties.cpp
@@ -347,13 +347,13 @@ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &v
\value AcceleratingFlickSpeedupFactor The current speed is multiplied by this number if an
accelerating flick is detected. Should be \c{>= 1}.
- \value SnapPositionRatio This is the distance that the user must drag the area beween two snap
+ \value SnapPositionRatio This is the distance that the user must drag the area between two snap
points in order to snap it to the next position. \c{0.33} means that the scroll must only
reach one third of the distance between two snap points to snap to the next one. The ratio must
be between \c 0 and \c 1.
\value SnapTime This is the time factor for the scrolling curve. A lower value means that the
- scrolling will take longer. The scrolling distance is independet of this value.
+ scrolling will take longer. The scrolling distance is independent of this value.
\value OvershootDragResistanceFactor This value is the factor between the mouse dragging and
the actual scroll area movement (during overshoot). The factor must be between \c 0 and \c 1.
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index ee52139913..203fcbc443 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -130,7 +130,9 @@ static QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon)
Only on X11, when a tooltip is requested, the QSystemTrayIcon receives a QHelpEvent
of type QEvent::ToolTip. Additionally, the QSystemTrayIcon receives wheel events of
- type QEvent::Wheel. These are not supported on any other platform.
+ type QEvent::Wheel. These are not supported on any other platform. Note: Since GNOME
+ Shell version 3.26, not all QSystemTrayIcon::ActivationReason are supported by the
+ system without shell extensions installed.
\sa QDesktopServices, QDesktopWidget, {Desktop Integration}, {System Tray Icon Example}
*/
@@ -190,7 +192,7 @@ QSystemTrayIcon::~QSystemTrayIcon()
The menu will pop up when the user requests the context menu for the system
tray icon by clicking the mouse button.
- On \macos, this is currenly converted to a NSMenu, so the
+ On \macos, this is currently converted to a NSMenu, so the
aboutToHide() signal is not emitted.
\note The system tray icon does not take ownership of the menu. You must
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 720a9f908a..ee43165ea0 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -202,7 +202,7 @@ void QAbstractScrollAreaScrollBarContainer::addWidget(QWidget *widget, LogicalPo
}
/*! \internal
- Retuns a list of scroll bar widgets for the given position. The scroll bar
+ Returns a list of scroll-bar widgets for the given position. The scroll bar
itself is not returned.
*/
QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition position)
@@ -442,8 +442,10 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol
viewportRect.adjust(right, top, -left, -bottom);
else
viewportRect.adjust(left, top, -right, -bottom);
+ viewportRect = QStyle::visualRect(opt.direction, opt.rect, viewportRect);
+ viewportRect.translate(-overshoot);
+ viewport->setGeometry(viewportRect); // resize the viewport last
- viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last
*needHorizontalScrollbar = needh;
*needVerticalScrollbar = needv;
}
diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp
index a0611565b8..5ba50b6792 100644
--- a/src/widgets/widgets/qabstractslider.cpp
+++ b/src/widgets/widgets/qabstractslider.cpp
@@ -107,7 +107,7 @@ QT_BEGIN_NAMESPACE
\row \li \l sliderReleased()
\li the user releases the slider.
\row \li \l actionTriggered()
- \li a slider action was triggerd.
+ \li a slider action was triggered.
\row \li \l rangeChanged()
\li a the range has changed.
\endtable
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index bb64edd85d..caa3cbfd4d 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2952,7 +2952,7 @@ void QCalendarWidget::setDateEditEnabled(bool enable)
\since 4.3
If the calendar widget's \l{dateEditEnabled}{date edit is enabled}, this
- property specifies the amount of time (in millseconds) that the date edit
+ property specifies the amount of time (in milliseconds) that the date edit
remains open after the most recent user input. Once this time has elapsed,
the date specified in the date edit is accepted and the popup is closed.
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 68bd647741..7a496c27e0 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -547,8 +547,6 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
setLineWidth(1);
}
- setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
-
if (top) {
layout->insertWidget(0, top);
connect(top, SIGNAL(doScroll(int)), this, SLOT(scrollItemView(int)));
@@ -561,7 +559,7 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
// Some styles (Mac) have a margin at the top and bottom of the popup.
layout->insertSpacing(0, 0);
layout->addSpacing(0);
- updateTopBottomMargin();
+ updateStyleSettings();
}
void QComboBoxPrivateContainer::scrollItemView(int action)
@@ -744,14 +742,20 @@ void QComboBoxPrivateContainer::updateTopBottomMargin()
boxLayout->invalidate();
}
+void QComboBoxPrivateContainer::updateStyleSettings()
+{
+ // add scroller arrows if style needs them
+ QStyleOptionComboBox opt = comboStyleOption();
+ view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
+ combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo));
+ setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
+ updateTopBottomMargin();
+}
+
void QComboBoxPrivateContainer::changeEvent(QEvent *e)
{
- if (e->type() == QEvent::StyleChange) {
- QStyleOptionComboBox opt = comboStyleOption();
- view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
- combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo));
- setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
- }
+ if (e->type() == QEvent::StyleChange)
+ updateStyleSettings();
QFrame::changeEvent(e);
}
@@ -2762,8 +2766,10 @@ void QComboBox::showPopup()
#endif
// set current item and select it
- view()->selectionModel()->setCurrentIndex(d->currentIndex,
- QItemSelectionModel::ClearAndSelect);
+ QItemSelectionModel::SelectionFlags selectionMode = QItemSelectionModel::ClearAndSelect;
+ if (view()->selectionBehavior() == QAbstractItemView::SelectRows)
+ selectionMode.setFlag(QItemSelectionModel::Rows);
+ view()->selectionModel()->setCurrentIndex(d->currentIndex, selectionMode);
QComboBoxPrivateContainer* container = d->viewContainer();
QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this));
@@ -2894,13 +2900,15 @@ void QComboBox::showPopup()
QGuiApplication::inputMethod()->reset();
}
- QScrollBar *sb = view()->horizontalScrollBar();
- Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy();
- bool needHorizontalScrollBar = (policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn)
- && sb->minimum() < sb->maximum();
- if (needHorizontalScrollBar) {
+ const QScrollBar *sb = view()->horizontalScrollBar();
+ const auto needHorizontalScrollBar = [this, sb]{
+ const Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy();
+ return (policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn)
+ && sb->minimum() < sb->maximum();
+ };
+ const bool neededHorizontalScrollBar = needHorizontalScrollBar();
+ if (neededHorizontalScrollBar)
listRect.adjust(0, 0, 0, sb->height());
- }
// Hide the scrollers here, so that the listrect gets the full height of the container
// If the scrollers are truly needed, the later call to container->updateScrollers()
@@ -2943,6 +2951,11 @@ void QComboBox::showPopup()
}
}
container->show();
+ if (!neededHorizontalScrollBar && needHorizontalScrollBar()) {
+ listRect.adjust(0, 0, 0, sb->height());
+ container->setGeometry(listRect);
+ }
+
container->updateScrollers();
view()->setFocus();
@@ -3112,6 +3125,8 @@ void QComboBox::changeEvent(QEvent *e)
Q_D(QComboBox);
switch (e->type()) {
case QEvent::StyleChange:
+ if (d->container)
+ d->container->updateStyleSettings();
d->updateDelegate();
#ifdef Q_OS_MAC
case QEvent::MacSizeChange:
@@ -3181,8 +3196,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/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index d7b2457c49..45580ba943 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -223,6 +223,7 @@ public:
int topMargin() const;
int bottomMargin() const { return topMargin(); }
void updateTopBottomMargin();
+ void updateStyleSettings();
QTimer blockMouseReleaseTimer;
QBasicTimer adjustSizeTimer;
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index e9462ed229..1d8b6cf4a5 100644
--- a/src/widgets/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
@@ -216,6 +216,7 @@ void QCommandLinkButtonPrivate::init()
Q_Q(QCommandLinkButton);
QPushButtonPrivate::init();
q->setAttribute(Qt::WA_Hover);
+ q->setAttribute(Qt::WA_MacShowFocusRect, false);
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::PushButton);
policy.setHeightForWidth(true);
@@ -272,6 +273,7 @@ QCommandLinkButton::QCommandLinkButton(QWidget *parent)
: QPushButton(*new QCommandLinkButtonPrivate, parent)
{
Q_D(QCommandLinkButton);
+ d->commandLink = true;
d->init();
}
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
index 7df2b59710..d36b6f8f9a 100644
--- a/src/widgets/widgets/qdatetimeedit_p.h
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -107,7 +107,7 @@ public:
if (keyboardTracking)
return maximum.toDateTime();
if (spec != Qt::LocalTime)
- return QDateTime(QDATETIMEEDIT_DATE_MIN.startOfDay(spec));
+ return QDateTime(QDATETIMEEDIT_DATE_MAX.endOfDay(spec));
return QDateTimeParser::getMaximum();
}
QLocale locale() const override { return q_func()->locale(); }
diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp
index 25d57970bf..8f774a3cc7 100644
--- a/src/widgets/widgets/qdial.cpp
+++ b/src/widgets/widgets/qdial.cpp
@@ -222,7 +222,7 @@ int QDialPrivate::valueFromPoint(const QPoint &p) const
If you are using the mouse wheel to adjust the dial, the increment
value is determined by the lesser value of
- \l{QApplication::wheelScrollLines()} {wheelScrollLines} multipled
+ \l{QApplication::wheelScrollLines()} {wheelScrollLines} multiplied
by \l {QAbstractSlider::singleStep} {singleStep}, and
\l {QAbstractSlider::pageStep} {pageStep}.
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 28c4f59d0d..9631d3cbf6 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -903,7 +903,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()
\property QDialogButtonBox::centerButtons
\brief whether the buttons in the button box are centered
- By default, this property is \c false. This behavior is appopriate
+ By default, this property is \c false. This behavior is appropriate
for most types of dialogs. A notable exception is message boxes
on most platforms (e.g. Windows), where the button box is
centered horizontally.
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 4663eda9eb..93362f4210 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -973,13 +973,27 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
&& mwlayout->pluggingWidget == nullptr
&& (event->pos() - state->pressPos).manhattanLength()
> QApplication::startDragDistance()) {
- startDrag();
- q->grabMouse();
- ret = true;
+
+#ifdef Q_OS_MACOS
+ if (windowHandle() && !q->isFloating()) {
+ // When using native widgets on mac, we have not yet been successful in
+ // starting a drag on an NSView that belongs to one window (QMainWindow),
+ // but continue the drag on another (QDockWidget). This is what happens if
+ // we try to make this widget floating during a drag. So as a fall back
+ // solution, we simply make this widget floating instead, when we would
+ // otherwise start a drag.
+ q->setFloating(true);
+ } else
+#endif
+ {
+ startDrag();
+ q->grabMouse();
+ ret = true;
+ }
}
}
- if (state->dragging && !state->nca) {
+ if (state && state->dragging && !state->nca) {
QMargins windowMargins = q->window()->windowHandle()->frameMargins();
QPoint windowMarginOffset = QPoint(windowMargins.left(), windowMargins.top());
QPoint pos = event->globalPos() - state->pressPos - windowMarginOffset;
@@ -1222,6 +1236,11 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
on whether it is docked; a docked QDockWidget has no frame and a smaller title
bar.
+ \note On macOS, if the QDockWidget has a native window handle (for example,
+ if winId() is called on it or the child widget), then due to a limitation it will not be
+ possible to drag the dock widget when undocking. Starting the drag will undock
+ the dock widget, but a second drag will be needed to move the dock widget itself.
+
\sa QMainWindow, {Dock Widgets Example}
*/
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index 4a99b0f962..289e2bc261 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -313,6 +313,10 @@ public:
void QFontComboBoxPrivate::_q_updateModel()
{
Q_Q(QFontComboBox);
+
+ if (QCoreApplication::closingDown())
+ return;
+
const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index 1661c5c881..7b50728ec9 100644
--- a/src/widgets/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
@@ -463,9 +463,9 @@ int QFrame::frameWidth() const
\brief the frame's rectangle
The frame's rectangle is the rectangle the frame is drawn in. By
- default, this is the entire widget. Setting the rectangle does
- does \e not cause a widget update. The frame rectangle is
- automatically adjusted when the widget changes size.
+ default, this is the entire widget. Setting the rectangle \e doesn't
+ cause a widget update. The frame rectangle is automatically adjusted
+ when the widget changes size.
If you set the rectangle to a null rectangle (for example,
QRect(0, 0, 0, 0)), then the resulting frame rectangle is
diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h
index 595dfa929d..6355c10ae5 100644
--- a/src/widgets/widgets/qframe.h
+++ b/src/widgets/widgets/qframe.h
@@ -123,6 +123,8 @@ private:
Q_DECLARE_PRIVATE(QFrame)
};
+Q_DECLARE_MIXED_ENUM_OPERATORS_SYMMETRIC(int, QFrame::Shape, QFrame::Shadow)
+
QT_END_NAMESPACE
#endif // QFRAME_H
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 30ff80cbb0..cf2605c17c 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
d->pixmap = new QPixmap(pixmap);
}
- if (d->pixmap->depth() == 1 && !d->pixmap->mask())
- d->pixmap->setMask(*((QBitmap *)d->pixmap));
-
d->updateLabel();
}
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 0c7256939c..3df42c4819 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -82,8 +82,7 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
-#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus) \
- && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
+#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
#else
@@ -1901,8 +1900,11 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
d->control->moveCursor(d->control->nextMaskBlank(0));
else if (!d->control->hasSelectedText())
selectAll();
+ else
+ updateMicroFocus();
} else if (e->reason() == Qt::MouseFocusReason) {
d->clickCausedFocus = 1;
+ updateMicroFocus();
}
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplicationPrivate::keypadNavigationEnabled() || (hasEditFocus() && ( e->reason() == Qt::PopupFocusReason))) {
@@ -1985,21 +1987,28 @@ void QLineEdit::paintEvent(QPaintEvent *)
p.setClipRect(r);
QFontMetrics fm = fontMetrics();
+ int fmHeight = 0;
+ if (d->shouldShowPlaceholderText())
+ fmHeight = fm.boundingRect(d->placeholderText).height();
+ else
+ fmHeight = fm.boundingRect(d->control->text() + d->control->preeditAreaText()).height();
+ fmHeight = qMax(fmHeight, fm.height());
+
Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment));
switch (va & Qt::AlignVertical_Mask) {
case Qt::AlignBottom:
- d->vscroll = r.y() + r.height() - fm.height() - QLineEditPrivate::verticalMargin;
+ d->vscroll = r.y() + r.height() - fmHeight - QLineEditPrivate::verticalMargin;
break;
case Qt::AlignTop:
d->vscroll = r.y() + QLineEditPrivate::verticalMargin;
break;
default:
//center
- d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2;
+ d->vscroll = r.y() + (r.height() - fmHeight + 1) / 2;
break;
}
QRect lineRect(r.x() + QLineEditPrivate::horizontalMargin, d->vscroll,
- r.width() - 2 * QLineEditPrivate::horizontalMargin, fm.height());
+ r.width() - 2 * QLineEditPrivate::horizontalMargin, fmHeight);
if (d->shouldShowPlaceholderText()) {
if (!d->placeholderText.isEmpty()) {
@@ -2082,8 +2091,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 b854d9d251..80c9258da4 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -407,8 +407,9 @@ void QLineEditIconButton::setHideWithText(bool hide)
void QLineEditIconButton::onAnimationFinished()
{
- if (shouldHideWithText() && isVisible() && !m_wasHidden) {
+ if (shouldHideWithText() && isVisible() && m_fadingOut) {
hide();
+ m_fadingOut = false;
// Invalidate previous geometry to take into account new size of side widgets
if (auto le = lineEditPrivate())
@@ -418,7 +419,7 @@ void QLineEditIconButton::onAnimationFinished()
void QLineEditIconButton::animateShow(bool visible)
{
- m_wasHidden = visible;
+ m_fadingOut = !visible;
if (shouldHideWithText() && !isVisible()) {
show();
@@ -480,7 +481,7 @@ void QLineEditPrivate::_q_clearButtonClicked()
Q_Q(QLineEdit);
if (!q->text().isEmpty()) {
q->clear();
- emit q->textEdited(QString());
+ _q_textEdited(QString());
}
}
@@ -664,10 +665,18 @@ static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWi
if (widgets.empty())
return defaultMargin;
- return defaultMargin + (parameters.margin + parameters.widgetWidth) *
- int(std::count_if(widgets.begin(), widgets.end(),
+ const auto visibleSideWidgetCount = std::count_if(widgets.begin(), widgets.end(),
[](const QLineEditPrivate::SideWidgetEntry &e) {
- return e.widget->isVisibleTo(e.widget->parentWidget()); }));
+#if QT_CONFIG(animation)
+ // a button that's fading out doesn't get any space
+ if (auto* iconButton = qobject_cast<QLineEditIconButton*>(e.widget))
+ return iconButton->needsSpace();
+
+#endif
+ return e.widget->isVisibleTo(e.widget->parentWidget());
+ });
+
+ return defaultMargin + (parameters.margin + parameters.widgetWidth) * visibleSideWidgetCount;
}
QMargins QLineEditPrivate::effectiveTextMargins() const
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 5ae402b992..f55210fc7f 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -95,6 +95,11 @@ public:
bool shouldHideWithText() const;
void setHideWithText(bool hide);
+ bool needsSpace() const {
+ if (m_fadingOut)
+ return false;
+ return isVisibleTo(parentWidget());
+ }
#endif
protected:
@@ -118,7 +123,7 @@ private:
#if QT_CONFIG(animation)
bool m_hideWithText = false;
- bool m_wasHidden = false;
+ bool m_fadingOut = false;
#endif
};
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index d56c6ab68b..fb49efc7a6 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -48,6 +48,7 @@
/*!
\class QMacCocoaViewContainer
+ \obsolete Use QWidget::createWindowContainer() and QWindow::fromWinId() instead.
\since 4.5
\brief The QMacCocoaViewContainer class provides a widget for \macos that can be used to wrap arbitrary
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index 874ca84b61..3566f4ed79 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -47,6 +47,7 @@
/*!
\class QMacNativeWidget
+ \obsolete Use QWidget::winId() instead.
\since 4.5
\brief The QMacNativeWidget class provides a widget for \macos that provides
a way to put Qt widgets into Cocoa hierarchies.
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 6b50f5e8ab..6310efc9da 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -954,10 +954,10 @@ void QMainWindow::setDockNestingEnabled(bool enabled)
\since 4.2
If this property is set to false, dock areas containing tabbed dock widgets
- display horizontal tabs, simmilar to Visual Studio.
+ display horizontal tabs, similar to Visual Studio.
If this property is set to true, then the right and left dock areas display vertical
- tabs, simmilar to KDevelop.
+ tabs, similar to KDevelop.
This property should be set before any dock widgets are added to the main window.
*/
@@ -1223,7 +1223,7 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
resized such that the yellowWidget is twice as big as the blueWidget
If some widgets are grouped in tabs, only one widget per group should be
- specified. Widgets not in the list might be changed to repect the constraints.
+ specified. Widgets not in the list might be changed to respect the constraints.
*/
void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks,
const QList<int> &sizes, Qt::Orientation orientation)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index d1571263eb..b90b5cdb80 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -2663,8 +2663,18 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
- if (qobject_cast<QDockWidgetGroupWindow *>(widget))
- allowed = true;
+ // Read permissions from a DockWidgetGroupWindow depending on its DockWidget children
+ if (QDockWidgetGroupWindow* dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ const QList<QDockWidget*> children = dwgw->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly);
+
+ if (children.count() == 1) {
+ // Group window has a single child => read its permissions
+ allowed = children.at(0)->isAreaAllowed(toDockWidgetArea(path.at(1)));
+ } else {
+ // Group window has more than one or no children => dock it anywhere
+ allowed = true;
+ }
+ }
#endif
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index a5f81d6542..15ef120d5e 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -259,11 +259,28 @@ static inline ControlElement<T> *ptr(QWidget *widget)
return nullptr;
}
+QString QMdiSubWindowPrivate::originalWindowTitleHelper() const
+{
+ Q_Q(const QMdiSubWindow);
+ // QTBUG-92240: When DontMaximizeSubWindowOnActivation is set and
+ // there is another subwindow maximized, use its original title.
+ if (auto *mdiArea = q->mdiArea()) {
+ const auto &subWindows = mdiArea->subWindowList();
+ for (auto *subWindow : subWindows) {
+ if (subWindow != q && subWindow->isMaximized()) {
+ auto *subWindowD = static_cast<QMdiSubWindowPrivate *>(qt_widget_private(subWindow));
+ if (!subWindowD->originalTitle.isNull())
+ return subWindowD->originalTitle;
+ }
+ }
+ }
+ return q->window()->windowTitle();
+}
+
QString QMdiSubWindowPrivate::originalWindowTitle()
{
- Q_Q(QMdiSubWindow);
if (originalTitle.isNull()) {
- originalTitle = q->window()->windowTitle();
+ originalTitle = originalWindowTitleHelper();
if (originalTitle.isNull())
originalTitle = QLatin1String("");
}
@@ -278,11 +295,17 @@ void QMdiSubWindowPrivate::setNewWindowTitle()
return;
QString original = originalWindowTitle();
if (!original.isEmpty()) {
- if (!original.contains(QMdiSubWindow::tr("- [%1]").arg(childTitle)))
- q->window()->setWindowTitle(QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle));
+ if (!original.contains(QMdiSubWindow::tr("- [%1]").arg(childTitle))) {
+ auto title = QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle);
+ ignoreWindowTitleChange = true;
+ q->window()->setWindowTitle(title);
+ ignoreWindowTitleChange = false;
+ }
} else {
+ ignoreWindowTitleChange = true;
q->window()->setWindowTitle(childTitle);
+ ignoreWindowTitleChange = false;
}
}
@@ -395,7 +418,7 @@ ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)
Q_UNUSED(subWindow);
setFocusPolicy(Qt::NoFocus);
updateWindowIcon();
- setFixedSize(label.size());
+ setFixedSize(label.size() / label.devicePixelRatio());
}
/*
@@ -403,7 +426,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/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index d3513b6708..043cf92201 100644
--- a/src/widgets/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
@@ -286,6 +286,7 @@ public:
#endif
void updateInternalWindowTitle();
QString originalWindowTitle();
+ QString originalWindowTitleHelper() const;
void setNewWindowTitle();
inline int titleBarHeight() const
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index a23d8b790d..284c83b8ec 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1651,7 +1651,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
and all other items are considered action items.
When inserting action items you usually specify a receiver and a
- slot. The receiver will be notifed whenever the item is
+ slot. The receiver will be notified whenever the item is
\l{QAction::triggered()}{triggered()}. In addition, QMenu provides
two signals, triggered() and hovered(), which signal the
QAction that was triggered from the menu.
@@ -2221,7 +2221,7 @@ void QMenu::setActiveAction(QAction *act)
{
Q_D(QMenu);
d->setCurrentAction(act, 0);
- if (d->scroll)
+ if (d->scroll && act)
d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
}
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 8724fa1a19..12b38ac148 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -583,7 +583,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
\inmodule QtWidgets
A menu bar consists of a list of pull-down menu items. You add
- menu items with addMenu(). For example, asuming that \c menubar
+ menu items with addMenu(). For example, assuming that \c menubar
is a pointer to a QMenuBar and \c fileMenu is a pointer to a
QMenu, the following statement inserts the menu into the menu bar:
\snippet code/src_gui_widgets_qmenubar.cpp 0
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 87e8af1382..144517ee0e 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -972,7 +972,7 @@ void QPlainTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCurso
}
if (moveCursor) {
- control->setTextCursor(cursor);
+ control->setTextCursor(cursor, moveMode == QTextCursor::KeepAnchor);
pageUpDownLastCursorYIsValid = true;
}
}
@@ -1942,7 +1942,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
// keep right margin clean from full-width selection
int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth)
- - document()->documentMargin();
+ - document()->documentMargin() + cursorWidth();
er.setRight(qMin(er.right(), maxX));
painter.setClipRect(er);
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index d182d7d33d..c70cfde3d9 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -326,6 +326,8 @@ void QPushButton::initStyleOption(QStyleOptionButton *option) const
option->features |= QStyleOptionButton::AutoDefaultButton;
if (d->defaultButton)
option->features |= QStyleOptionButton::DefaultButton;
+ if (d->commandLink)
+ option->features |= QStyleOptionButton::CommandLinkButton;
if (d->down || d->menuOpen)
option->state |= QStyle::State_Sunken;
if (d->checked)
@@ -583,6 +585,13 @@ void QPushButton::showMenu()
d->_q_popupPressed();
}
+void QPushButtonPrivate::init()
+{
+ Q_Q(QPushButton);
+ q->setAttribute(Qt::WA_MacShowFocusRect);
+ resetLayoutItemMargins();
+}
+
void QPushButtonPrivate::_q_popupPressed()
{
Q_Q(QPushButton);
diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h
index 7a5458ea3b..e8f112d62c 100644
--- a/src/widgets/widgets/qpushbutton_p.h
+++ b/src/widgets/widgets/qpushbutton_p.h
@@ -70,10 +70,10 @@ public:
QPushButtonPrivate()
: QAbstractButtonPrivate(QSizePolicy::PushButton), autoDefault(Auto),
defaultButton(false), flat(false), menuOpen(false), hovering(false),
- lastAutoDefault(false)
+ commandLink(false), lastAutoDefault(false)
{}
- inline void init() { resetLayoutItemMargins(); }
+ void init();
static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); }
#if QT_CONFIG(menu)
QPoint adjustedMenuPosition();
@@ -92,6 +92,7 @@ public:
uint flat : 1;
uint menuOpen : 1;
uint hovering : 1;
+ uint commandLink : 1;
mutable uint lastAutoDefault : 1;
};
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index f7a4f8e446..e8fdadb648 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -196,7 +196,23 @@ void QScrollAreaPrivate::updateScrollBars()
if (resizable) {
if ((widget->layout() ? widget->layout()->hasHeightForWidth() : widget->sizePolicy().hasHeightForWidth())) {
QSize p_hfw = p.expandedTo(min).boundedTo(max);
- int h = widget->heightForWidth( p_hfw.width() );
+ int h = widget->heightForWidth(p_hfw.width());
+ // If the height we calculated requires a vertical scrollbar,
+ // then we need to constrain the width and calculate the height again,
+ // otherwise we end up flipping the scrollbar on and off all the time.
+ if (vbarpolicy == Qt::ScrollBarAsNeeded) {
+ int vbarWidth = vbar->sizeHint().width();
+ QSize m_hfw = m.expandedTo(min).boundedTo(max);
+ // is there any point in searching?
+ if (widget->heightForWidth(m_hfw.width() - vbarWidth) <= m.height()) {
+ while (h > m.height() && vbarWidth) {
+ --vbarWidth;
+ --m_hfw.rwidth();
+ h = widget->heightForWidth(m_hfw.width());
+ }
+ }
+ max = QSize(m_hfw.width(), qMax(m_hfw.height(), h));
+ }
min = QSize(p_hfw.width(), qMax(p_hfw.height(), h));
}
}
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 568cf3b2e0..dd7f1ab964 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -175,7 +175,7 @@ QT_BEGIN_NAMESPACE
\li Up/Down move a vertical scroll bar by one single step.
\li PageUp moves up one page.
\li PageDown moves down one page.
- \li Home moves to the start (mininum).
+ \li Home moves to the start (minimum).
\li End moves to the end (maximum).
\endlist
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 95a4beeb57..d16afef157 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -271,6 +271,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) {
@@ -290,11 +302,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)
diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp
index 161e4ba27a..7458d0732e 100644
--- a/src/widgets/widgets/qslider.cpp
+++ b/src/widgets/widgets/qslider.cpp
@@ -250,7 +250,7 @@ QStyle::SubControl QSliderPrivate::newHoverControl(const QPoint &pos)
\li Up/Down move a vertical slider by one single step.
\li PageUp moves up one page.
\li PageDown moves down one page.
- \li Home moves to the start (mininum).
+ \li Home moves to the start (minimum).
\li End moves to the end (maximum).
\endlist
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 4b649a70ac..9a382e96dd 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -407,10 +407,12 @@ void QTabBarPrivate::init()
{
Q_Q(QTabBar);
leftB = new QToolButton(q);
+ leftB->setObjectName(QStringLiteral("ScrollLeftButton"));
leftB->setAutoRepeat(true);
QObject::connect(leftB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
leftB->hide();
rightB = new QToolButton(q);
+ rightB->setObjectName(QStringLiteral("ScrollRightButton"));
rightB->setAutoRepeat(true);
QObject::connect(rightB, SIGNAL(clicked()), q, SLOT(_q_scrollTabs()));
rightB->hide();
@@ -831,21 +833,24 @@ void QTabBarPrivate::_q_scrollTabs()
Q_Q(QTabBar);
const QObject *sender = q->sender();
const bool horizontal = !verticalTabs(shape);
- const QRect scrollRect = normalizedScrollRect();
+ const QRect scrollRect = normalizedScrollRect().translated(scrollOffset, 0);
+
int i = -1;
if (sender == leftB) {
for (i = tabList.count() - 1; i >= 0; --i) {
int start = horizontal ? tabList.at(i).rect.left() : tabList.at(i).rect.top();
- if (start < scrollRect.left() + scrollOffset) {
+ if (start < scrollRect.left()) {
makeVisible(i);
return;
}
}
} else if (sender == rightB) {
for (i = 0; i < tabList.count(); ++i) {
- int end = horizontal ? tabList.at(i).rect.right() : tabList.at(i).rect.bottom();
- if (end > scrollRect.right() + scrollOffset) {
+ const auto tabRect = tabList.at(i).rect;
+ int start = horizontal ? tabRect.left() : tabRect.top();
+ int end = horizontal ? tabRect.right() : tabRect.bottom();
+ if (end > scrollRect.right() && start > scrollOffset) {
makeVisible(i);
return;
}
@@ -997,14 +1002,16 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text));
#endif
d->firstVisible = qMax(qMin(index, d->firstVisible), 0);
- d->lastVisible = qMax(index, d->lastVisible);
d->refresh();
if (d->tabList.count() == 1)
setCurrentIndex(index);
- else if (index <= d->currentIndex) {
+ else if (index <= d->currentIndex)
++d->currentIndex;
+
+ if (index <= d->lastVisible)
++d->lastVisible;
- }
+ else
+ d->lastVisible = index;
if (d->closeButtonOnTabs) {
QStyleOptionTabV4 opt;
@@ -2397,7 +2404,7 @@ void QTabBar::timerEvent(QTimerEvent *event)
This property controls how items are elided when there is not
enough space to show them for a given tab bar size.
- By default the value is style dependent.
+ By default the value is style-dependent.
\sa QTabWidget::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode
*/
@@ -2426,7 +2433,7 @@ void QTabBar::setElideMode(Qt::TextElideMode mode)
When there are too many tabs in a tab bar for its size, the tab bar can either choose
to expand its size or to add buttons that allow you to scroll through the tabs.
- By default the value is style dependant.
+ By default the value is style-dependent.
\sa elideMode, QTabWidget::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows
*/
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index a19dacda52..5553c9a1a2 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -1348,7 +1348,7 @@ void QTabWidget::setIconSize(const QSize &size)
This property controls how items are elided when there is not
enough space to show them for a given tab bar size.
- By default the value is style dependant.
+ By default the value is style dependent.
\sa QTabBar::elideMode, usesScrollButtons, QStyle::SH_TabBar_ElideMode
*/
@@ -1371,7 +1371,7 @@ void QTabWidget::setElideMode(Qt::TextElideMode mode)
When there are too many tabs in a tab bar for its size, the tab bar can either choose
to expand its size or to add buttons that allow you to scroll through the tabs.
- By default the value is style dependant.
+ By default the value is style dependent.
\sa elideMode, QTabBar::usesScrollButtons, QStyle::SH_TabBar_PreferNoArrows
*/
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 78fde94fad..122a8529e8 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -916,7 +916,7 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type
being the new source.
Source changes happen both programmatically when calling
- setSource(), forward(), backword() or home() or when the user
+ setSource(), forward(), backward() or home() or when the user
clicks on links or presses the equivalent key sequences.
*/
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 8ddda78f7d..656062fcd6 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -270,7 +270,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)
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 493c094cc1..fb9a275f65 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -1364,10 +1364,14 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
}
if (applyingLayout) {
+ // Clear the previous widgetItem for the toolBar, so that it's
+ // assigned correctly in QWidgetItemV2 constructor.
+ auto *toolBarPrivate = QWidgetPrivate::get(toolBar);
+ toolBarPrivate->widgetItem = nullptr;
item.widgetItem = new QWidgetItemV2(toolBar);
toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
toolBar->setVisible(shown & 1);
- toolBar->d_func()->setWindowState(floating, true, rect);
+ toolBar->d_func()->setWindowState(floating, false, rect);
item.preferredSize = item.size;
line.toolBarItems.append(item);
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 9dd61c2c6a..66db5ccac7 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1662,6 +1662,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
break;
#endif
if (!m_completer->currentCompletion().isEmpty() && hasSelectedText()
+ && !m_completer->completionPrefix().isEmpty()
&& textAfterSelection().isEmpty()) {
setText(m_completer->currentCompletion());
inlineCompletionAccepted = true;
@@ -1948,10 +1949,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/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index e2a07c0043..ba9b6e0587 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -52,13 +52,13 @@
#include <qclipboard.h>
#if QT_CONFIG(menu)
#include <qmenu.h>
+#include "private/qmenu_p.h"
#endif
#include <qstyle.h>
#include <qtimer.h>
#include "private/qapplication_p.h"
#include "private/qtextdocumentlayout_p.h"
#include "private/qabstracttextdocumentlayout_p.h"
-#include "private/qmenu_p.h"
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
#include "qtextlist.h"
@@ -97,8 +97,7 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>
-#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
- && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
+#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
@@ -456,15 +455,20 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString
// #### doc->documentLayout()->setPaintDevice(viewport);
- QObject::connect(doc, SIGNAL(contentsChanged()), q, SLOT(_q_updateCurrentCharFormatAndSelection()));
- QObject::connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), q, SLOT(_q_emitCursorPosChanged(QTextCursor)));
- QObject::connect(doc, SIGNAL(documentLayoutChanged()), q, SLOT(_q_documentLayoutChanged()));
+ QObjectPrivate::connect(doc, &QTextDocument::contentsChanged, this,
+ &QWidgetTextControlPrivate::_q_updateCurrentCharFormatAndSelection);
+ QObjectPrivate::connect(doc, &QTextDocument::cursorPositionChanged, this,
+ &QWidgetTextControlPrivate::_q_emitCursorPosChanged);
+ QObjectPrivate::connect(doc, &QTextDocument::documentLayoutChanged, this,
+ &QWidgetTextControlPrivate::_q_documentLayoutChanged);
// convenience signal forwards
- QObject::connect(doc, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
- QObject::connect(doc, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
- QObject::connect(doc, SIGNAL(modificationChanged(bool)), q, SIGNAL(modificationChanged(bool)));
- QObject::connect(doc, SIGNAL(blockCountChanged(int)), q, SIGNAL(blockCountChanged(int)));
+ QObject::connect(doc, &QTextDocument::undoAvailable, q, &QWidgetTextControl::undoAvailable);
+ QObject::connect(doc, &QTextDocument::redoAvailable, q, &QWidgetTextControl::redoAvailable);
+ QObject::connect(doc, &QTextDocument::modificationChanged, q,
+ &QWidgetTextControl::modificationChanged);
+ QObject::connect(doc, &QTextDocument::blockCountChanged, q,
+ &QWidgetTextControl::blockCountChanged);
}
bool previousUndoRedoState = doc->isUndoRedoEnabled();
@@ -526,7 +530,8 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString
q->ensureCursorVisible();
emit q->cursorPositionChanged();
- QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q, SLOT(_q_contentsChanged(int,int,int)), Qt::UniqueConnection);
+ QObjectPrivate::connect(doc, &QTextDocument::contentsChange, this,
+ &QWidgetTextControlPrivate::_q_contentsChanged, Qt::UniqueConnection);
}
void QWidgetTextControlPrivate::startDrag()
@@ -706,10 +711,12 @@ void QWidgetTextControlPrivate::_q_documentLayoutChanged()
{
Q_Q(QWidgetTextControl);
QAbstractTextDocumentLayout *layout = doc->documentLayout();
- QObject::connect(layout, SIGNAL(update(QRectF)), q, SIGNAL(updateRequest(QRectF)));
- QObject::connect(layout, SIGNAL(updateBlock(QTextBlock)), q, SLOT(_q_updateBlock(QTextBlock)));
- QObject::connect(layout, SIGNAL(documentSizeChanged(QSizeF)), q, SIGNAL(documentSizeChanged(QSizeF)));
-
+ QObject::connect(layout, &QAbstractTextDocumentLayout::update, q,
+ &QWidgetTextControl::updateRequest);
+ QObjectPrivate::connect(layout, &QAbstractTextDocumentLayout::updateBlock, this,
+ &QWidgetTextControlPrivate::_q_updateBlock);
+ QObject::connect(layout, &QAbstractTextDocumentLayout::documentSizeChanged, q,
+ &QWidgetTextControl::documentSizeChanged);
}
void QWidgetTextControlPrivate::setCursorVisible(bool visible)
@@ -922,7 +929,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;
@@ -936,6 +943,13 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
d->repaintOldAndNewSelection(oldSelection);
if (posChanged)
emit cursorPositionChanged();
+
+#ifndef QT_NO_CLIPBOARD
+ if (selectionClipboard)
+ d->setClipboardSelection();
+#else
+ Q_UNUSED(selectionClipboard);
+#endif
}
QTextCursor QWidgetTextControl::textCursor() const
@@ -1225,6 +1239,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
@@ -1273,7 +1290,7 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
// example)
repaintSelection();
- if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier)) {
+ if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~(Qt::ShiftModifier | Qt::GroupSwitchModifier))) {
QTextBlockFormat blockFmt = cursor.blockFormat();
QTextList *list = cursor.currentList();
if (list && cursor.atBlockStart() && !cursor.hasSelection()) {
@@ -1376,6 +1393,10 @@ process:
accept:
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
+
e->accept();
cursorOn = true;
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index c445ecaf80..3f756e7db5 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);
@@ -277,13 +277,8 @@ protected:
private:
Q_DISABLE_COPY_MOVE(QWidgetTextControl)
- Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
- Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
Q_PRIVATE_SLOT(d_func(), void _q_copyLink())
- Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
- Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_contentsChanged(int, int, int))
};