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 QDESIGNER_ACTIONS_H
30#define QDESIGNER_ACTIONS_H
31
32#include "assistantclient.h"
33#include "qdesigner_settings.h"
34
35#include <QtCore/qobject.h>
36#include <QtCore/qpointer.h>
37
38QT_BEGIN_NAMESPACE
39
40class QDesignerWorkbench;
41
42class QDir;
43class QTimer;
44class QAction;
45class QActionGroup;
46class QDesignerFormEditorInterface;
47class QDesignerFormWindowInterface;
48class AppFontDialog;
49
50class QRect;
51class QWidget;
52class QPixmap;
53class QPrinter;
54class QMenu;
55
56namespace qdesigner_internal {
57 class PreviewConfiguration;
58 class PreviewManager;
59 enum class UicLanguage;
60}
61
62class QDesignerActions: public QObject
63{
64 Q_OBJECT
65public:
66 explicit QDesignerActions(QDesignerWorkbench *mainWindow);
67 ~QDesignerActions() override;
68
69 QDesignerWorkbench *workbench() const;
70 QDesignerFormEditorInterface *core() const;
71
72 bool saveForm(QDesignerFormWindowInterface *fw);
73 bool readInForm(const QString &fileName);
74 bool writeOutForm(QDesignerFormWindowInterface *formWindow, const QString &fileName, bool check = true);
75
76 QActionGroup *fileActions() const;
77 QActionGroup *recentFilesActions() const;
78 QActionGroup *editActions() const;
79 QActionGroup *formActions() const;
80 QActionGroup *settingsActions() const;
81 QActionGroup *windowActions() const;
82 QActionGroup *toolActions() const;
83 QActionGroup *helpActions() const;
84 QActionGroup *uiMode() const;
85 QActionGroup *styleActions() const;
86 // file actions
87 QAction *openFormAction() const;
88 QAction *closeFormAction() const;
89 // window actions
90 QAction *minimizeAction() const;
91 // edit mode actions
92 QAction *editWidgets() const;
93 // form actions
94 QAction *previewFormAction() const;
95 QAction *viewCodeAction() const;
96
97 void setBringAllToFrontVisible(bool visible);
98 void setWindowListSeparatorVisible(bool visible);
99
100 bool openForm(QWidget *parent);
101
102 QString uiExtension() const;
103
104 // Boolean dynamic property set on actions to
105 // show them in the default toolbar layout
106 static const char *defaultToolbarPropertyName;
107
108public slots:
109 void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow);
110 void createForm();
111 void slotOpenForm();
112 void helpRequested(const QString &manual, const QString &document);
113
114signals:
115 void useBigIcons(bool);
116
117private slots:
118 void saveForm();
119 void saveFormAs();
120 void saveAllForms();
121 void saveFormAsTemplate();
122 void notImplementedYet();
123 void shutdown();
124 void editWidgetsSlot();
125 void openRecentForm();
126 void clearRecentFiles();
127 void closeForm();
128 void showDesignerHelp();
129 void aboutDesigner();
130 void showWidgetSpecificHelp();
131 void backupForms();
132 void showNewFormDialog(const QString &fileName);
133 void showPreferencesDialog();
134 void showAppFontDialog();
135 void savePreviewImage();
136 void printPreviewImage();
137 void updateCloseAction();
138 void formWindowCountChanged();
139 void formWindowSettingsChanged(QDesignerFormWindowInterface *fw);
140
141private:
142 QAction *createRecentFilesMenu();
143 bool saveFormAs(QDesignerFormWindowInterface *fw);
144 void updateRecentFileActions();
145 void addRecentFile(const QString &fileName);
146 void showHelp(const QString &help);
147 void closePreview();
148 QRect fixDialogRect(const QRect &rect) const;
149 QString fixResourceFileBackupPath(QDesignerFormWindowInterface *fwi, const QDir& backupDir);
150 void showStatusBarMessage(const QString &message) const;
151 QActionGroup *createHelpActions();
152 bool ensureBackupDirectories();
153 QPixmap createPreviewPixmap(QDesignerFormWindowInterface *fw);
154 qdesigner_internal::PreviewConfiguration previewConfiguration();
155 void viewCode(qdesigner_internal::UicLanguage language);
156
157 enum { MaxRecentFiles = 10 };
158 QDesignerWorkbench *m_workbench;
159 QDesignerFormEditorInterface *m_core;
160 QDesignerSettings m_settings;
161 AssistantClient m_assistantClient;
162 QString m_openDirectory;
163 QString m_saveDirectory;
164
165
166 QString m_backupPath;
167 QString m_backupTmpPath;
168
169 QTimer* m_backupTimer;
170
171 QActionGroup *m_fileActions;
172 QActionGroup *m_recentFilesActions;
173 QActionGroup *m_editActions;
174 QActionGroup *m_formActions;
175 QActionGroup *m_settingsActions;
176 QActionGroup *m_windowActions;
177 QActionGroup *m_toolActions;
178 QActionGroup *m_helpActions = nullptr;
179 QActionGroup *m_styleActions = nullptr;
180
181 QAction *m_editWidgetsAction;
182
183 QAction *m_newFormAction;
184 QAction *m_openFormAction;
185 QAction *m_saveFormAction;
186 QAction *m_saveFormAsAction;
187 QAction *m_saveAllFormsAction;
188 QAction *m_saveFormAsTemplateAction;
189 QAction *m_closeFormAction;
190 QAction *m_savePreviewImageAction;
191 QAction *m_printPreviewAction;
192
193 QAction *m_quitAction;
194
195 QAction *m_previewFormAction = nullptr;
196 QAction *m_viewCppCodeAction;
197 QAction *m_viewPythonCodeAction;
198
199 QAction *m_minimizeAction;
200 QAction *m_bringAllToFrontSeparator;
201 QAction *m_bringAllToFrontAction;
202 QAction *m_windowListSeparatorAction;
203
204 QAction *m_preferencesAction;
205 QAction *m_appFontAction;
206
207 QPointer<AppFontDialog> m_appFontDialog;
208
209 QPrinter *m_printer = nullptr;
210
211 qdesigner_internal::PreviewManager *m_previewManager = nullptr;
212};
213
214QT_END_NAMESPACE
215
216#endif // QDESIGNER_ACTIONS_H
217

source code of qttools/src/designer/src/designer/qdesigner_actions.h