Files
KDDockWidgets/src/private/DropAreaWithCentralFrame.cpp
Sergio Martins 1ccdf445eb Introduce MainWindowOption_HasCentralWidget
You can now set an arbitrary widget as "central widget".
It's similar to MainWindowOption_HasCentralFrame, however the widget
won't be detachable and won't show tabs.

Similar to what you'd get with QMainWindow central widget concept.

Example:
    QWidget *myWidget = new MyWidget();
    mainWindow->setPersistentCentralWidget(myWidget);

Fixes #225
2021-08-30 10:12:46 +01:00

49 lines
1.6 KiB
C++

/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "DropAreaWithCentralFrame_p.h"
#include "Config.h"
#include "FrameworkWidgetFactory.h"
using namespace KDDockWidgets;
DropAreaWithCentralFrame::DropAreaWithCentralFrame(QWidgetOrQuick *parent, MainWindowOptions options)
: DropArea(parent)
, m_centralFrame(createCentralFrame(options))
{
if (m_centralFrame)
addWidget(m_centralFrame, KDDockWidgets::Location_OnTop, {});
}
DropAreaWithCentralFrame::~DropAreaWithCentralFrame()
{
}
Frame *DropAreaWithCentralFrame::createCentralFrame(MainWindowOptions options)
{
Frame *frame = nullptr;
if (options & MainWindowOption_HasCentralFrame) {
FrameOptions frameOptions = FrameOption_IsCentralFrame;
const bool hasPersistentCentralWidget = (options & MainWindowOption_HasCentralWidget) == MainWindowOption_HasCentralWidget;
if (hasPersistentCentralWidget) {
frameOptions |= FrameOption_NonDockable;
} else {
// With a persistent central widget we don't allow detaching it
frameOptions |= FrameOption_AlwaysShowsTabs;
}
frame = Config::self().frameworkWidgetFactory()->createFrame(nullptr, frameOptions);
frame->setObjectName(QStringLiteral("central frame"));
}
return frame;
}