QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
Public Types | Public Member Functions | Properties | List of all members
QtMvvm::MessageConfig Class Reference

A configuration for a simple dialog to be shown from the core code. More...

#include <message.h>

Public Types

enum  StandardButton {
  NoButton = 0x00000000, Ok = 0x00000400, Save = 0x00000800, SaveAll = 0x00001000,
  Open = 0x00002000, Yes = 0x00004000, YesToAll = 0x00008000, No = 0x00010000,
  NoToAll = 0x00020000, Abort = 0x00040000, Retry = 0x00080000, Ignore = 0x00100000,
  Close = 0x00200000, Cancel = 0x00400000, Discard = 0x00800000, Help = 0x01000000,
  Apply = 0x02000000, Reset = 0x04000000, RestoreDefaults = 0x08000000
}
 The Possible Buttons a dialog can have. More...
 

Public Member Functions

 MessageConfig (const QByteArray &type=TypeMessageBox, const QByteArray &subType={})
 Default constructor, can take a type and a subtype.
 
 MessageConfig (const MessageConfig &other)
 Copy constructor.
 
 MessageConfig (MessageConfig &&other) noexcept
 Move constructor.
 
MessageConfigoperator= (const MessageConfig &other)
 Copy assignment operator.
 
MessageConfigoperator= (MessageConfig &&other) noexcept
 Move assignment operator.
 
QByteArray type () const
 READ accessor for MessageConfig::type.
 
QByteArray subType () const
 READ accessor for MessageConfig::subType.
 
QString title () const
 READ accessor for MessageConfig::title.
 
QString text () const
 READ accessor for MessageConfig::text.
 
StandardButtons buttons () const
 READ accessor for MessageConfig::buttons.
 
QHash< StandardButton, QStringbuttonTexts () const
 READ accessor for MessageConfig::buttonTexts.
 
QVariant defaultValue () const
 READ accessor for MessageConfig::defaultValue.
 
QVariantMap viewProperties () const
 READ accessor for MessageConfig::viewProperties.
 
MessageConfigsetType (const QByteArray &type)
 WRITE accessor for MessageConfig::type.
 
MessageConfigsetSubType (const QByteArray &subType)
 WRITE accessor for MessageConfig::subType.
 
MessageConfigsetTitle (const QString &title)
 WRITE accessor for MessageConfig::title.
 
MessageConfigsetText (const QString &text)
 WRITE accessor for MessageConfig::text.
 
MessageConfigsetButtons (StandardButtons buttons)
 WRITE accessor for MessageConfig::buttons.
 
MessageConfigaddButton (StandardButton button)
 WRITE accessor for MessageConfig::buttons.
 
MessageConfigsetButtonTexts (const QHash< StandardButton, QString > &buttonTexts)
 WRITE accessor for MessageConfig::buttonTexts.
 
MessageConfigsetButtonText (StandardButton button, const QString &text)
 WRITE accessor for MessageConfig::buttonTexts.
 
MessageConfigsetDefaultValue (const QVariant &defaultValue)
 WRITE accessor for MessageConfig::defaultValue.
 
MessageConfigsetViewProperties (const QVariantMap &viewProperties)
 WRITE accessor for MessageConfig::viewProperties.
 
MessageConfigsetViewProperty (const QString &key, const QVariant &value)
 WRITE accessor for MessageConfig::viewProperties.
 
MessageConfigresetSubType ()
 RESET accessor for MessageConfig::subType.
 
MessageConfigresetButtons ()
 RESET accessor for MessageConfig::buttons.
 

Static Public Attributes

Possible standard values for MessageConfig::type
static const QByteArray TypeMessageBox
 A type to show a standard message box. More...
 
static const QByteArray TypeInputDialog
 A type to show a generic input dialog. More...
 
static const QByteArray TypeFileDialog
 A type to show a generic file dialog. More...
 
static const QByteArray TypeColorDialog
 A type to show a generic color dialog. More...
 
static const QByteArray TypeProgressDialog
 A type to show a generic progress dialog. More...
 
Possible values for MessageConfig::subType when using the type MessageConfig::TypeMessageBox
static const QByteArray SubTypeInformation
 A subType to show an information message. More...
 
static const QByteArray SubTypeWarning
 A subType to show a warning message. More...
 
static const QByteArray SubTypeCritical
 A subType to show a critical error message. More...
 
