NDEVR
API Documentation
QCustomMessageBox

A message box displays a primary text to alert the user to a situation, an informative text to further explain the situation, and an optional detailed text to provide even more data if the user requests it. More...

Inheritance diagram for QCustomMessageBox:
[legend]
Collaboration diagram for QCustomMessageBox:
[legend]

Public Member Functions

void clearButtons ()
 Removes all buttons from the message box.
virtual bool processKeyEvent (const StringView &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) override
 Processes a key event for keyboard interaction with the message box.
virtual void resetKeyControllerToDefaults () override
 Resets the key controller bindings to their default values.
void setButtons (const Buffer< TranslatedString > &button_labels)
 Replaces the current buttons with custom labeled buttons.
void setButtons (QMessageBox::StandardButtons buttons)
 Replaces the current buttons with a set of standard Qt buttons.
void setCallback (std::function< void(QMessageBox::StandardButton, PopupInfo)> callback)
 Sets the callback invoked when a standard button is pressed.
void setGenericOptionCallback (std::function< void(GenericOption, PopupInfo)> callback)
 Sets the callback invoked when a generic option entry is submitted.
void setIcon (const StringView &image, fltp08 icon_size_mult=1.0)
 Sets the icon displayed in the message box.
void setLabelCallback (std::function< void(TranslatedString, PopupInfo)> callback)
 Sets the callback invoked when a custom labeled button is pressed.
void setText (const TranslatedString &text)
 Sets the main informational text displayed in the message box.
QSize sizeHint () const override
 Returns the recommended size for the message box.
Public Member Functions inherited from BasicKeyController
 BasicKeyController (const TranslatedString &key_controller_title)
 Constructs a BasicKeyController with the given title.
virtual void addKeyOption (const KeyOption &option)
 Adds a new key option mapping to this controller.
const Buffer< KeyOption > & currentKeyMaps () const
 Returns the current set of key option mappings.
virtual void getINI (INIFactory &factory) override
 Serializes or deserializes key controller settings to/from an INI file.
const TranslatedStringkeyControllerTitle () const
 Returns the display title of this key controller.
bool processKeyEvent (const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) final override
 Processes a key event by matching it against registered key options.
virtual void setKeyOption (const KeyOption &option)
 Sets or updates an existing key option mapping.
Public Member Functions inherited from INIInterface
 INIInterface ()
 Constructs an INIInterface with no default INI file.
 INIInterface (const File &default_ini)
 Constructs an INIInterface with the specified default INI file.
virtual ~INIInterface ()
 Virtual destructor for safe polymorphic cleanup.
virtual void finishReadingINI (INIFactory &)
 Called after reading an INI file.
virtual void prepareForINI (INIFactory &)
 Called before reading or writing an INI file.
virtual bool readINIOptions ()
 Reads INI options from the default INI file.
virtual bool readINIOptions (File &ini_file)
 Reads INI options from the specified INI file.
virtual bool saveINIOptions (bool multithead=false)
 Saves INI options to the default INI file.
virtual bool saveINIOptions (File &ini_file, bool multithead=false)
 Saves INI options to the specified INI file.
void setDefaultINIFile (const File &file)
 Sets the default INI file path used for reading and writing options.
virtual void writeToLog (const StringView &title, LogPtr log, uint01 log_level=2U)
 Writes the current INI options to the specified log with a title.
virtual void writeToLog (LogPtr log, uint01 log_level=2U)
 Writes the current INI options to the specified log.

Static Public Member Functions

static QCustomMessageBoxCreateMessageBox (const GenericOption &entry_type, std::function< void(GenericOption, PopupInfo)> on_select=nullptr)
 Creates a message box with a generic option entry and displays it as a popup.
static QCustomMessageBoxCreateMessageBox (const TranslatedString &title, const TranslatedString &text, const Buffer< TranslatedString > &button_labels, std::function< void(TranslatedString, PopupInfo)> on_select=nullptr)
 Creates a message box with custom labeled buttons and displays it as a popup.
static QCustomMessageBoxCreateMessageBox (const TranslatedString &title, const TranslatedString &text, QMessageBox::StandardButtons buttons, std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select=nullptr)
 Creates a message box with standard Qt buttons and displays it as a popup.

Protected Member Functions

 QCustomMessageBox (const GenericOption &entry_type, std::function< void(GenericOption, PopupInfo)> on_select)
 Constructs a message box with a generic option entry for user input.
 QCustomMessageBox (const TranslatedString &title, const TranslatedString &text, const Buffer< TranslatedString > &button_labels, std::function< void(TranslatedString, PopupInfo)> on_select=nullptr)
 Constructs a message box with custom labeled buttons.
 QCustomMessageBox (const TranslatedString &title, const TranslatedString &text, QMessageBox::StandardButtons buttons, std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select=nullptr)
 Constructs a message box with standard Qt buttons.
