ICF 3.1.1.10
Technical documentation of ICF Libraries
CSimpleMainWindowGuiComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iqtgui_CSimpleMainWindowGuiComp_included
7#define iqtgui_CSimpleMainWindowGuiComp_included
8
9
10// Qt includes
11#include <QtCore/QtGlobal>
12#include <QtWidgets/QMainWindow>
13#include <QtWidgets/QMenuBar>
14
15// ICF includes
21#include <istdgui/IDialog.h>
26
27
28namespace istdgui
29{
30
31
36class CSimpleMainWindowGuiCompBase: public istdgui::TRestorableGuiWrap< istdgui::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", true, 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(istdgui::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(istdgui::IDialog, m_aboutDialogCompPtr);
68 I_REF(istdgui::IDialog, m_settingsDialogCompPtr);
69 I_MULTIREF(istdgui::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 (istdgui::IGuiObject)
112 void OnTryClose(bool* ignoredPtr = nullptr) override;
113
114protected:
115 virtual void UpdateMenuActions();
116
117 virtual void SetupMainWindowComponents(QMainWindow& mainWindow);
118
119 virtual void AddMainComponent(int componentIndex, istdgui::IMainWindowComponent& component);
121
122 virtual void CreateMenuBar();
124 virtual void SetupMenu();
125
126 virtual std::unique_ptr<QToolBar> CreateDefaultToolBar() const;
127
137 virtual bool IsMainWindowActive(int index) const;
138
139 // reimplemented (TRestorableGuiWrap)
140 void OnRestoreSettings(const QSettings& settings) override;
141 void OnSaveSettings(QSettings& settings) const override;
142
143 // reimplemented (istdgui::CGuiComponentBase)
144 void OnGuiCreated() override;
145 void OnGuiDestroyed() override;
146 void OnRetranslate() override;
147 void OnGuiShown() override;
148
149 // reimplemented (QObject)
150 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);
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 int GetOptionOperationFlags(int index = -1) const override;
187 bool SetOptionEnabled(int index, bool isEnabled = true) override;
188 bool RemoveOption(int index) override;
189 bool InsertOption(
190 const QString& optionName,
191 const QByteArray& optionId,
192 const QString& optionDescription = QString(),
193 int index = -1) override;
194 bool SwapOptions(int index1, int index2) override;
195 bool SetOptionName(int optionIndex, const QString& optionName) override;
196 bool SetOptionDescription(int optionIndex, const QString& optionDescription) override;
197
198 // reimplemented (iprm::IOptionsList)
199 int GetOptionsFlags() const override;
200 int GetOptionsCount() const override;
201 QString GetOptionName(int index) const override;
202 QString GetOptionDescription(int index) const override;
203 QByteArray GetOptionId(int index) const override;
204 bool IsOptionEnabled(int index) const override;
205
206 private:
207 CSimpleMainWindowGuiComp* m_parentPtr;
208 };
209
210 template <class InterfaceType>
211 static InterfaceType* GetVisibleWindowsManager(CSimpleMainWindowGuiComp& parent)
212 {
213 return &parent.m_visibleWindowsManager;
214 }
215
216 std::unique_ptr<QMenuBar> m_menuBarPtr;
217 std::unique_ptr<QToolBar> m_standardToolBarPtr;
218
219 bool m_isStandardToolbarVisible;
220 bool m_areToolbarsVisible;
221 bool m_isFullScreen;
222
223 std::vector<QToolBar*> m_userToolbars;
224
225 istdgui::CHierarchicalCommand m_menuCommands;
226
227 istdgui::CHierarchicalCommand m_viewCommand;
228 istdgui::CHierarchicalCommand m_toolsCommand;
229 istdgui::CHierarchicalCommand m_helpCommand;
230
231 // view menu group
232 istdgui::CHierarchicalCommand m_showToolBarsCommand;
233 istdgui::CHierarchicalCommand m_showOtherWindows;
234#if !defined(Q_OS_MAC)
235 istdgui::CHierarchicalCommand m_fullScreenCommand;
236#endif
237
238 // tools menu group
239 istdgui::CHierarchicalCommand m_settingsCommand;
240
241 // help menu group
242 istdgui::CHierarchicalCommand m_aboutCommand;
243 istdgui::CHierarchicalCommand m_manualCommand;
244
245 istdgui::CHierarchicalCommand m_fixedCommands;
246
247 QByteArray m_beforeFullScreenGeometry;
248 QByteArray m_beforeFullScreenState;
249
250 imod::TModelWrap<VisibleWindowsManager> m_visibleWindowsManager;
251
252 QMap<int, int> m_commandIndexToMainCompMap;
253
254 I_ATTR(bool, m_enableGeometryRestoringAttrPtr);
255 I_REF(ilog::IMessageConsumer, m_progressMessagesComsumerCompPtr);
256};
257
258
259} // namespace istdgui
260
261
262#endif // !iqtgui_CSimpleMainWindowGuiComp_included
263
264
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:29
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:28
Constraints of selection from set of possibilities.
Common interface for the management of the dynamic selection constraints.
Set of change flags (its IDs).
Definition IChangeable.h:38
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
Implementation of hierarchical command based on QAction from Qt.
void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
Called when some model observed by dispatcher will be changed.
CommandsObserver(CSimpleMainWindowGuiComp &parent)
istdgui::TRestorableGuiWrap< istdgui::TGuiComponentBase< QMainWindow > > BaseClass
void OnSaveSettings(QSettings &settings) const override
bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
virtual void UpdateViewCommands(istdgui::CHierarchicalCommand &viewCommand)
void OnTryClose(bool *ignoredPtr=nullptr) override
Called on trying to close application.
CSimpleMainWindowGuiCompBase BaseClass
virtual void AppendMenuActions(istdgui::CHierarchicalCommand &menuCommands)
void OnRestoreSettings(const QSettings &settings) override
virtual void AddMainComponent(int componentIndex, istdgui::IMainWindowComponent &component)
virtual void RemoveMainComponent(istdgui::IMainWindowComponent &component)
void OnGuiShown() override
Called from widget event filter when slave widget is shown.
virtual void UpdateMainWindowComponentsVisibility()
Set main window visible or invisible, depending on menu commands.
virtual void UpdateToolsCommands(istdgui::CHierarchicalCommand &toolsCommand)
virtual void SetupMainWindowComponents(QMainWindow &mainWindow)
virtual void UpdateHelpCommands(istdgui::CHierarchicalCommand &helpCommand)
void OnGuiDestroyed() override
Called just before GUI is released.
virtual bool IsMainWindowActive(int index) const
virtual std::unique_ptr< QToolBar > CreateDefaultToolBar() const
void OnGuiCreated() override
Called just after GUI is initialized.
void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
void OnShowOtherCommandTriggered(bool enabled)
virtual void UpdateFixedCommands(istdgui::CHierarchicalCommand &fixedCommands)
Interface for a dialog widget.
Definition IDialog.h:23
Common interface for GUI objects using in component context.
Definition IGuiObject.h:27
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.
Standard GUI specific interfaces and components based on Qt.

© Witold Gantzke and Kirill Lepskiy