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 FORMWINDOWMANAGER_H |
30 | #define FORMWINDOWMANAGER_H |
31 | |
32 | #include "formeditor_global.h" |
33 | |
34 | #include <QtDesigner/private/qdesigner_formwindowmanager_p.h> |
35 | |
36 | #include <QtCore/qobject.h> |
37 | #include <QtCore/qlist.h> |
38 | #include <QtCore/qpointer.h> |
39 | #include <QtCore/qmap.h> |
40 | #include <QtCore/qset.h> |
41 | |
42 | QT_BEGIN_NAMESPACE |
43 | |
44 | class QAction; |
45 | class QActionGroup; |
46 | class QUndoGroup; |
47 | class QDesignerFormEditorInterface; |
48 | class QDesignerWidgetBoxInterface; |
49 | |
50 | namespace qdesigner_internal { |
51 | |
52 | class FormWindow; |
53 | class PreviewManager; |
54 | class PreviewActionGroup; |
55 | |
56 | class QT_FORMEDITOR_EXPORT FormWindowManager |
57 | : public QDesignerFormWindowManager |
58 | { |
59 | Q_OBJECT |
60 | public: |
61 | explicit FormWindowManager(QDesignerFormEditorInterface *core, QObject *parent = nullptr); |
62 | ~FormWindowManager() override; |
63 | |
64 | QDesignerFormEditorInterface *core() const override; |
65 | |
66 | QAction *action(Action action) const override; |
67 | QActionGroup *actionGroup(ActionGroup actionGroup) const override; |
68 | |
69 | QDesignerFormWindowInterface *activeFormWindow() const override; |
70 | |
71 | int formWindowCount() const override; |
72 | QDesignerFormWindowInterface *formWindow(int index) const override; |
73 | |
74 | QDesignerFormWindowInterface *createFormWindow(QWidget *parentWidget = nullptr, Qt::WindowFlags flags = {}) override; |
75 | |
76 | QPixmap createPreviewPixmap() const override; |
77 | |
78 | bool eventFilter(QObject *o, QEvent *e) override; |
79 | |
80 | void dragItems(const QList<QDesignerDnDItemInterface*> &item_list) override; |
81 | |
82 | QUndoGroup *undoGroup() const; |
83 | |
84 | PreviewManager *previewManager() const override { return m_previewManager; } |
85 | |
86 | public slots: |
87 | void addFormWindow(QDesignerFormWindowInterface *formWindow) override; |
88 | void removeFormWindow(QDesignerFormWindowInterface *formWindow) override; |
89 | void setActiveFormWindow(QDesignerFormWindowInterface *formWindow) override; |
90 | void closeAllPreviews() override; |
91 | void deviceProfilesChanged(); |
92 | |
93 | private slots: |
94 | #if QT_CONFIG(clipboard) |
95 | void slotActionCutActivated(); |
96 | void slotActionCopyActivated(); |
97 | void slotActionPasteActivated(); |
98 | #endif |
99 | void slotActionDeleteActivated(); |
100 | void slotActionSelectAllActivated(); |
101 | void slotActionLowerActivated(); |
102 | void slotActionRaiseActivated(); |
103 | void createLayout(); |
104 | void slotActionBreakLayoutActivated(); |
105 | void slotActionAdjustSizeActivated(); |
106 | void slotActionSimplifyLayoutActivated(); |
107 | void showPreview() override; |
108 | void slotActionGroupPreviewInStyle(const QString &style, int deviceProfileIndex); |
109 | void slotActionShowFormWindowSettingsDialog(); |
110 | |
111 | void slotUpdateActions(); |
112 | |
113 | private: |
114 | void setupActions(); |
115 | FormWindow *findFormWindow(QWidget *w); |
116 | QWidget *findManagedWidget(FormWindow *fw, QWidget *w); |
117 | |
118 | void setCurrentUndoStack(QUndoStack *stack); |
119 | |
120 | private: |
121 | enum CreateLayoutContext { LayoutContainer, LayoutSelection, MorphLayout }; |
122 | |
123 | QDesignerFormEditorInterface *m_core; |
124 | FormWindow *m_activeFormWindow; |
125 | QList<FormWindow*> m_formWindows; |
126 | |
127 | PreviewManager *m_previewManager; |
128 | |
129 | /* Context of the layout actions and base for morphing layouts. Determined |
130 | * in slotUpdateActions() and used later on in the action slots. */ |
131 | CreateLayoutContext m_createLayoutContext; |
132 | QWidget *m_morphLayoutContainer; |
133 | |
134 | // edit actions |
135 | #if QT_CONFIG(clipboard) |
136 | QAction *m_actionCut = nullptr; |
137 | QAction *m_actionCopy = nullptr; |
138 | QAction *m_actionPaste = nullptr; |
139 | #endif |
140 | QAction *m_actionSelectAll = nullptr; |
141 | QAction *m_actionDelete = nullptr; |
142 | QAction *m_actionLower = nullptr; |
143 | QAction *m_actionRaise = nullptr; |
144 | // layout actions |
145 | QAction *m_actionHorizontalLayout = nullptr; |
146 | QAction *m_actionVerticalLayout = nullptr; |
147 | QAction *m_actionFormLayout = nullptr; |
148 | QAction *m_actionSplitHorizontal = nullptr; |
149 | QAction *m_actionSplitVertical = nullptr; |
150 | QAction *m_actionGridLayout = nullptr; |
151 | QAction *m_actionBreakLayout = nullptr; |
152 | QAction *m_actionSimplifyLayout = nullptr; |
153 | QAction *m_actionAdjustSize = nullptr; |
154 | // preview actions |
155 | QAction *m_actionDefaultPreview = nullptr; |
156 | mutable PreviewActionGroup *m_actionGroupPreviewInStyle = nullptr; |
157 | QAction *m_actionShowFormWindowSettingsDialog = nullptr; |
158 | |
159 | QAction *m_actionUndo = nullptr; |
160 | QAction *m_actionRedo = nullptr; |
161 | |
162 | QSet<QWidget *> getUnsortedLayoutsToBeBroken(bool firstOnly) const; |
163 | bool hasLayoutsToBeBroken() const; |
164 | QWidgetList layoutsToBeBroken(QWidget *w) const; |
165 | QWidgetList layoutsToBeBroken() const; |
166 | |
167 | QUndoGroup *m_undoGroup = nullptr; |
168 | |
169 | }; |
170 | |
171 | } // namespace qdesigner_internal |
172 | |
173 | QT_END_NAMESPACE |
174 | |
175 | #endif // FORMWINDOWMANAGER_H |
176 | |