void addButtonsToLayout ()
 Adds the current set of buttons to the message box layout.
void buttonPressed (const TranslatedString &button_label, PopupInfo)
 Handles the event when a custom labeled button is pressed.
void buttonPressed (QMessageBox::StandardButton button, PopupInfo)
 Handles the event when a standard button is pressed.

Protected Attributes

Buffer< Button * > m_buttons
 The collection of buttons displayed in the message box.
std::function< void(QMessageBox::StandardButton, PopupInfo)> m_callback
 Callback for standard button selection.
GenericOption m_generic_option
 The generic option used for user input collection.
ImageViewm_image_view
 The image view widget displaying the icon.
std::function< void(TranslatedString, PopupInfo)> m_label_callback
 Callback for custom labeled button selection.
String m_pixmap
 The icon resource name for the message box icon.
QLabel * m_text
 The label displaying the main message text.
QHBoxLayout * m_top_layout
 The top horizontal layout containing the icon and text.
std::function< void(GenericOption, PopupInfo)> m_user_entry_callback
 Callback for generic option entry submission.
Protected Attributes inherited from BasicKeyController
TranslatedString m_key_controller_title
 The display title for this key controller.
Buffer< KeyOptionm_key_options
 The collection of registered key option mappings.
bool m_save_ini_on_change_key_option_change = false
 Whether to automatically save INI settings when a key option changes.
Protected Attributes inherited from INIInterface
File m_default_ini
 The default file path used for reading and writing INI options.

Static Protected Attributes

static Dictionary< UUID, QPointer< QCustomMessageBox > > s_message_boxes
 Global registry of active message boxes keyed by UUID.

Detailed Description

A message box displays a primary text to alert the user to a situation, an informative text to further explain the situation, and an optional detailed text to provide even more data if the user requests it.


The interface for this object allows from either a set of predefined user options (OK, Load, Cancel, etc) or a set of program defined responses that the user can choose from.

Definition at line 61 of file QCustomMessageBox.h.

Constructor & Destructor Documentation

◆ QCustomMessageBox() [1/3]

QCustomMessageBox::QCustomMessageBox ( const TranslatedString & title,
const TranslatedString & text,
QMessageBox::StandardButtons buttons,
std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select = nullptr )
protected

Constructs a message box with standard Qt buttons.

Parameters
[in]titleThe title text displayed at the top of the message box.
[in]textThe main informational text displayed in the message box.
[in]buttonsThe set of standard buttons to display (e.g., OK, Cancel).
[in]on_selectOptional callback invoked when the user selects a standard button.

Referenced by QCustomMessageBox(), CreateMessageBox(), CreateMessageBox(), and CreateMessageBox().

◆ QCustomMessageBox() [2/3]

QCustomMessageBox::QCustomMessageBox ( const TranslatedString & title,
const TranslatedString & text,
const Buffer< TranslatedString > & button_labels,
std::function< void(TranslatedString, PopupInfo)> on_select = nullptr )
protected

Constructs a message box with custom labeled buttons.

Parameters
[in]titleThe title text displayed at the top of the message box.
[in]textThe main informational text displayed in the message box.
[in]button_labelsThe labels for each custom button to display.
[in]on_selectOptional callback invoked when the user selects a labeled button.

◆ QCustomMessageBox() [3/3]

QCustomMessageBox::QCustomMessageBox ( const GenericOption & entry_type,
std::function< void(GenericOption, PopupInfo)> on_select )
protected

Constructs a message box with a generic option entry for user input.

Parameters
[in]entry_typeThe generic option describing the type of input to collect.
[in]on_selectCallback invoked when the user submits the generic option.

References QCustomMessageBox().

Member Function Documentation

◆ buttonPressed() [1/2]

void QCustomMessageBox::buttonPressed ( const TranslatedString & button_label,
PopupInfo  )
protected

Handles the event when a custom labeled button is pressed.

Parameters
[in]button_labelThe label of the button that was pressed.
[in]infoThe popup info associated with the message box display.

◆ buttonPressed() [2/2]

void QCustomMessageBox::buttonPressed ( QMessageBox::StandardButton button,
PopupInfo  )
protected

Handles the event when a standard button is pressed.

Parameters
[in]buttonThe standard button that was pressed.
[in]infoThe popup info associated with the message box display.