static const QByteArray SubTypeQuestion
 A subType to show a question message. More...
 
static const QByteArray SubTypeAbout
 A subType to show an about dialog. More...
 
Possible values for MessageConfig::subType when using the type MessageConfig::TypeFileDialog
static const QByteArray SubTypeDir
 A subType to show an open directory dialog. More...
 
static const QByteArray SubTypeOpenFile
 A subType for to show an open file dialog. More...
 
static const QByteArray SubTypeOpenFiles
 A subType for to show an open files dialog. More...
 
static const QByteArray SubTypeSaveFile
 A subType for to show a save file dialog. More...
 
Possible values for MessageConfig::subType when using the type MessageConfig::TypeColorDialog
static const QByteArray SubTypeRgb
 A subType to show a color dialog without an alpha channel. More...
 
static const QByteArray SubTypeArgb
 A subType to show a color dialog with an alpha channel. More...
 
Possible values for MessageConfig::subType when using the type MessageConfig::TypeProgressDialog
static const QByteArray SubTypeProgress
 A subType to show a dialog with a progress bar. More...
 
static const QByteArray SubTypeBusy
 A subType to show a dialog with a busy indicator. More...
 

Properties

QByteArray type
 The general type of dialog to be shown. More...
 
QByteArray subType
 A subtype for the dialog to specify what exactly it should show. More...
 
QString title
 The dialog title or window title. More...
 
QString text
 The primary text/message to be displayed. More...
 
StandardButtons buttons
 The available buttons a user may press. More...
 
QVariantMap buttonTexts
 A map of name overwrites for the texts shown on buttons. More...
 
QVariant defaultValue
 A default value for dialogs that take some kind of input. More...
 
QVariantMap viewProperties
 Additional properties to be set on the created views. More...
 

Detailed Description

A configuration for a simple dialog to be shown from the core code.

You can use the configuration to show simple dialogs from the core application. Typically, you can use the wrapper methods, but for more advanced dialogs you may need to create a message config explicitly.

See also
CoreApp::showDialog, QtMvvm::information, QtMvvm::question, QtMvvm::warning, QtMvvm::critical, QtMvvm::about, QtMvvm::getInput, QtMvvm::getExistingDirectory, QtMvvm::getOpenFile, QtMvvm::getOpenFiles, QtMvvm::getSaveFile

Definition at line 20 of file message.h.

Member Enumeration Documentation

◆ StandardButton

The Possible Buttons a dialog can have.

Note
The values are kept in sync with QMessageBox::StandardButton etc. This means you can simply cast the values to the other standard buttons without any risk. This goes for other classes like QDialogButtonBox and the QML variants as well.
Enumerator
NoButton 

Equivalent to QMessageBox::NoButton.

Ok 

Equivalent to QMessageBox::Ok.

Save 

Equivalent to QMessageBox::Save.

SaveAll 

Equivalent to QMessageBox::SaveAll.

Open 

Equivalent to QMessageBox::Open.

Yes 

Equivalent to QMessageBox::Yes.

YesToAll 

Equivalent to QMessageBox::YesToAll.

No 

Equivalent to QMessageBox::No.

NoToAll 

Equivalent to QMessageBox::NoToAll.

Abort 

Equivalent to QMessageBox::Abort.

Retry 

Equivalent to QMessageBox::Retry.

Ignore 

Equivalent to QMessageBox::Ignore.

Close 

Equivalent to QMessageBox::Close.

Cancel 

Equivalent to QMessageBox::Cancel.

Discard 

Equivalent to QMessageBox::Discard.

Help 

Equivalent to QMessageBox::Help.

Apply 

Equivalent to QMessageBox::Apply.

Reset 

Equivalent to QMessageBox::Reset.

RestoreDefaults 

Equivalent to QMessageBox::RestoreDefaults.

Definition at line 46 of file message.h.

Member Data Documentation

◆ SubTypeAbout

QtMvvm::MessageConfig::SubTypeAbout
static

A subType to show an about dialog.

Value: "about"

An about dialog is a simple informative dialog showing information about the application in a neutral manner, but in a sligthly different style than a simple information message.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox

Definition at line 100 of file message.h.

◆ SubTypeArgb

QtMvvm::MessageConfig::SubTypeArgb
static

A subType to show a color dialog with an alpha channel.

