CuteHMI - CuteHMI (CuteHMI.2)
cutehmi::Message Class Reference

Message. More...

#include <cutehmi/Message.hpp>

Inheritance diagram for cutehmi::Message:
QObject CuteHMI::Message

Public Types

enum  Type { INFO = 1 , WARNING = 2 , CRITICAL = 3 , QUESTION = 4 }
 
enum  Button : qint32 {
  BUTTON_OK = 0x00000400 , BUTTON_OPEN = 0x00002000 , BUTTON_SAVE = 0x00000800 , BUTTON_CANCEL = 0x00400000 ,
  BUTTON_CLOSE = 0x00200000 , BUTTON_DISCARD = 0x00800000 , BUTTON_APPLY = 0x02000000 , BUTTON_RESET = 0x04000000 ,
  BUTTON_RESTORE_DEFAULTS = 0x08000000 , BUTTON_HELP = 0x01000000 , BUTTON_SAVE_ALL = 0x00001000 , BUTTON_YES = 0x00004000 ,
  BUTTON_YES_TO_ALL = 0x00008000 , BUTTON_NO = 0x00010000 , BUTTON_NO_TO_ALL = 0x00020000 , BUTTON_ABORT = 0x00040000 ,
  BUTTON_RETRY = 0x00080000 , BUTTON_IGNORE = 0x00100000 , NO_BUTTON = 0x00000000
}
 Dialog button. More...
 

Public Slots

void acceptResponse (cutehmi::Message::Button response)
 Accept response. More...
 

Signals

void typeChanged ()
 
void textChanged ()
 
void informativeTextChanged ()
 
void detailedTextChanged ()
 
void buttonsChanged ()
 
void responseChanged ()
 
void responseArrived (cutehmi::Message::Button response)
 

Public Member Functions

 Message (Type type=INFO, const QString &text=QString(), Buttons buttons=Message::NO_BUTTON, QObject *parent=nullptr)
 Constructor. More...
 
 Message (Type type, const QString &text, const QString &informativeText, Buttons buttons=Message::NO_BUTTON, QObject *parent=nullptr)
 Constructor. More...
 
 Message (Type type, const QString &text, const QString &informativeText, const QString &detailedText, Buttons buttons=Message::NO_BUTTON, QObject *parent=nullptr)
 Constructor. More...
 
 ~Message () override=default
 Destructor. More...
 
Type type () const
 Get dialog type. More...
 
void setType (Type type)
 Set dialog type. More...
 
QString text () const
 Get text. More...
 
void setText (const QString &text)
 Set text. More...
 
QString informativeText () const
 Get informative text. More...
 
void setInformativeText (const QString &informativeText)
 Set informative text. More...
 
QString detailedText () const
 Get detailed text. More...
 
void setDetailedText (const QString &detailedText)
 Set detailed text. More...
 
Buttons buttons () const
 Get message dialog buttons. More...
 
void setButtons (Buttons buttons)
 Set buttons. More...
 
Button response () const
 Get user response. More...
 
std::unique_ptr< Messageclone () const
 Clone message. More...
 
Button exec ()
 Block until user provides a response. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Member Functions

static std::unique_ptr< MessageInfo (const QString &text, Message::Buttons buttons=Message::BUTTON_OK)
 Notice message. More...
 
static std::unique_ptr< MessageWarning (const QString &text, Message::Buttons buttons=Message::BUTTON_OK)
 Warning message. More...
 
static std::unique_ptr< MessageQuestion (const QString &text, Message::Buttons buttons=Message::Buttons{Message::BUTTON_YES, Message::BUTTON_NO})
 Question. More...
 
static std::unique_ptr< MessageCritical (const QString &text, Message::Buttons buttons=Message::BUTTON_OK)
 Critical message. More...
 
static std::unique_ptr< MessageCritical (const ErrorInfo &errorInfo, Message::Buttons buttons=Message::BUTTON_OK)
 Critical message. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Properties

Type type
 
QString text
 
QString informativeText
 
QString detailedText
 
Buttons buttons
 
Button response
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

Message.

Member Enumeration Documentation

◆ Button

enum cutehmi::Message::Button : qint32

Dialog button.

Remarks
This enum is registered as metatype by Init instance.
Enumerator
BUTTON_OK 
BUTTON_OPEN 
BUTTON_SAVE 
BUTTON_CANCEL 
BUTTON_CLOSE 
BUTTON_DISCARD 
BUTTON_APPLY 
BUTTON_RESET 
BUTTON_RESTORE_DEFAULTS 
BUTTON_HELP 
BUTTON_SAVE_ALL 
BUTTON_YES 
BUTTON_YES_TO_ALL 
BUTTON_NO 
BUTTON_NO_TO_ALL 
BUTTON_ABORT 
BUTTON_RETRY 
BUTTON_IGNORE 
NO_BUTTON 

◆ Type

Enumerator
INFO 
WARNING 
CRITICAL 
QUESTION 

Constructor & Destructor Documentation

◆ Message() [1/3]

cutehmi::Message::Message ( Type  type = INFO,
const QString text = QString(),
Buttons  buttons = Message::NO_BUTTON,
QObject parent = nullptr 
)
explicit

Constructor.

Parameters
typedialog type.
textmessage for the user.
buttonsmessage dialog buttons.
parentparent object.

◆ Message() [2/3]

cutehmi::Message::Message ( Type  type,
const QString text,
const QString informativeText,
Buttons  buttons = Message::NO_BUTTON,
QObject parent = nullptr 
)

Constructor.

Parameters
typedialog type.
textmessage for the user.
informativeTextinformative message.
buttonsmessage dialog buttons.
parentparent object.

