Rename more frame variables to group
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
- FloatingWindow now honours the dockwidget's max-size, if there's a single
|
||||
dock widget docked. Tabbed cases are more difficult since QStackedLayout doesn't
|
||||
propagate size constraints.
|
||||
- Added MainWindowBase::frameCountChanged()
|
||||
- Added MainWindowBase::groupCountChanged()
|
||||
- Introduced Config::setDropIndicatorsInhibited(), which allows you to disable support
|
||||
for drop indicators while dragging.
|
||||
- Fixed embedding the main window into a non-kddw main window (#204, #168)
|
||||
|
||||
@@ -59,7 +59,7 @@ A visual separator between two widgets, which allows the user to resize dock wid
|
||||
## FloatingWindow
|
||||
|
||||
When a dock widget isn't embedded into a window it's said to be floating. It's its own
|
||||
top-level native window. This class ties all the previous together. It contains one layout, which contains multiple frames.
|
||||
top-level native window. This class ties all the previous together. It contains one layout, which contains multiple groups.
|
||||
|
||||
|
||||
## MainWindow
|
||||
|
||||
@@ -225,8 +225,8 @@ Controllers::Group *DockRegistry::groupInMDIResize() const
|
||||
continue;
|
||||
|
||||
Layout *layout = mw->layout();
|
||||
const QList<Controllers::Group *> frames = layout->frames();
|
||||
for (Controllers::Group *group : frames) {
|
||||
const QList<Controllers::Group *> groups = layout->groups();
|
||||
for (Controllers::Group *group : groups) {
|
||||
if (WidgetResizeHandler *wrh = group->resizeHandler()) {
|
||||
if (wrh->isResizing())
|
||||
return group;
|
||||
@@ -237,7 +237,7 @@ Controllers::Group *DockRegistry::groupInMDIResize() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QObject *DockRegistry::frameViewInMDIResize() const
|
||||
QObject *DockRegistry::groupViewInMDIResize() const
|
||||
{
|
||||
if (auto group = groupInMDIResize())
|
||||
return group->view()->asQObject();
|
||||
@@ -521,7 +521,7 @@ const QVector<Controllers::Layout *> DockRegistry::layouts() const
|
||||
return m_layouts;
|
||||
}
|
||||
|
||||
const Controllers::Group::List DockRegistry::frames() const
|
||||
const Controllers::Group::List DockRegistry::groups() const
|
||||
{
|
||||
return m_groups;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class DOCKS_EXPORT DockRegistry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(
|
||||
QObject *frameViewInMDIResize READ frameViewInMDIResize NOTIFY frameInMDIResizeChanged)
|
||||
QObject *groupViewInMDIResize READ groupViewInMDIResize NOTIFY groupInMDIResizeChanged)
|
||||
public:
|
||||
enum class DockByNameFlag
|
||||
{
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
const QVector<Controllers::Layout *> layouts() const;
|
||||
|
||||
///@brief returns a list of all Frame instances
|
||||
const QList<Controllers::Group *> frames() const;
|
||||
const QList<Controllers::Group *> groups() const;
|
||||
|
||||
///@brief returns all FloatingWindow instances. Not necessarily all floating dock widgets,
|
||||
/// As there might be DockWidgets which weren't morphed yet.
|
||||
@@ -236,14 +236,14 @@ public:
|
||||
Controllers::Group *groupInMDIResize() const;
|
||||
|
||||
/// Returns the Frame view, for QtQuick
|
||||
QObject *frameViewInMDIResize() const;
|
||||
QObject *groupViewInMDIResize() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/// @brief emitted when a main window or a floating window change screen
|
||||
void windowChangedScreen(std::shared_ptr<Window>);
|
||||
|
||||
/// @brief emitted when the MDI frame that's being resized changed
|
||||
void frameInMDIResizeChanged();
|
||||
void groupInMDIResizeChanged();
|
||||
|
||||
/// @brief emitted whenever Config::dropIndicatorsInhibited changes
|
||||
void dropIndicatorsInhibitedChanged(bool inhibited);
|
||||
|
||||
@@ -127,14 +127,14 @@ void from_json(const nlohmann::json &json, LayoutSaver::Group &f)
|
||||
void to_json(nlohmann::json &json, const LayoutSaver::MultiSplitter &s)
|
||||
{
|
||||
json["layout"] = s.layout;
|
||||
auto &frames = json["frames"];
|
||||
for (const auto &frame : qAsConst(s.frames)) {
|
||||
frames[frame.id.toStdString()] = frame;
|
||||
auto &groups = json["frames"];
|
||||
for (const auto &frame : qAsConst(s.groups)) {
|
||||
groups[frame.id.toStdString()] = frame;
|
||||
}
|
||||
}
|
||||
void from_json(const nlohmann::json &json, LayoutSaver::MultiSplitter &s)
|
||||
{
|
||||
s.frames.clear();
|
||||
s.groups.clear();
|
||||
s.layout = json.value("layout", QVariantMap());
|
||||
auto it = json.find("frames");
|
||||
if (it == json.end())
|
||||
@@ -149,7 +149,7 @@ void from_json(const nlohmann::json &json, LayoutSaver::MultiSplitter &s)
|
||||
for (const auto &kv : frms.items()) {
|
||||
QString key = QString::fromStdString(kv.key());
|
||||
auto group = kv.value().get<LayoutSaver::Group>();
|
||||
s.frames.insert(key, group);
|
||||
s.groups.insert(key, group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ void LayoutSaver::Private::deleteEmptyFrames()
|
||||
// After a restore it can happen that some DockWidgets didn't exist, so weren't restored.
|
||||
// Delete their frame now.
|
||||
|
||||
for (auto group : m_dockRegistry->frames()) {
|
||||
for (auto group : m_dockRegistry->groups()) {
|
||||
if (!group->beingDeletedLater() && group->isEmpty() && !group->isCentralFrame())
|
||||
delete group;
|
||||
}
|
||||
@@ -986,7 +986,7 @@ bool LayoutSaver::MultiSplitter::isValid() const
|
||||
|
||||
bool LayoutSaver::MultiSplitter::hasSingleDockWidget() const
|
||||
{
|
||||
return frames.size() == 1 && frames.cbegin()->hasSingleDockWidget();
|
||||
return groups.size() == 1 && groups.cbegin()->hasSingleDockWidget();
|
||||
}
|
||||
|
||||
LayoutSaver::DockWidget::Ptr LayoutSaver::MultiSplitter::singleDockWidget() const
|
||||
@@ -994,12 +994,12 @@ LayoutSaver::DockWidget::Ptr LayoutSaver::MultiSplitter::singleDockWidget() cons
|
||||
if (!hasSingleDockWidget())
|
||||
return {};
|
||||
|
||||
return frames.cbegin()->singleDockWidget();
|
||||
return groups.cbegin()->singleDockWidget();
|
||||
}
|
||||
|
||||
bool LayoutSaver::MultiSplitter::skipsRestore() const
|
||||
{
|
||||
return std::all_of(frames.cbegin(), frames.cend(), [](const LayoutSaver::Group &frame) {
|
||||
return std::all_of(groups.cbegin(), groups.cend(), [](const LayoutSaver::Group &frame) {
|
||||
return frame.skipsRestore();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ QString DockWidget::title() const
|
||||
auto dropAreaGuest = d->guest ? guestView()->asDropAreaController() : nullptr;
|
||||
Q_ASSERT(dropAreaGuest);
|
||||
if (dropAreaGuest->hasSingleFrame()) {
|
||||
return dropAreaGuest->frames().constFirst()->title();
|
||||
return dropAreaGuest->groups().constFirst()->title();
|
||||
} else {
|
||||
return qGuiApp->applicationName();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ DropArea::~DropArea()
|
||||
qCDebug(creation) << "~DropArea";
|
||||
}
|
||||
|
||||
Controllers::Group::List DropArea::frames() const
|
||||
Controllers::Group::List DropArea::groups() const
|
||||
{
|
||||
const Layouting::Item::List children = m_rootItem->items_recursive();
|
||||
Controllers::Group::List groups;
|
||||
@@ -138,8 +138,8 @@ Controllers::Group *DropArea::groupContainingPos(QPoint globalPos) const
|
||||
|
||||
void DropArea::updateFloatingActions()
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
for (Controllers::Group *group : frames)
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
for (Controllers::Group *group : groups)
|
||||
group->updateFloatingActions();
|
||||
}
|
||||
|
||||
@@ -216,8 +216,8 @@ bool DropArea::containsDockWidget(Controllers::DockWidget *dw) const
|
||||
|
||||
bool DropArea::hasSingleFloatingFrame() const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
return frames.size() == 1 && frames.first()->isFloating();
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
return groups.size() == 1 && groups.first()->isFloating();
|
||||
}
|
||||
|
||||
bool DropArea::hasSingleFrame() const
|
||||
@@ -548,8 +548,8 @@ void DropArea::addWidget(View *w, Location location,
|
||||
|
||||
Layouting::Item *newItem = nullptr;
|
||||
|
||||
Controllers::Group::List frames = framesFrom(w);
|
||||
unrefOldPlaceholders(frames);
|
||||
Controllers::Group::List groups = groupsFrom(w);
|
||||
unrefOldPlaceholders(groups);
|
||||
auto dw = w->asDockWidgetController();
|
||||
auto thisView = view();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
DropLocation hover(WindowBeingDragged *draggedWindow, QPoint globalPos);
|
||||
///@brief Called when a user drops a widget via DND
|
||||
bool drop(WindowBeingDragged *droppedWindow, QPoint globalPos);
|
||||
QList<Controllers::Group *> frames() const;
|
||||
QList<Controllers::Group *> groups() const;
|
||||
|
||||
Layouting::Item *centralFrame() const;
|
||||
DropIndicatorOverlay *dropIndicatorOverlay() const
|
||||
|
||||
@@ -185,7 +185,7 @@ FloatingWindow::FloatingWindow(Controllers::Group *group, QRect suggestedGeometr
|
||||
DropArea *dropAreaMDIWrapper = dwMDIWrapper->d->mdiDropAreaWrapper();
|
||||
|
||||
if (dropAreaMDIWrapper->hasSingleFrame()) {
|
||||
Controllers::Group *innerFrame = dropAreaMDIWrapper->frames().constFirst();
|
||||
Controllers::Group *innerFrame = dropAreaMDIWrapper->groups().constFirst();
|
||||
if (innerFrame->hasSingleDockWidget()) {
|
||||
// When pressing the unfloat button, the dock widgets gets docked to the previous
|
||||
// position it was at. Controllers::DockWidget::Private::m_lastPosition stores that location,
|
||||
@@ -259,9 +259,9 @@ std::unique_ptr<WindowBeingDragged> FloatingWindow::makeWindow()
|
||||
|
||||
Controllers::DockWidget *FloatingWindow::singleDockWidget() const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
if (frames.size() == 1) {
|
||||
Controllers::Group *group = frames.first();
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
if (groups.size() == 1) {
|
||||
Controllers::Group *group = groups.first();
|
||||
if (group->hasSingleDockWidget())
|
||||
return group->dockWidgetAt(0);
|
||||
}
|
||||
@@ -274,10 +274,10 @@ const Controllers::DockWidget::List FloatingWindow::dockWidgets() const
|
||||
return m_dropArea->dockWidgets();
|
||||
}
|
||||
|
||||
const Controllers::Group::List FloatingWindow::frames() const
|
||||
const Controllers::Group::List FloatingWindow::groups() const
|
||||
{
|
||||
Q_ASSERT(m_dropArea);
|
||||
return m_dropArea->frames();
|
||||
return m_dropArea->groups();
|
||||
}
|
||||
|
||||
QSize FloatingWindow::maxSizeHint() const
|
||||
@@ -289,13 +289,13 @@ QSize FloatingWindow::maxSizeHint() const
|
||||
return result;
|
||||
}
|
||||
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
if (frames.size() == 1) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
if (groups.size() == 1) {
|
||||
// Let's honour max-size when we have a single-frame.
|
||||
// multi-frame cases are more complicated and we're not sure if we want the window to
|
||||
// bounce around. single-frame is the most common case, like floating a dock widget, so
|
||||
// let's do that first, it's also easy.
|
||||
Controllers::Group *group = frames[0];
|
||||
Controllers::Group *group = groups[0];
|
||||
if (group->dockWidgetCount() == 1) { // We don't support if there's tabbing
|
||||
const QSize waste = (view()->minSize() - group->view()->minSize()).expandedTo(QSize(0, 0));
|
||||
result = group->view()->maxSizeHint() + waste;
|
||||
@@ -365,7 +365,7 @@ bool FloatingWindow::isInDragArea(QPoint globalPoint) const
|
||||
|
||||
bool FloatingWindow::anyNonClosable() const
|
||||
{
|
||||
for (Controllers::Group *group : frames()) {
|
||||
for (Controllers::Group *group : groups()) {
|
||||
if (group->anyNonClosable())
|
||||
return true;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ bool FloatingWindow::anyNonClosable() const
|
||||
|
||||
bool FloatingWindow::anyNonDockable() const
|
||||
{
|
||||
for (Controllers::Group *group : frames()) {
|
||||
for (Controllers::Group *group : groups()) {
|
||||
if (group->anyNonDockable())
|
||||
return true;
|
||||
}
|
||||
@@ -388,20 +388,20 @@ bool FloatingWindow::hasSingleFrame() const
|
||||
|
||||
bool FloatingWindow::hasSingleDockWidget() const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
if (frames.size() != 1)
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
if (groups.size() != 1)
|
||||
return false;
|
||||
|
||||
Controllers::Group *group = frames.first();
|
||||
Controllers::Group *group = groups.first();
|
||||
return group->dockWidgetCount() == 1;
|
||||
}
|
||||
|
||||
Controllers::Group *FloatingWindow::singleFrame() const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
|
||||
return frames.isEmpty() ? nullptr
|
||||
: frames.first();
|
||||
return groups.isEmpty() ? nullptr
|
||||
: groups.first();
|
||||
}
|
||||
|
||||
bool FloatingWindow::beingDeleted() const
|
||||
@@ -409,7 +409,7 @@ bool FloatingWindow::beingDeleted() const
|
||||
if (m_deleteScheduled || m_inDtor)
|
||||
return true;
|
||||
|
||||
for (Controllers::Group *f : frames()) {
|
||||
for (Controllers::Group *f : groups()) {
|
||||
if (f->beingDeletedLater())
|
||||
return true;
|
||||
}
|
||||
@@ -459,14 +459,14 @@ void FloatingWindow::updateTitleBarVisibility()
|
||||
|
||||
bool visible = true;
|
||||
|
||||
for (Controllers::Group *group : frames())
|
||||
for (Controllers::Group *group : groups())
|
||||
group->updateTitleBarVisibility();
|
||||
|
||||
if (KDDockWidgets::usesClientTitleBar()) {
|
||||
const auto flags = Config::self().flags();
|
||||
if ((flags & Config::Flag_HideTitleBarWhenTabsVisible) && !(flags & Config::Flag_AlwaysTitleBarWhenFloating)) {
|
||||
if (hasSingleFrame()) {
|
||||
visible = !frames().first()->hasTabsVisible();
|
||||
visible = !groups().first()->hasTabsVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,8 +480,8 @@ void FloatingWindow::updateTitleBarVisibility()
|
||||
|
||||
QStringList FloatingWindow::affinities() const
|
||||
{
|
||||
auto frames = this->frames();
|
||||
return frames.isEmpty() ? QStringList() : frames.constFirst()->affinities();
|
||||
auto groups = this->groups();
|
||||
return groups.isEmpty() ? QStringList() : groups.constFirst()->affinities();
|
||||
}
|
||||
|
||||
void FloatingWindow::updateTitleAndIcon()
|
||||
@@ -489,7 +489,7 @@ void FloatingWindow::updateTitleAndIcon()
|
||||
QString title;
|
||||
QIcon icon;
|
||||
if (hasSingleFrame()) {
|
||||
const Controllers::Group *group = frames().constFirst();
|
||||
const Controllers::Group *group = groups().constFirst();
|
||||
title = group->title();
|
||||
icon = group->icon();
|
||||
} else {
|
||||
@@ -561,7 +561,7 @@ QRect FloatingWindow::dragRect() const
|
||||
rect = m_titleBar->rect();
|
||||
rect.moveTopLeft(m_titleBar->view()->mapToGlobal(QPoint(0, 0)));
|
||||
} else if (hasSingleFrame()) {
|
||||
rect = frames().constFirst()->dragRect();
|
||||
rect = groups().constFirst()->dragRect();
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "Expected a title bar";
|
||||
}
|
||||
@@ -571,32 +571,32 @@ QRect FloatingWindow::dragRect() const
|
||||
|
||||
bool FloatingWindow::allDockWidgetsHave(DockWidgetOption option) const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
return std::all_of(frames.begin(), frames.end(), [option](Controllers::Group *group) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
return std::all_of(groups.begin(), groups.end(), [option](Controllers::Group *group) {
|
||||
return group->allDockWidgetsHave(option);
|
||||
});
|
||||
}
|
||||
|
||||
bool FloatingWindow::anyDockWidgetsHas(DockWidgetOption option) const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
return std::any_of(frames.begin(), frames.end(), [option](Controllers::Group *group) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
return std::any_of(groups.begin(), groups.end(), [option](Controllers::Group *group) {
|
||||
return group->anyDockWidgetsHas(option);
|
||||
});
|
||||
}
|
||||
|
||||
bool FloatingWindow::allDockWidgetsHave(LayoutSaverOption option) const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
return std::all_of(frames.begin(), frames.end(), [option](Controllers::Group *group) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
return std::all_of(groups.begin(), groups.end(), [option](Controllers::Group *group) {
|
||||
return group->allDockWidgetsHave(option);
|
||||
});
|
||||
}
|
||||
|
||||
bool FloatingWindow::anyDockWidgetsHas(LayoutSaverOption option) const
|
||||
{
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
return std::any_of(frames.begin(), frames.end(), [option](Controllers::Group *group) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
return std::any_of(groups.begin(), groups.end(), [option](Controllers::Group *group) {
|
||||
return group->anyDockWidgetsHas(option);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
bool isWindow() const override;
|
||||
|
||||
const QVector<DockWidget *> dockWidgets() const;
|
||||
const Controllers::Group::List frames() const;
|
||||
const Controllers::Group::List groups() const;
|
||||
DropArea *dropArea() const;
|
||||
|
||||
int userType() const;
|
||||
|
||||
@@ -277,7 +277,7 @@ void Group::addWidget(Group *group, InitialOption addingOption)
|
||||
void Group::addWidget(FloatingWindow *floatingWindow, InitialOption addingOption)
|
||||
{
|
||||
Q_ASSERT(floatingWindow);
|
||||
for (Group *f : floatingWindow->frames())
|
||||
for (Group *f : floatingWindow->groups())
|
||||
addWidget(f, addingOption);
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ FloatingWindow *Group::detachTab(DockWidget *dockWidget)
|
||||
const QPoint globalPoint = mapToGlobal(QPoint(0, 0));
|
||||
newFrame->addWidget(dockWidget);
|
||||
|
||||
// We're potentially already dead at this point, as frames with 0 tabs auto-destruct. Don't access members from this point.
|
||||
// We're potentially already dead at this point, as groups with 0 tabs auto-destruct. Don't access members from this point.
|
||||
|
||||
auto floatingWindow = new FloatingWindow(newFrame, {});
|
||||
r.moveTopLeft(globalPoint);
|
||||
@@ -468,7 +468,7 @@ void Group::updateTitleBarVisibility()
|
||||
} else if ((Config::self().flags() & Config::Flag_HideTitleBarWhenTabsVisible) && hasTabsVisible()) {
|
||||
visible = false;
|
||||
} else if (FloatingWindow *fw = floatingWindow()) {
|
||||
// If there's nested frames then show each Frame's title bar
|
||||
// If there's nested groups then show each Frame's title bar
|
||||
visible = !fw->hasSingleFrame();
|
||||
} else if (isMDIWrapper()) {
|
||||
auto dropArea = this->mdiDropAreaWrapper();
|
||||
@@ -513,7 +513,7 @@ Controllers::TitleBar *Group::titleBar() const
|
||||
Controllers::TitleBar *Group::actualTitleBar() const
|
||||
{
|
||||
if (FloatingWindow *fw = floatingWindow()) {
|
||||
// If there's nested frames then show each Frame's title bar
|
||||
// If there's nested groups then show each Frame's title bar
|
||||
if (fw->hasSingleFrame())
|
||||
return fw->titleBar();
|
||||
} else if (auto mdiDropArea = mdiDropAreaWrapper()) {
|
||||
|
||||
@@ -149,8 +149,8 @@ void Layout::dumpLayout() const
|
||||
void Layout::restorePlaceholder(Controllers::DockWidget *dw, Layouting::Item *item, int tabIndex)
|
||||
{
|
||||
if (item->isPlaceholder()) {
|
||||
auto newFrame = new Controllers::Group(view());
|
||||
item->restore(newFrame->view());
|
||||
auto newGroup = new Controllers::Group(view());
|
||||
item->restore(newGroup->view());
|
||||
}
|
||||
|
||||
auto group = item->asFrameController();
|
||||
@@ -165,9 +165,9 @@ void Layout::restorePlaceholder(Controllers::DockWidget *dw, Layouting::Item *it
|
||||
group->setVisible(true);
|
||||
}
|
||||
|
||||
void Layout::unrefOldPlaceholders(const Controllers::Group::List &framesBeingAdded) const
|
||||
void Layout::unrefOldPlaceholders(const Controllers::Group::List &groupsBeingAdded) const
|
||||
{
|
||||
for (Controllers::Group *group : framesBeingAdded) {
|
||||
for (Controllers::Group *group : groupsBeingAdded) {
|
||||
for (Controllers::DockWidget *dw : group->dockWidgets()) {
|
||||
dw->d->lastPosition()->removePlaceholders(this);
|
||||
}
|
||||
@@ -224,25 +224,25 @@ Layouting::Item *Layout::itemForFrame(const Controllers::Group *group) const
|
||||
Controllers::DockWidget::List Layout::dockWidgets() const
|
||||
{
|
||||
Controllers::DockWidget::List dockWidgets;
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
for (Controllers::Group *group : frames)
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
for (Controllers::Group *group : groups)
|
||||
dockWidgets << group->dockWidgets();
|
||||
|
||||
return dockWidgets;
|
||||
}
|
||||
|
||||
Controllers::Group::List Layout::framesFrom(View *frameOrMultiSplitter) const
|
||||
Controllers::Group::List Layout::groupsFrom(View *groupOrMultiSplitter) const
|
||||
{
|
||||
if (auto group = frameOrMultiSplitter->asFrameController())
|
||||
if (auto group = groupOrMultiSplitter->asFrameController())
|
||||
return { group };
|
||||
|
||||
if (auto msw = frameOrMultiSplitter->asDropAreaController())
|
||||
return msw->frames();
|
||||
if (auto msw = groupOrMultiSplitter->asDropAreaController())
|
||||
return msw->groups();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Controllers::Group::List Layout::frames() const
|
||||
Controllers::Group::List Layout::groups() const
|
||||
{
|
||||
const Layouting::Item::List items = m_rootItem->items_recursive();
|
||||
|
||||
@@ -279,14 +279,14 @@ void Layout::updateSizeConstraints()
|
||||
|
||||
bool Layout::deserialize(const LayoutSaver::MultiSplitter &l)
|
||||
{
|
||||
QHash<QString, View *> frames;
|
||||
for (const LayoutSaver::Group &group : qAsConst(l.frames)) {
|
||||
QHash<QString, View *> groups;
|
||||
for (const LayoutSaver::Group &group : qAsConst(l.groups)) {
|
||||
Controllers::Group *f = Controllers::Group::deserialize(group);
|
||||
Q_ASSERT(!group.id.isEmpty());
|
||||
frames.insert(group.id, f->view());
|
||||
groups.insert(group.id, f->view());
|
||||
}
|
||||
|
||||
m_rootItem->fillFromVariantMap(l.layout, frames);
|
||||
m_rootItem->fillFromVariantMap(l.layout, groups);
|
||||
|
||||
updateSizeConstraints();
|
||||
|
||||
@@ -316,11 +316,11 @@ LayoutSaver::MultiSplitter Layout::serialize() const
|
||||
LayoutSaver::MultiSplitter l;
|
||||
l.layout = m_rootItem->toVariantMap();
|
||||
const Layouting::Item::List items = m_rootItem->items_recursive();
|
||||
l.frames.reserve(items.size());
|
||||
l.groups.reserve(items.size());
|
||||
for (Layouting::Item *item : items) {
|
||||
if (!item->isContainer()) {
|
||||
if (auto group = item->asFrameController()) {
|
||||
l.frames.insert(group->view()->id(), group->serialize());
|
||||
l.groups.insert(group->view()->id(), group->serialize());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,8 +351,8 @@ void Layout::onCloseEvent(QCloseEvent *e)
|
||||
{
|
||||
e->accept(); // Accepted by default (will close unless ignored)
|
||||
|
||||
const Controllers::Group::List frames = this->frames();
|
||||
for (Controllers::Group *group : frames) {
|
||||
const Controllers::Group::List groups = this->groups();
|
||||
for (Controllers::Group *group : groups) {
|
||||
Platform::instance()->sendEvent(group->view(), e);
|
||||
if (!e->isAccepted())
|
||||
break; // Stop when the first frame prevents closing
|
||||
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
/**
|
||||
* @brief Returns this list of Frame objects contained in this layout
|
||||
*/
|
||||
QList<Controllers::Group *> frames() const;
|
||||
QList<Controllers::Group *> groups() const;
|
||||
|
||||
/// @brief Returns the list of dock widgets contained in this layout
|
||||
QVector<Controllers::DockWidget *> dockWidgets() const;
|
||||
@@ -214,7 +214,7 @@ protected:
|
||||
void setLayoutMinimumSize(QSize);
|
||||
|
||||
/**
|
||||
* @brief Removes unneeded placeholder items when adding new frames.
|
||||
* @brief Removes unneeded placeholder items when adding new groups.
|
||||
*
|
||||
* A floating frame A might have a placeholder in the main window (for example to remember its
|
||||
* position on the Left), but then the user might attach it to the right, so the left
|
||||
@@ -222,14 +222,14 @@ protected:
|
||||
* placeholder, otherwise it's unrefed while we're adding causing a segfault. So what this does
|
||||
* is making the unrefing happen a bit earlier.
|
||||
*/
|
||||
void unrefOldPlaceholders(const QList<Controllers::Group *> &framesBeingAdded) const;
|
||||
void unrefOldPlaceholders(const QList<Controllers::Group *> &groupsBeingAdded) const;
|
||||
|
||||
/**
|
||||
* @brief returns the frames contained in @p frameOrMultiSplitter
|
||||
* If frameOrMultiSplitter is a Frame, it returns a list of 1 element, with that frame
|
||||
* If frameOrMultiSplitter is a MultiSplitter then it returns a list of all frames it contains
|
||||
* @brief returns the groups contained in @p groupOrMultiSplitter-
|
||||
* If groupOrMultiSplitter- is a Frame, it returns a list of 1 element, with that frame
|
||||
* If groupOrMultiSplitter- is a MultiSplitter then it returns a list of all groups it contains
|
||||
*/
|
||||
QList<Controllers::Group *> framesFrom(View *frameOrMultiSplitter) const;
|
||||
QList<Controllers::Group *> groupsFrom(View *groupOrMultiSplitter) const;
|
||||
|
||||
private:
|
||||
bool onResize(QSize newSize);
|
||||
|
||||
@@ -146,7 +146,7 @@ void MainWindow::init(const QString &name)
|
||||
|
||||
setUniqueName(name);
|
||||
|
||||
d->m_visibleWidgetCountConnection = d->m_layout->visibleWidgetCountChanged.connect(&MainWindow::frameCountChanged, this);
|
||||
d->m_visibleWidgetCountConnection = d->m_layout->visibleWidgetCountChanged.connect(&MainWindow::groupCountChanged, this);
|
||||
view()->d->closeRequested.connect([this](QCloseEvent *ev) {
|
||||
d->m_layout->onCloseEvent(ev);
|
||||
});
|
||||
@@ -700,7 +700,7 @@ bool MainWindow::closeDockWidgets(bool force)
|
||||
// The dock widget was closed and this frame is empty, delete immediately instead of
|
||||
// waiting. I'm not a big fan of deleting stuff later, as state becomes inconsistent
|
||||
|
||||
// Empty frames are historically deleted later since they are triggered by mouse click
|
||||
// Empty groups are historically deleted later since they are triggered by mouse click
|
||||
// on the title bar, and the title bar is inside the frame.
|
||||
// When doing it programmatically we can delete immediately.
|
||||
|
||||
|
||||
@@ -231,10 +231,10 @@ protected:
|
||||
Q_SIGNALS:
|
||||
void uniqueNameChanged();
|
||||
|
||||
/// @brief emitted when the number of docked frames changes
|
||||
/// @brief emitted when the number of docked groups changes
|
||||
/// Note that we're using the "Frame" nomenculature instead of "DockWidget" here, as DockWidgets
|
||||
/// can be tabbed together, in which case this signal isn't emitted.
|
||||
void frameCountChanged(int);
|
||||
void groupCountChanged(int);
|
||||
|
||||
void overlayMarginChanged(int margin);
|
||||
|
||||
|
||||
@@ -499,7 +499,7 @@ Controllers::DockWidget::List TitleBar::dockWidgets() const
|
||||
{
|
||||
if (m_floatingWindow) {
|
||||
DockWidget::List result;
|
||||
for (Group *f : m_floatingWindow->frames()) {
|
||||
for (Group *f : m_floatingWindow->groups()) {
|
||||
result << f->dockWidgets();
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -186,7 +186,7 @@ struct LayoutSaver::MultiSplitter
|
||||
bool skipsRestore() const;
|
||||
|
||||
QVariantMap layout;
|
||||
QHash<QString, LayoutSaver::Group> frames;
|
||||
QHash<QString, LayoutSaver::Group> groups;
|
||||
};
|
||||
|
||||
struct LayoutSaver::FloatingWindow
|
||||
|
||||
@@ -145,7 +145,7 @@ bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
||||
|
||||
m_resizingInProgress = true;
|
||||
if (isMDI())
|
||||
Q_EMIT DockRegistry::self()->frameInMDIResizeChanged();
|
||||
Q_EMIT DockRegistry::self()->groupInMDIResizeChanged();
|
||||
mNewPosition = Qt5Qt6Compat::eventGlobalPos(mouseEvent);
|
||||
mCursorPos = cursorPos;
|
||||
|
||||
@@ -154,7 +154,7 @@ bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
||||
case QEvent::MouseButtonRelease: {
|
||||
m_resizingInProgress = false;
|
||||
if (isMDI()) {
|
||||
Q_EMIT DockRegistry::self()->frameInMDIResizeChanged();
|
||||
Q_EMIT DockRegistry::self()->groupInMDIResizeChanged();
|
||||
// Usually in KDDW all geometry changes are done in the layout items, which propagate to the widgets
|
||||
// When resizing a MDI however, we're resizing the widget directly. So update the corresponding layout
|
||||
// item when we're finished.
|
||||
|
||||
@@ -26,7 +26,7 @@ Rectangle {
|
||||
property bool hasCustomMouseEventRedirector: false
|
||||
property int mouseResizeMargin: 8
|
||||
readonly property bool isMDI: frameCpp && frameCpp.isMDI
|
||||
readonly property bool resizeAllowed: root.isMDI && !_kddwDragController.isDragging && _kddwDockRegistry && (!_kddwDockRegistry.frameViewInMDIResize || _kddwDockRegistry.frameViewInMDIResize === frameCpp)
|
||||
readonly property bool resizeAllowed: root.isMDI && !_kddwDragController.isDragging && _kddwDockRegistry && (!_kddwDockRegistry.groupViewInMDIResize || _kddwDockRegistry.groupViewInMDIResize === frameCpp)
|
||||
property alias tabBarHeight: tabbar.height
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -109,7 +109,7 @@ void MDIArea_qtwidgets::resizeDockWidget(Views::DockWidgetViewInterface *dwView,
|
||||
resizeDockWidget(dw, size);
|
||||
}
|
||||
|
||||
QList<Controllers::Group *> MDIArea_qtwidgets::frames() const
|
||||
QList<Controllers::Group *> MDIArea_qtwidgets::groups() const
|
||||
{
|
||||
return d->layout->frames();
|
||||
return d->layout->groups();
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
void moveDockWidget(Views::DockWidgetViewInterface *, QPoint pos);
|
||||
void resizeDockWidget(Views::DockWidgetViewInterface *, QSize size);
|
||||
|
||||
/// @brief Returns the list of frames in this MDI Area
|
||||
/// @brief Returns the list of groups in this MDI Area
|
||||
/// Each Frame object represents a 'window' emebedded in the MDI Area
|
||||
QList<Controllers::Group *> frames() const;
|
||||
QList<Controllers::Group *> groups() const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
||||
@@ -472,7 +472,7 @@ void TestQtWidgets::tst_mdi_mixed_with_docking2()
|
||||
QVERIFY(dropArea2.isNull());
|
||||
QVERIFY(dwWrapper2.isNull());
|
||||
|
||||
auto mdiFrames = mdiArea->frames();
|
||||
auto mdiFrames = mdiArea->groups();
|
||||
QCOMPARE(mdiFrames.count(), 1);
|
||||
mdiFrame1 = mdiFrames.first();
|
||||
QVERIFY(mdiFrame1->isMDI());
|
||||
@@ -482,7 +482,7 @@ void TestQtWidgets::tst_mdi_mixed_with_docking2()
|
||||
mdiTitleBar1->makeWindow();
|
||||
|
||||
QVERIFY(Platform::instance()->tests_waitForDeleted(mdiFrame1));
|
||||
QCOMPARE(mdiArea->frames().size(), 0);
|
||||
QCOMPARE(mdiArea->groups().size(), 0);
|
||||
|
||||
// Dock again:
|
||||
mdiArea->addDockWidget(mdiWidget1, QPoint(10, 10));
|
||||
@@ -498,8 +498,8 @@ void TestQtWidgets::tst_mdi_mixed_with_docking2()
|
||||
|
||||
drag(mdiWidget1->view(), globalDest);
|
||||
|
||||
QCOMPARE(mdiArea->frames().count(), 2);
|
||||
auto mdiTitleBar = mdiArea->frames().first()->titleBar();
|
||||
QCOMPARE(mdiArea->groups().count(), 2);
|
||||
auto mdiTitleBar = mdiArea->groups().first()->titleBar();
|
||||
QVERIFY(mdiTitleBar->isVisible());
|
||||
|
||||
QVERIFY(!mdiWidget3->isFloating());
|
||||
@@ -507,11 +507,11 @@ void TestQtWidgets::tst_mdi_mixed_with_docking2()
|
||||
mdiTitleBar->onFloatClicked();
|
||||
QVERIFY(mdiWidget3->isFloating());
|
||||
|
||||
QVERIFY(Platform::instance()->tests_waitForDeleted(mdiArea->frames().constFirst()));
|
||||
QCOMPARE(mdiArea->frames().size(), 1);
|
||||
QVERIFY(Platform::instance()->tests_waitForDeleted(mdiArea->groups().constFirst()));
|
||||
QCOMPARE(mdiArea->groups().size(), 1);
|
||||
|
||||
QVERIFY(!mdiWidget2->isFloating());
|
||||
Controllers::Group *lastMdiFrame = mdiArea->frames().constFirst();
|
||||
Controllers::Group *lastMdiFrame = mdiArea->groups().constFirst();
|
||||
QVERIFY(lastMdiFrame->titleBar()->isVisible());
|
||||
QVERIFY(!lastMdiFrame->titleBar()->isFloating());
|
||||
lastMdiFrame->titleBar()->onFloatClicked();
|
||||
@@ -547,7 +547,7 @@ void TestQtWidgets::tst_mdi_mixed_with_docking_setMDISize()
|
||||
mdiArea->addDockWidget(mdiWidget1, QPoint(10, 10));
|
||||
mdiArea->addDockWidget(mdiWidget2, QPoint(50, 50));
|
||||
|
||||
Controllers::Group *group1 = mdiArea->frames().at(0);
|
||||
Controllers::Group *group1 = mdiArea->groups().at(0);
|
||||
|
||||
const QSize sz1 = group1->view()->size();
|
||||
const QSize increment(200, 200);
|
||||
@@ -1459,7 +1459,7 @@ void TestQtWidgets::tst_complex()
|
||||
|
||||
// Cleanup
|
||||
qDeleteAll(docks);
|
||||
qDeleteAll(DockRegistry::self()->frames());
|
||||
qDeleteAll(DockRegistry::self()->groups());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ void TestDocks::tst_restoreNonExistingDockWidget()
|
||||
QVERIFY(restorer.restoreLayout(saved));
|
||||
auto da = m->dropArea();
|
||||
QVERIFY(m->dropArea()->checkSanity());
|
||||
QCOMPARE(da->frames().size(), 0);
|
||||
QCOMPARE(da->groups().size(), 0);
|
||||
|
||||
QVERIFY(dock2->isOpen());
|
||||
QVERIFY(dock2->isFloating());
|
||||
@@ -2077,7 +2077,7 @@ void TestDocks::tst_crash2()
|
||||
}
|
||||
|
||||
qDeleteAll(docks);
|
||||
qDeleteAll(DockRegistry::self()->frames());
|
||||
qDeleteAll(DockRegistry::self()->groups());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2112,7 +2112,7 @@ void TestDocks::tst_crash2()
|
||||
layout->checkSanity();
|
||||
|
||||
qDeleteAll(docks);
|
||||
qDeleteAll(DockRegistry::self()->frames());
|
||||
qDeleteAll(DockRegistry::self()->groups());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2138,7 +2138,7 @@ void TestDocks::tst_closeAllDockWidgets()
|
||||
nestDockWidget(dock6, fw->dropArea(), nullptr, KDDockWidgets::Location_OnTop);
|
||||
|
||||
QVERIFY(oldFWHeight <= fw->height());
|
||||
QCOMPARE(fw->frames().size(), 2);
|
||||
QCOMPARE(fw->groups().size(), 2);
|
||||
|
||||
QVERIFY(dock3->window()->equals(fw->view()));
|
||||
QVERIFY(dock4->window()->equals(m->view()));
|
||||
@@ -2475,7 +2475,7 @@ void TestDocks::tst_dockWindowWithTwoSideBySideFramesIntoCenter()
|
||||
auto fw = createFloatingWindow();
|
||||
auto dock2 = createDockWidget("doc2");
|
||||
nestDockWidget(dock2, fw->dropArea(), nullptr, KDDockWidgets::Location_OnLeft);
|
||||
QCOMPARE(fw->frames().size(), 2);
|
||||
QCOMPARE(fw->groups().size(), 2);
|
||||
QVERIFY(fw->dropArea()->checkSanity());
|
||||
|
||||
auto fw2 = createFloatingWindow();
|
||||
@@ -2490,8 +2490,8 @@ void TestDocks::tst_dockWindowWithTwoSideBySideFramesIntoCenter()
|
||||
dragFloatingWindowTo(fw, dragDestPos);
|
||||
QVERIFY(fw2->dropArea()->checkSanity());
|
||||
|
||||
QCOMPARE(fw2->frames().size(), 1);
|
||||
auto f2 = fw2->frames().constFirst();
|
||||
QCOMPARE(fw2->groups().size(), 1);
|
||||
auto f2 = fw2->groups().constFirst();
|
||||
QCOMPARE(f2->dockWidgetCount(), 3);
|
||||
QVERIFY(Platform::instance()->tests_waitForDeleted(fw));
|
||||
delete fw2;
|
||||
@@ -2709,13 +2709,13 @@ void TestDocks::tst_dockWindowWithTwoSideBySideFramesIntoRight()
|
||||
auto fw = createFloatingWindow();
|
||||
auto dock2 = createDockWidget("doc2");
|
||||
nestDockWidget(dock2, fw->dropArea(), nullptr, KDDockWidgets::Location_OnTop); // No we stack on top, unlike in previous test
|
||||
QCOMPARE(fw->frames().size(), 2);
|
||||
QCOMPARE(fw->groups().size(), 2);
|
||||
|
||||
auto fw2 = createFloatingWindow();
|
||||
fw2->view()->move(fw->x() + fw->width() + 100, fw->y());
|
||||
|
||||
dragFloatingWindowTo(fw, fw2->dropArea(), DropLocation_Right); // Outter right instead of Left
|
||||
QCOMPARE(fw2->frames().size(), 3);
|
||||
QCOMPARE(fw2->groups().size(), 3);
|
||||
QVERIFY(fw2->dropArea()->checkSanity());
|
||||
|
||||
fw2->deleteLater();
|
||||
@@ -2731,7 +2731,7 @@ void TestDocks::tst_dockWindowWithTwoSideBySideFramesIntoLeft()
|
||||
|
||||
auto dock2 = createDockWidget("doc2");
|
||||
nestDockWidget(dock2, fw->dropArea(), nullptr, KDDockWidgets::Location_OnLeft);
|
||||
QCOMPARE(fw->frames().size(), 2);
|
||||
QCOMPARE(fw->groups().size(), 2);
|
||||
|
||||
auto fw2 = createFloatingWindow();
|
||||
fw2->setObjectName("fw2");
|
||||
@@ -2739,7 +2739,7 @@ void TestDocks::tst_dockWindowWithTwoSideBySideFramesIntoLeft()
|
||||
|
||||
QVERIFY(fw2->dropArea()->checkSanity());
|
||||
dragFloatingWindowTo(fw, fw2->dropArea(), DropLocation_Left);
|
||||
QCOMPARE(fw2->frames().size(), 3);
|
||||
QCOMPARE(fw2->groups().size(), 3);
|
||||
|
||||
QVERIFY(fw2->dropArea()->checkSanity());
|
||||
|
||||
@@ -3577,13 +3577,13 @@ void TestDocks::tst_restoreWithCentralFrameWithTabs()
|
||||
m->addDockWidgetAsTab(dock1);
|
||||
m->addDockWidgetAsTab(dock2);
|
||||
|
||||
QCOMPARE(DockRegistry::self()->frames().size(), 1);
|
||||
QCOMPARE(DockRegistry::self()->groups().size(), 1);
|
||||
|
||||
LayoutSaver saver;
|
||||
const QByteArray saved = saver.serializeLayout();
|
||||
QVERIFY(saver.restoreLayout(saved));
|
||||
|
||||
QCOMPARE(DockRegistry::self()->frames().size(), 1);
|
||||
QCOMPARE(DockRegistry::self()->groups().size(), 1);
|
||||
}
|
||||
|
||||
void TestDocks::tst_restoreWithPlaceholder()
|
||||
@@ -3865,7 +3865,7 @@ void TestDocks::tst_notClosable()
|
||||
auto fw = dock1->floatingWindow();
|
||||
QVERIFY(fw);
|
||||
Controllers::TitleBar *titlebarFW = fw->titleBar();
|
||||
Controllers::TitleBar *titleBarFrame = fw->frames().at(0)->titleBar();
|
||||
Controllers::TitleBar *titleBarFrame = fw->groups().at(0)->titleBar();
|
||||
QVERIFY(titlebarFW->isCloseButtonVisible());
|
||||
QVERIFY(!titlebarFW->isCloseButtonEnabled());
|
||||
QVERIFY(!titleBarFrame->isCloseButtonVisible());
|
||||
@@ -3896,7 +3896,7 @@ void TestDocks::tst_notClosable()
|
||||
auto fw = dock1->floatingWindow();
|
||||
QVERIFY(fw);
|
||||
Controllers::TitleBar *titlebarFW = fw->titleBar();
|
||||
Controllers::TitleBar *titleBarFrame = fw->frames().at(0)->titleBar();
|
||||
Controllers::TitleBar *titleBarFrame = fw->groups().at(0)->titleBar();
|
||||
|
||||
QVERIFY(titlebarFW->isCloseButtonVisible());
|
||||
QVERIFY(!titleBarFrame->isCloseButtonVisible());
|
||||
|
||||
@@ -148,7 +148,7 @@ inline View *draggableFor(View *view)
|
||||
if (auto group = dw->d->group())
|
||||
draggable = group->titleBar()->view();
|
||||
} else if (auto fw = view->asFloatingWindowController()) {
|
||||
Controllers::Group *group = fw->hasSingleFrame() ? static_cast<Controllers::Group *>(fw->frames().first())
|
||||
Controllers::Group *group = fw->hasSingleFrame() ? static_cast<Controllers::Group *>(fw->groups().first())
|
||||
: nullptr;
|
||||
|
||||
if ((KDDockWidgets::Config::self().flags() & KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible) && group && group->hasTabsVisible()) {
|
||||
|
||||
Reference in New Issue
Block a user