Value: "argb"

A color dialog that lets the user select a color, including the alpha channel. Please note that not all native dialogs support alpha channel editing.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeColorDialog

Definition at line 124 of file message.h.

◆ SubTypeBusy

QtMvvm::MessageConfig::SubTypeBusy
static

A subType to show a dialog with a busy indicator.

Value: "busy"

A dialog with a busy indicator shown. This indicator can and will always only show an indeterminate progress, other values of the ProgressControl are ignored. On platforms that do not have a seperate busy indicator, an indeterminate progress bar can be shown.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeProgressDialog, ProgressControl

Definition at line 134 of file message.h.

◆ SubTypeCritical

QtMvvm::MessageConfig::SubTypeCritical
static

A subType to show a critical error message.

Value: "critical"

An critical message box typically shows a critical and often unrecoverable error.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox

Definition at line 96 of file message.h.

◆ SubTypeDir

QtMvvm::MessageConfig::SubTypeDir
static

A subType to show an open directory dialog.

Value: "dir"

A file dialog to open a directory lets the user select a single, existing directory. Depending on the platform he might be able to create a new directory via the dialog, but he can only select an existing one.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog

Definition at line 108 of file message.h.

◆ SubTypeInformation

QtMvvm::MessageConfig::SubTypeInformation
static

A subType to show an information message.

Value: "information"

An information message box typically shows a neutral/positiv information.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox

Definition at line 92 of file message.h.

◆ SubTypeOpenFile

QtMvvm::MessageConfig::SubTypeOpenFile
static

A subType for to show an open file dialog.

Value: "open"

A file dialog to open a file lets the user select a single, existing file.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog

Definition at line 110 of file message.h.

◆ SubTypeOpenFiles

QtMvvm::MessageConfig::SubTypeOpenFiles
static

A subType for to show an open files dialog.

Value: "files"

A file dialog to open multiple files lets the user select a list of existing files. They can be in different folders, if the platform allows this.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog

Definition at line 112 of file message.h.

◆ SubTypeProgress

QtMvvm::MessageConfig::SubTypeProgress
static

A subType to show a dialog with a progress bar.

Value: "progress"

A dialog with a standard progess bar. This bar can either display a classical progress with min, max and value, or be shown as indeterminate progress (can be switched dynamically via the ProgressControl)

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeProgressDialog, ProgressControl

Definition at line 132 of file message.h.

◆ SubTypeQuestion

QtMvvm::MessageConfig::SubTypeQuestion
static

A subType to show a question message.

Value: "question"

An question message box typically asks the user a simple Yes-No question he can reply using the buttons.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox

Definition at line 98 of file message.h.

◆ SubTypeRgb

QtMvvm::MessageConfig::SubTypeRgb
static

A subType to show a color dialog without an alpha channel.

Value: "rgb"

A color dialog that lets the user select a color, without allowing editing of the alpha channel. The alpha channel will always be set to 0xFF, i.e. non transparent.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeColorDialog

Definition at line 122 of file message.h.

◆ SubTypeSaveFile

QtMvvm::MessageConfig::SubTypeSaveFile
static

A subType for to show a save file dialog.

Value: "save"

A file dialog to save a file lets the user select a single file to be created or overwritten to save content to it.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog

Definition at line 114 of file message.h.

◆ SubTypeWarning

QtMvvm::MessageConfig::SubTypeWarning
static

A subType to show a warning message.

Value: "warning"

An warning message box typically shows a (non critical) warning.

See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox

Definition at line 94 of file message.h.

◆ TypeColorDialog

QtMvvm::MessageConfig::TypeColorDialog
static

A type to show a generic color dialog.

Value: "color"

Shows a generic color dialog. If possible, this will use the systems default, otherwise a simple color picker gui.

Dialog Type subType value
Select a color without alpha MessageConfig::SubTypeRgb
Select a color with alpha MessageConfig::SubTypeArgb
See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog

Definition at line 82 of file message.h.

◆ TypeFileDialog

QtMvvm::MessageConfig::TypeFileDialog
static

A type to show a generic file dialog.

Value: "file"

Shows a generic file dialog utilizing the operating systems default file dialogs in order to show a native dialog the user can use to select files or directories