◆ Message() [3/3]

cutehmi::Message::Message ( Type  type,
const QString text,
const QString informativeText,
const QString detailedText,
Buttons  buttons = Message::NO_BUTTON,
QObject parent = nullptr 
)

Constructor.

Parameters
typedialog type.
textmessage for the user.
informativeTextinformative message.
detailedTextdetailed message.
buttonsmessage dialog buttons.
parentparent object.

◆ ~Message()

cutehmi::Message::~Message ( )
overridedefault

Destructor.

Member Function Documentation

◆ acceptResponse

void cutehmi::Message::acceptResponse ( cutehmi::Message::Button  response)
slot

Accept response.

Normally a response can be accepted only once. Subsequent calls of this function will not change the value of response property and should be avoided.

Parameters
responseresponse to be set.

◆ buttons()

Message::Buttons cutehmi::Message::buttons ( ) const

Get message dialog buttons.

Returns
message dialog buttons available to the user.

◆ buttonsChanged

void cutehmi::Message::buttonsChanged ( )
signal

◆ clone()

std::unique_ptr< Message > cutehmi::Message::clone ( ) const

Clone message.

Returns
message clone.

◆ Critical() [1/2]

std::unique_ptr< Message > cutehmi::Message::Critical ( const ErrorInfo errorInfo,
Message::Buttons  buttons = Message::BUTTON_OK 
)
static

Critical message.

Convenient function that creates critical dialog from ErrorInfo object and advertises it through Messenger instance.

Parameters
errorInfoerror info object.
buttonsmessage dialog buttons.
Returns
message instance.

◆ Critical() [2/2]

std::unique_ptr< Message > cutehmi::Message::Critical ( const QString text,
Message::Buttons  buttons = Message::BUTTON_OK 
)
static

Critical message.

Convenient function that creates critical dialog and advertises it through Messenger instance.

Parameters
textmessage for the user.
buttonsmessage dialog buttons.
Returns
message instance.

◆ detailedText()

QString cutehmi::Message::detailedText ( ) const

Get detailed text.

Returns
detailed message for the user.

◆ detailedTextChanged

void cutehmi::Message::detailedTextChanged ( )
signal

◆ exec()

Message::Button cutehmi::Message::exec ( )

Block until user provides a response.

This function creates local event loop and blocks until user provides a response. Before calling exec() you have to connect some signal to acceptResponse() slot.

Returns
user response.
Note
nested event loops should be avoided in general.
Returns
button that has been pressed by the user.

◆ Info()

std::unique_ptr< Message > cutehmi::Message::Info ( const QString text,
Message::Buttons  buttons = Message::BUTTON_OK 
)
static

Notice message.

Convenient function that creates informative dialog and advertises it through Messenger instance.

Parameters
textmessage for the user.
buttonsmessage dialog buttons.
Returns
message instance.

◆ informativeText()

QString cutehmi::Message::informativeText ( ) const

Get informative text.

Returns
informative message for the user.

◆ informativeTextChanged

void cutehmi::Message::informativeTextChanged ( )
signal

◆ Question()

std::unique_ptr< Message > cutehmi::Message::Question ( const QString text,
Message::Buttons  buttons = Message::Buttons{Message::BUTTON_YESMessage::BUTTON_NO} 
)
static

Question.

Convenient function that creates question dialog and advertises it through Messenger instance.

Parameters
textmessage for the user.
buttonsmessage dialog buttons.
Returns
message instance.

◆ response()

Message::Button cutehmi::Message::response ( ) const

Get user response.

Returns
button that has been pressed by the user or Message::NO_BUTTON if user didn't make a choice.

◆ responseArrived

void cutehmi::Message::responseArrived ( cutehmi::Message::Button  response)
signal

◆ responseChanged

void cutehmi::Message::responseChanged ( )
signal

◆ setButtons()

void cutehmi::Message::setButtons ( Buttons  buttons)

Set buttons.

Parameters
buttonsbuttons that should be available to the user.

◆ setDetailedText()

void cutehmi::Message::setDetailedText ( const QString detailedText)

Set detailed text.

Parameters
detailedTextdetailed message for the user.

◆ setInformativeText()

void cutehmi::Message::setInformativeText ( const QString informativeText)

Set informative text.

Parameters
informativeTextinformative message for the user.

◆ setText()

void cutehmi::Message::setText ( const QString text)

Set text.

Parameters
textmessage for the user.

◆ setType()

void cutehmi::Message::setType ( Type  type)

Set dialog type.

Parameters
typedialog type.

◆ text()

QString cutehmi::Message::text ( ) const

Get text.

Returns
text message for the user.

◆ textChanged

void cutehmi::Message::textChanged ( )
signal

◆ type()

Message::Type cutehmi::Message::type ( ) const

Get dialog type.

Returns
dialog type.

◆ typeChanged

void cutehmi::Message::typeChanged ( )
signal

◆ Warning()

std::unique_ptr< Message > cutehmi::Message::Warning ( const QString text,
Message::Buttons  buttons = Message::BUTTON_OK 
)
static

Warning message.

Convenient function that creates warning dialog and advertises it through Messenger instance.

Parameters
textmessage for the user.
buttonsmessage dialog buttons.
Returns
message instance.

Property Documentation

◆ buttons

Buttons cutehmi::Message::buttons
readwrite

◆ detailedText

QString cutehmi::Message::detailedText
readwrite

◆ informativeText

QString cutehmi::Message::informativeText
readwrite

◆ response

Button cutehmi::Message::response
read

◆ text

QString cutehmi::Message::text
readwrite

◆ type

Type cutehmi::Message::type
readwrite