Class sh::ui::DialogManager

class sh::ui::DialogManager

Creates and drives dialogs (in child windows), i.e. instances of Dialog.

Subclass it for implementing the low level mechanisms for handling dialogs in a particular ui mode (e.g. qt, web).

The infrastructure will use one of this implementations for creating and managing most kinds of dialogs.

Subclassed by sh::ui::qt::QtDialogManager, sh::ui::web::WebDialogManager

Public Functions

std::shared_ptr<Dialog> getDialogById(qint64 id)

Returns a Dialog by dialog id.

Must be called in main thread.

QList<std::shared_ptr<Dialog>> getAllDialogs()

Returns a list of all dialogs currently shown (in order of creation).

Must be called in main thread.

QList<qint64> getAllDialogIds()

Returns a list of dialog ids of all dialogs currently shown (in order of creation).

Must be called in main thread.

template<class TDlg, typename ...Args>
std::shared_ptr<TDlg> createAndShowDialog(Args... args)

Creates and shows a Dialog by class and constructor parameters.

Those dialogs (TDlg) have to implement Dialog (typically a subclass of it, representing a particular dialog, like FilePropertyDialog), and also some ui mode (e.g. qt, web) specific class (depends on that ui mode).

You typically should not have to use it outside of MainWindow or subclasses. The MainWindow interface allows to create all available dialogs in a ui mode independent way.

May be called in any thread.

Return

The created Dialog instance.

~DialogManager()

Private Functions

void closeDialog(std::shared_ptr<Dialog> dialog)

Closes this dialog, including internal bookkeeping.

Must be called in main thread.

void initAndShowDialog(std::shared_ptr<Dialog> dialog)

Initializes and shows a freshly created dialog.

Must be called in main thread.

bool wasAccepted(std::shared_ptr<Dialog> dialog) = 0

Returns if the dialog was ‘accepted’ by the user (typically by clicking some ‘OK’ button).

The result is undefined before the dialog was closed.

Must be called in main thread.

void waitClosed(std::shared_ptr<Dialog> dialog) = 0

Wait until the user closed the dialog in some way.

May be called in any thread.

void stopDialog(std::shared_ptr<Dialog> dialog) = 0

This method implements the ui mode specific mechanism for stopping (i.e. closing) a dialog.

Must be called in main thread.

void showDialog(std::shared_ptr<Dialog> dialog) = 0

This method implements the ui mode specific mechanism for showing a dialog.

Must be called in main thread.

Private Members

QHash<qint64, std::shared_ptr<Dialog>> _openDialogs
qint64 _nextDialogId = 0

Friends

friend class Dialog