summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-08 15:48:29 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-08 15:49:18 +0100
commitdd756011da13b95fdb630a1bbb90234f1e60f415 (patch)
treea6259b1e9b6463108796ce912e3d1752e301505f /src/widgets
parent0c50edbe84914469973a3b10e0170023ccdd66fe (diff)
parentb6bf2a33f4c33a212da7b58a049b3b5b20b3f327 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts: configure.json mkspecs/win32-icc/qmake.conf Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qdialog.cpp2
-rw-r--r--src/widgets/dialogs/qdialog_p.h18
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp106
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp4
-rw-r--r--src/widgets/widgets/qmainwindow.cpp2
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp29
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h3
-rw-r--r--src/widgets/widgets/qtabbar.cpp2
10 files changed, 98 insertions, 75 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index e8883df527..e5715ecd57 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -557,8 +557,8 @@ int QDialog::exec()
void QDialog::done(int r)
{
Q_D(QDialog);
- hide();
setResult(r);
+ hide();
d->close_helper(QWidgetPrivate::CloseNoEvent);
d->resetModalitySetByOpen();
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
index 1c7c5f3c2a..ae9e3bcc93 100644
--- a/src/widgets/dialogs/qdialog_p.h
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -119,6 +119,24 @@ private:
mutable bool m_platformHelperCreated;
};
+template <typename T>
+class QAutoPointer {
+ QPointer<T> o;
+ struct internal { void func() {} };
+ typedef void (internal::*RestrictedBool)();
+public:
+ explicit QAutoPointer(T *t) Q_DECL_NOTHROW : o(t) {}
+ ~QAutoPointer() { delete o; }
+
+ T *operator->() const Q_DECL_NOTHROW { return get(); }
+ T *get() const Q_DECL_NOTHROW { return o; }
+ T &operator*() const { return *get(); }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : Q_NULLPTR; }
+ bool operator!() const Q_DECL_NOTHROW { return !o; }
+private:
+ Q_DISABLE_COPY(QAutoPointer);
+};
+
QT_END_NAMESPACE
#endif // QDIALOG_P_H
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index d09f77ea35..4ca3923d8d 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -1194,10 +1194,6 @@ void QInputDialog::done(int result)
\snippet dialogs/standarddialogs/dialog.cpp 3
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getInt(), getDouble(), getItem(), getMultiLineText()
*/
@@ -1205,18 +1201,18 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
QLineEdit::EchoMode mode, const QString &text, bool *ok,
Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
{
- QInputDialog dialog(parent, flags);
- dialog.setWindowTitle(title);
- dialog.setLabelText(label);
- dialog.setTextValue(text);
- dialog.setTextEchoMode(mode);
- dialog.setInputMethodHints(inputMethodHints);
+ QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
+ dialog->setWindowTitle(title);
+ dialog->setLabelText(label);
+ dialog->setTextValue(text);
+ dialog->setTextEchoMode(mode);
+ dialog->setInputMethodHints(inputMethodHints);
- int ret = dialog.exec();
+ const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if (ret) {
- return dialog.textValue();
+ return dialog->textValue();
} else {
return QString();
}
@@ -1246,10 +1242,6 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
\snippet dialogs/standarddialogs/dialog.cpp 4
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getInt(), getDouble(), getItem(), getText()
*/
@@ -1257,18 +1249,18 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co
const QString &text, bool *ok, Qt::WindowFlags flags,
Qt::InputMethodHints inputMethodHints)
{
- QInputDialog dialog(parent, flags);
- dialog.setOptions(QInputDialog::UsePlainTextEditForTextInput);
- dialog.setWindowTitle(title);
- dialog.setLabelText(label);
- dialog.setTextValue(text);
- dialog.setInputMethodHints(inputMethodHints);
+ QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
+ dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput);
+ dialog->setWindowTitle(title);
+ dialog->setLabelText(label);
+ dialog->setTextValue(text);
+ dialog->setInputMethodHints(inputMethodHints);
- int ret = dialog.exec();
+ const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if (ret) {
- return dialog.textValue();
+ return dialog->textValue();
} else {
return QString();
}
@@ -1298,28 +1290,24 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co
\snippet dialogs/standarddialogs/dialog.cpp 0
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getText(), getDouble(), getItem(), getMultiLineText()
*/
int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &label, int value,
int min, int max, int step, bool *ok, Qt::WindowFlags flags)
{
- QInputDialog dialog(parent, flags);
- dialog.setWindowTitle(title);
- dialog.setLabelText(label);
- dialog.setIntRange(min, max);
- dialog.setIntValue(value);
- dialog.setIntStep(step);
+ QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
+ dialog->setWindowTitle(title);
+ dialog->setLabelText(label);
+ dialog->setIntRange(min, max);
+ dialog->setIntValue(value);
+ dialog->setIntStep(step);
- int ret = dialog.exec();
+ const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if (ret) {
- return dialog.intValue();
+ return dialog->intValue();
} else {
return value;
}
@@ -1350,10 +1338,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
\snippet dialogs/standarddialogs/dialog.cpp 0
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getText(), getDouble(), getItem(), getMultiLineText()
*/
@@ -1379,10 +1363,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
\snippet dialogs/standarddialogs/dialog.cpp 1
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getText(), getInt(), getItem(), getMultiLineText()
*/
@@ -1390,18 +1370,18 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
double value, double min, double max, int decimals, bool *ok,
Qt::WindowFlags flags)
{
- QInputDialog dialog(parent, flags);
- dialog.setWindowTitle(title);
- dialog.setLabelText(label);
- dialog.setDoubleDecimals(decimals);
- dialog.setDoubleRange(min, max);
- dialog.setDoubleValue(value);
+ QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
+ dialog->setWindowTitle(title);
+ dialog->setLabelText(label);
+ dialog->setDoubleDecimals(decimals);
+ dialog->setDoubleRange(min, max);
+ dialog->setDoubleValue(value);
- int ret = dialog.exec();
+ const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if (ret) {
- return dialog.doubleValue();
+ return dialog->doubleValue();
} else {
return value;
}
@@ -1433,10 +1413,6 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
\snippet dialogs/standarddialogs/dialog.cpp 2
- \warning Do not delete \a parent during the execution of the dialog. If you
- want to do this, you should create the dialog yourself using one of the
- QInputDialog constructors.
-
\sa getText(), getInt(), getDouble(), getMultiLineText()
*/
@@ -1446,19 +1422,19 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
{
QString text(items.value(current));
- QInputDialog dialog(parent, flags);
- dialog.setWindowTitle(title);
- dialog.setLabelText(label);
- dialog.setComboBoxItems(items);
- dialog.setTextValue(text);
- dialog.setComboBoxEditable(editable);
- dialog.setInputMethodHints(inputMethodHints);
+ QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
+ dialog->setWindowTitle(title);
+ dialog->setLabelText(label);
+ dialog->setComboBoxItems(items);
+ dialog->setTextValue(text);
+ dialog->setComboBoxEditable(editable);
+ dialog->setInputMethodHints(inputMethodHints);
- int ret = dialog.exec();
+ const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if (ret) {
- return dialog.textValue();
+ return dialog->textValue();
} else {
return text;
}
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index b69a523c51..bd5bf08bb8 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -6596,7 +6596,7 @@ QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) con
}
/*!
- \since 4,4
+ \since 4.4
Returns \c true if this item is currently under the mouse cursor in one of
the views; otherwise, false is returned.
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index d9d270643c..9be19b2679 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3916,10 +3916,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (pb->minimum == 0 && pb->maximum == 0) {
int chunkCount = fillWidth/chunkWidth;
int offset = 0;
+#if QT_CONFIG(animation)
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
offset = animation->animationStep() * 8 % rect.width();
else
d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject));
+#endif
int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
while (chunkCount > 0) {
r.setRect(x, rect.y(), chunkWidth, rect.height());
@@ -3950,8 +3952,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
subRule.drawRule(p, r);
x += reverse ? -chunkWidth : chunkWidth;
}
-
+#if QT_CONFIG(animation)
d->stopAnimation(opt->styleObject);
+#endif
}
p->restore();
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index f9370a2cc7..0ce8dde74c 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -1729,10 +1729,12 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
int step = 0;
int chunkCount = w / unit_width + 1;
+#if QT_CONFIG(animation)
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
step = (animation->animationStep() / 3) % chunkCount;
else
d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject));
+#endif
int chunksInRow = 5;
int myY = pbBits.rect.y();
int myHeight = pbBits.rect.height();
@@ -1766,7 +1768,9 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
p->restore(); //restore state
}
else {
+#if QT_CONFIG(animation)
d->stopAnimation(opt->styleObject);
+#endif
QCommonStyle::drawControl(ce, opt, p, widget);
}
}
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index abfdfbea9b..c9349ac72d 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -676,7 +676,7 @@ void QMainWindow::setCentralWidget(QWidget *widget)
The ownership of the removed widget is passed to the caller.
- \since Qt 5.2
+ \since 5.2
*/
QWidget *QMainWindow::takeCentralWidget()
{
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 72e06e4efa..68ca571acf 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1951,6 +1951,27 @@ void QMainWindowLayout::invalidate()
minSize = szHint = QSize();
}
+#ifndef QT_NO_DOCKWIDGET
+void QMainWindowLayout::setCurrentHoveredFloat(QWidget *w)
+{
+ if (currentHoveredFloat != w) {
+ if (currentHoveredFloat) {
+ disconnect(currentHoveredFloat.data(), &QObject::destroyed,
+ this, &QMainWindowLayout::updateGapIndicator);
+ }
+
+ currentHoveredFloat = w;
+
+ if (w) {
+ connect(w, &QObject::destroyed,
+ this, &QMainWindowLayout::updateGapIndicator, Qt::UniqueConnection);
+ }
+
+ updateGapIndicator();
+ }
+}
+#endif //QT_NO_DOCKWIDGET
+
/******************************************************************************
** QMainWindowLayout - remaining stuff
*/
@@ -2037,7 +2058,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
dropTo->setParent(floatingTabs);
dropTo->show();
dropTo->d_func()->plug(QRect());
- currentHoveredFloat = floatingTabs;
+ setCurrentHoveredFloat(floatingTabs);
}
#endif // QT_CONFIG(tabwidget)
#if QT_CONFIG(tabbar)
@@ -2190,7 +2211,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
currentGapPos.clear();
pluggingWidget = 0;
#if QT_CONFIG(dockwidget)
- currentHoveredFloat = nullptr;
+ setCurrentHoveredFloat(nullptr);
#endif
//applying the state will make sure that the currentGap is updated correctly
//and all the geometries (especially the one from the central widget) is correct
@@ -2497,12 +2518,12 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
if (!w->geometry().contains(mousePos))
continue;
- currentHoveredFloat = w;
+ setCurrentHoveredFloat(w);
restore(true);
return;
}
}
- currentHoveredFloat = Q_NULLPTR;
+ setCurrentHoveredFloat(nullptr);
#endif //QT_NO_DOCKWIDGET
QPoint pos = parentWidget()->mapFromGlobal(mousePos);
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 857a05eb8e..ed8da61bc3 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -306,13 +306,13 @@ public:
#endif
#ifndef QT_NO_DOCKWIDGET
QPointer<QWidget> currentHoveredFloat; // set when dragging over a floating dock widget
+ void setCurrentHoveredFloat(QWidget *w);
#endif
void hover(QLayoutItem *widgetItem, const QPoint &mousePos);
bool plug(QLayoutItem *widgetItem);
QLayoutItem *unplug(QWidget *widget, bool group = false);
void revert(QLayoutItem *widgetItem);
- void updateGapIndicator();
void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
void applyState(QMainWindowLayoutState &newState, bool animate = true);
void restore(bool keepSavedState = false);
@@ -320,6 +320,7 @@ public:
void animationFinished(QWidget *widget);
private Q_SLOTS:
+ void updateGapIndicator();
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
void tabChanged();
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 37d0f751cb..9bf062b407 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1447,7 +1447,7 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
/*!
Returns the minimum tab size hint for the tab at position \a index.
- \since Qt 5.0
+ \since 5.0
*/
QSize QTabBar::minimumTabSizeHint(int index) const