CGuiApplicationComp.h
Go to the documentation of this file.
1 #ifndef iqtgui_CGuiApplicationComp_included
2 #define iqtgui_CGuiApplicationComp_included
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
15 #include <iprm/IEnableableParam.h>
16 #include <ilog/IMessageConsumer.h>
18 #include <iqtgui/IGuiObject.h>
19 #include <iqtgui/IGuiApplication.h>
21 
22 
23 namespace iqtgui
24 {
25 
26 
47  public QObject,
48  public CApplicationCompBase,
49  protected imod::TSingleModelObserverBase<iprm::IEnableableParam>,
50  virtual public iqtgui::IGuiApplication
51 {
52  Q_OBJECT
53 public:
56 
57  I_BEGIN_COMPONENT(CGuiApplicationComp);
58  I_REGISTER_INTERFACE(ibase::IApplication);
59  I_REGISTER_SUBELEMENT(TrayMessages);
60  I_REGISTER_SUBELEMENT_INTERFACE(TrayMessages, ilog::IMessageConsumer, ExtractTrayMessages);
61  I_ASSIGN(m_mainGuiCompPtr, "MainGui", "Gui object shown as main window", false, "MainGui");
62  I_ASSIGN(m_allowApplicationCloseCompPtr, "AllowClose", "Controls closing of the application", false, "AllowClose");
63  I_ASSIGN_TO(m_allowApplicationCloseModelCompPtr, m_allowApplicationCloseCompPtr, false);
64  I_ASSIGN(m_trayIconCommandsCompPtr, "TrayIconsCommands", "Provider of tray icons commands. The commands are shown in the menu of the system tray", false, "TrayIconsCommands");
65  I_ASSIGN(m_frameSpaceSizeAttrPtr, "FrameSpaceSize", "Number of pixels will be added on the all window sides", false, 9);
66  I_ASSIGN(m_uiStartModeAttrPtr, "UiStartMode", "UI mode by application start up.\n0 - normal\n1 - full screen\n2 - minimized\n3 - maximized", false, 0);
67  I_ASSIGN(m_useMenuIconsOnMacAttrPtr, "UseMenuIconsOnMac", "If enabled, the menu icons will be used in the application's menu bar on Mac OS", true, false);
68  I_ASSIGN(m_useTrayIconAttrPtr, "UseTrayIcon", "If enabled, the tray icon for the application will be used", true, false);
69  I_END_COMPONENT;
70 
72 
73  // reimplemented (ibase::IGuiApplication)
74  virtual const iqtgui::IGuiObject* GetApplicationGui() const;
75 
76  // reimplemented (ibase::IApplication)
77  virtual bool InitializeApplication(int argc, char** argv);
78  virtual int Execute(int argc, char** argv);
79  virtual QString GetHelpText() const;
80 
81 protected:
82  // reimplemented (imod::TSingleModelObserverBase)
83  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
84 
85  // reimplemented (icomp::CComponentBase)
86  virtual void OnComponentDestroyed();
87 
88 protected:
89  template <class InterfaceType>
90  static InterfaceType* ExtractTrayMessages(CGuiApplicationComp& component)
91  {
92  return &component.m_trayMessages;
93  }
94 
95  class TrayMessages: virtual public ilog::IMessageConsumer
96  {
97  public:
98  explicit TrayMessages(CGuiApplicationComp& parent);
99 
100  // reimplemented (ilog::IMessageConsumer)
101  virtual bool IsMessageSupported(
102  int messageCategory = -1,
103  int messageId = -1,
104  const istd::IInformationProvider* messagePtr = NULL) const;
105  virtual void AddMessage(const MessagePtr& messagePtr);
106 
107  private:
108  CGuiApplicationComp& m_parent;
109  };
110 
111 private:
112  void UpdateMainWidgetDecorations();
113  void ShowWindow();
114 
115 private Q_SLOTS:
116  void OnQuit();
117 
118 protected:
119  I_REF(IGuiObject, m_mainGuiCompPtr);
120  I_REF(iprm::IEnableableParam, m_allowApplicationCloseCompPtr);
121  I_REF(imod::IModel, m_allowApplicationCloseModelCompPtr);
122  I_REF(ibase::ICommandsProvider, m_trayIconCommandsCompPtr);
123  I_ATTR(int, m_frameSpaceSizeAttrPtr);
124  I_ATTR(int, m_uiStartModeAttrPtr);
125  I_ATTR(bool, m_useMenuIconsOnMacAttrPtr);
126  I_ATTR(bool, m_useTrayIconAttrPtr);
127 
134  Qt::WindowFlags m_defaultWidgetFlags;
136 
138 
140 };
141 
142 
143 } // namespace iqtgui
144 
145 
146 #endif // iqtgui_CGuiApplicationComp_included
147 
Interface for Qt based application with GUI.
imod::TSingleModelObserverBase< iprm::IEnableableParam > BaseClass2
virtual QString GetHelpText() const
Get information about the possible command line arguments of this application.
istd::TDelPtr< QSystemTrayIcon > m_trayIconPtr
virtual bool IsMessageSupported(int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const
Check if some messge is supported.
TrayMessages(CGuiApplicationComp &parent)
Basic implementation for a single model observer with binding to concrete data object interface...
Interface for a provider of the heriarchical commands.
virtual void AddMessage(const MessagePtr &messagePtr)
Adds a message item to the container.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
istd::TDelPtr< QWidget > m_mainWidgetPtr
Interface for objects which can be enabled/disabled.
Implementation of a smart pointer.
Definition: TSmartPtr.h:24
Common interface for GUI objects using in component context.
Definition: IGuiObject.h:25
#define NULL
Definition: istd.h:64
Standard component for a Qt based GUI application.
Common interface for a message container consuming information objects (messages).
virtual const iqtgui::IGuiObject * GetApplicationGui() const
Get the main UI object of the application.
CApplicationCompBase BaseClass
virtual void OnComponentDestroyed()
Common interface for class providing some basic information object.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual bool InitializeApplication(int argc, char **argv)
Initialize the application object.
static InterfaceType * ExtractTrayMessages(CGuiApplicationComp &component)
Standard component for a Qt based GUI application.
Interface for the main entry point of a component-based application.
Definition: IApplication.h:22
virtual int Execute(int argc, char **argv)
Start execution loop of the application.

© 2007-2017 Witold Gantzke and Kirill Lepskiy