CApplicationCompBase.h
Go to the documentation of this file.
1 #ifndef iqtgui_CApplicationCompBase_included
2 #define iqtgui_CApplicationCompBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QtGlobal>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QApplication>
9 #else
10 #include <QtGui/QApplication>
11 #endif
12 
13 // ACF includes
14 #include <istd/CGeneralTimeStamp.h>
15 #include <imod/TModelWrap.h>
16 #include <icomp/CComponentBase.h>
17 #include <ibase/IApplication.h>
18 #include <ibase/IApplicationInfo.h>
21 #include <iqtgui/IGuiObject.h>
22 
23 
24 namespace iqtgui
25 {
26 
27 
34  public icomp::CComponentBase,
35  virtual public ibase::IApplication
36 {
37 public:
39 
40  I_BEGIN_BASE_COMPONENT(CApplicationCompBase);
41  I_REGISTER_INTERFACE(ibase::IApplication);
42  I_REGISTER_SUBELEMENT(RuntimeStatus);
43  I_REGISTER_SUBELEMENT_INTERFACE(RuntimeStatus, ibase::IRuntimeStatusProvider, ExtractRuntimeStatus);
44  I_REGISTER_SUBELEMENT_INTERFACE(RuntimeStatus, imod::IModel, ExtractRuntimeStatus);
45  I_REGISTER_SUBELEMENT_INTERFACE(RuntimeStatus, istd::IChangeable, ExtractRuntimeStatus);
46  I_ASSIGN(m_splashScreenCompPtr, "SplashScreen", "Splash screen shown before application is launched", false, "SplashScreen");
47  I_ASSIGN(m_applicationInfoCompPtr, "ApplicationInfo", "Application info used to set main window title", false, "ApplicationInfo");
48  I_ASSIGN(m_translationManagerCompPtr, "TranslationManager", "Translation manager", false, "TranslationManager");
49  I_ASSIGN(m_splashTimeAttrPtr, "SplashTime", "Minimal time splash screen will be shown", true, 2);
50  I_ASSIGN(m_styleSheetAttrPtr, "StyleSheet", "Style sheet for the GUI", false, "");
51  I_ASSIGN(m_iconPathAttrPtr, "IconPath", "file path for the application icon", true, ":/Icons/AcfLogo");
52  I_ASSIGN(m_titleFormatAttrPtr, "TitleFormat", "Describe format of title bar, tags:\n\t$(CompanyName) - name of company\n\t$(ProductName) - product name\n\t$(AppName) - application name\n\t$(AppSubName) - application sub name\n\t$(AppType) - type of application\n\t$(Version) - main application version", true, "$(AppName)");
53  I_ASSIGN_MULTI_0(m_componentsToInitializeCompPtr, "ComponentsToInitialize", "List of components to be initialized after creation of the application instance (QCoreApplication)", false);
54  I_END_COMPONENT;
55 
57 
58  // reimplemented (ibase::IApplication)
59  virtual bool InitializeApplication(int argc, char** argv);
60  virtual QStringList GetApplicationArguments() const;
61 
62 protected:
63  QApplication* GetQtApplication() const;
64  bool TryShowSplashScreen();
65  void HideSplashScreen();
67  void ApplyStyleSheet();
68 
69  // reimplemented (icomp::CComponentBase)
70  virtual void OnComponentCreated();
71 
72 private:
73  class RuntimeStatus: public ibase::IRuntimeStatusProvider
74  {
75  public:
76  RuntimeStatus();
77 
78  void SetRuntimeStatus(IRuntimeStatusProvider::RuntimeStatus runtimeStatus);
79 
80  // reimplemented (ibase::IRuntimeStatusProvider)
81  virtual IRuntimeStatusProvider::RuntimeStatus GetRuntimeStatus() const;
82 
83  private:
84  IRuntimeStatusProvider::RuntimeStatus m_status;
85  };
86 
87  // static template methods for sub element access
88  template <class InterfaceType>
89  static InterfaceType* ExtractRuntimeStatus(CApplicationCompBase& component)
90  {
91  return &component.m_runtimeStatus;
92  }
93 
94 protected:
96 
97 private:
98  I_REF(IGuiObject, m_splashScreenCompPtr);
99  I_REF(ibase::IApplicationInfo, m_applicationInfoCompPtr);
100  I_REF(iqt::ITranslationManager, m_translationManagerCompPtr);
101  I_ATTR(double, m_splashTimeAttrPtr);
102  I_ATTR(QString, m_styleSheetAttrPtr);
103  I_ATTR(QString, m_iconPathAttrPtr);
104  I_ATTR(QString, m_titleFormatAttrPtr);
105  I_MULTIREF(istd::IPolymorphic, m_componentsToInitializeCompPtr);
106 
107  bool m_useSplashScreen;
108  istd::CGeneralTimeStamp m_splashScreenTimer;
109 
110  istd::TDelPtr<QApplication> m_applicationPtr;
111 
112  QStringList m_applicationArguments;
113 
114  QByteArray m_appStyle;
115  QString m_styleSheetFile;
116 };
117 
118 
119 } // namespace iqtgui
120 
121 
122 #endif // iqtgui_CApplicationCompBase_included
123 
A general time stamp implementation.
icomp::CComponentBase BaseClass
Base class for component implementation.
Provider of the run-time status.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Base interface for all used interfaces and implementations.
Definition: IPolymorphic.h:17
This interface provides some information about the application.
Common interface for GUI objects using in component context.
Definition: IGuiObject.h:25
Common interface for the localization manager.
virtual void OnComponentCreated()
virtual bool InitializeApplication(int argc, char **argv)
Initialize the application object.
virtual QStringList GetApplicationArguments() const
Get the command line arguments of this application.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
imod::TModelWrap< RuntimeStatus > m_runtimeStatus
Standard component for a Qt based GUI application.
Interface for the main entry point of a component-based application.
Definition: IApplication.h:22
QApplication * GetQtApplication() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy