1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef QMDIAREA_CONTAINER_H |
30 | #define QMDIAREA_CONTAINER_H |
31 | |
32 | #include <QtDesigner/container.h> |
33 | |
34 | |
35 | #include <qdesigner_propertysheet_p.h> |
36 | #include <extensionfactory_p.h> |
37 | |
38 | #include <QtWidgets/qmdiarea.h> |
39 | |
40 | QT_BEGIN_NAMESPACE |
41 | |
42 | namespace qdesigner_internal { |
43 | |
44 | // Container for QMdiArea |
45 | class QMdiAreaContainer: public QObject, public QDesignerContainerExtension |
46 | { |
47 | Q_OBJECT |
48 | Q_INTERFACES(QDesignerContainerExtension) |
49 | public: |
50 | explicit QMdiAreaContainer(QMdiArea *widget, QObject *parent = nullptr); |
51 | |
52 | int count() const override; |
53 | QWidget *widget(int index) const override; |
54 | int currentIndex() const override; |
55 | void setCurrentIndex(int index) override; |
56 | void addWidget(QWidget *widget) override; |
57 | void insertWidget(int index, QWidget *widget) override; |
58 | void remove(int index) override; |
59 | |
60 | // Semismart positioning of a new MDI child after cascading |
61 | static void positionNewMdiChild(const QWidget *area, QWidget *mdiChild); |
62 | |
63 | private: |
64 | QMdiArea *m_mdiArea; |
65 | }; |
66 | |
67 | // PropertySheet for QMdiArea: Fakes window title and name. |
68 | |
69 | class QMdiAreaPropertySheet: public QDesignerPropertySheet |
70 | { |
71 | Q_OBJECT |
72 | Q_INTERFACES(QDesignerPropertySheetExtension) |
73 | public: |
74 | explicit QMdiAreaPropertySheet(QWidget *mdiArea, QObject *parent = nullptr); |
75 | |
76 | void setProperty(int index, const QVariant &value) override; |
77 | bool reset(int index) override; |
78 | bool isEnabled(int index) const override; |
79 | bool isChanged(int index) const override; |
80 | QVariant property(int index) const override; |
81 | |
82 | // Check whether the property is to be saved. Returns false for the page |
83 | // properties (as the property sheet has no concept of 'stored') |
84 | static bool checkProperty(const QString &propertyName); |
85 | |
86 | private: |
87 | const QString m_windowTitleProperty; |
88 | QWidget *currentWindow() const; |
89 | QDesignerPropertySheetExtension *currentWindowSheet() const; |
90 | |
91 | enum MdiAreaProperty { MdiAreaSubWindowName, MdiAreaSubWindowTitle, MdiAreaNone }; |
92 | static MdiAreaProperty mdiAreaProperty(const QString &name); |
93 | }; |
94 | |
95 | // Factories |
96 | |
97 | using QMdiAreaContainerFactory = ExtensionFactory<QDesignerContainerExtension, QMdiArea, QMdiAreaContainer>; |
98 | using QMdiAreaPropertySheetFactory = QDesignerPropertySheetFactory<QMdiArea, QMdiAreaPropertySheet>; |
99 | } // namespace qdesigner_internal |
100 | |
101 | QT_END_NAMESPACE |
102 | |
103 | #endif // QMDIAREA_CONTAINER_H |
104 | |