diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-15 19:47:57 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-15 19:47:57 +0200 |
commit | 40a1f69e8663fb79560c26cfad5ead45b1b3ee5f (patch) | |
tree | a8ceb093a098a38b29c0fe27e41af480ae10b876 /src/widgets | |
parent | 446afc10451d5097d7bd20b1b8d20325c4d54fa5 (diff) | |
parent | 6b2071c697d4c48f0cd289b28b443ebffc3432e6 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
configure.json
mkspecs/macx-tvos-clang/qmake.conf
mkspecs/macx-watchos-clang/qmake.conf
Change-Id: Iaf32339ace59dff9ed344972472744c55d75025c
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/configure.json | 567 | ||||
-rw-r--r-- | src/widgets/configure.pri | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qtwidgetsglobal.h | 1 | ||||
-rw-r--r-- | src/widgets/kernel/qtwidgetsglobal_p.h | 1 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 12 | ||||
-rw-r--r-- | src/widgets/styles/styles.pri | 2 | ||||
-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 |
10 files changed, 669 insertions, 48 deletions
diff --git a/src/widgets/configure.json b/src/widgets/configure.json new file mode 100644 index 0000000000..c1931d9d80 --- /dev/null +++ b/src/widgets/configure.json @@ -0,0 +1,567 @@ +{ + "module": "widgets", + "depends": [ + "core-private", + "gui" + ], + "testDir": "../../config.tests", + + "commandline": { + "options": { + "android-style-assets": "boolean", + "gtk": { "type": "boolean", "name": "gtk3" }, + "style-windows": "boolean", + "style-windowsxp": "boolean", + "style-windowsvista": "boolean", + "style-fusion": "boolean", + "style-mac": "boolean", + "style-android": "boolean" + } + }, + + "libraries": { + "gtk3": { + "label": "GTK+", + "sources": [ + { "type": "pkgConfig", "args": "gtk+-3.0" } + ] + } + }, + + "tests": { + "uxtheme": { + "label": "uxtheme.h", + "type": "files", + "files": [ "uxtheme.h" ] + } + }, + + "features": { + "gtk3": { + "label": "GTK+", + "autoDetect": "!config.darwin", + "condition": "features.glib && libs.gtk3", + "output": [ "privateFeature" ] + }, + "style-fusion": { + "label": "Fusion", + "output": [ "styles" ] + }, + "style-mac": { + "label": "macOS", + "condition": "config.osx", + "output": [ "styles" ] + }, + "style-windows": { + "label": "Windows", + "output": [ "styles" ] + }, + "style-windowsxp": { + "label": "WindowsXP", + "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme", + "output": [ "styles" ] + }, + "style-windowsvista": { + "label": "WindowsVista", + "condition": "features.style-windowsxp", + "output": [ "styles" ] + }, + "style-android": { + "label": "Android", + "autoDetect": "config.android", + "output": [ "styles" ] + }, + "style-stylesheet": { + "label": "QStyleSheetStyle", + "purpose": "Provides a widget style which is configurable via CSS.", + "section": "Styles", + "condition": "features.style-windows && features.properties && features.cssparser", + "output": [ "publicFeature", "feature" ] + }, + "android-style-assets": { + "label": "Android Style Assets", + "condition": "features.style-android", + "output": [ "privateConfig" ] + }, + "effects": { + "label": "Effects", + "purpose": "Provides special widget effects (e.g. fading and scrolling).", + "section": "Kernel" + }, + "filesystemmodel": { + "label": "QFileSystemModel", + "purpose": "Provides a data model for the local filesystem.", + "section": "File I/O", + "output": [ "publicFeature", "feature" ] + }, + "itemviews": { + "label": "The Model/View Framework", + "purpose": "Provides the model/view architecture managing the relationship between data and the way it is presented to the user.", + "section": "ItemViews", + "condition": "features.itemmodel && features.rubberband && features.scrollarea", + "output": [ "publicFeature", "feature" ] + }, + "treewidget": { + "label": "QTreeWidget", + "purpose": "Provides views using tree models.", + "section": "Widgets", + "condition": "features.treeview", + "output": [ "publicFeature", "feature" ] + }, + "listwidget": { + "label": "QListWidget", + "purpose": "Provides item-based list widgets.", + "section": "Widgets", + "condition": "features.listview", + "output": [ "publicFeature", "feature" ] + }, + "tablewidget": { + "label": "QTableWidget", + "purpose": "Provides item-based table views.", + "section": "Widgets", + "condition": "features.tableview", + "output": [ "publicFeature", "feature" ] + }, + "datetimeedit": { + "label": "QDateTimeEdit", + "purpose": "Supports editing dates and times.", + "section": "Widgets", + "condition": "features.calendarwidget && features.datestring", + "output": [ "publicFeature", "feature" ] + }, + "stackedwidget": { + "label": "QStackedWidget", + "purpose": "Provides stacked widgets.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "textbrowser": { + "label": "QTextBrowser", + "purpose": "Supports HTML document browsing.", + "section": "Widgets", + "condition": "features.textedit", + "output": [ "publicFeature", "feature" ] + }, + "splashscreen": { + "label": "QSplashScreen", + "purpose": "Supports splash screens that can be shown during application startup.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "splitter": { + "label": "QSplitter", + "purpose": "Provides user controlled splitter widgets.", + "section": "Widgets", + "condition": "features.rubberband", + "output": [ "publicFeature", "feature" ] + }, + "lcdnumber": { + "label": "QLCDNumber", + "purpose": "Provides LCD-like digits.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "menu": { + "label": "QMenu", + "purpose": "Provides popup-menus.", + "section": "Widgets", + "condition": "features.action", + "output": [ "publicFeature", "feature" ] + }, + "lineedit": { + "label": "QLineEdit", + "purpose": "Provides single-line edits.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "spinbox": { + "label": "QSpinBox", + "purpose": "Provides spin boxes handling integers and discrete sets of values.", + "section": "Widgets", + "condition": "features.spinwidget && features.lineedit && features.validator", + "output": [ "publicFeature", "feature" ] + }, + "tabbar": { + "label": "QTabBar", + "purpose": "Provides tab bars, e.g., for use in tabbed dialogs.", + "section": "Widgets", + "condition": "features.toolbutton", + "output": [ "publicFeature", "feature" ] + }, + "tabwidget": { + "label": "QTabWidget", + "purpose": "Supports stacking tabbed widgets.", + "section": "Widgets", + "condition": "features.tabbar && features.stackedwidget", + "output": [ "publicFeature", "feature" ] + }, + "combobox": { + "label": "QComboBox", + "purpose": "Provides drop-down boxes presenting a list of options to the user.", + "section": "Widgets", + "condition": "features.lineedit && features.standarditemmodel && features.listview", + "output": [ "publicFeature", "feature" ] + }, + "fontcombobox": { + "label": "QFontComboBox", + "purpose": "Provides a combobox that lets the user select a font family.", + "section": "Widgets", + "condition": "features.combobox && features.stringlistmodel", + "output": [ "publicFeature", "feature" ] + }, + "toolbutton": { + "label": "QToolButton", + "purpose": "Provides quick-access buttons to commands and options.", + "section": "Widgets", + "condition": "features.action", + "output": [ "publicFeature", "feature" ] + }, + "toolbar": { + "label": "QToolBar", + "purpose": "Provides movable panels containing a set of controls.", + "section": "Widgets", + "condition": "features.mainwindow", + "output": [ "publicFeature", "feature" ] + }, + "toolbox": { + "label": "QToolBox", + "purpose": "Provides columns of tabbed widget items.", + "section": "Widgets", + "condition": "features.toolbutton && features.scrollarea", + "output": [ "publicFeature", "feature" ] + }, + "groupbox": { + "label": "QGroupBox", + "purpose": "Provides widget grouping boxes with frames.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "buttongroup": { + "label": "QButtonGroup", + "purpose": "Supports organizing groups of button widgets.", + "section": "Widgets", + "condition": "features.groupbox", + "output": [ "publicFeature", "feature" ] + }, + "mainwindow": { + "label": "QMainWindow", + "purpose": "Provides main application windows.", + "section": "Widgets", + "condition": "features.menu && features.resizehandler && features.toolbutton", + "output": [ "publicFeature", "feature" ] + }, + "dockwidget": { + "label": "QDockwidget", + "purpose": "Supports docking widgets inside a QMainWindow or floated as a top-level window on the desktop.", + "section": "Widgets", + "condition": "features.rubberband && features.mainwindow", + "output": [ "publicFeature", "feature" ] + }, + "mdiarea": { + "label": "QMdiArea", + "purpose": "Provides an area in which MDI windows are displayed.", + "section": "Widgets", + "condition": "features.scrollarea", + "output": [ "publicFeature", "feature" ] + }, + "resizehandler": { + "label": "QWidgetResizeHandler", + "purpose": "Provides an internal resize handler for dock widgets.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "statusbar": { + "label": "QStatusBar", + "purpose": "Supports presentation of status information.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "menubar": { + "label": "QMenuBar", + "purpose": "Provides pull-down menu items.", + "section": "Widgets", + "condition": "features.menu && features.toolbutton", + "output": [ "publicFeature", "feature" ] + }, + "contextmenu": { + "label": "Context menus", + "purpose": "Adds pop-up menus on right mouse click to numerous widgets.", + "section": "Widgets", + "condition": "features.menu", + "output": [ "publicFeature", "feature" ] + }, + "progressbar": { + "label": "QProgressBar", + "purpose": "Supports presentation of operation progress.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "slider": { + "label": "QSlider", + "purpose": "Provides sliders controlling a bounded value.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "scrollbar": { + "label": "QScrollBar", + "purpose": "Provides scrollbars allowing the user access parts of a document that is larger than the widget used to display it.", + "section": "Widgets", + "condition": "features.slider", + "output": [ "publicFeature", "feature" ] + }, + "dial": { + "label": "QDial", + "purpose": "Provides a rounded range control, e.g., like a speedometer.", + "section": "Widgets", + "condition": "features.slider", + "output": [ "publicFeature", "feature" ] + }, + "scrollarea": { + "label": "QScrollArea", + "purpose": "Supports scrolling views onto widgets.", + "section": "Widgets", + "condition": "features.scrollbar", + "output": [ "publicFeature", "feature" ] + }, + "graphicsview": { + "label": "QGraphicsView", + "purpose": "Provides a canvas/sprite framework.", + "section": "Widgets", + "condition": "features.scrollarea", + "output": [ "publicFeature", "feature" ] + }, + "graphicseffect": { + "label": "QGraphicsEffect", + "purpose": "Provides various graphics effects.", + "section": "Widgets", + "condition": "features.graphicsview", + "output": [ "publicFeature", "feature" ] + }, + "spinbox": { + "label": "QSpinBox", + "purpose": "Provides spinbox control widgets.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "textedit": { + "label": "QTextEdit", + "purpose": "Supports rich text editing.", + "section": "Widgets", + "condition": "features.scrollarea && features.properties", + "output": [ "publicFeature", "feature" ] + }, + "syntaxhighlighter": { + "label": "QSyntaxHighlighter", + "purpose": "Supports custom syntax highlighting.", + "section": "Widgets", + "condition": "features.textedit", + "output": [ "publicFeature", "feature" ] + }, + "rubberband": { + "label": "QRubberBand", + "purpose": "Supports using rubberbands to indicate selections and boundaries.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "tooltip": { + "label": "QToolTip", + "purpose": "Supports presentation of tooltips.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "statustip": { + "label": "Status Tip", + "purpose": "Supports status tip functionality and events.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "whatsthis": { + "label": "QWhatsThis", + "purpose": "Supports displaying \"What's this\" help.", + "section": "Widgets", + "condition": "features.toolbutton", + "output": [ "publicFeature", "feature" ] + }, + "sizegrip": { + "label": "QSizeGrip", + "purpose": "Provides corner-grips for resizing top-level windows.", + "section": "Widgets", + "output": [ "publicFeature", "feature" ] + }, + "calendarwidget": { + "label": "QCalendarWidget", + "purpose": "Provides a monthly based calendar widget allowing the user to select a date.", + "section": "Widgets", + "condition": "features.tableview && features.menu && features.textdate && features.spinbox && features.toolbutton", + "output": [ "publicFeature", "feature" ] + }, + "keysequenceedit": { + "label": "QKeySequenceEdit", + "purpose": "Provides a widget for editing QKeySequences.", + "section": "Widgets", + "condition": "features.lineedit && features.shortcut", + "output": [ "publicFeature", "feature" ] + }, + "messagebox": { + "label": "QMessageBox", + "purpose": "Provides message boxes displaying informative messages and simple questions.", + "section": "Dialogs", + "output": [ "publicFeature", "feature" ] + }, + "colordialog": { + "label": "QColorDialog", + "purpose": "Provides a dialog widget for specifying colors.", + "section": "Dialogs", + "condition": "features.spinbox", + "output": [ "publicFeature", "feature" ] + }, + "filedialog": { + "label": "QFileDialog", + "purpose": "Provides a dialog widget for selecting files or directories.", + "section": "Dialogs", + "condition": "features.dirmodel && features.treeview && features.combobox && features.toolbutton && features.buttongroup && features.tooltip && features.splitter && features.stackedwidget && features.proxymodel", + "output": [ "publicFeature", "feature" ] + }, + "fontdialog": { + "label": "QFontDialog", + "purpose": "Provides a dialog widget for selecting fonts.", + "section": "Dialogs", + "condition": "features.stringlistmodel && features.combobox && features.validator && features.groupbox", + "output": [ "publicFeature", "feature" ] + }, + "progressdialog": { + "label": "QProgressDialog", + "purpose": "Provides feedback on the progress of a slow operation.", + "section": "Dialogs", + "condition": "features.progressbar", + "output": [ "publicFeature", "feature" ] + }, + "inputdialog": { + "label": "QInputDialog", + "purpose": "Provides a simple convenience dialog to get a single value from the user.", + "section": "Dialogs", + "condition": "features.combobox && features.spinbox && features.stackedwidget", + "output": [ "publicFeature", "feature" ] + }, + "errormessage": { + "label": "QErrorMessage", + "purpose": "Provides an error message display dialog.", + "section": "Dialogs", + "condition": "features.textedit", + "output": [ "publicFeature", "feature" ] + }, + "wizard": { + "label": "QWizard", + "purpose": "Provides a framework for multi-page click-through dialogs.", + "section": "Dialogs", + "condition": "features.properties", + "output": [ "publicFeature", "feature" ] + }, + "dirmodel": { + "label": "QDirModel", + "purpose": "Provides a data model for the local filesystem.", + "section": "ItemViews", + "condition": "features.itemviews && features.filesystemmodel", + "output": [ "publicFeature", "feature" ] + }, + "listview": { + "label": "QListView", + "purpose": "Provides a list or icon view onto a model.", + "section": "ItemViews", + "condition": "features.itemviews", + "output": [ "publicFeature", "feature" ] + }, + "tableview": { + "label": "QTableView", + "purpose": "Provides a default model/view implementation of a table view.", + "section": "ItemViews", + "condition": "features.itemviews", + "output": [ "publicFeature", "feature" ] + }, + "treeview": { + "label": "QTreeView", + "purpose": "Provides a default model/view implementation of a tree view.", + "section": "ItemViews", + "condition": "features.itemviews", + "output": [ "publicFeature", "feature" ] + }, + "datawidgetmapper": { + "label": "QDataWidgetMapper", + "purpose": "Provides mapping between a section of a data model to widgets.", + "section": "ItemViews", + "condition": "features.itemviews && features.properties", + "output": [ "publicFeature", "feature" ] + }, + "columnview": { + "label": "QColumnView", + "purpose": "Provides a model/view implementation of a column view.", + "section": "ItemViews", + "condition": "features.listview", + "output": [ "publicFeature", "feature" ] + }, + "paint_debug": { + "label": "Painting Debug Utilities", + "purpose": "Enabled debugging painting with the environment variables QT_FLUSH_UPDATE and QT_FLUSH_PAINT.", + "section": "Painting", + "output": [ "publicFeature", "feature" ] + }, + "completer": { + "label": "QCompleter", + "purpose": "Provides completions based on an item model.", + "section": "Utilities", + "condition": "features.proxymodel", + "output": [ "publicFeature", "feature" ] + }, + "fscompleter": { + "label": "QFSCompleter", + "purpose": "Provides file name completion in QFileDialog.", + "section": "Utilities", + "condition": "features.filesystemmodel && features.completer", + "output": [ "publicFeature", "feature" ] + }, + "undocommand": { + "label": "QUndoCommand", + "purpose": "Applies (redo or) undo of a single change in a document.", + "section": "Utilities", + "output": [ "publicFeature", "feature" ] + }, + "undostack": { + "label": "QUndoStack", + "purpose": "Provides the ability to (redo or) undo a list of changes in a document.", + "section": "Utilities", + "condition": "features.undocommand", + "output": [ "publicFeature", "feature" ] + }, + "undogroup": { + "label": "QUndoGroup", + "purpose": "Provides the ability to cluster QUndoCommands.", + "section": "Utilities", + "condition": "features.undostack", + "output": [ "publicFeature", "feature" ] + }, + "undoview": { + "label": "QUndoView", + "purpose": "Provides a widget which shows the contents of an undo stack.", + "section": "Utilities", + "condition": "features.undostack && features.listview", + "output": [ "publicFeature", "feature" ] + } + }, + + "report": [ + ], + + "summary": [ + { + "section": "Qt Widgets", + "entries": [ + "gtk3", + { + "message": "Styles", + "type": "featureList", + "args": "style-fusion style-mac style-windows style-windowsxp style-windowsvista style-android" + } + ] + } + ] +} diff --git a/src/widgets/configure.pri b/src/widgets/configure.pri new file mode 100644 index 0000000000..ddb3657700 --- /dev/null +++ b/src/widgets/configure.pri @@ -0,0 +1,8 @@ +# custom outputs + +defineTest(qtConfOutput_styles) { + !$${2}: return() + + style = $$replace($${1}.feature, "style-", "") + qtConfOutputVar(append, "privatePro", "styles", $$style) +} diff --git a/src/widgets/kernel/qtwidgetsglobal.h b/src/widgets/kernel/qtwidgetsglobal.h index f6d003e629..1c74f37618 100644 --- a/src/widgets/kernel/qtwidgetsglobal.h +++ b/src/widgets/kernel/qtwidgetsglobal.h @@ -41,6 +41,7 @@ #define QTWIDGETSGLOBAL_H #include <QtGui/qtguiglobal.h> +#include <QtWidgets/qtwidgets-config.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qtwidgetsglobal_p.h b/src/widgets/kernel/qtwidgetsglobal_p.h index 7dd545415c..22ba876022 100644 --- a/src/widgets/kernel/qtwidgetsglobal_p.h +++ b/src/widgets/kernel/qtwidgetsglobal_p.h @@ -53,5 +53,6 @@ #include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/private/qtguiglobal_p.h> +#include <QtWidgets/private/qtwidgets-config_p.h> #endif // QTWIDGETSGLOBAL_P_H diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 690524b64b..b214dae154 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/styles/styles.pri b/src/widgets/styles/styles.pri index 7b9497172c..69e13fb6ec 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -35,6 +35,8 @@ SOURCES += \ RESOURCES += styles/qstyle.qrc +include($$OUT_PWD/qtwidgets-config.pri) + contains( styles, mac ) { HEADERS += \ styles/qmacstyle_mac_p.h \ diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index b347e93807..a7e865ff05 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2617,6 +2617,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, @@ -3043,15 +3058,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); @@ -3063,7 +3090,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) dockWidget->d_func()->setWindowState(true); #endif - item.placeHolderItem = 0; + item->placeHolderItem = 0; delete placeHolder; return true; @@ -3099,9 +3126,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) @@ -3114,9 +3139,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, @@ -3178,9 +3201,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 aa6e4232e0..f22a3d2de2 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -262,6 +262,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 c5b08387a3..939453473a 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 @@ -2093,7 +2105,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 7f35f78111..c06122b9c7 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -81,7 +81,7 @@ public: : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; QDockWidget *topDockWidget() const; - void destroyIfEmpty(); + void destroyOrHideIfEmpty(); void adjustFlags(); protected: bool event(QEvent *) Q_DECL_OVERRIDE; |