Files
qt5-legatus-legacy/Lts/Common/LtsWidgets/lts_message_dialog_helper.h
T
2026-08-13 18:33:10 +02:00

56 lines
1.5 KiB
C++
Executable File

#pragma once
#include "lts_frameless_dialog.h"
#include "lts_message_dialog.h"
#include <QHash>
#include <QObject>
#include <QString>
class QPushButton;
class QHBoxLayout;
namespace LtsWidgets
{
/**
* @brief The LtsMessageDialogHelper class cannot be exported and only is a helper class which is actually instantiated, shows the LtsMessageDialog.
* To provide the blocking call to showMessage (call with return type), an event loop is created and exited when the user has selected a button to close the dialog.
* If the behaviour is non-modal, closing the Dialog by clicking outside of it will return Button::Cancel.
*/
class LtsMessageDialogHelper : public QObject
{
Q_OBJECT
public:
explicit LtsMessageDialogHelper(QObject *parent = nullptr);
~LtsMessageDialogHelper() = default;
Button showMessage(QWidget *parent,
const QString &message,
const QString &title,
Behaviour behaviour,
LtsWidgets::Buttons buttons,
const QHash<Button, QString> &buttonTexts);
private:
QPushButton *addButton(const QString &text, QHBoxLayout *thatLayout, LtsFramelessDialog *dialog, const Button &button, QWidget *parent);
Button m_result;
LtsFramelessDialog *m_dialog;
private slots:
void slotOkay();
void slotYes();
void slotNo();
void slotCancel();
void slotApply();
void slotDiscard();
signals:
void signalQuitEventLoop();
};
} // namespace LtsWidgets