Qt for HarmonyOS/qtohosextras doc/QOhosAppContext Class
QOhosAppContext Class
(QtOhosExtras::QOhosAppContext)
The QOhosAppContext class contains API to manage native application context. More...
| Header: | #include <QOhosAppContext> |
| qmake: | QT += ohosextras |
| Since: | Qt 5.12.12 |
| Inherits: | QObject |
Public Types
| enum | ColorThemeMode { LightTheme, DarkTheme, FollowSystemSetting } |
Public Functions
| virtual bool | darkThemeActive() const = 0 |
| virtual void | enableContextMenuEventOnLongPress() = 0 |
| virtual double | fontSizeScale() const = 0 |
| int | getBundleInfo() const |
| virtual bool | isPermissionGranted(int permission) const = 0 |
| virtual bool | isPermissionGranted(const QString &permissionName) const = 0 |
| virtual void | requestPermissionFromUserIfNeeded(int permission) = 0 |
| virtual void | requestPermissionOnSettingIfNeeded(int permission) = 0 |
| virtual void | restartApp() = 0 |
| virtual void | restartApp(const int &want) = 0 |
| virtual void | setColorThemeMode(QtOhosExtras::QOhosAppContext::ColorThemeMode mode) = 0 |
- 31 public functions inherited from QObject
Signals
| void | darkThemeActiveChanged(bool darkThemeActive) |
| void | fontSizeScaleChanged(double fontSizeScale) |
| void | permissionRequestOnSettingResponseReceived(int permission, bool permissionGranted) |
| void | permissionRequestResponseReceived(int permission, bool permissionGranted) |
| void | permissionRequestResponseWithResultReceived(int permission, int result) |
- 2 signals inherited from QObject
Static Public Members
| int | getAppLaunchWant() |
| int | getAppLaunchWantInfo() |
| QtOhosExtras::QOhosAppContext * | instance() |
| bool | isNoUiChildMode() |
| void | startNoUiChildProcess(QString libraryName, QStringList args) |
| const QMetaObject | staticMetaObject |
- 9 static public members inherited from QObject
Protected Functions
| QOhosAppContext() | |
| QOhosAppContext(const QtOhosExtras::QOhosAppContext &) | |
| virtual | ~QOhosAppContext() override |
| QtOhosExtras::QOhosAppContext & | operator=(const QtOhosExtras::QOhosAppContext &) |
- 9 protected functions inherited from QObject
Additional Inherited Members
Member Type Documentation
enum QOhosAppContext::ColorThemeMode
Defines the color theme mode for the application.
| Constant | Value | Description |
|---|---|---|
QtOhosExtras::QOhosAppContext::LightTheme |
0 |
Uses the light theme colors (default). |
QtOhosExtras::QOhosAppContext::DarkTheme |
1 |
Uses the dark theme colors. |
QtOhosExtras::QOhosAppContext::FollowSystemSetting |
2 |
Automatically updates the theme based on the system setting. See Configuration Updated. |
This enum was introduced or modified in Qt 5.12.12.
Member Function Documentation
QOhosAppContext::QOhosAppContext() [protected]QOhosAppContext::QOhosAppContext(const QtOhosExtras::QOhosAppContext &) [protected]
QOhosAppContext::~QOhosAppContext() [override virtual protected]bool QOhosAppContext::darkThemeActive() const [pure virtual]See also darkThemeActiveChanged() and setColorThemeMode().
void QOhosAppContext::darkThemeActiveChanged(bool darkThemeActive) [signal]See also darkThemeActive() and setColorThemeMode().
void QOhosAppContext::enableContextMenuEventOnLongPress() [pure virtual]The function should be called at the application start, before app.exec();.
double QOhosAppContext::fontSizeScale() const [pure virtual]See also fontSizeScaleChanged(double fontSizeScale).
void QOhosAppContext::fontSizeScaleChanged(double fontSizeScale) [signal]int QOhosAppContext::getAppLaunchWant() [static]See also getAppLaunchWantInfo().
int QOhosAppContext::getAppLaunchWantInfo() [static]int QOhosAppContext::getBundleInfo() constQtOhosExtras::QOhosAppContext *QOhosAppContext::instance() [static]
bool QOhosAppContext::isNoUiChildMode() [static]
bool QOhosAppContext::isPermissionGranted(int permission) const [pure virtual]bool QOhosAppContext::isPermissionGranted(const QString &permissionName) const [pure virtual]void QOhosAppContext::permissionRequestOnSettingResponseReceived(int permission, bool permissionGranted) [signal]See also requestPermissionOnSettingIfNeeded(QtOhosExtras::AppPermissions::Permission permission).
void QOhosAppContext::permissionRequestResponseReceived(int permission, bool permissionGranted) [signal]See also requestPermissionFromUserIfNeeded().
void QOhosAppContext::permissionRequestResponseWithResultReceived(int permission, int result) [signal]See also requestPermissionFromUserIfNeeded().
void QOhosAppContext::requestPermissionFromUserIfNeeded(int permission) [pure virtual]See also permissionRequestResponseReceived().
void QOhosAppContext::requestPermissionOnSettingIfNeeded(int permission) [pure virtual]See also permissionRequestOnSettingResponseReceived().
void QOhosAppContext::restartApp() [pure virtual]The current application will be killed using SIGKILL and a new instance of the application will be launched with the application start want.
All abilities and sub-widnows created within this process will be closed.
The application will be killed ungracefully. This function won't return to the caller.
The caller must ensure, that the application has system focus when this function is called, otherwise the application will be killed but the new application won't be started. OHOS system treats some system dialogs (for example File Dialog) as separate from the application. If such dialog is open, the application loses the system focus.
If restartApp is called too frequently, the system call will be throttled to avoid errors.
Use this function, if you want to restart app with app launch want, instead of calling
See also QtOhosExtras::QOhosAppContext::restartApp(const QtOhosExtras::QOhosWant &requestWant), with, QtOhosExtras::QOhosAppContext::getAppLaunchWant(), as, a, parameter, and ..
void QOhosAppContext::restartApp(const int &want) [pure virtual]void QOhosAppContext::setColorThemeMode(QtOhosExtras::QOhosAppContext::ColorThemeMode mode) [pure virtual]Calling this function with mode `FollowSystemSetting` allows the application to adjust its theme dynamically based on the system's theme configuration. The theme will be updated to match the system theme when `FollowSystemSetting` is set. See Configuration Updated. If the color theme actually changes as a result of this call, the darkThemeActiveChanged() signal will be emitted.
See also darkThemeActive() and darkThemeActiveChanged().
void QOhosAppContext::startNoUiChildProcess(QString libraryName, QStringList args) [static] QtOhosExtras::QOhosAppContext::startNoUiChildProcess(
"libapp.so",
QStringList{
"first arg",
"second arg",
});
QtOhosExtras::QOhosAppContext &QOhosAppContext::operator=(const QtOhosExtras::QOhosAppContext &) [protected]