Dialog Type subType value
Open Directory MessageConfig::SubTypeDir
Open File MessageConfig::SubTypeOpenFile
Open Files MessageConfig::SubTypeOpenFiles
Save File MessageConfig::SubTypeSaveFile
See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog, MessageConfig::TypeMessageBox

Definition at line 80 of file message.h.

◆ TypeInputDialog

QtMvvm::MessageConfig::TypeInputDialog
static

A type to show a generic input dialog.

Value: "input"

Shows a generic input dialog with a title and a short label, together with some kind of edit view in order to input a single value. The datatype to get as well as the kind of input view to create is determined by MessageConfig:subType. Theoretically, and type that can be passed via QVariant can be used as input value. However, only for the most common types do default edit views exist. In case you want to use types not present in the list below, you need to create edit views yourself

Type Widgets edit Quick edit Quick delegate
bool QCheckBox CheckBox BoolDelegate
switch QCheckBox Switch SwitchDelegate
QString, string QLineEdit TextField MsgDelegate (*)
int QSpinBox SpinBox MsgDelegate
double, number QDoubleSpinBox DoubleSpinBox MsgDelegate
range (int) QSlider Slider RangeDelegate
QDate QDateEdit DateEdit MsgDelegate
QTime QTimeEdit TimeEdit MsgDelegate
QDateTime, date QDateTimeEdit DateTimeEdit MsgDelegate
QColor, color ColorButton ColorEdit ColorDelegate
QFont, font QFontComboBox FontEdit MsgDelegate
QKeySequence QKeySequenceEdit -/- -/-
QUrl, url QLineEdit with QUrlValidator UrlField MsgDelegate
selection, list QComboBox ListEdit ListDelegate
radiolist -/- RadioListEdit -/-
action (settings only) QPushButton -/- ItemDelegate

(*) The MsgDelegate is used for any type but the ones that have explicit delegates. It will show a dialog with an input of the "Quick edit" column

The following types have special properties as well:

  • QString, string:
  • QUrl, url:
    • allowedSchemes: A QStringList with allowed schemes for the URL
  • selection, list, radiolist:
    • listElements: A list of elemets the user can select from. Can either be:
      • QString elements: They will serve as display value and returned value
      • QVariantMap elements: A map containing the following values:
        • name: A QString shown to the user to select
        • value: A QVariant value that is returned instead of the selected name
See also
MessageConfig::type, MessageConfig::subType, InputViewFactory, InputWidgetFactory, MessageConfig::TypeMessageBox, MessageConfig::TypeFileDialog

Definition at line 78 of file message.h.

◆ TypeMessageBox

QtMvvm::MessageConfig::TypeMessageBox
static

A type to show a standard message box.

Value: "msgbox"

Shows a generic message box with a title and primary text to inform the user of some kind of event or ask him a question. The MessageConfig:subType is used to determine the kind of message to show:

Message Type subType value
Information MessageConfig::SubTypeInformation
Question MessageConfig::SubTypeWarning
Warning MessageConfig::SubTypeCritical
Critical Error MessageConfig::SubTypeQuestion
About Dialog MessageConfig::SubTypeAbout

The widgets implementation does support a few extra properties for this type:

  • modal (bool = true), configure application modality
  • windowTitle (QString), the window title
  • details (QString), the message box details box
  • checkable (bool = false), gives the messagebox a small checkbox
  • checkString (QString), the string to display for that checkbox
See also
MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog, MessageConfig::TypeFileDialog

Definition at line 76 of file message.h.

◆ TypeProgressDialog

QtMvvm::MessageConfig::TypeProgressDialog
static

A type to show a generic progress dialog.

Value: "progress"

Shows a generic progress dialog. The dialog can by dynamically and asynchronously controlled from the core app via the ProgressControl class. You must pass an instance of a ProgressControl via the MessageConfig::defaultValue property when creating one yourself. The passed control will automatically be connected to the corresponding dialog.

Dialog Type subType value
Display a progress bar MessageConfig::SubTypeProgress
Display a busy indicator MessageConfig::SubTypeBusy
See also
MessageConfig::type, MessageConfig::subType, ProgressControl

Definition at line 84 of file message.h.

Property Documentation

◆ buttons

QtMvvm::MessageConfig::buttons
readwrite

The available buttons a user may press.

Default: Depends on the type used

