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
This commit is contained in:
Sergio Martins
2021-08-30 09:49:51 +01:00
parent 3fb8861eee
commit 1ccdf445eb
9 changed files with 114 additions and 6 deletions

View File

@@ -31,7 +31,16 @@ Frame *DropAreaWithCentralFrame::createCentralFrame(MainWindowOptions options)
{
Frame *frame = nullptr;
if (options & MainWindowOption_HasCentralFrame) {
frame = Config::self().frameworkWidgetFactory()->createFrame(nullptr, FrameOptions() | FrameOption_IsCentralFrame | FrameOption_AlwaysShowsTabs);
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"));
}