ICF 3.1.1.10
Technical documentation of ICF Libraries
CGuiComponentBase.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_CGuiComponentBase_included
7#define iqtgui_CGuiComponentBase_included
8
9
10// Qt includes
11#include <QtCore/QString>
12#include <QtGui/QIcon>
13
14// ICF includes
16#include <imod/TModelWrap.h>
19#include <istdgui/IGuiObject.h>
21
22
23namespace istdgui
24{
25
26
31 public QObject,
32 public ibase::TVisualChangesHandlerWrap<icomp::CComponentBase>,
33 virtual public IGuiObject
34{
35public:
37
38 I_BEGIN_BASE_COMPONENT(CGuiComponentBase);
39 I_REGISTER_INTERFACE(IGuiObject);
40 I_REGISTER_SUBELEMENT(VisualStatus);
41 I_REGISTER_SUBELEMENT_INTERFACE_T(VisualStatus, IVisualStatus, ExtractVisualStatus);
42 I_REGISTER_SUBELEMENT_INTERFACE_T(VisualStatus, istd::IChangeable, ExtractVisualStatus);
43 I_REGISTER_SUBELEMENT_INTERFACE_T(VisualStatus, imod::IModel, ExtractVisualStatus);
44 I_ASSIGN(m_defaultStatusIconPathAttrPtr, "DefaultStatusIcon", "Path of status icon used by default", false, "");
45 I_ASSIGN(m_defaultStatusTextAttrPtr, "DefaultStatusText", "Status text used by default", true, "");
46 I_ASSIGN(m_styleSheetPathAttrPtr, "StyleSheet", "Path to the style sheet file used for this UI component.", false, "");
47 I_ASSIGN(m_objectIdAttrPtr, "WidgetId", "QT ID of the widget", false, "");
48 I_ASSIGN(m_fixedWidthAttrPtr, "FixedWidth", "Fixed width of the widget", false, 300);
49 I_ASSIGN(m_fixedHeightAttrPtr, "FixedHeight", "Fixed height of the widget", false, 300);
50 I_END_COMPONENT;
51
53
54 bool IsGuiShown() const;
55
56 // reimplemented (istdgui::IGuiObject)
57 bool IsGuiCreated() const override;
58 bool CreateGui(QWidget* parentPtr) override;
59 bool DestroyGui() override;
60 QWidget* GetWidget() const override;
61 void OnTryClose(bool* ignoredPtr = nullptr) override;
62
63 static void MakeAutoSlotConnection(const QWidget& widget, QObject& object);
64
65protected:
66 class VisualStatus: virtual public IVisualStatus
67 {
68 public:
69 // reimplemented (istdgui::IVisualStatus)
70 QIcon GetStatusIcon() const override;
71 QString GetStatusText() const override;
72
73 friend class CGuiComponentBase;
74
75 private:
76 QIcon m_statusIcon;
77 QString m_statusText;
78 };
79
83 virtual void OnGuiShown();
84
88 virtual void OnGuiHidden();
89
94 virtual bool OnKeyPressed(QKeyEvent* event);
95
99 virtual void OnRetranslate();
100
104 virtual void OnGuiRetranslate();
105
109 virtual void OnGuiCreated();
110
114 virtual void OnGuiDestroyed();
115
119 void SetStatusIcon(const QIcon& icon);
123 void SetStatusText(const QString& text);
124
125 // reimplemented (ibase::TVisualChangesHandlerWrap)
126 void OnLanguageChanged() override;
127 void OnDesignSchemaChanged() override;
128
129 // reimplemented (QObject)
130 bool eventFilter(QObject* sourcePtr, QEvent* eventPtr) override;
131
132 // reimplemented (icomp::CComponentBase)
133 void OnComponentCreated() override;
134 void OnComponentDestroyed() override;
135
136 // abstract methods
140 virtual QWidget* CreateQtWidget(QWidget* parentPtr) = 0;
141
142 // provides call of GUI functions from any thread
144
145 // attributes
147
148private:
149 I_ATTR(QString, m_defaultStatusIconPathAttrPtr);
150 I_TEXTATTR(m_defaultStatusTextAttrPtr);
151 I_ATTR(QString, m_styleSheetPathAttrPtr);
152 I_ATTR(QByteArray, m_objectIdAttrPtr);
153 I_ATTR(int, m_fixedWidthAttrPtr);
154 I_ATTR(int, m_fixedHeightAttrPtr);
155
156 QWidget* m_widgetPtr;
157 bool m_isGuiShown;
158
159 QIcon m_defaultStatusIcon;
160
161 // static template methods for subelement access
162 template <class InterfaceType>
163 static InterfaceType* ExtractVisualStatus(CGuiComponentBase& component)
164 {
165 return &component.m_visualStatus;
166 }
167};
168
169
170// inline methods
171
173{
174 return m_isGuiShown;
175}
176
177
178// reimplemented (istdgui::IGuiObject)
179
180inline QWidget* CGuiComponentBase::GetWidget() const
181{
182 return m_widgetPtr;
183}
184
185
186} // namespace istdgui
187
188
189#endif // !iqtgui_CGuiComponentBase_included
190
191
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
Call some function in main application thread.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
QIcon GetStatusIcon() const override
Get the icon describing current status.
QString GetStatusText() const override
Get status text.
Base class for classes implementing interface istdgui::IGuiObject.
void SetStatusText(const QString &text)
Set status text;.
void OnTryClose(bool *ignoredPtr=nullptr) override
Called on trying to close application.
virtual void OnGuiCreated()
Called just after GUI is initialized.
imod::TModelWrap< VisualStatus > m_visualStatus
ibase::TVisualChangesHandlerWrap< icomp::CComponentBase > BaseClass
void SetStatusIcon(const QIcon &icon)
Set status icon;.
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.
void OnComponentCreated() override
virtual void OnGuiHidden()
Called from widget event filter when slave widget is hidden.
bool DestroyGui() override
Release GUI and disconnect it from parent.
QWidget * GetWidget() const override
Get access to internal QWidget object.
bool CreateGui(QWidget *parentPtr) override
Initialize GUI and connect it to the parent.
static void MakeAutoSlotConnection(const QWidget &widget, QObject &object)
virtual void OnRetranslate()
Called when non-GUI elements (like commands) should be retranslated.
virtual QWidget * CreateQtWidget(QWidget *parentPtr)=0
Create slave widget object.
bool IsGuiCreated() const override
Inform if GUI was initilized.
void OnComponentDestroyed() override
virtual bool OnKeyPressed(QKeyEvent *event)
Called from widget event filter when key is pressed.
virtual void OnGuiDestroyed()
Called just before GUI is released.
bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
void OnLanguageChanged() override
istd::CMainThreadCaller m_updateGuiCaller
virtual void OnGuiShown()
Called from widget event filter when slave widget is shown.
void OnDesignSchemaChanged() override
Common interface for GUI objects using in component context.
Definition IGuiObject.h:27
Extends standard information provider to provide additional visual informations.
Standard GUI specific interfaces and components based on Qt.

© Witold Gantzke and Kirill Lepskiy