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;
85 return pw->parentView()->asMainWindowController();
87 if (
auto mw = pw->asMainWindowController())
98 return parent ? parent->asFloatingWindowController() :
nullptr;
103 delete d->m_rootItem;
104 d->m_rootItem = root;
105 d->m_rootItem->numVisibleItemsChanged.connect(
106 [
this](
int count) { d->visibleWidgetCountChanged.emit(
count); });
108 d->m_minSizeChangedHandler =
114 return d->m_rootItem->minSize();
119 return d->m_rootItem->maxSizeHint();
124 if (sz != d->m_rootItem->minSize()) {
127 d->m_rootItem->setMinSize(sz);
133 return d->m_rootItem->size();
138 d->m_rootItem->clear();
143 return d->m_rootItem->checkSanity();
148 d->m_rootItem->dumpLayout();
153 if (item->isPlaceholder()) {
155 item->restore(newGroup->asLayoutingGuest());
160 if (group->inDtor() || group->beingDeletedLater()) {
163 KDDW_ERROR(
"Layout::restorePlaceholder: Trying to use a group that's being deleted");
166 if (tabIndex != -1 && group->dockWidgetCount() >= tabIndex) {
167 group->insertWidget(dw, tabIndex);
172 group->Controller::setVisible(
true);
178 const auto dws = group->dockWidgets();
180 dw->d->lastPosition()->removePlaceholders(d);
188 d->m_rootItem->setSize_recursive(
size);
196 return d->m_rootItem->items_recursive();
201 return d->m_rootItem->contains_recursive(item);
211 return d->m_rootItem->count_recursive();
216 return d->m_rootItem->visibleCount_recursive();
248 return msw->groups();
255 const Core::Item::List
items = d->m_rootItem->items_recursive();
260 for (Core::Item *item :
items) {
262 result.push_back(group);
272 KDDW_ERROR(
"nullptr item");
276 item->parentContainer()->removeItem(item);
281 const Size newMinSize = d->m_rootItem->minSize();
287 std::unordered_map<QString, LayoutingGuest *>
groups;
288 for (
const auto &it : l.groups) {
289 const LayoutSaver::Group &group = it.second;
294 assert(!group.id.isEmpty());
298 d->m_rootItem->fillFromJson(l.layout,
groups);
301 const Size newLayoutSize =
view()->
size().expandedTo(d->m_rootItem->minSize());
303 d->m_rootItem->setSize_recursive(newLayoutSize);
308bool Layout::onResize(Size newSize)
310 ScopedValueRollback resizeGuard(d->m_inResizeEvent,
true);
322 LayoutSaver::MultiSplitter l;
323 d->m_rootItem->to_json(l.layout);
324 const Core::Item::List
items = d->m_rootItem->items_recursive();
325 l.groups.reserve(
size_t(
items.size()));
326 for (Core::Item *item :
items) {
327 if (!item->isContainer()) {
329 l.groups[group->view()->d->id()] = group->serialize();
345 return v->asMDILayoutController();
352 return d->m_rootItem;
361 group->view()->d->requestClose(e);
362 if (!e->isAccepted())
377bool Layout::Private::supportsHonouringLayoutMinSize()
const
379 if (
auto window = q->view()->window()) {
380 return window->supportsHonouringLayoutMinSize();
387Layout::Private::Private(
Layout *qq)
392Layout::Private::~Private() =
default;
398 if (
auto layoutPriv =
dynamic_cast<Core::Layout::Private *
>(host))
399 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.