diff options
author | Liang Qi <liang.qi@qt.io> | 2017-02-10 21:10:21 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-02-10 22:35:04 +0100 |
commit | 364b161122b567e3a6f7343d438fb540b9fb7e5c (patch) | |
tree | 3d49953be9a58295a8c956cf5fdb00f581020605 /src/widgets | |
parent | e58401a75b29beb38d37a40072106d5ef7cb0336 (diff) | |
parent | 8a410f60ae39b06555d807581caf7cb8bfab4fac (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/widgets/widgets/qmainwindowlayout_p.h
Change-Id: Id406a67606b885052ed405b0fbc8eea7d9d03224
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qdialog_p.h | 18 | ||||
-rw-r--r-- | src/widgets/dialogs/qinputdialog.cpp | 106 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 9 | ||||
-rw-r--r-- | src/widgets/kernel/qsizepolicy.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 5 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 4 | ||||
-rw-r--r-- | src/widgets/util/qundostack.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 29 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout_p.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 18 |
14 files changed, 122 insertions, 83 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/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 008b2a0d77..2c85ed3c0b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2161,11 +2161,14 @@ QWidget *qt_tlw_for_window(QWindow *wnd) // QTBUG-32177, wnd might be a QQuickView embedded via window container. while (wnd && !wnd->isTopLevel()) { QWindow *parent = wnd->parent(); + if (!parent) + break; + // Don't end up in windows not belonging to this application - if (parent && parent->type() != Qt::ForeignWindow) - wnd = wnd->parent(); - else + if (parent->handle() && parent->handle()->isForeignWindow()) break; + + wnd = wnd->parent(); } if (wnd) { const auto tlws = qApp->topLevelWidgets(); diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index 34ad64217b..a03523d2af 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -400,7 +400,7 @@ void QSizePolicy::setControlType(ControlType type) */ /*! - \fn QSizePolicy QSizePolicy::transposed() + \fn QSizePolicy QSizePolicy::transposed() const \since 5.9 Returns a size policy object with the horizontal and vertical diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 759821a057..d35ad87c8d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1483,6 +1483,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->handle()->setFrameStrutEventsEnabled(true); data.window_flags = win->flags(); + if (!win->isTopLevel()) // In a Widget world foreign windows can only be top level + data.window_flags &= ~Qt::ForeignWindow; if (!topData()->role.isNull()) QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); 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/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 3d21320655..dc0b6855ac 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -164,7 +164,7 @@ bool QUndoCommand::isObsolete() const /*! \since 5.9 - Sets whether the command is obsolete. + Sets whether the command is obsolete to \a obsolete. \sa isObsolete(), mergeWith(), QUndoStack::push(), QUndoStack::undo(), QUndoStack::redo() */ diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 34eef201b8..8eb5669f1c 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -661,7 +661,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 4ed4b8f767..4f94f6e654 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1856,6 +1856,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 */ @@ -1942,7 +1963,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) @@ -2095,7 +2116,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 @@ -2395,12 +2416,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 94706d2347..507759fe96 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -305,18 +305,20 @@ 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); 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 ba67baeadb..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 @@ -1756,7 +1756,10 @@ void QTabBar::paintEvent(QPaintEvent *) p.drawControl(QStyle::CE_TabBarTab, tab); else { int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); - d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); + if (verticalTabs(d->shape)) + d->movingTab->setGeometry(tab.rect.adjusted(0, -taboverlap, 0, taboverlap)); + else + d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); } } @@ -2035,7 +2038,10 @@ void QTabBarPrivate::setupMovableTab() int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q); QRect grabRect = q->tabRect(pressedIndex); - grabRect.adjust(-taboverlap, 0, taboverlap, 0); + if (verticalTabs(shape)) + grabRect.adjust(0, -taboverlap, 0, taboverlap); + else + grabRect.adjust(-taboverlap, 0, taboverlap, 0); QPixmap grabImage(grabRect.size() * q->devicePixelRatioF()); grabImage.setDevicePixelRatio(q->devicePixelRatioF()); @@ -2045,7 +2051,11 @@ void QTabBarPrivate::setupMovableTab() QStyleOptionTab tab; q->initStyleOption(&tab, pressedIndex); - tab.rect.moveTopLeft(QPoint(taboverlap, 0)); + tab.position = QStyleOptionTab::OnlyOneTab; + if (verticalTabs(shape)) + tab.rect.moveTopLeft(QPoint(0, taboverlap)); + else + tab.rect.moveTopLeft(QPoint(taboverlap, 0)); p.drawControl(QStyle::CE_TabBarTab, tab); p.end(); |