The buttons are the buttons in the dialog to "complete" it. Use these flags to select the buttons the user can click on. Each button will close the dialog and be reported back via the MessageResult::dialogDone signal.

Note
The RESET-Accessor will reset both, the buttons and the buttonTexts
Accessors
READbuttons()
WRITEsetButtons()
WRITEaddButton()
RESETresetButtons()
See also
MessageConfig::StandardButton, MessageConfig::buttonTexts, MessageResult::dialogDone

Definition at line 35 of file message.h.

◆ buttonTexts

QtMvvm::MessageConfig::buttonTexts
readwrite

A map of name overwrites for the texts shown on buttons.

Default: Empty

All buttons in this map will be shown in addition to the ones in the MessageConfig::buttons property. The will keep their role, but show the text specified in the map instead of their normal text.

Note
The RESET-Accessor will reset both, the buttons and the buttonTexts
Accessors
READbuttonTexts()
WRITEsetButtonTexts()
WRITEsetButtonText()
RESETresetButtons()
See also
MessageConfig::StandardButton, MessageConfig::buttons

Definition at line 37 of file message.h.

◆ defaultValue

QtMvvm::MessageConfig::defaultValue
readwrite

A default value for dialogs that take some kind of input.

Default: Invalid

Some dialogs allow the users to enter some kind of result besides of the buttons they can press. For such dialogs, this property can be used to provide the input with a default value. For others, this may serve as a hint for the input.

Accessors
READdefaultValue()
WRITEsetDefaultValue()
See also
MessageConfig::type

Definition at line 40 of file message.h.

◆ subType

QtMvvm::MessageConfig::subType
readwrite

A subtype for the dialog to specify what exactly it should show.

Default: Depends on the type used

The subType is a finer specification of what kind of dialog to show. It depends on the MessageConfig::type that is used. The possible valid subtypes depend on the MessageConfig::type used.

It is possible to define your own subtypes, but that means you have to customize the presenters to add support for those dialogs.

The subtypes supported by default are:

Accessors
READsubType()
WRITEsetSubType()
RESETresetSubType()
See also
MessageConfig::type, MessageConfig::TypeMessageBox, MessageConfig::TypeInputDialog, MessageConfig::TypeFileDialog

Definition at line 28 of file message.h.

◆ text

QtMvvm::MessageConfig::text
readwrite

The primary text/message to be displayed.

Default: Emtpy

The text is shown as primary content, a more descriptive label, or tooltip or similar. It can be of arbitrary length. It's role and contents heavily depend on the type and subtype beeing used.

Accessors
READtext()
WRITEsetText()
See also
MessageConfig::title, MessageConfig::buttonTexts, MessageConfig::viewProperties

Definition at line 33 of file message.h.

◆ title

QtMvvm::MessageConfig::title
readwrite

The dialog title or window title.

Default: Emtpy

The title is typically bigger then the rest of the text and serves as a short text to hint the content. Depending on the platform and type it may be shown as window title or other kind of decorative text.

Accessors
READtitle()
WRITEsetTitle()
See also
MessageConfig::text

Definition at line 31 of file message.h.

◆ type

QtMvvm::MessageConfig::type
readwrite

The general type of dialog to be shown.

Default: MessageConfig::TypeMessageBox

The type determines what kind of dialog is show. The type is a general category of dialogs. The MessageConfig::subType is used to set the final type of dialog shown. It's interpretation depends on the type used.

It is possible to define your own types, but that means you have to customize the presenters to add support for those dialogs.

The types supported by default are:

Accessors
READtype()
WRITEsetType()
See also
MessageConfig::subType, MessageConfig::TypeMessageBox, MessageConfig::TypeInputDialog, MessageConfig::TypeFileDialog, MessageConfig::TypeColorDialog, MessageConfig::TypeProgressDialog

Definition at line 26 of file message.h.

◆ viewProperties

QtMvvm::MessageConfig::viewProperties
readwrite

Additional properties to be set on the created views.

Default: Empty

The view properties are additional properties to be set on the created views. This allows you to configure the appearance of the dialog from within the core code.

Note
The properties are always set on all views. If a view does not have such a property, it will do nothing. This allows you to set properties for all the different views you support.
Accessors
READviewProperties()
WRITEsetViewProperties()
WRITEsetViewProperty()
See also
MessageConfig::type

Definition at line 42 of file message.h.


The documentation for this class was generated from the following files: