KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
MainWindowQuick.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Sérgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#include "MainWindowQuick_p.h"
13#include "../LayoutWidget_p.h"
14
15#include <QDebug>
16
17using namespace KDDockWidgets;
18
19MainWindowQuick::MainWindowQuick(const QString &uniqueName, MainWindowOptions options,
20 QQuickItem *parent, Qt::WindowFlags flags)
21 : MainWindowBase(uniqueName, options, parent, flags)
22{
23 QWidgetAdapter::makeItemFillParent(this);
24
25 LayoutWidget *lw = layoutWidget();
26 QWidgetAdapter::makeItemFillParent(lw);
27
28
29 // MainWindowQuick has the same constraints as LayoutWidget, so just forward the signal
30 connect(lw, &LayoutWidget::geometryUpdated, this, &MainWindowQuick::geometryUpdated);
31
32 connect(lw, &LayoutWidget::geometryUpdated, this,
33 &MainWindowQuick::onMultiSplitterGeometryUpdated);
34}
35
36MainWindowQuick::~MainWindowQuick()
37{
38 if (isTopLevel()) {
39 if (QWindow *window = windowHandle()) {
40 QObject::setParent(nullptr);
41 delete window;
42 }
43 }
44}
45
46QSize MainWindowQuick::minimumSize() const
47{
48 return layoutWidget()->layoutMinimumSize();
49}
50
51QSize MainWindowQuick::maximumSize() const
52{
53 return layoutWidget()->layoutMaximumSizeHint();
54}
55
56SideBar *MainWindowQuick::sideBar(SideBarLocation) const
57{
58 return nullptr;
59}
60
61QMargins MainWindowQuick::centerWidgetMargins() const
62{
63 qDebug() << Q_FUNC_INFO << "SideBar hasn't been implemented yet";
64 return {};
65}
66
67void MainWindowQuick::onMultiSplitterGeometryUpdated()
68{
69 const QSize minSz = minimumSize();
70 const bool mainWindowIsTooSmall = minSz.expandedTo(size()) != size();
71 if (mainWindowIsTooSmall) {
72 if (isTopLevel()) {
73 // If we're a top-level, let's go ahead and resize the QWindow
74 // any other case is too complex for QtQuick as there's no layout propagation.
75 windowHandle()->resize(minSz);
76 }
77 }
78}
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
SideBarLocation
Each main window supports 4 sidebars.
void setParent(QObject *parent)
QSize expandedTo(const QSize &otherSize) const const
typedef WindowFlags

© 2019-2023 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated on Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8