KDDockWidgets API Documentation  1.5
MainWindowQuick.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 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 
17 using namespace KDDockWidgets;
18 
19 MainWindowQuick::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 
36 MainWindowQuick::~MainWindowQuick()
37 {
38  if (isTopLevel()) {
39  if (QWindow *window = windowHandle()) {
40  QObject::setParent(nullptr);
41  delete window;
42  }
43  }
44 }
45 
46 QSize MainWindowQuick::minimumSize() const
47 {
48  return layoutWidget()->layoutMinimumSize();
49 }
50 
51 QSize MainWindowQuick::maximumSize() const
52 {
53  return layoutWidget()->layoutMaximumSizeHint();
54 }
55 
56 SideBar *MainWindowQuick::sideBar(SideBarLocation) const
57 {
58  return nullptr;
59 }
60 
61 QMargins MainWindowQuick::centerWidgetMargins() const
62 {
63  qDebug() << Q_FUNC_INFO << "SideBar hasn't been implemented yet";
64  return {};
65 }
66 
67 void 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 }
KDDockWidgets::MainWindowBase::layoutWidget
LayoutWidget * layoutWidget() const
Definition: MainWindowBase.cpp:200
QWindow
QSize
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Qt::WindowFlags
typedef WindowFlags
QString
QMargins
KDDockWidgets::SideBarLocation
SideBarLocation
Each main window supports 4 sidebars.
Definition: KDDockWidgets.h:211
QSize::expandedTo
QSize expandedTo(const QSize &otherSize) const const
QObject::setParent
void setParent(QObject *parent)
KDDockWidgets
Definition: Config.cpp:36
KDDockWidgets::MainWindowBase
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
Definition: MainWindowBase.h:56

© 2019-2022 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 Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20