Qtohosextras QOhosAppContext Class
QOhosAppContext Class
(QtOhosExtras::QOhosAppContext)
The QOhosAppContext class contains API to manage native application context. More...
| Header: | #include <[[../qtcore/qohosappcontext-sub-qtcore.html|QOhosAppContext]]> |
| qmake: | QT += ohosextras |
| Since: | Qt 5.12.12 |
| Inherits: | [[../qtcore/qobject.html|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 [[../qtcore/qobject.html#public-functions|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 [[../qtcore/qobject.html#signals|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 [[../qtcore/qobject.html#static-public-members|QObject]]
Protected Functions
| QOhosAppContext() | |
| QOhosAppContext(const QtOhosExtras::QOhosAppContext &) | |
| virtual | ~QOhosAppContext() override |
| QtOhosExtras::QOhosAppContext & | operator=(const QtOhosExtras::QOhosAppContext &) |
- 9 protected functions inherited from [[../qtcore/qobject.html#protected-functions|QObject]]
Additional Inherited Members
- 1 property inherited from [[../qtcore/qobject.html#properties|QObject]]
- 1 public slot inherited from [[../qtcore/qobject.html#public-slots|QObject]]
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
[protected]
QOhosAppContext::QOhosAppContext()
[protected]Default constructs an instance of QOhosAppContext.
[protected]
QOhosAppContext::QOhosAppContext(const QtOhosExtras::QOhosAppContext &)
[protected]Default constructs an instance of QOhosAppContext.
[override virtual protected]
QOhosAppContext::~QOhosAppContext()
[override virtual protected]Destroys the instance of QOhosAppContext. The destructor is virtual.
[pure virtual]
bool QOhosAppContext::darkThemeActive() const
[pure virtual]Returns whether the dark color theme is active. By default, this function returns `false`, meaning the light theme is used.
See also darkThemeActiveChanged() and setColorThemeMode().
[signal]
void QOhosAppContext::darkThemeActiveChanged(bool darkThemeActive)
[signal]Signal emitted when the application's color theme changes between dark and light modes.
See also darkThemeActive() and setColorThemeMode().
[pure virtual]
void QOhosAppContext::enableContextMenuEventOnLongPress()
[pure virtual]Enable context menu triggering on long press touch for the entire application lifetime. Mimic Windows long touch behavior by generating a contextMenuEvent with the [[../qtgui/qcontextmenuevent.html#Reason-enum|QContextMenuEvent::Other]] reason.
The function should be called at the application start, before app.exec();.
[pure virtual]
double QOhosAppContext::fontSizeScale() const
[pure virtual]Returns font size scale ratio. The value ranges from 0 to 3.2. The default value is 1. See Font Size Scale.
See also fontSizeScaleChanged(double fontSizeScale).
[signal]
void QOhosAppContext::fontSizeScaleChanged(double fontSizeScale)
[signal]Signal emitted on system configuration update. fontSizeScale is the system current font size scale. See Configuration Updated.
See also fontSizeScale().
[static]
int QOhosAppContext::getAppLaunchWant()
[static]Returns the Want object that was used to launch initial instance of the application's QAbility. It is recommended to use newer getAppLaunchWantInfo() method.
See also getAppLaunchWantInfo().
[static]
int QOhosAppContext::getAppLaunchWantInfo()
[static]Returns the Want object that was used to launch initial instance of the application's QAbility.
int QOhosAppContext::getBundleInfo() const
Returns QOhosBundleInfo object for the current application. The obtained information does not contain information about the signature, HAP module, ability, ExtensionAbility, or permission.
[static]
QtOhosExtras::QOhosAppContext *QOhosAppContext::instance()
[static]Gets QOhosAppContext global instance.
[static]
bool QOhosAppContext::isNoUiChildMode()
[static]Returns true if the current process was started as a "No UI" child.
[pure virtual]
bool QOhosAppContext::isPermissionGranted(int permission) const
[pure virtual]Returns true is a given permission is granted, false otherwise. See Check Access Token.
[pure virtual]
bool QOhosAppContext::isPermissionGranted(const [[../qtcore/qstring.html|QString]] &permissionName) const
[pure virtual]
[signal]
void QOhosAppContext::permissionRequestOnSettingResponseReceived(int permission, bool permissionGranted)
[signal]Signal emitted on requestPermissionOnSettingIfNeeded(QtOhosExtras::AppPermissions::Permission permission) request result. Provides permissionGranted state for a checked permission.
See also requestPermissionOnSettingIfNeeded(QtOhosExtras::AppPermissions::Permission permission).
[signal]
void QOhosAppContext::permissionRequestResponseReceived(int permission, bool permissionGranted)
[signal]Signal emitted on requestPermissionFromUserIfNeeded() request result. Provides permissionGranted state for a checked permission.
See also requestPermissionFromUserIfNeeded().
[signal]
void QOhosAppContext::permissionRequestResponseWithResultReceived(int permission, int result)
[signal]Signal emitted on requestPermissionFromUserIfNeeded() request result. Provides result for a checked permission.
See also requestPermissionFromUserIfNeeded().
[pure virtual]
void QOhosAppContext::requestPermissionFromUserIfNeeded(int permission)
[pure virtual]Request a given application permission from the User. This is asynchronous call which result will be emitted by permissionRequestResponseReceived() signal.
See also permissionRequestResponseReceived().
[pure virtual]
void QOhosAppContext::requestPermissionOnSettingIfNeeded(int permission)
[pure virtual]Request a given application permission in a Settings dialog box. This is asynchronous call which result will be emitted by permissionRequestOnSettingResponseReceived() signal.
See also permissionRequestOnSettingResponseReceived().
[pure virtual]
void QOhosAppContext::restartApp()
[pure virtual]Restarts the Application using the app launch want.
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 ..
[pure virtual]
void QOhosAppContext::restartApp(const int &want)
[pure virtual]
[pure virtual]
void QOhosAppContext::setColorThemeMode(QtOhosExtras::QOhosAppContext::ColorThemeMode mode)
[pure virtual]Sets the application's color theme to fixed value or enables automatic theme updates.
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().
[static]
void QOhosAppContext::startNoUiChildProcess([[../qtcore/qstring.html|QString]] libraryName, [[../qtcore/qstringlist.html|QStringList]] args)
[static]Starts "No UI" child process for a given libraryName and args. Arguments passed to the startNoUiChildProcess() function are forwarded to the child's main() function. See Child Process Manager.
QtOhosExtras::QOhosAppContext::startNoUiChildProcess(
"libapp.so",
QStringList{
"first arg",
"second arg",
});
[protected]
QtOhosExtras::QOhosAppContext &QOhosAppContext::operator=(const QtOhosExtras::QOhosAppContext &)
[protected]Copy-assignment operator.