Class sh::ui::web::WebDialog

class sh::ui::web::WebDialog : public sh::tools::Jsonable

Abstract base class for a web based dialog. Typically used for also implementing some sh::ui::Dialog.

A web dialog is a dialog window presented to the user on browser side. A web dialog implementation consists of a backend part (a subclass of WebDialog) and a browser side part (basically a subclass of shwebui.Dialog).

For implementing a web dialog, implement a subclass of WebDialog (which in turn will specify the browser side part) and sh::ui::Dialog. Create such dialogs by means of WebDialogManager.

Communicating values between backend and browser typically works by dialogProperty() and setDialogProperty(), also dialogResult() for the dialog result after closing.

Subclassed by sh::ui::web::WebAboutDialog, sh::ui::web::WebExceptionDialog, sh::ui::web::WebFilePropertyDialog, sh::ui::web::WebLogViewDialog, sh::ui::web::WebManageBookmarksDialog, sh::ui::web::WebManageProfilesDialog, sh::ui::web::WebOpenWithDialog, sh::ui::web::WebStoreProfileDialog, sh::ui::web::WebTuningDialog

Public Functions

WebDialog(QString dialogClassName)

See WebDialogManager.

Parameters
  • dialogClassName: The name of the shwebui.Dialog subclass which implements the web dialog on browser side.

QVariant dialogProperty(QString dlgPropertyKey, QVariant deflt = QVariant())

Returns a dialog property value by key.

void setDialogProperty(QString dlgPropertyKey, QVariant value)

Sets a dialog property value for a key.

QVariantHash dialogResult()

Returns the dialog result as hash.

The browser side of a web dialog can ‘accept’ a dialog while closing by setting a non-empty dialog result. This mechanism allows browser side dialogs to return data to the backend. It’s up to the backend to interpret the content of this hash.

If the dialog was cancelled, or is still open, the returned hash is empty. See also wasClosed().

void triggerDialogEvent(QString name, QJsonObject data = QJsonObject())

Triggers a dialog event (at the browsers).

They in turn typically fetch some data again in order to refresh the ui.

void setCloseableByUser(bool v = true)

Sets if this dialog shall be directly closeable by the user by the window decoration. Set to false if the user has to react on this dialog by clicking on some controls in the dialog body.

This method must be called during construction.

bool isCloseableByUser()

Returns if this dialog shall be directly closeable by the user by the window decoration.

~WebDialog()
QJsonObject toJson() override

Returns the json respesentation as QJsonObject.

Private Members

QVariantHash _properties
QString _dialogClassName
qint64 _webts_created

Friends

friend class WebDialogManager