CCIMXDesktop
 
Loading...
Searching...
No Matches
applicationwrapper.h
1#ifndef APPLICATIONWRAPPER_H
2#define APPLICATIONWRAPPER_H
3
4#include <QObject>
5#include <QProcess>
6
8class AppWidget;
9
16class ApplicationWrapper : public QObject {
17 Q_OBJECT
18public:
26 friend bool operator==(const ApplicationWrapper& application_wrapper_a, const ApplicationWrapper& application_wrapper_b) {
27 return application_wrapper_a.internal_app_code == application_wrapper_b.internal_app_code;
28 }
29
35 explicit ApplicationWrapper(QObject* parent, DesktopMainWindow* desktopWindow);
36
42
47 void bindAppWidget(AppWidget* appWidget) noexcept { this->appWidget = appWidget; }
48
53 AppWidget* app_widget() const { return this->appWidget; }
54
56 using AppCode = QString;
57
62 AppCode app_code() const { return internal_app_code; }
63
71 inline void set_app_path(const QString& app_path) noexcept { this->app_path = app_path; }
72
77 inline QString get_app_path() const { return app_path; }
78
83 inline void install_args(const QStringList& args) noexcept { app_args = args; }
84
89 inline QStringList args() const { return app_args; }
90
96 inline QProcess* process_handle() const { return appProcess; }
97
103 virtual void depatch_app();
104
109 virtual bool depatchable() { return mainWindow; }
110
112 using HandlingFinHook = void (*)(ApplicationWrapper* wrapper, int exit_hook, QProcess::ExitStatus status);
113
118 inline void install_finhook(HandlingFinHook hook) { rawAppFinHook = hook; }
119
121 using ErrorDepatchHook = void (*)(ApplicationWrapper* wrapper);
122
127 inline void install_error_handler(ErrorDepatchHook hook) { error_handler = hook; }
128signals:
138
139private:
140 DesktopMainWindow* mainWindow;
141 QProcess* appProcess { nullptr };
142
143 QString app_path;
144 QStringList app_args;
145 const AppCode internal_app_code;
146 AppWidget* appWidget;
147
148 HandlingFinHook rawAppFinHook { nullptr };
149 ErrorDepatchHook error_handler { nullptr };
150
156 void do_fin_hook(int exitCode, QProcess::ExitStatus status);
157
161 void def_error_handler();
162};
163
164#endif // APPLICATIONWRAPPER_H
The AppWidget class represents an application widget placed on the desktop.
Definition appwidget.h:19
The ApplicationWrapper class is the process wrapper.
Definition applicationwrapper.h:16
void self_depatched_success()
self_depatched_success signals is using for depatch time success
void install_finhook(HandlingFinHook hook)
Installs a hook called when the application finishes.
Definition applicationwrapper.h:118
void(*)(ApplicationWrapper *wrapper) ErrorDepatchHook
Function pointer type for handling depatch errors.
Definition applicationwrapper.h:121
QProcess * process_handle() const
Returns the internal QProcess handle.
Definition applicationwrapper.h:96
QStringList args() const
Returns the argument list for the application.
Definition applicationwrapper.h:89
QString AppCode
AppCode is used to uniquely identify applications.
Definition applicationwrapper.h:56
void install_args(const QStringList &args) noexcept
Sets the arguments to pass to the application on launch.
Definition applicationwrapper.h:83
virtual bool depatchable()
depatchable
Definition applicationwrapper.h:109
void install_error_handler(ErrorDepatchHook hook)
Installs an error handler hook for depatch failures.
Definition applicationwrapper.h:127
void bindAppWidget(AppWidget *appWidget) noexcept
Bind the UI widget associated with the application.
Definition applicationwrapper.h:47
void self_mission_finished()
self_mission_finished mission finished
AppCode app_code() const
Returns the installed app code.
Definition applicationwrapper.h:62
AppWidget * app_widget() const
Returns the bound application widget.
Definition applicationwrapper.h:53
Q_DISABLE_COPY(ApplicationWrapper)
Disable copy constructor and assignment operator. This class is not copyable.
void(*)(ApplicationWrapper *wrapper, int exit_hook, QProcess::ExitStatus status) HandlingFinHook
Function pointer type for handling application finish hooks.
Definition applicationwrapper.h:112
void set_app_path(const QString &app_path) noexcept
Sets the file system path to the application executable.
Definition applicationwrapper.h:71
QString get_app_path() const
Returns the application executable path.
Definition applicationwrapper.h:77
friend bool operator==(const ApplicationWrapper &application_wrapper_a, const ApplicationWrapper &application_wrapper_b)
provide a function for compares
Definition applicationwrapper.h:26
virtual void depatch_app()
Launches the application (depatch).
Definition applicationwrapper.cpp:36
DesktopMainWindow is the main frontend window of the application. For beginners, this is the starting...
Definition desktopmainwindow.h:33