ACF $AcfVersion:0$
CSimpleMainWindowGuiComp.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QtGlobal>
7#if QT_VERSION >= 0x050000
8#include <QtWidgets/QMainWindow>
9#include <QtWidgets/QMenuBar>
10#else
11#include <QtGui/QMainWindow>
12#include <QtGui/QMenuBar>
13#endif
14
15// ACF includes
21#include <iqtgui/IDialog.h>
26
27
28namespace iqtgui
29{
30
31
36class CSimpleMainWindowGuiCompBase: public iqtgui::TRestorableGuiWrap< iqtgui::TGuiComponentBase<QMainWindow> >
37{
38public:
40
41 I_BEGIN_BASE_COMPONENT(CSimpleMainWindowGuiCompBase);
42 I_ASSIGN(m_workspaceCompPtr, "Workspace", "Main widget", true, "Workspace");
43 I_ASSIGN_TO(m_workspaceCommandsCompPtr, m_workspaceCompPtr, false);
44 I_ASSIGN_TO(m_workspaceCommandsModelCompPtr, m_workspaceCompPtr, false);
45 I_ASSIGN(m_aboutDialogCompPtr, "AboutDialog", "Gui displayed if 'About' action is triggered", false, "AboutDialog");
46 I_ASSIGN(m_settingsDialogCompPtr, "SettingsDialog", "Dialog window displayed if 'Settings' action is triggered", false, "SettingsDialog");
47 I_ASSIGN_MULTI_0(m_mainWindowComponentsCompPtr, "MainWindowComponents", "Additional GUI components", false);
48 I_ASSIGN_TO(m_mainWindowCommandsCompPtr, m_mainWindowComponentsCompPtr, false);
49 I_ASSIGN_TO(m_mainWindowCommandsModelCompPtr, m_mainWindowComponentsCompPtr, false);
50 I_ASSIGN(m_isNestingEnabledAttrPtr, "IsNestingEnabled", "If true, docking nesting is enabled,\nmore than one docking widget is allowed on the same size", true, false);
51 I_ASSIGN(m_isAllowTabbedDockAttrPtr, "IsTabbedDockAllowed", "If true, stacking docking windows on each other is enabled", true, false);
52 I_ASSIGN(m_isMenuVisibleAttrPtr, "IsMenuVisible", "If true, menu bar will be visible", true, true);
53 I_ASSIGN(m_isToolbarVisibleAttrPtr, "IsToolbarVisible", "If true, tool bar will be visible", true, true);
54 I_ASSIGN(m_toolBarAreaAttrPtr, "ToolBarArea", "Specify the area where the standard toolbar will be placed\n 0 - left\n 1 - right\n 2 - top\n 3 - bottom", false, 0);
55 I_ASSIGN(m_toolBarDockFeaturesAttrPtr, "ToolBarDockFeatures", "Specify the dock features for the standard tool bar\nIt is combination of options:\n2 - moveable\n4 - floatable", true, IMainWindowComponent::WCF_MOVEABLE | IMainWindowComponent::WCF_FLOATABLE);
56 I_ASSIGN(m_iconSizeAttrPtr, "IconSize", "Size of icons using in the main window", false, 16);
57 I_ASSIGN(m_useIconTextAttrPtr, "UseIconText", "Enable text under the tool bar icons", false, false);
58 I_ASSIGN(m_helpFilePathPtr, "HelpFile", "Path to the help (manual) file opened by F1", false, "HelpFile");
59 I_END_COMPONENT;
60
61protected:
62 I_REF(iqtgui::IGuiObject, m_workspaceCompPtr);
63 I_REF(ibase::ICommandsProvider, m_workspaceCommandsCompPtr);
64 I_REF(imod::IModel, m_workspaceCommandsModelCompPtr);
65 I_MULTIREF(ibase::ICommandsProvider, m_mainWindowCommandsCompPtr);
66 I_MULTIREF(imod::IModel, m_mainWindowCommandsModelCompPtr);
67 I_REF(iqtgui::IDialog, m_aboutDialogCompPtr);
68 I_REF(iqtgui::IDialog, m_settingsDialogCompPtr);
69 I_MULTIREF(iqtgui::IMainWindowComponent, m_mainWindowComponentsCompPtr);
70 I_ATTR(bool, m_isNestingEnabledAttrPtr);
71 I_ATTR(bool, m_isAllowTabbedDockAttrPtr);
72 I_ATTR(bool, m_isMenuVisibleAttrPtr);
73 I_ATTR(bool, m_isToolbarVisibleAttrPtr);
74 I_ATTR(int, m_toolBarAreaAttrPtr);
75 I_ATTR(int, m_toolBarDockFeaturesAttrPtr);
76 I_ATTR(int, m_iconSizeAttrPtr);
77 I_ATTR(bool, m_useIconTextAttrPtr);
78 I_REF(ifile::IFileNameParam, m_helpFilePathPtr);
79};
80
81
83{
84 Q_OBJECT
85
86public:
88
89 I_BEGIN_COMPONENT(CSimpleMainWindowGuiComp);
90 I_REGISTER_SUBELEMENT(VisibleWindowsManager);
91 I_REGISTER_SUBELEMENT_INTERFACE(VisibleWindowsManager, iprm::IOptionsManager, GetVisibleWindowsManager);
92 I_REGISTER_SUBELEMENT_INTERFACE(VisibleWindowsManager, iprm::IOptionsList, GetVisibleWindowsManager);
93 I_REGISTER_SUBELEMENT_INTERFACE(VisibleWindowsManager, imod::IModel, GetVisibleWindowsManager);
94 I_REGISTER_SUBELEMENT_INTERFACE(VisibleWindowsManager, istd::IChangeable, GetVisibleWindowsManager);
95 I_ASSIGN(m_enableGeometryRestoringAttrPtr, "EnableGeometryRestoring", "If enabled geometry will be restored", true, true);
96 I_ASSIGN(m_progressMessagesComsumerCompPtr, "ProgressMessagesConsumer", "Consumer of the progress messages", false, "");
97 I_END_COMPONENT;
98
100 {
101 GI_SETTINGS = 0x400
102 };
103
105 {
106 MI_PREFERENCE_COMMAND = 0x1000
107 };
108
110
111 // reimplemented (iqtgui::IGuiObject)
112 virtual void OnTryClose(bool* ignoredPtr = NULL) override;
113
114protected:
115 virtual void UpdateMenuActions();
116
117 virtual void SetupMainWindowComponents(QMainWindow& mainWindow);
118
119 virtual void AddMainComponent(int componentIndex, iqtgui::IMainWindowComponent* componentPtr);
121
122 virtual void CreateMenuBar();
123 virtual void CreateDefaultToolBar();
124 virtual void SetToolBarsVisible(bool isVisible = true);
125 virtual void SetupMenu();
126
136 virtual bool IsMainWindowActive(int index) const;
137
138 // reimplemented (TRestorableGuiWrap)
139 virtual void OnRestoreSettings(const QSettings& settings) override;
140 virtual void OnSaveSettings(QSettings& settings) const override;
141
142 // reimplemented (iqtgui::CGuiComponentBase)
143 virtual void OnGuiCreated() override;
144 virtual void OnGuiDestroyed() override;
145 virtual void OnRetranslate() override;
146 virtual void OnGuiShown() override;
147 virtual void OnGuiDesignChanged() override;
148
149 // reimplemented (QObject)
150 virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr) override;
151
152protected Q_SLOTS:
155 void OnAbout();
158 void OnShowOtherCommandTriggered(bool enabled);
159
160protected:
162 {
163 public:
165
167
168 // reimplemented (imod::CMultiModelDispatcherBase)
169 void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
170
171 private:
172 CSimpleMainWindowGuiComp& m_parent;
173 };
174
176
177private:
178 class VisibleWindowsManager: public iprm::IOptionsManager
179 {
180 public:
181 VisibleWindowsManager();
182
183 void SetParent(CSimpleMainWindowGuiComp* parentPtr);
184
185 // reimplemented (iprm::IOptionsManager)
186 virtual int GetOptionOperationFlags(int index = -1) const override;
187 virtual bool SetOptionEnabled(int index, bool isEnabled = true) override;
188 virtual bool RemoveOption(int index) override;
189 virtual bool InsertOption(
190 const QString& optionName,
191 const QByteArray& optionId,
192 const QString& optionDescription = QString(),
193 int index = -1) override;
194 virtual bool SwapOptions(int index1, int index2) override;
195 virtual bool SetOptionName(int optionIndex, const QString& optionName) override;
196 virtual bool SetOptionDescription(int optionIndex, const QString& optionDescription) override;
197
198 // reimplemented (iprm::IOptionsList)
199 virtual int GetOptionsFlags() const override;
200 virtual int GetOptionsCount() const override;
201 virtual QString GetOptionName(int index) const override;
202 virtual QString GetOptionDescription(int index) const override;
203 virtual QByteArray GetOptionId(int index) const override;
204 virtual bool IsOptionEnabled(int index) const override;
205
206 // reimplemented (iprm::ISelectionParam)
207 virtual const iprm::IOptionsList* GetSelectionConstraints() const override;
208 virtual int GetSelectedOptionIndex() const override;
209 virtual bool SetSelectedOptionIndex(int index) override;
210 virtual iprm::ISelectionParam* GetSubselection(int index) const override;
211
212 // reimplemented (iser::ISerializable)
213 virtual bool Serialize(iser::IArchive& archive) override;
214
215 private:
216 CSimpleMainWindowGuiComp* m_parentPtr;
217 };
218
219 template <class InterfaceType>
220 static InterfaceType* GetVisibleWindowsManager(CSimpleMainWindowGuiComp& parent)
221 {
222 return &parent.m_visibleWindowsManager;
223 }
224
225 istd::TDelPtr<QMenuBar> m_menuBarPtr;
226 istd::TDelPtr<QToolBar> m_standardToolBarPtr;
227
229
230 iqtgui::CHierarchicalCommand m_menuCommands;
231
232 iqtgui::CHierarchicalCommand m_viewCommand;
233 iqtgui::CHierarchicalCommand m_toolsCommand;
234 iqtgui::CHierarchicalCommand m_helpCommand;
235
236 // view menu group
237 iqtgui::CHierarchicalCommand m_showToolBarsCommand;
238 iqtgui::CHierarchicalCommand m_showOtherWindows;
239#if !defined(Q_OS_MAC)
240 iqtgui::CHierarchicalCommand m_fullScreenCommand;
241#endif
242
243 // tools menu group
244 iqtgui::CHierarchicalCommand m_settingsCommand;
245
246 // help menu group
247 iqtgui::CHierarchicalCommand m_aboutCommand;
248 iqtgui::CHierarchicalCommand m_manualCommand;
249
250 iqtgui::CHierarchicalCommand m_fixedCommands;
251
252 QByteArray m_beforeFullScreenGeometry;
253 QByteArray m_beforeFullScreenState;
254
255 imod::TModelWrap<VisibleWindowsManager> m_visibleWindowsManager;
256
257 typedef QMap<int, int> IndexToIndexMap;
258
259 IndexToIndexMap m_commandIndexToMainCompMap;
260
261 I_ATTR(bool, m_enableGeometryRestoringAttrPtr);
262 I_REF(ilog::IMessageConsumer, m_progressMessagesComsumerCompPtr);
263};
264
265
266} // namespace iqtgui
267
268
269
270
Interface for a provider of the heriarchical commands.
Common interface for any file system item name (e.g directory, file or URL path)
Common interface for a message container consuming information objects (messages).
Generic implementation of a data model changes notifier.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
Constraints of selection from set of possibilities.
Common interface for the management of dynamic selection constraints.
Interface allowing to select single option from list of options.
Implementation of hierarchical command based on QAction from Qt.
CommandsObserver(CSimpleMainWindowGuiComp &parent)
void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet) override
Called when some model observed by dispatcher will be changed.
iqtgui::TRestorableGuiWrap< iqtgui::TGuiComponentBase< QMainWindow > > BaseClass
CSimpleMainWindowGuiCompBase BaseClass
virtual void UpdateHelpCommands(iqtgui::CHierarchicalCommand &helpCommand)
virtual bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
virtual void AddMainComponent(int componentIndex, iqtgui::IMainWindowComponent *componentPtr)
virtual void UpdateViewCommands(iqtgui::CHierarchicalCommand &viewCommand)
virtual bool IsMainWindowActive(int index) const
virtual void OnGuiShown() override
Called from widget event filter when slave widget is shown.
virtual void OnTryClose(bool *ignoredPtr=NULL) override
Called when the application is attempting to close.
virtual void UpdateFixedCommands(iqtgui::CHierarchicalCommand &fixedCommands)
virtual void SetupMainWindowComponents(QMainWindow &mainWindow)
virtual void OnGuiDestroyed() override
Called just before GUI is released.
void OnShowOtherCommandTriggered(bool enabled)
virtual void OnRestoreSettings(const QSettings &settings) override
virtual void OnGuiDesignChanged() override
virtual void UpdateToolsCommands(iqtgui::CHierarchicalCommand &toolsCommand)
virtual void SetToolBarsVisible(bool isVisible=true)
virtual void UpdateMainWindowComponentsVisibility()
Set main window visible or invisible, depending on menu commands.
virtual void RemoveMainComponent(iqtgui::IMainWindowComponent *componentPtr)
virtual void AppendMenuActions(iqtgui::CHierarchicalCommand &menuCommands)
virtual void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
virtual void OnGuiCreated() override
Called just after GUI is initialized.
virtual void OnSaveSettings(QSettings &settings) const override
Interface for a dialog widget.
Definition IDialog.h:18
Common interface for GUI objects used in ACF component context.
Definition IGuiObject.h:133
A common interface for main window component such as dock widget, tool bar and so on.
@ WCF_FLOATABLE
Element can be float from the main window to be standalone window.
@ WCF_MOVEABLE
Element can be moved.
A wrapper for saving/restoring of GUI component states in the application settings.
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Implementation of a special pointer container, which controls the live cycle of the pointer object,...
#define NULL
Definition istd.h:74
Standard GUI specific interfaces and components based on Qt.