◆ CreateMessageBox() [1/3]

QCustomMessageBox * QCustomMessageBox::CreateMessageBox ( const GenericOption & entry_type,
std::function< void(GenericOption, PopupInfo)> on_select = nullptr )
static

Creates a message box with a generic option entry and displays it as a popup.

Parameters
[in]entry_typeThe generic option describing the type of input to collect.
[in]on_selectOptional callback invoked when the user submits the entry.
Returns
A pointer to the newly created message box.

References QCustomMessageBox().

◆ CreateMessageBox() [2/3]

QCustomMessageBox * QCustomMessageBox::CreateMessageBox ( const TranslatedString & title,
const TranslatedString & text,
const Buffer< TranslatedString > & button_labels,
std::function< void(TranslatedString, PopupInfo)> on_select = nullptr )
static

Creates a message box with custom labeled buttons and displays it as a popup.

Parameters
[in]titleThe title text displayed at the top of the message box.
[in]textThe main informational text displayed in the message box.
[in]button_labelsThe labels for each custom button to display.
[in]on_selectOptional callback invoked when the user selects a labeled button.
Returns
A pointer to the newly created message box.

References QCustomMessageBox().

◆ CreateMessageBox() [3/3]

QCustomMessageBox * QCustomMessageBox::CreateMessageBox ( const TranslatedString & title,
const TranslatedString & text,
QMessageBox::StandardButtons buttons,
std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select = nullptr )
static

Creates a message box with standard Qt buttons and displays it as a popup.

Parameters
[in]titleThe title text displayed at the top of the message box.
[in]textThe main informational text displayed in the message box.
[in]buttonsThe set of standard buttons to display.
[in]on_selectOptional callback invoked when the user selects a button.
Returns
A pointer to the newly created message box.

References QCustomMessageBox().

◆ processKeyEvent()

virtual bool QCustomMessageBox::processKeyEvent ( const StringView & id,
const KeyEvent & key_event,
DesignObjectLookup * lookup,
Camera * camera )
overridevirtual

Processes a key event for keyboard interaction with the message box.

Parameters
[in]idThe identifier for the key controller context.
[in]key_eventThe key event to process.
[in]lookupThe design object lookup for context.
[in]cameraThe active camera, if applicable.
Returns
True if the key event was handled, false otherwise.

Implements BasicKeyController.

◆ setButtons() [1/2]

void QCustomMessageBox::setButtons ( const Buffer< TranslatedString > & button_labels)

Replaces the current buttons with custom labeled buttons.

Parameters
[in]button_labelsThe labels for each custom button.

◆ setButtons() [2/2]

void QCustomMessageBox::setButtons ( QMessageBox::StandardButtons buttons)

Replaces the current buttons with a set of standard Qt buttons.

Parameters
[in]buttonsThe standard buttons to display.

◆ setCallback()

void QCustomMessageBox::setCallback ( std::function< void(QMessageBox::StandardButton, PopupInfo)> callback)
inline

Sets the callback invoked when a standard button is pressed.

Parameters
[in]callbackThe function to call with the selected button and popup info.

Definition at line 118 of file QCustomMessageBox.h.

References m_callback.

◆ setGenericOptionCallback()

void QCustomMessageBox::setGenericOptionCallback ( std::function< void(GenericOption, PopupInfo)> callback)
inline

Sets the callback invoked when a generic option entry is submitted.

Parameters
[in]callbackThe function to call with the generic option and popup info.

Definition at line 128 of file QCustomMessageBox.h.

References m_user_entry_callback.

◆ setIcon()

void QCustomMessageBox::setIcon ( const StringView & image,
fltp08 icon_size_mult = 1.0 )

Sets the icon displayed in the message box.

Parameters
[in]imageThe icon resource name or path.
[in]icon_size_multMultiplier for the icon size relative to the default.

◆ setLabelCallback()

void QCustomMessageBox::setLabelCallback ( std::function< void(TranslatedString, PopupInfo)> callback)
inline

Sets the callback invoked when a custom labeled button is pressed.

Parameters
[in]callbackThe function to call with the selected label and popup info.

Definition at line 123 of file QCustomMessageBox.h.

References m_label_callback.

◆ setText()

void QCustomMessageBox::setText ( const TranslatedString & text)

Sets the main informational text displayed in the message box.

Parameters
[in]textThe translated text to display.

◆ sizeHint()

QSize QCustomMessageBox::sizeHint ( ) const
override

Returns the recommended size for the message box.

Returns
The recommended QSize for layout calculations.

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