diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-05 06:39:30 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-05 13:57:12 +0200 |
commit | 657c2bfbeceda3faa2c7a76b4ccec6a65a3445a2 (patch) | |
tree | 83e0a1dab04afb291e181bb8fb6152ba96678795 /src | |
parent | 676129d7ee57347798683d444823e7723776d8ec (diff) | |
parent | b94111116f09a6e48741d35cf7abea47af99ef26 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
tests/auto/testlib/selftests/generate_expected_output.py
Change-Id: If856162abf9a24ae2c9946d336a7d1da03520fa7
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 7 | ||||
-rw-r--r-- | src/gui/image/qicon.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 65 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 4 | ||||
-rw-r--r-- | src/platformsupport/cglconvenience/cglconvenience.mm | 5 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 10 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 13 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 4 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_win_p.h | 6 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 12 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 53 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout_p.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 70 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout_p.h | 2 |
18 files changed, 173 insertions, 97 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 285931e794..d0eb2af423 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -950,7 +950,8 @@ # endif /* VC 11 */ # if _MSC_VER >= 1800 /* C++11 features in VC12 = VC2013 */ -# define Q_COMPILER_DEFAULT_MEMBERS +/* Implemented, but can't be used on move special members */ +/* # define Q_COMPILER_DEFAULT_MEMBERS */ # define Q_COMPILER_DELETE_MEMBERS # define Q_COMPILER_DELEGATING_CONSTRUCTORS # define Q_COMPILER_EXPLICIT_CONVERSIONS @@ -968,6 +969,7 @@ # endif /* VC 12 SP 2 RC */ # if _MSC_VER >= 1900 /* C++11 features in VC14 = VC2015 */ +# define Q_COMPILER_DEFAULT_MEMBERS # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF // Partial support, insufficient for Qt diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c9d6f4e411..08a70a06c7 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -303,13 +303,14 @@ char *qstrncpy(char *dst, const char *src, uint len) { if (!src || !dst) return 0; + if (len > 0) { #if defined(_MSC_VER) && _MSC_VER >= 1400 - strncpy_s(dst, len, src, len-1); + strncpy_s(dst, len, src, len - 1); #else - strncpy(dst, src, len); + strncpy(dst, src, len); #endif - if (len > 0) dst[len-1] = '\0'; + } return dst; } diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 716a7c52c2..db118edf04 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -841,8 +841,11 @@ QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); // Handle the simple normal-dpi case: - if (!(devicePixelRatio > 1.0)) - return d->engine->pixmap(size, mode, state); + if (!(devicePixelRatio > 1.0)) { + QPixmap pixmap = d->engine->pixmap(size, mode, state); + pixmap.setDevicePixelRatio(1.0); + return pixmap; + } // Try get a pixmap that is big enough to be displayed at device pixel resolution. QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 5f71bdaded..18e8bcf99c 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2195,6 +2195,9 @@ void QWindowPrivate::deliverUpdateRequest() */ void QWindow::requestUpdate() { + Q_ASSERT_X(QThread::currentThread() == QCoreApplication::instance()->thread(), + "QWindow", "Updates can only be scheduled from the GUI (main) thread"); + Q_D(QWindow); if (d->updateRequestPending || !d->platformWindow) return; diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index b6e8855d46..14581c89f6 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1288,11 +1288,11 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ ? context->hasExtension(QByteArrayLiteral("GL_EXT_read_format_bgra")) : context->hasExtension(QByteArrayLiteral("GL_EXT_bgra")); +#ifndef Q_OS_IOS const char *renderer = reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER)); const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION)); // Blacklist GPU chipsets that have problems with their BGRA support. -#ifndef Q_OS_IOS const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 && ::strstr(ver, "1.3") != 0) || (qstrcmp(renderer, "Mali-T760") == 0 diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 30d3dee473..867eb76200 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5383,17 +5383,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_transformed_argb, // ARGB32_Premultiplied blend_transformed_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, @@ -5411,16 +5411,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_transformed_tiled_argb, // ARGB32_Premultiplied blend_transformed_tiled_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, @@ -5438,17 +5439,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_src_generic, // ARGB32_Premultiplied blend_transformed_bilinear_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index c4a130e04c..283d03f22c 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -842,9 +842,13 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo return retList; } +static void initializeDb(); + static QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) { QFontDatabasePrivate *db = privateDb(); + if (!db->count) + initializeDb(); const FallbacksCacheKey cacheKey = { family, style, styleHint, script }; diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index a18510a9e2..a4c5c7f61e 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -75,8 +75,11 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) QVector<NSOpenGLPixelFormatAttribute> attrs; - if (format.swapBehavior() != QSurfaceFormat::SingleBuffer) + if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer + || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior) attrs.append(NSOpenGLPFADoubleBuffer); + else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer) + attrs.append(NSOpenGLPFATripleBuffer); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 7a12969972..628357eb39 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -312,8 +312,16 @@ void QCocoaGLContext::updateSurfaceFormat() m_format.setSamples(samples); int doubleBuffered = -1; + int tripleBuffered = -1; [pixelFormat getValues:&doubleBuffered forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0]; - m_format.setSwapBehavior(doubleBuffered == 1 ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer); + [pixelFormat getValues:&tripleBuffered forAttribute:NSOpenGLPFATripleBuffer forVirtualScreen:0]; + + if (tripleBuffered == 1) + m_format.setSwapBehavior(QSurfaceFormat::TripleBuffer); + else if (doubleBuffered == 1) + m_format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); + else + m_format.setSwapBehavior(QSurfaceFormat::SingleBuffer); int steroBuffers = -1; [pixelFormat getValues:&steroBuffers forAttribute:NSOpenGLPFAStereo forVirtualScreen:0]; diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index d5e5f87e5c..817728dca2 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1050,12 +1050,15 @@ void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory) QString QWindowsNativeFileDialogBase::directory() const { + QString result; #ifndef Q_OS_WINCE IShellItem *item = 0; - if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) - return QWindowsNativeFileDialogBase::itemPath(item); + if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) { + result = QWindowsNativeFileDialogBase::itemPath(item); + item->Release(); + } #endif - return QString(); + return result; } void QWindowsNativeFileDialogBase::doExec(HWND owner) @@ -1520,8 +1523,10 @@ QList<QUrl> QWindowsNativeSaveFileDialog::selectedFiles() const QList<QUrl> result; IShellItem *item = 0; const HRESULT hr = fileDialog()->GetCurrentSelection(&item); - if (SUCCEEDED(hr) && item) + if (SUCCEEDED(hr) && item) { result.push_back(QUrl::fromLocalFile(QWindowsNativeSaveFileDialog::itemPath(item))); + item->Release(); + } return result; } diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 228607d7e3..dd2bf3a0a3 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -924,14 +924,14 @@ void QWin32PrintEnginePrivate::initialize() Q_ASSERT(hPrinter); Q_ASSERT(pInfo); + initHDC(); + if (devMode) { num_copies = devMode->dmCopies; devMode->dmCollate = DMCOLLATE_TRUE; updatePageLayout(); } - initHDC(); - #if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS qDebug("QWin32PrintEngine::initialize()"); debugMetrics(); diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h index 32da184b08..b436f5c9b0 100644 --- a/src/printsupport/kernel/qprintengine_win_p.h +++ b/src/printsupport/kernel/qprintengine_win_p.h @@ -130,10 +130,14 @@ public: state(QPrinter::Idle), resolution(0), m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))), + stretch_x(1), stretch_y(1), origin_x(0), origin_y(0), + dpi_x(96), dpi_y(96), dpi_display(96), num_copies(1), printToFile(false), reinit(false), - embed_fonts(true) + complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false), + embed_fonts(true), + txop(0 /* QTransform::TxNone */) { } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 714841d6cf..dfc7ee3a61 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2311,7 +2311,7 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi return QLatin1String("QString()"); QString result; - const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_dindent); + const QString comment = commentHint.isEmpty() ? QString(QLatin1String("Q_NULLPTR")) : fixString(commentHint, m_dindent); if (m_option.translateFunction.isEmpty()) { if (m_option.idBased) { diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 4cf77b7a1e..e8e99a4386 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3818,6 +3818,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q ParentStyle::drawControl(ce, opt, p, w); return; } + if (subRule.hasFont) { + const QFont oldFont = p->font(); + p->setFont(subRule.font.resolve(p->font())); + baseStyle()->drawControl(ce, opt, p, w); + p->setFont(oldFont); + return; + } } break; case CE_HeaderSection: @@ -4931,13 +4938,14 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_HeaderSection: { if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); - if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) { + if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) { sz = subRule.adjustSize(csz); if (!subRule.hasGeometry()) { QSize nativeContentsSize; bool nullIcon = hdr->icon.isNull(); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); - QSize txt = hdr->fontMetrics.size(0, hdr->text); + const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) + : hdr->fontMetrics.size(0, hdr->text); nativeContentsSize.setHeight(qMax(iconSize, txt.height())); nativeContentsSize.setWidth(iconSize + txt.width()); sz = sz.expandedTo(nativeContentsSize); diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index fd155bf156..50be36ae93 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2610,6 +2610,21 @@ void QDockAreaLayout::remove(const QList<int> &path) docks[index].remove(path.mid(1)); } +void QDockAreaLayout::removePlaceHolder(const QString &name) +{ + QList<int> index = indexOfPlaceHolder(name); + if (!index.isEmpty()) + remove(index); + foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren<QDockWidgetGroupWindow *>( + QString(), Qt::FindDirectChildrenOnly)) { + index = dwgw->layoutInfo()->indexOfPlaceHolder(name); + if (!index.isEmpty()) { + dwgw->layoutInfo()->remove(index); + dwgw->destroyOrHideIfEmpty(); + } + } +} + static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); } void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, @@ -3036,15 +3051,27 @@ QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) { - QList<int> index = indexOfPlaceHolder(dockWidget->objectName()); - if (index.isEmpty()) - return false; + QDockAreaLayoutItem *item = 0; + foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren<QDockWidgetGroupWindow *>( + QString(), Qt::FindDirectChildrenOnly)) { + QList<int> index = dwgw->layoutInfo()->indexOfPlaceHolder(dockWidget->objectName()); + if (!index.isEmpty()) { + dockWidget->setParent(dwgw); + item = const_cast<QDockAreaLayoutItem *>(&dwgw->layoutInfo()->item(index)); + break; + } + } + if (!item) { + QList<int> index = indexOfPlaceHolder(dockWidget->objectName()); + if (index.isEmpty()) + return false; + item = const_cast<QDockAreaLayoutItem *>(&this->item(index)); + } - QDockAreaLayoutItem &item = this->item(index); - QPlaceHolderItem *placeHolder = item.placeHolderItem; + QPlaceHolderItem *placeHolder = item->placeHolderItem; Q_ASSERT(placeHolder != 0); - item.widgetItem = new QDockWidgetItem(dockWidget); + item->widgetItem = new QDockWidgetItem(dockWidget); if (placeHolder->window) { const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget); @@ -3056,7 +3083,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) dockWidget->d_func()->setWindowState(true); #endif - item.placeHolderItem = 0; + item->placeHolderItem = 0; delete placeHolder; return true; @@ -3092,9 +3119,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do info = new_info; } - QList<int> index = indexOfPlaceHolder(dockWidget->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(dockWidget->objectName()); } void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) @@ -3107,9 +3132,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) Q_ASSERT(info != 0); info->tab(path.last(), new QDockWidgetItem(second)); - QList<int> index = indexOfPlaceHolder(second->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(second->objectName()); } void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, @@ -3171,9 +3194,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, Q_ASSERT(info != 0); info->split(path.last(), orientation, new QDockWidgetItem(dockWidget)); - QList<int> index = indexOfPlaceHolder(dockWidget->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(dockWidget->objectName()); } void QDockAreaLayout::apply(bool animate) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 0ae1350394..bc9d418783 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -261,6 +261,7 @@ public: QLayoutItem *plug(const QList<int> &path); QLayoutItem *unplug(const QList<int> &path); void remove(const QList<int> &path); + void removePlaceHolder(const QString &name); void fitLayout(); diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index b2c7225e8a..b138c42ba2 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -221,11 +221,10 @@ public: } void setGeometry(const QRect&r) Q_DECL_OVERRIDE { + static_cast<QDockWidgetGroupWindow *>(parent())->destroyOrHideIfEmpty(); QDockAreaLayoutInfo *li = layoutInfo(); - if (li->isEmpty()) { - static_cast<QDockWidgetGroupWindow *>(parent())->destroyIfEmpty(); + if (li->isEmpty()) return; - } int fw = frameWidth(); li->reparentWidgets(parentWidget()); li->rect = r.adjusted(fw, fw, -fw, -fw); @@ -278,6 +277,10 @@ bool QDockWidgetGroupWindow::event(QEvent *e) if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child())) adjustFlags(); break; + case QEvent::LayoutRequest: + // We might need to show the widget again + destroyOrHideIfEmpty(); + break; default: break; } @@ -331,34 +334,43 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const } /*! \internal - Destroy this window if there is no more QDockWidget in it. + Destroy or hide this window if there is no more QDockWidget in it. + Otherwise make sure it is shown. */ -void QDockWidgetGroupWindow::destroyIfEmpty() -{ - if (layoutInfo()->isEmpty()) { - // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent - foreach (QDockWidget *dw, - findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) { - bool wasFloating = dw->isFloating(); - bool wasHidden = dw->isHidden(); - dw->setParent(parentWidget()); - if (wasFloating) { - dw->setFloating(true); - } else { - // maybe it was hidden, we still have to put it back in the main layout. - QMainWindowLayout *ml = qt_mainwindow_layout(static_cast<QMainWindow*>(parentWidget())); - Qt::DockWidgetArea area = ml->dockWidgetArea(this); - if (area == Qt::NoDockWidgetArea) - area = Qt::LeftDockWidgetArea; - static_cast<QMainWindow*>(parentWidget())->addDockWidget(area, dw); - } - if (!wasHidden) - dw->show(); +void QDockWidgetGroupWindow::destroyOrHideIfEmpty() +{ + if (!layoutInfo()->isEmpty()) { + show(); // It might have been hidden, + return; + } + // There might still be placeholders + if (!layoutInfo()->item_list.isEmpty()) { + hide(); + return; + } + + // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent + foreach (QDockWidget *dw, findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) { + bool wasFloating = dw->isFloating(); + bool wasHidden = dw->isHidden(); + dw->setParent(parentWidget()); + if (wasFloating) { + dw->setFloating(true); + } else { + // maybe it was hidden, we still have to put it back in the main layout. + QMainWindowLayout *ml = + qt_mainwindow_layout(static_cast<QMainWindow *>(parentWidget())); + Qt::DockWidgetArea area = ml->dockWidgetArea(this); + if (area == Qt::NoDockWidgetArea) + area = Qt::LeftDockWidgetArea; + static_cast<QMainWindow *>(parentWidget())->addDockWidget(area, dw); } - foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly)) - tb->setParent(parentWidget()); - deleteLater(); + if (!wasHidden) + dw->show(); } + foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly)) + tb->setParent(parentWidget()); + deleteLater(); } /*! \internal @@ -2089,7 +2101,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) item.subinfo->reparentWidgets(parentWidget()); item.subinfo->setTabBarShape(parentInfo->tabBarShape); } - dwgw->destroyIfEmpty(); + dwgw->destroyOrHideIfEmpty(); } if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) { diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 4c61374d83..4f2e8078d3 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -80,7 +80,7 @@ public: : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; QDockWidget *topDockWidget() const; - void destroyIfEmpty(); + void destroyOrHideIfEmpty(); void adjustFlags(); protected: bool event(QEvent *) Q_DECL_OVERRIDE; |