14#include "LayoutSaver_p.h"
15#include "Position_p.h"
22#include "ScopedValueRollback_p.h"
24#include "DockWidget_p.h"
28#include "layouting/Item_p.h"
30#include <unordered_map>
38 , d(new Private(this))
43 view->
d->resized.connect(&Layout::onResize,
this);
48 d->m_minSizeChangedHandler.disconnect();
50 if (d->m_rootItem && !d->m_viewDeleted)
59 if (d == d->m_rootItem->host()) {
61 d->m_rootItem =
nullptr;
64 d->m_viewDeleted =
true;
88 return pw->parentView()->asMainWindowController();
90 if (
auto mw = pw->asMainWindowController())
101 return parent ? parent->asFloatingWindowController() :
nullptr;
106 delete d->m_rootItem;
107 d->m_rootItem = root;
108 d->m_rootItem->numVisibleItemsChanged.connect(
109 [
this](
int count) { d->visibleWidgetCountChanged.emit(
count); });
111 d->m_minSizeChangedHandler =
117 return d->m_rootItem->minSize();
122 return d->m_rootItem->maxSizeHint();
127 if (sz != d->m_rootItem->minSize()) {
130 d->m_rootItem->setMinSize(sz);
136 return d->m_rootItem->size();
141 d->m_rootItem->clear();
146 return d->m_rootItem->checkSanity();
151 d->m_rootItem->dumpLayout();
156 if (item->isPlaceholder()) {
158 item->restore(newGroup->asLayoutingGuest());
163 if (group->inDtor() || group->beingDeletedLater()) {
166 KDDW_ERROR(
"Layout::restorePlaceholder: Trying to use a group that's being deleted");
169 if (tabIndex != -1 && group->dockWidgetCount() >= tabIndex) {
170 group->insertWidget(dw, tabIndex);
175 group->Controller::setVisible(
true);
181 const auto dws = group->dockWidgets();
183 dw->d->lastPosition()->removePlaceholders(d);
191 d->m_rootItem->setSize_recursive(
size);
199 return d->m_rootItem->items_recursive();
204 return d->m_rootItem->contains_recursive(item);
214 return d->m_rootItem->count_recursive();
219 return d->m_rootItem->visibleCount_recursive();
251 return msw->groups();
258 const Core::Item::List
items = d->m_rootItem->items_recursive();
263 for (Core::Item *item :
items) {
265 result.push_back(group);
275 KDDW_ERROR(
"nullptr item");
279 item->parentContainer()->removeItem(item);
284 const Size newMinSize = d->m_rootItem->minSize();
290 std::unordered_map<QString, LayoutingGuest *>
groups;
291 for (
const auto &it : l.groups) {
292 const LayoutSaver::Group &group = it.second;
297 assert(!group.id.isEmpty());
301 d->m_rootItem->fillFromJson(l.layout,
groups);
304 const Size newLayoutSize =
view()->
size().expandedTo(d->m_rootItem->minSize());
306 d->m_rootItem->setSize_recursive(newLayoutSize);
311bool Layout::onResize(Size newSize)
313 ScopedValueRollback resizeGuard(d->m_inResizeEvent,
true);
325 LayoutSaver::MultiSplitter l;
326 d->m_rootItem->to_json(l.layout);
327 const Core::Item::List
items = d->m_rootItem->items_recursive();
328 l.groups.reserve(
size_t(
items.size()));
329 for (Core::Item *item :
items) {
330 if (!item->isContainer()) {
332 l.groups[group->view()->d->id()] = group->serialize();
348 return v->asMDILayoutController();
355 return d->m_rootItem;
364 group->view()->d->requestClose(e);
365 if (!e->isAccepted())
380bool Layout::Private::supportsHonouringLayoutMinSize()
const
382 if (
auto window = q->view()->window()) {
383 return window->supportsHonouringLayoutMinSize();
390Layout::Private::Private(
Layout *qq)
395Layout::Private::~Private() =
default;
401 if (
auto layoutPriv =
dynamic_cast<Core::Layout::Private *
>(host))
402 return layoutPriv->q;
Application-wide config to tune certain behaviours of the framework.
A widget that supports an arbitrary number of splitters (called Separators) in any combination of ver...
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
QMainWindow sub-class to enable KDDockWidgets support.