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

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