summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-10-25 07:21:05 +0200
committerLiang Qi <liang.qi@qt.io>2018-10-25 07:21:53 +0200
commite28e91ae99b8c3859899e04cc9370534c7c7b86d (patch)
treecca81b1e745be4f25aab78e8e917c2324594e539 /src/widgets
parent5ea233ca6782eb27adf596515cb66ef3dadc1d5e (diff)
parentebfad73b4e44fe6db8059200da105b4b87888718 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: src/corelib/animation/qpropertyanimation.cpp src/gui/image/qicon.cpp tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp Change-Id: I3698172b7b44ebb487cb38f50fd2c4a9f8a35b21
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/itemviews.cpp2
-rw-r--r--src/widgets/configure.json4
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp22
-rw-r--r--src/widgets/dialogs/qfiledialog.h2
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp4
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp15
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp49
-rw-r--r--src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp58
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp16
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp16
-rw-r--r--src/widgets/itemviews/qcolumnview_p.h4
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp2
-rw-r--r--src/widgets/itemviews/qtreeview.cpp28
-rw-r--r--src/widgets/itemviews/qtreeview.h4
-rw-r--r--src/widgets/itemviews/qtreeview_p.h6
-rw-r--r--src/widgets/kernel/qformlayout.cpp48
-rw-r--r--src/widgets/kernel/qtooltip.cpp17
-rw-r--r--src/widgets/kernel/qwidget.cpp23
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/styles/qcommonstyle.cpp4
-rw-r--r--src/widgets/styles/qcommonstyle.h2
-rw-r--r--src/widgets/styles/qcommonstyle_p.h9
-rw-r--r--src/widgets/styles/qfusionstyle.cpp12
-rw-r--r--src/widgets/styles/qstyleanimation.cpp4
-rw-r--r--src/widgets/styles/qstyleanimation_p.h6
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp2
-rw-r--r--src/widgets/styles/styles.pri7
-rw-r--r--src/widgets/util/qscroller.cpp29
-rw-r--r--src/widgets/util/qscroller_p.h6
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp4
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp4
-rw-r--r--src/widgets/widgets/qlineedit_p.h4
-rw-r--r--src/widgets/widgets/qmainwindow.cpp21
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp9
-rw-r--r--src/widgets/widgets/qtabbar.cpp6
-rw-r--r--src/widgets/widgets/qtabbar_p.h10
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp18
-rw-r--r--src/widgets/widgets/qwidgetanimator_p.h2
41 files changed, 329 insertions, 203 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 159d61d683..51cfaa7f5e 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -973,7 +973,7 @@ void QAccessibleTableCell::unselectCell()
{
QAbstractItemView::SelectionMode selectionMode = view->selectionMode();
- if (!m_index.isValid() || (selectionMode & QAbstractItemView::NoSelection))
+ if (!m_index.isValid() || (selectionMode == QAbstractItemView::NoSelection))
return;
QAccessibleTableInterface *cellTable = table()->tableInterface();
diff --git a/src/widgets/configure.json b/src/widgets/configure.json
index b3a5227d26..cc9019dfdd 100644
--- a/src/widgets/configure.json
+++ b/src/widgets/configure.json
@@ -47,7 +47,7 @@
},
"style-mac": {
"label": "macOS",
- "condition": "config.osx",
+ "condition": "config.osx && features.animation",
"output": [ "privateFeature", "styles" ]
},
"style-windows": {
@@ -56,7 +56,7 @@
},
"style-windowsvista": {
"label": "WindowsVista",
- "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme",
+ "condition": "features.style-windows && features.animation && config.win32 && !config.winrt && tests.uxtheme",
"output": [ "privateFeature", "styles" ]
},
"style-android": {
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 870a833b34..5c6c03d3aa 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -59,7 +59,9 @@
#include <stdlib.h>
#include <qsettings.h>
#include <qdebug.h>
+#if QT_CONFIG(mimetype)
#include <qmimedatabase.h>
+#endif
#include <qapplication.h>
#include <qstylepainter.h>
#include "ui_qfiledialog.h"
@@ -1518,7 +1520,7 @@ void QFileDialog::setFilter(QDir::Filters filters)
d->showHiddenAction->setChecked((filters & QDir::Hidden));
}
-#ifndef QT_NO_MIMETYPE
+#if QT_CONFIG(mimetype)
static QString nameFilterForMime(const QString &mimeType)
{
@@ -1599,7 +1601,7 @@ void QFileDialog::selectMimeTypeFilter(const QString &filter)
}
}
-#endif // QT_NO_MIMETYPE
+#endif // mimetype
/*!
* \since 5.9
@@ -1612,7 +1614,7 @@ QString QFileDialog::selectedMimeTypeFilter() const
if (!d->usingWidgets())
mimeTypeFilter = d->selectedMimeTypeFilter_sys();
-#ifndef QT_NO_MIMETYPE
+#if QT_CONFIG(mimetype)
if (mimeTypeFilter.isNull() && !d->options->mimeTypeFilters().isEmpty()) {
const auto nameFilter = selectedNameFilter();
const auto mimeTypes = d->options->mimeTypeFilters();
@@ -2109,9 +2111,7 @@ QString QFileDialog::labelText(DialogLabel label) const
strings. If you want multiple filters, separate them with ';;', for
example:
- \code
- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
- \endcode
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 14
The \a options argument holds various options about how to run the dialog,
see the QFileDialog::Option enum for more information on the flags you can
@@ -2224,9 +2224,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
\a selectedFilter and \a filter may be empty strings. If you need multiple
filters, separate them with ';;', for instance:
- \code
- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
- \endcode
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 14
The dialog's caption is set to \a caption. If \a caption is not specified
then a default caption will be used.
@@ -2340,9 +2338,7 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
parameters \a dir, \a selectedFilter, and \a filter may be empty strings.
Multiple filters are separated with ';;'. For instance:
- \code
- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
- \endcode
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 14
The \a options argument holds various options about how to run the dialog,
see the QFileDialog::Option enum for more information on the flags you can
@@ -3037,7 +3033,7 @@ void QFileDialogPrivate::createWidgets()
if (!options->sidebarUrls().isEmpty())
q->setSidebarUrls(options->sidebarUrls());
q->setDirectoryUrl(options->initialDirectory());
-#ifndef QT_NO_MIMETYPE
+#if QT_CONFIG(mimetype)
if (!options->mimeTypeFilters().isEmpty())
q->setMimeTypeFilters(options->mimeTypeFilters());
else
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index 8646894750..a4d289a77a 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -127,7 +127,7 @@ public:
QString selectedMimeTypeFilter() const;
QString selectedNameFilter() const;
-#ifndef QT_NO_MIMETYPE
+#if QT_CONFIG(mimetype)
void setMimeTypeFilters(const QStringList &filters);
QStringList mimeTypeFilters() const;
void selectMimeTypeFilter(const QString &filter);
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
index 58f0ae560f..06cca37111 100644
--- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -140,3 +140,7 @@ QFileDialog dialog(this);
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.exec();
//! [13]
+
+//! [14]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [14]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
index 8d8c63db9e..ebca9d5368 100644
--- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
@@ -271,3 +271,18 @@ QRect deviceRect = xform.mapRect(rect).toAlignedRect();
view->viewport()->scroll(dx, dy, deviceRect);
//! [19]
+//! [20]
+item->setTransform(QTransform().rotate(angle), true);
+//! [20]
+
+//! [21]
+setTransform(QTransform::fromScale(sx, sy), true);
+//! [21]
+
+//! [22]
+setTransform(QTransform().shear(sh, sv), true);
+//! [22]
+
+//! [23]
+setTransform(QTransform::fromTranslate(dx, dy), true);
+//! [23]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
index eadf753ded..a2ac780a82 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -84,3 +84,51 @@ formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
formLayout->setLabelAlignment(Qt::AlignLeft);
//! [2]
+
+//! [3]
+QFormLayout *flay = ...;
+QPointer<QLineEdit> le = new QLineEdit;
+flay->insertRow(2, "User:", le);
+// later:
+flay->removeRow(2); // le == nullptr at this point
+//! [3]
+
+//! [4]
+QFormLayout *flay = ...;
+QPointer<QLineEdit> le = new QLineEdit;
+flay->insertRow(2, "User:", le);
+// later:
+flay->removeRow(le); // le == nullptr at this point
+//! [4]
+
+//! [5]
+QFormLayout *flay = ...;
+QPointer<QVBoxLayout> vbl = new QVBoxLayout;
+flay->insertRow(2, "User:", vbl);
+// later:
+flay->removeRow(layout); // vbl == nullptr at this point
+//! [5]
+
+//! [6]
+QFormLayout *flay = ...;
+QPointer<QLineEdit> le = new QLineEdit;
+flay->insertRow(2, "User:", le);
+// later:
+QFormLayout::TakeRowResult result = flay->takeRow(2);
+//! [6]
+
+//! [7]
+QFormLayout *flay = ...;
+QPointer<QLineEdit> le = new QLineEdit;
+flay->insertRow(2, "User:", le);
+// later:
+QFormLayout::TakeRowResult result = flay->takeRow(widget);
+//! [7]
+
+//! [8]
+QFormLayout *flay = ...;
+QPointer<QVBoxLayout> vbl = new QVBoxLayout;
+flay->insertRow(2, "User:", vbl);
+// later:
+QFormLayout::TakeRowResult result = flay->takeRow(widget);
+//! [8]
diff --git a/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp b/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp
new file mode 100644
index 0000000000..2b3d825266
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_widgets_util_qscroller.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWidgets module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ QWidget *w = ...;
+ QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture);
+//! [0]
+
+//! [1]
+ QWidget *w = ...;
+ QScroller *scroller = QScroller::scroller(w);
+ scroller->scrollTo(QPointF(100, 100));
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp b/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp
new file mode 100644
index 0000000000..8ebaaf3991
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_widgets_widgets_qmainwindow.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWidgets module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ void MainWindow::createMenus()
+ {
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(newAct);
+ fileMenu->addAction(openAct);
+ fileMenu->addAction(saveAct);
+//! [0]
+
+//! [1]
+ void MainWindow::createToolBars()
+ {
+ fileToolBar = addToolBar(tr("File"));
+ fileToolBar->addAction(newAct);
+//! [1]
+
+//! [2]
+ resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);
+//! [2]
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 623d770f2f..00323eace6 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -520,7 +520,7 @@
user had manually called the corresponding QWidget::setPalette() and
QWidget::setFont() methods on all of the QWidgets targeted by the style
sheet. If this would have caused propagation in C++, it will cause
- propagation in style sheets and visa versa.
+ propagation in style sheets and vice versa.
\section1 Widgets Inside C++ Namespaces
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index a32f1388bf..e81eab4c46 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -4666,9 +4666,7 @@ void QGraphicsItem::resetTransform()
Use
- \code
- item->setTransform(QTransform().rotate(angle), true);
- \endcode
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 20
instead.
@@ -4689,9 +4687,7 @@ void QGraphicsItem::resetTransform()
Use
- \code
- setTransform(QTransform::fromScale(sx, sy), true);
- \endcode
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 21
instead.
@@ -4712,9 +4708,7 @@ void QGraphicsItem::resetTransform()
Use
- \code
- setTransform(QTransform().shear(sh, sv), true);
- \endcode
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 22
instead.
@@ -4730,9 +4724,7 @@ void QGraphicsItem::resetTransform()
Use setPos() or setTransformOriginPoint() instead. For identical
behavior, use
- \code
- setTransform(QTransform::fromTranslate(dx, dy), true);
- \endcode
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 23
Translates the current item transformation by (\a dx, \a dy).
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 5100d2a427..1fe17721ba 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -103,12 +103,12 @@ void QColumnViewPrivate::initialize()
{
Q_Q(QColumnView);
q->setTextElideMode(Qt::ElideMiddle);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
QObject::connect(&currentAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn()));
currentAnimation.setTargetObject(hbar);
currentAnimation.setPropertyName("value");
currentAnimation.setEasingCurve(QEasingCurve::InOutQuad);
-#endif //QT_NO_ANIMATION
+#endif // animation
delete itemDelegate;
q->setItemDelegate(new QColumnViewDelegate(q));
}
@@ -258,12 +258,12 @@ void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint)
if (!index.isValid() || d->columns.isEmpty())
return;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (d->currentAnimation.state() == QPropertyAnimation::Running)
return;
d->currentAnimation.stop();
-#endif //QT_NO_ANIMATION
+#endif // animation
// Fill up what is needed to get to index
d->closeColumns(index, true);
@@ -326,13 +326,13 @@ void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint)
}
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, this)) {
d->currentAnimation.setDuration(animationDuration);
d->currentAnimation.setEndValue(newScrollbarValue);
d->currentAnimation.start();
} else
-#endif //QT_NO_ANIMATION
+#endif // animation
{
horizontalScrollBar()->setValue(newScrollbarValue);
}
@@ -402,10 +402,10 @@ void QColumnView::resizeEvent(QResizeEvent *event)
void QColumnViewPrivate::updateScrollbars()
{
Q_Q(QColumnView);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (currentAnimation.state() == QPropertyAnimation::Running)
return;
-#endif //QT_NO_ANIMATION
+#endif // animation
// find the total horizontal length of the laid out columns
int horizontalLength = 0;
diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h
index 850ab02747..9f0d2a40dc 100644
--- a/src/widgets/itemviews/qcolumnview_p.h
+++ b/src/widgets/itemviews/qcolumnview_p.h
@@ -57,7 +57,9 @@
#include <private/qabstractitemview_p.h>
#include <QtCore/qabstractitemmodel.h>
+#if QT_CONFIG(animation)
#include <QtCore/qpropertyanimation.h>
+#endif
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtWidgets/qabstractitemview.h>
#include <QtWidgets/qitemdelegate.h>
@@ -169,7 +171,7 @@ public:
QVector<int> columnSizes; // used during init and corner moving
bool showResizeGrips;
int offset;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
QPropertyAnimation currentAnimation;
#endif
QWidget *previewWidget;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 169cc5a17c..bf4d5d46ff 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -225,7 +225,7 @@ QTableWidgetItem *QTableModel::takeItem(int row, int column)
itm->view = 0;
itm->d->id = -1;
tableItems[i] = 0;
- QModelIndex ind = index(itm);
+ const QModelIndex ind = index(row, column);
emit dataChanged(ind, ind);
}
return itm;
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index b65cf5af2b..60da0eb6c3 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1319,12 +1319,12 @@ void QTreeView::paintEvent(QPaintEvent *event)
Q_D(QTreeView);
d->executePostedLayout();
QPainter painter(viewport());
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (d->isAnimating()) {
drawTree(&painter, event->region() - d->animatedOperation.rect());
d->drawAnimatedOperation(&painter);
} else
-#endif //QT_NO_ANIMATION
+#endif // animation
{
drawTree(&painter, event->region());
#if QT_CONFIG(draganddrop)
@@ -3036,10 +3036,10 @@ void QTreeViewPrivate::initialize()
header->setStretchLastSection(true);
header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
q->setHeader(header);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0;
QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation()));
-#endif //QT_NO_ANIMATION
+#endif // animation
}
void QTreeViewPrivate::expand(int item, bool emitSignal)
@@ -3052,10 +3052,10 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
if (index.flags() & Qt::ItemNeverHasChildren)
return;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (emitSignal && animationsEnabled)
prepareAnimatedOperation(item, QVariantAnimation::Forward);
-#endif //QT_NO_ANIMATION
+#endif // animation
//if already animating, stateBeforeAnimation is set to the correct value
if (state != QAbstractItemView::AnimatingState)
stateBeforeAnimation = state;
@@ -3069,10 +3069,10 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
model->fetchMore(index);
if (emitSignal) {
emit q->expanded(index);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (animationsEnabled)
beginAnimatedOperation();
-#endif //QT_NO_ANIMATION
+#endif // animation
}
}
@@ -3127,10 +3127,10 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal)
if (it == expandedIndexes.end() || viewItems.at(item).expanded == false)
return; // nothing to do
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (emitSignal && animationsEnabled)
prepareAnimatedOperation(item, QVariantAnimation::Backward);
-#endif //QT_NO_ANIMATION
+#endif // animation
//if already animating, stateBeforeAnimation is set to the correct value
if (state != QAbstractItemView::AnimatingState)
@@ -3148,14 +3148,14 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal)
if (emitSignal) {
emit q->collapsed(modelIndex);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (animationsEnabled)
beginAnimatedOperation();
-#endif //QT_NO_ANIMATION
+#endif // animation
}
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void QTreeViewPrivate::prepareAnimatedOperation(int item, QVariantAnimation::Direction direction)
{
animatedOperation.item = item;
@@ -3260,7 +3260,7 @@ void QTreeViewPrivate::_q_endAnimatedOperation()
q->updateGeometries();
viewport->update();
}
-#endif //QT_NO_ANIMATION
+#endif // animation
void QTreeViewPrivate::_q_modelAboutToBeReset()
{
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index 09ce0e3fff..33dbf1c1ce 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -230,9 +230,9 @@ private:
Q_DECLARE_PRIVATE(QTreeView)
Q_DISABLE_COPY(QTreeView)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
-#endif //QT_NO_ANIMATION
+#endif // animation
Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
};
diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h
index 8b217036a2..0a0e7aae87 100644
--- a/src/widgets/itemviews/qtreeview_p.h
+++ b/src/widgets/itemviews/qtreeview_p.h
@@ -53,7 +53,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractitemview_p.h"
+#if QT_CONFIG(animation)
#include <QtCore/qvariantanimation.h>
+#endif
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qvector.h>
@@ -105,7 +107,7 @@ public:
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const override;
void adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex &current) const override;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
struct AnimatedOperation : public QVariantAnimation
{
int item;
@@ -123,7 +125,7 @@ public:
void drawAnimatedOperation(QPainter *painter) const;
QPixmap renderTreeToPixmapForAnimation(const QRect &rect) const;
void _q_endAnimatedOperation();
-#endif //QT_NO_ANIMATION
+#endif // animation
void expand(int item, bool emitSignal);
void collapse(int item, bool emitSignal);
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 595ff3eb6e..66e8858e21 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1435,13 +1435,7 @@ static void clearAndDestroyQLayoutItem(QLayoutItem *item)
up one row and the freed vertical space is redistributed amongst the remaining rows.
You can use this function to undo a previous addRow() or insertRow():
- \code
- QFormLayout *flay = ...;
- QPointer<QLineEdit> le = new QLineEdit;
- flay->insertRow(2, "User:", le);
- // later:
- flay->removeRow(2); // le == nullptr at this point
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 3
If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.
@@ -1467,13 +1461,7 @@ void QFormLayout::removeRow(int row)
up one row and the freed vertical space is redistributed amongst the remaining rows.
You can use this function to undo a previous addRow() or insertRow():
- \code
- QFormLayout *flay = ...;
- QPointer<QLineEdit> le = new QLineEdit;
- flay->insertRow(2, "User:", le);
- // later:
- flay->removeRow(le); // le == nullptr at this point
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 4
If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.
@@ -1499,13 +1487,7 @@ void QFormLayout::removeRow(QWidget *widget)
up one row and the freed vertical space is redistributed amongst the remaining rows.
You can use this function to undo a previous addRow() or insertRow():
- \code
- QFormLayout *flay = ...;
- QPointer<QVBoxLayout> vbl = new QVBoxLayout;
- flay->insertRow(2, "User:", vbl);
- // later:
- flay->removeRow(layout); // vbl == nullptr at this point
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 5
If you want to remove the row from the form layout without deleting the inserted layout,
use takeRow() instead.
@@ -1532,13 +1514,7 @@ void QFormLayout::removeRow(QLayout *layout)
up one row and the freed vertical space is redistributed amongst the remaining rows.
You can use this function to undo a previous addRow() or insertRow():
- \code
- QFormLayout *flay = ...;
- QPointer<QLineEdit> le = new QLineEdit;
- flay->insertRow(2, "User:", le);
- // later:
- QFormLayout::TakeRowResult result = flay->takeRow(2);
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 6
If you want to remove the row from the layout and delete the widgets, use removeRow() instead.
@@ -1583,13 +1559,7 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(int row)
After this call, rowCount() is decremented by one. All following rows are shifted
up one row and the freed vertical space is redistributed amongst the remaining rows.
- \code
- QFormLayout *flay = ...;
- QPointer<QLineEdit> le = new QLineEdit;
- flay->insertRow(2, "User:", le);
- // later:
- QFormLayout::TakeRowResult result = flay->takeRow(widget);
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 7
If you want to remove the row from the layout and delete the widgets, use removeRow() instead.
@@ -1628,13 +1598,7 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(QWidget *widget)
After this call, rowCount() is decremented by one. All following rows are shifted
up one row and the freed vertical space is redistributed amongst the remaining rows.
- \code
- QFormLayout *flay = ...;
- QPointer<QVBoxLayout> vbl = new QVBoxLayout;
- flay->insertRow(2, "User:", vbl);
- // later:
- QFormLayout::TakeRowResult result = flay->takeRow(widget);
- \endcode
+ \snippet code/src_gui_kernel_qformlayout.cpp 8
If you want to remove the row from the form layout and delete the inserted layout,
use removeRow() instead.
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 8c5573d3a3..2e6575c163 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -229,12 +229,17 @@ void QTipLabel::updateSize(const QPoint &pos)
++extra.rheight();
QSize sh = sizeHint();
if (wordWrap()) {
- const QRect screenRect = QGuiApplication::screenAt(pos)->geometry();
- if (sh.width() > screenRect.width()) {
- // Try to use widely accepted 75chars max length or 80% of the screen width else.
- // See https://en.wikipedia.org/wiki/Line_length
- sh.setWidth(qMin(fm.averageCharWidth() * 75, static_cast<int>(screenRect.width() * .8)));
- sh.setHeight(heightForWidth(sh.width()));
+ QScreen *screen = QGuiApplication::screenAt(pos);
+ if (!screen)
+ screen = QGuiApplication::primaryScreen();
+ if (screen) {
+ const qreal screenWidth = screen->geometry().width();
+ if (sh.width() > screenWidth) {
+ // Try to use widely accepted 75chars max length or 80% of the screen width else.
+ // See https://en.wikipedia.org/wiki/Line_length
+ sh.setWidth(qMin(fm.averageCharWidth() * 75, static_cast<int>(screenWidth * .8)));
+ sh.setHeight(heightForWidth(sh.width()));
+ }
}
}
resize(sh + extra);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index ca4f958c14..1bca3fc119 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1580,9 +1580,6 @@ QWidget::~QWidget()
d->gestureContext.clear();
#endif
- // force acceptDrops false before winId is destroyed.
- d->registerDropSite(false);
-
#ifndef QT_NO_ACTION
// remove all actions from this widget
for (int i = 0; i < d->actions.size(); ++i) {
@@ -3466,11 +3463,6 @@ void QWidget::setAcceptDrops(bool on)
}
-void QWidgetPrivate::registerDropSite(bool on)
-{
- Q_UNUSED(on);
-}
-
/*!
Disables widget input events if \a disable is true; otherwise
enables input events.
@@ -10099,20 +10091,24 @@ void QWidget::hideEvent(QHideEvent *)
which are passed in the \a message parameter.
In your reimplementation of this function, if you want to stop the
- event being handled by Qt, return true and set \a result.
- If you return false, this native event is passed back to Qt,
- which translates the event into a Qt event and sends it to the widget.
+ event being handled by Qt, return true and set \a result. The \a result
+ parameter has meaning only on Windows. If you return false, this native
+ event is passed back to Qt, which translates the event into a Qt event
+ and sends it to the widget.
- \note Events are only delivered to this event handler if the widget is
- has a native Window handle.
+ \note Events are only delivered to this event handler if the widget
+ has a native window handle.
\note This function superseedes the event filter functions
x11Event(), winEvent() and macEvent() of Qt 4.
+ \sa QAbstractNativeEventFilter
+
\table
\header \li Platform \li Event Type Identifier \li Message Type \li Result Type
\row \li Windows \li "windows_generic_MSG" \li MSG * \li LRESULT
\row \li macOS \li "NSEvent" \li NSEvent * \li
+ \row \li XCB \li "xcb_generic_event_t" \li xcb_generic_event_t * \li
\endtable
*/
@@ -11206,7 +11202,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break;
}
case Qt::WA_DropSiteRegistered: {
- d->registerDropSite(on);
for (int i = 0; i < d->children.size(); ++i) {
QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index c8eaabf8e2..0c7a5b1944 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -484,7 +484,6 @@ public:
void _q_showIfNotHidden();
void setEnabled_helper(bool);
- void registerDropSite(bool);
static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
void updateFrameStrut();
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index b9943533ee..0821c6af59 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -108,7 +108,9 @@
#include <qsettings.h>
#include <qvariant.h>
#include <qpixmapcache.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#include <limits.h>
@@ -1196,7 +1198,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w
}
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
/*! \internal */
QList<const QObject*> QCommonStylePrivate::animationTargets() const
{
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
index f39915295e..78c5171717 100644
--- a/src/widgets/styles/qcommonstyle.h
+++ b/src/widgets/styles/qcommonstyle.h
@@ -97,7 +97,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QCommonStyle)
Q_DISABLE_COPY(QCommonStyle)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
Q_PRIVATE_SLOT(d_func(), void _q_removeAnimation())
#endif
};
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 93db75ac2d..b347c8563a 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -43,8 +43,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcommonstyle.h"
#include "qstyle_p.h"
+#if QT_CONFIG(animation)
#include "qstyleanimation_p.h"
-
+#endif
#include "qstyleoption.h"
QT_BEGIN_NAMESPACE
@@ -76,7 +77,7 @@ public:
~QCommonStylePrivate()
{
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
qDeleteAll(animations);
#endif
#if QT_CONFIG(itemviews)
@@ -115,7 +116,7 @@ public:
#endif
int animationFps;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void _q_removeAnimation();
QList<const QObject*> animationTargets() const;
@@ -125,7 +126,7 @@ public:
private:
mutable QHash<const QObject*, QStyleAnimation*> animations;
-#endif // QT_NO_ANIMATION
+#endif // animation
};
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 7474cd23d6..5231f04df9 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1429,14 +1429,14 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
painter->drawRoundedRect(progressBar.adjusted(1, 1, -1, -1), 1, 1);
if (!indeterminate) {
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
(const_cast<QFusionStylePrivate*>(d))->stopAnimation(option->styleObject);
#endif
} else {
highlightedGradientStartColor.setAlpha(120);
painter->setPen(QPen(highlightedGradientStartColor, 9.0));
painter->setClipRect(progressBar.adjusted(1, 1, -1, -1));
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
step = animation->animationStep() % 22;
else
@@ -2463,7 +2463,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
styleObject->setProperty("_q_stylestate", static_cast<QStyle::State::Int>(scrollBar->state));
styleObject->setProperty("_q_stylecontrols", static_cast<uint>(scrollBar->activeSubControls));
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
// if the scrollbar is transient or its attributes, geometry or
// state has changed, the opacity is reset back to 100% opaque
opacity = 1.0;
@@ -2481,10 +2481,10 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
} else if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
d->stopAnimation(styleObject);
}
-#endif // !QT_NO_ANIMATION
+#endif // animation
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
QScrollbarStyleAnimation *anim = qobject_cast<QScrollbarStyleAnimation *>(d->animation(styleObject));
if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
// once a scrollbar was active (hovered/pressed), it retains
@@ -2513,7 +2513,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
}
}
painter->setOpacity(opacity);
-#endif // !QT_NO_ANIMATION
+#endif // animation
}
bool transient = proxy()->styleHint(SH_ScrollBar_Transient, option, widget);
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp
index 0b8e32be19..b9202eae69 100644
--- a/src/widgets/styles/qstyleanimation.cpp
+++ b/src/widgets/styles/qstyleanimation.cpp
@@ -39,8 +39,6 @@
#include "qstyleanimation_p.h"
-#ifndef QT_NO_ANIMATION
-
#include <qcoreapplication.h>
#include <qwidget.h>
#include <qevent.h>
@@ -367,5 +365,3 @@ void QScrollbarStyleAnimation::updateCurrentTime(int time)
QT_END_NAMESPACE
#include "moc_qstyleanimation_p.cpp"
-
-#endif //QT_NO_ANIMATION
diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h
index a2ad4a91da..d28fc6ebab 100644
--- a/src/widgets/styles/qstyleanimation_p.h
+++ b/src/widgets/styles/qstyleanimation_p.h
@@ -45,9 +45,9 @@
#include "qdatetime.h"
#include "qimage.h"
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(animation);
-#ifndef QT_NO_ANIMATION
+QT_BEGIN_NAMESPACE
//
// W A R N I N G
@@ -201,8 +201,6 @@ private:
bool _active;
};
-#endif // QT_NO_ANIMATION
-
QT_END_NAMESPACE
#endif // QSTYLEANIMATION_P_H
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index f2af8aee32..6cfb65a800 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -85,7 +85,9 @@
#include <qheaderview.h>
#endif
#include <private/qwindowsstyle_p_p.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#if QT_CONFIG(tabbar)
#include <qtabbar.h>
#endif
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 611de6991f..12ca5201c1 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -86,7 +86,9 @@
#include <private/qhighdpiscaling_p.h>
#include <private/qstylehelper_p.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#include <algorithm>
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 0c0f8b7bc7..821c40af81 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -3,7 +3,6 @@
HEADERS += \
styles/qdrawutil.h \
styles/qstyle.h \
- styles/qstyleanimation_p.h \
styles/qstylefactory.h \
styles/qstyleoption.h \
styles/qstyleplugin.h \
@@ -21,7 +20,6 @@ HEADERS += \
SOURCES += \
styles/qdrawutil.cpp \
styles/qstyle.cpp \
- styles/qstyleanimation.cpp \
styles/qstylefactory.cpp \
styles/qstyleoption.cpp \
styles/qstyleplugin.cpp \
@@ -37,6 +35,11 @@ RESOURCES += styles/qstyle.qrc
include($$OUT_PWD/qtwidgets-config.pri)
+qtConfig(animation) {
+ HEADERS += styles/qstyleanimation_p.h
+ SOURCES += styles/qstyleanimation.cpp
+}
+
qtConfig(style-windows) {
HEADERS += styles/qwindowsstyle_p.h styles/qwindowsstyle_p_p.h
SOURCES += styles/qwindowsstyle.cpp
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index 28504f5631..e229a885a8 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -191,7 +191,7 @@ static qreal progressForValue(const QEasingCurve &curve, qreal value)
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
class QScrollTimer : public QAbstractAnimation
{
public:
@@ -230,7 +230,7 @@ private:
bool ignoreUpdate;
int skip;
};
-#endif // QT_NO_ANIMATION
+#endif // animation
/*!
\class QScroller
@@ -249,18 +249,11 @@ private:
scrolling speed and takes care of updates.
QScroller can be triggered by a flick gesture
- \code
- QWidget *w = ...;
- QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture);
- \endcode
+ \snippet code/src_widgets_util_qscroller.cpp 0
or directly like this:
- \code
- QWidget *w = ...;
- QScroller *scroller = QScroller::scroller(w);
- scroller->scrollTo(QPointF(100, 100));
- \endcode
+ \snippet code/src_widgets_util_qscroller.cpp 1
The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to
update its geometry information and a QScrollEvent whenever the content of the object should
@@ -896,7 +889,7 @@ QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
, snapIntervalX(0.0)
, snapFirstY(-1.0)
, snapIntervalY(0.0)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
, scrollTimer(new QScrollTimer(this))
#endif
, q_ptr(q)
@@ -938,7 +931,7 @@ const char *QScrollerPrivate::inputName(QScroller::Input input)
void QScrollerPrivate::targetDestroyed()
{
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
scrollTimer->stop();
#endif
delete q_ptr;
@@ -966,7 +959,7 @@ void QScrollerPrivate::timerTick()
}
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
scrollTimer->stop();
#endif
}
@@ -1690,7 +1683,7 @@ void QScrollerPrivate::setState(QScroller::State newstate)
switch (newstate) {
case QScroller::Inactive:
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
scrollTimer->stop();
#endif
@@ -1702,7 +1695,7 @@ void QScrollerPrivate::setState(QScroller::State newstate)
break;
case QScroller::Pressed:
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
scrollTimer->stop();
#endif
@@ -1712,14 +1705,14 @@ void QScrollerPrivate::setState(QScroller::State newstate)
case QScroller::Dragging:
dragDistance = QPointF(0, 0);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (state == QScroller::Pressed)
scrollTimer->start();
#endif
break;
case QScroller::Scrolling:
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
scrollTimer->start();
#endif
break;
diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h
index 5e0c359514..13e2032a5c 100644
--- a/src/widgets/util/qscroller_p.h
+++ b/src/widgets/util/qscroller_p.h
@@ -64,7 +64,9 @@
#include <qscroller.h>
#include <qscrollerproperties.h>
#include <private/qscrollerproperties_p.h>
+#if QT_CONFIG(animation)
#include <QAbstractAnimation>
+#endif
QT_BEGIN_NAMESPACE
@@ -72,7 +74,7 @@ QT_BEGIN_NAMESPACE
class QFlickGestureRecognizer;
#endif
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
class QScrollTimer;
#endif
class QScrollerPrivate : public QObject
@@ -196,7 +198,7 @@ public:
QElapsedTimer monotonicTimer;
QPointF releaseVelocity; // the starting velocity of the scrolling state
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
QScrollTimer *scrollTimer;
#endif
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 1eafb73ba8..4e1aa51b4b 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE
\li \l alignment: The alignment of the text in the QAbstractSpinBox.
\li \l wrapping: Whether the QAbstractSpinBox wraps from the
- minimum value to the maximum value and vica versa.
+ minimum value to the maximum value and vice versa.
\endlist
@@ -285,7 +285,7 @@ void QAbstractSpinBox::setSpecialValueText(const QString &specialValueText)
\brief whether the spin box is circular.
If wrapping is true stepping up from maximum() value will take you
- to the minimum() value and vica versa. Wrapping only make sense if
+ to the minimum() value and vice versa. Wrapping only make sense if
you have minimum() and maximum() values set.
\snippet code/src_gui_widgets_qabstractspinbox.cpp 0
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index fce3d47b17..df8d534afa 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -57,7 +57,9 @@
#include "qlist.h"
#endif
#include <qpainter.h>
+#if QT_CONFIG(animation)
#include <qpropertyanimation.h>
+#endif
#include <qstylehints.h>
#include <qvalidator.h>
@@ -389,7 +391,7 @@ void QLineEditIconButton::setOpacity(qreal value)
}
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void QLineEditIconButton::startOpacityAnimation(qreal endValue)
{
QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity"));
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 71a67e3d10..7cd91dfc29 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -89,7 +89,7 @@ public:
qreal opacity() const { return m_opacity; }
void setOpacity(qreal value);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void animateShow(bool visible) { startOpacityAnimation(visible ? 1.0 : 0.0); }
#endif
@@ -101,7 +101,7 @@ private slots:
void updateCursor();
private:
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void startOpacityAnimation(qreal endValue);
#endif
QLineEditPrivate *lineEditPrivate() const;
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 9172168761..fae3aebba4 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -249,14 +249,7 @@ void QMainWindowPrivate::init()
An example of how to create menus follows:
- \code
- void MainWindow::createMenus()
- {
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAct);
- \endcode
+ \snippet code/src_widgets_widgets_qmainwindow.cpp 0
The \c createPopupMenu() function creates popup menus when the
main window receives context menu events. The default
@@ -283,12 +276,7 @@ void QMainWindowPrivate::init()
An example of toolbar creation follows:
- \code
- void MainWindow::createToolBars()
- {
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newAct);
- \endcode
+ \snippet code/src_widgets_widgets_qmainwindow.cpp 1
\section2 Creating Dock Widgets
@@ -1231,9 +1219,8 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
to the relative weight of the sizes.
Example:
- \code
- resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);
- \endcode
+ \snippet code/src_widgets_widgets_qmainwindow.cpp 2
+
If the blue and the yellow widget are nested on the same level they will be
resized such that the yellowWidget is twice as big as the blueWidget
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 36a150396c..b498d5fe7a 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -294,6 +294,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
QTextBlock changeStartBlock = doc->findBlock(from);
QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsChanged - 1));
+ bool blockVisibilityChanged = false;
if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) {
QTextBlock block = changeStartBlock;
@@ -311,14 +312,18 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
QTextBlock block = changeStartBlock;
do {
block.clearLayout();
+ const int lineCount = block.isVisible() ? 1 : 0;
+ if (block.lineCount() != lineCount) {
+ blockVisibilityChanged = true;
+ block.setLineCount(lineCount);
+ }
if (block == changeEndBlock)
break;
block = block.next();
} while(block.isValid());
}
- if (newBlockCount != d->blockCount) {
-
+ if (newBlockCount != d->blockCount || blockVisibilityChanged) {
int changeEnd = changeEndBlock.blockNumber();
int blockDiff = newBlockCount - d->blockCount;
int oldChangeEnd = changeEnd - blockDiff;
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 5959dd0ae4..68453e1842 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2126,13 +2126,13 @@ void QTabBarPrivate::moveTabFinished(int index)
Q_Q(QTabBar);
bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
bool allAnimationsFinished = true;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
for(int i = 0; allAnimationsFinished && i < tabList.count(); ++i) {
const Tab &t = tabList.at(i);
if (t.animation && t.animation->state() == QAbstractAnimation::Running)
allAnimationsFinished = false;
}
-#endif //QT_NO_ANIMATION
+#endif // animation
if (allAnimationsFinished && cleanup) {
if(movingTab)
movingTab->setVisible(false); // We might not get a mouse release
@@ -2697,7 +2697,7 @@ void CloseButton::paintEvent(QPaintEvent *)
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue(const QVariant &current)
{
priv->moveTab(priv->tabList.indexOf(*tab), current.toInt());
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 3948b42bc1..9b798e89c9 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -58,7 +58,9 @@
#include <qicon.h>
#include <qtoolbutton.h>
#include <qdebug.h>
+#if QT_CONFIG(animation)
#include <qvariantanimation.h>
+#endif
#define ANIMATION_DURATION 250
@@ -107,9 +109,9 @@ public:
inline Tab(const QIcon &ico, const QString &txt)
: enabled(true) , shortcutId(0), text(txt), icon(ico),
leftWidget(0), rightWidget(0), lastTab(-1), dragOffset(0)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
, animation(0)
-#endif //QT_NO_ANIMATION
+#endif // animation
{}
bool operator==(const Tab &other) const { return &other == this; }
bool enabled;
@@ -136,7 +138,7 @@ public:
QString accessibleName;
#endif
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
~Tab() { delete animation; }
struct TabBarAnimation : public QVariantAnimation {
TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv)
@@ -166,7 +168,7 @@ public:
#else
void startAnimation(QTabBarPrivate *priv, int duration)
{ Q_UNUSED(duration); priv->moveTabFinished(priv->tabList.indexOf(*this)); }
-#endif //QT_NO_ANIMATION
+#endif // animation
};
QList<Tab> tabList;
mutable QHash<QString, QSize> textSizes;
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
index b6828a14ef..b1e527e3b6 100644
--- a/src/widgets/widgets/qwidgetanimator.cpp
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -37,15 +37,17 @@
**
****************************************************************************/
+#include "qwidgetanimator_p.h"
+
+#if QT_CONFIG(animation)
#include <QtCore/qpropertyanimation.h>
+#endif
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qstyle.h>
#if QT_CONFIG(mainwindow)
#include <private/qmainwindowlayout_p.h>
#endif
-#include "qwidgetanimator_p.h"
-
QT_BEGIN_NAMESPACE
QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)
@@ -54,7 +56,7 @@ QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout
void QWidgetAnimator::abort(QWidget *w)
{
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
const auto it = m_animation_map.constFind(w);
if (it == m_animation_map.cend())
return;
@@ -68,16 +70,16 @@ void QWidgetAnimator::abort(QWidget *w)
#endif
#else
Q_UNUSED(w); //there is no animation to abort
-#endif //QT_NO_ANIMATION
+#endif // animation
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void QWidgetAnimator::animationFinished()
{
QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
abort(static_cast<QWidget*>(anim->targetObject()));
}
-#endif //QT_NO_ANIMATION
+#endif // animation
void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)
{
@@ -91,7 +93,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
//If the QStyle has animations, animate
if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, widget)) {
AnimationMap::const_iterator it = m_animation_map.constFind(widget);
@@ -106,7 +108,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
connect(anim, SIGNAL(finished()), SLOT(animationFinished()));
anim->start(QPropertyAnimation::DeleteWhenStopped);
} else
-#endif //QT_NO_ANIMATION
+#endif // animation
{
//we do it in one shot
widget->setGeometry(final_geometry);
diff --git a/src/widgets/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h
index 90be22c271..920cc3ffc8 100644
--- a/src/widgets/widgets/qwidgetanimator_p.h
+++ b/src/widgets/widgets/qwidgetanimator_p.h
@@ -73,7 +73,7 @@ public:
void abort(QWidget *widget);
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
private Q_SLOTS:
void animationFinished();
#endif