API Documentation
Loading...
Searching...
No Matches
QCustomMessageBox.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: QCustomMessageBox
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/KeyController.h>
35#include <NDEVR/Buffer.h>
36#include <NDEVR/String.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/UUID.h>
39#include <NDEVR/GenericOption.h>
40#include <QWidget>
41#include <QMessageBox>
42#include <QLabel>
43#include <QPointer>
44#include <functional>
45class QHBoxLayout;
46class QSize;
47namespace NDEVR
48{
49 class Button;
50 class ImageView;
51 class String;
52 struct PopupInfo;
53 /**--------------------------------------------------------------------------------------------------
54 \brief A message box displays a primary text to alert the user to a situation, an informative text to
55 further explain the situation, and an optional detailed text to provide even more data if the
56 user requests it.
57 The interface for this object allows from either a set of predifined user options (OK, Load, Cancel, etc)
58 or a set of program defined responses that the user can choose from.
59 *-----------------------------------------------------------------------------------------------**/
61 {
62 Q_OBJECT
63 protected:
64 QCustomMessageBox(const TranslatedString& title, const TranslatedString& text, QMessageBox::StandardButtons buttons, std::function<void(QMessageBox::StandardButton, PopupInfo)> on_select = nullptr);
65 QCustomMessageBox(const TranslatedString& title, const TranslatedString& text, const Buffer<TranslatedString>& button_labels, std::function<void(TranslatedString, PopupInfo)> on_select = nullptr);
66 QCustomMessageBox(const GenericOption& entry_type, std::function<void(GenericOption, PopupInfo)> on_select);
68 public:
70 void setIcon(const String& image, fltp08 icon_size_mult = 1.0);
71 void setText(const TranslatedString& text);
72 void setButtons(QMessageBox::StandardButtons buttons);
73 void setButtons(const Buffer<TranslatedString>& button_labels);
74 void setCallback(std::function<void(QMessageBox::StandardButton, PopupInfo)> callback) { m_callback = callback; };
75 void setLabelCallback(std::function<void(TranslatedString, PopupInfo)> callback) { m_label_callback = callback; };
76 void setGenericOptionCallback(std::function<void(GenericOption, PopupInfo)> callback) { m_user_entry_callback = callback; };
77 static QCustomMessageBox* CreateMessageBox(const TranslatedString& title, const TranslatedString& text, QMessageBox::StandardButtons buttons, std::function<void(QMessageBox::StandardButton, PopupInfo)> on_select = nullptr);
78 static QCustomMessageBox* CreateMessageBox(const TranslatedString& title, const TranslatedString& text, const Buffer<TranslatedString>& button_labels, std::function<void(TranslatedString, PopupInfo)> on_select = nullptr);
79 static QCustomMessageBox* CreateMessageBox(const GenericOption& entry_type, std::function<void(GenericOption, PopupInfo)> on_select = nullptr);
80 QSize sizeHint() const override;
81 virtual bool processKeyEvent(const String& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) override;
82 virtual void resetKeyControllerToDefaults() override;
83 protected:
84 void buttonPressed(QMessageBox::StandardButton button, PopupInfo);
85 void buttonPressed(const TranslatedString& button_label, PopupInfo);
87 protected:
88 QLabel* m_text;
91 QHBoxLayout* m_top_layout;
94 std::function<void(QMessageBox::StandardButton, PopupInfo)> m_callback;
98 };
99}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
The core class for assigning actions to key-presses and registering them as a program-wide service.
Definition KeyController.h:68
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
A core class where all Design Objects including models, materials, and geometries are stored.
Definition DesignObjectLookup.h:65
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
A widget that shows a raster image or icon.
Definition ImageView.h:43
A class which describes a user key press.
Definition Event.h:47
A message box displays a primary text to alert the user to a situation, an informative text to furthe...
Definition QCustomMessageBox.h:61
ImageView * m_image_view
Definition QCustomMessageBox.h:92
GenericOption m_generic_option
Definition QCustomMessageBox.h:97
void setButtons(const Buffer< TranslatedString > &button_labels)
static QCustomMessageBox * CreateMessageBox(const TranslatedString &title, const TranslatedString &text, const Buffer< TranslatedString > &button_labels, std::function< void(TranslatedString, PopupInfo)> on_select=nullptr)
String m_pixmap
Definition QCustomMessageBox.h:90
QCustomMessageBox(const GenericOption &entry_type, std::function< void(GenericOption, PopupInfo)> on_select)
QSize sizeHint() const override
void buttonPressed(QMessageBox::StandardButton button, PopupInfo)
QCustomMessageBox(const TranslatedString &title, const TranslatedString &text, QMessageBox::StandardButtons buttons, std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select=nullptr)
static Dictionary< UUID, QPointer< QCustomMessageBox > > s_message_boxes
Definition QCustomMessageBox.h:93
void setButtons(QMessageBox::StandardButtons buttons)
void setText(const TranslatedString &text)
std::function< void(QMessageBox::StandardButton, PopupInfo)> m_callback
Definition QCustomMessageBox.h:94
QLabel * m_text
Definition QCustomMessageBox.h:88
static QCustomMessageBox * CreateMessageBox(const TranslatedString &title, const TranslatedString &text, QMessageBox::StandardButtons buttons, std::function< void(QMessageBox::StandardButton, PopupInfo)> on_select=nullptr)
QCustomMessageBox(const TranslatedString &title, const TranslatedString &text, const Buffer< TranslatedString > &button_labels, std::function< void(TranslatedString, PopupInfo)> on_select=nullptr)
QHBoxLayout * m_top_layout
Definition QCustomMessageBox.h:91
void buttonPressed(const TranslatedString &button_label, PopupInfo)
virtual void resetKeyControllerToDefaults() override
static QCustomMessageBox * CreateMessageBox(const GenericOption &entry_type, std::function< void(GenericOption, PopupInfo)> on_select=nullptr)
std::function< void(GenericOption, PopupInfo)> m_user_entry_callback
Definition QCustomMessageBox.h:96
void setIcon(const String &image, fltp08 icon_size_mult=1.0)
void setLabelCallback(std::function< void(TranslatedString, PopupInfo)> callback)
Definition QCustomMessageBox.h:75
void setCallback(std::function< void(QMessageBox::StandardButton, PopupInfo)> callback)
Definition QCustomMessageBox.h:74
Buffer< Button * > m_buttons
Definition QCustomMessageBox.h:89
std::function< void(TranslatedString, PopupInfo)> m_label_callback
Definition QCustomMessageBox.h:95
void setGenericOptionCallback(std::function< void(GenericOption, PopupInfo)> callback)
Definition QCustomMessageBox.h:76
virtual bool processKeyEvent(const String &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) override
The core String class for the software.
Definition String.h:47
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
Stores a generic option of any type as well as some information about how the user.
Definition GenericOptions.h:57
Definition PopupInfo.h:10