ACF $AcfVersion:0$
CGuiApplicationComp.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/QSystemTrayIcon>
9#else
10#include <QtGui/QSystemTrayIcon>
11#endif
12
13// ACF includes
18#include <iqtgui/IGuiObject.h>
21
22
23namespace iqtgui
24{
25
26
48 protected imod::TSingleModelObserverBase<iprm::IEnableableParam>,
49 virtual public iqtgui::IGuiApplication
50{
51 Q_OBJECT
52public:
55
56 I_BEGIN_COMPONENT(CGuiApplicationComp);
57 I_REGISTER_INTERFACE(ibase::IApplication);
58 I_REGISTER_SUBELEMENT(TrayMessages);
59 I_REGISTER_SUBELEMENT_INTERFACE(TrayMessages, ilog::IMessageConsumer, ExtractTrayMessages);
60 I_ASSIGN(m_mainGuiCompPtr, "MainGui", "Gui object shown as main window", false, "MainGui");
61 I_ASSIGN(m_allowApplicationCloseCompPtr, "AllowClose", "Controls closing of the application", false, "AllowClose");
62 I_ASSIGN_TO(m_allowApplicationCloseModelCompPtr, m_allowApplicationCloseCompPtr, false);
63 I_ASSIGN(m_trayIconCommandsCompPtr, "TrayIconsCommands", "Provider of tray icons commands. The commands are shown in the menu of the system tray", false, "TrayIconsCommands");
64 I_ASSIGN(m_frameSpaceSizeAttrPtr, "FrameSpaceSize", "Number of pixels will be added on the all window sides", false, 9);
65 I_ASSIGN(m_uiStartModeAttrPtr, "UiStartMode", "UI mode by application start up.\n0 - normal\n1 - full screen\n2 - minimized\n3 - maximized", false, 0);
66 I_ASSIGN(m_useMenuIconsOnMacAttrPtr, "UseMenuIconsOnMac", "If enabled, the menu icons will be used in the application's menu bar on Mac OS", true, false);
67 I_ASSIGN(m_useTrayIconAttrPtr, "UseTrayIcon", "If enabled, the tray icon for the application will be used", true, false);
68 I_ASSIGN(m_trayIconToolTip, "TrayIconToolTip", "This property holds the tooltip for the system tray entry \n Note: On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.", false, "");
69 I_ASSIGN(m_useFullScreenBorderOnWindowsAttrPtr, "UseFullScreenBorderOnWindows", "If enabled, 1-pixel border will be created by Windows in full screen mode", true, false);
70 I_END_COMPONENT;
71
73
74 // reimplemented (ibase::IGuiApplication)
75 virtual const iqtgui::IGuiObject* GetApplicationGui() const override;
76
77 // reimplemented (ibase::IApplication)
78 virtual bool InitializeApplication(int argc, char** argv) override;
79 virtual int Execute(int argc, char** argv) override;
80 virtual QString GetHelpText() const override;
81
82protected:
83 // reimplemented (imod::TSingleModelObserverBase)
84 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
85
86 // reimplemented (icomp::CComponentBase)
87 virtual void OnComponentDestroyed() override;
88
89 // reimplemented (QObject)
90 virtual bool eventFilter(QObject* obj, QEvent* ev) override;
91
92protected:
93 template <class InterfaceType>
94 static InterfaceType* ExtractTrayMessages(CGuiApplicationComp& component)
95 {
96 return &component.m_trayMessages;
97 }
98
100 {
101 public:
103
104 // reimplemented (ilog::IMessageConsumer)
105 virtual bool IsMessageSupported(
106 int messageCategory = -1,
107 int messageId = -1,
108 const istd::IInformationProvider* messagePtr = NULL) const override;
109 virtual void AddMessage(const MessagePtr& messagePtr) override;
110
111 private:
112 CGuiApplicationComp& m_parent;
113 };
114
115private:
116 void UpdateMainWidgetDecorations();
117 void ShowWindow();
118 void ShowFullScreen();
119
120private Q_SLOTS:
121 void OnQuit();
122 void OnEventLoopStarted();
123
124Q_SIGNALS:
126
127protected:
128 I_REF(IGuiObject, m_mainGuiCompPtr);
129 I_REF(iprm::IEnableableParam, m_allowApplicationCloseCompPtr);
130 I_REF(imod::IModel, m_allowApplicationCloseModelCompPtr);
131 I_REF(ibase::ICommandsProvider, m_trayIconCommandsCompPtr);
132 I_ATTR(int, m_frameSpaceSizeAttrPtr);
133 I_ATTR(int, m_uiStartModeAttrPtr);
134 I_ATTR(bool, m_useMenuIconsOnMacAttrPtr);
135 I_ATTR(bool, m_useTrayIconAttrPtr);
136 I_TEXTATTR(m_trayIconToolTip);
137
142 I_ATTR(bool, m_useFullScreenBorderOnWindowsAttrPtr);
143
150 Qt::WindowFlags m_defaultWidgetFlags;
152
154
156};
157
158
159} // namespace iqtgui
160
161
162
Interface for the main entry point of a component-based application.
Interface for a provider of the heriarchical commands.
Common interface for a message container consuming information objects (messages).
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Basic implementation for a single model observer with binding to concrete data object interface.
Interface for objects which can be enabled/disabled.
Standard component for a Qt based GUI application.
virtual bool IsMessageSupported(int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
Check if a message is supported by this consumer.
virtual void AddMessage(const MessagePtr &messagePtr) override
Adds a message to this consumer.
TrayMessages(CGuiApplicationComp &parent)
Standard component for a Qt based GUI application.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet) override
Called on update of observed model.
virtual bool InitializeApplication(int argc, char **argv) override
Initialize the application object.
virtual const iqtgui::IGuiObject * GetApplicationGui() const override
Get the main UI object of the application.
imod::TSingleModelObserverBase< iprm::IEnableableParam > BaseClass2
istd::TDelPtr< QSystemTrayIcon > m_trayIconPtr
virtual bool eventFilter(QObject *obj, QEvent *ev) override
virtual void OnComponentDestroyed() override
virtual QString GetHelpText() const override
Get information about the possible command line arguments of this application.
static InterfaceType * ExtractTrayMessages(CGuiApplicationComp &component)
I_TEXTATTR(m_trayIconToolTip)
virtual int Execute(int argc, char **argv) override
Start execution loop of the application.
istd::TDelPtr< QWidget > m_mainWidgetPtr
Interface for Qt based application with GUI.
Common interface for GUI objects used in ACF component context.
Definition IGuiObject.h:133
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for class providing some basic information object.
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Shared ownership smart pointer for interface types.
#define NULL
Definition istd.h:74
Standard GUI specific interfaces and components based on Qt.