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

83 lines
2.4 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Helper Class, which manages a progress Dialog with two states.
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2016-06-20
*/
#pragma once
#include "lts_widgets_export.h"
#include <QObject>
#include <QPointer>
class QLabel;
class QWidget;
namespace LtsWidgets
{
class LtsFramelessDialog;
/**
* @brief The LtsProgressDialogHelper class is a helper class, which can be used to easily
* show a Dialog with eather a wait state (indefinite progress bar), or a default message,
* adjusted to the result type (see ReplyResult)
*/
class LTSWIDGETS_EXPORT LtsProgressDialogHelper : public QObject
{
Q_OBJECT
public:
/**
* @brief The ReplyResult enum describes the behaviour of the slotSopWaitForReplyWindow method.
*/
enum class ReplyResult
{
Close = 0, // say nothing, just close automatically
Success, // dialog with success message, has to be receipted
Failure, // dialog with failure message plus reply string, has to be receipted
TimeOut, // dialog with timeout message, has to be receipted
};
explicit LtsProgressDialogHelper(QWidget *parent = nullptr);
~LtsProgressDialogHelper();
bool isShown() const { return !!m_waitDlg; }
void setCustomText(const QString &customText = QString());
void setParentWidget(QWidget *newParent);
public slots:
/**
* @brief slotShowWaitForReplyWindow shows a centered wait dialog which does not allow the user to interact with the application and cannot be canceled.
*/
void slotShowWaitForReplyWindow(/*const QString &textToShow*/);
/**
* @brief slotStopWaitForReplyWindow closes the wait dialog. Nothing happens when there was no show wait dialog called before.
* @param replyResult The wait dialog is closed on ReplyResult::Close. A new centered, modal dialog is shown on ReplyResult::Failure/Success/Timeout with an error message in it.
* @param replyString An explanatory string shown on ReplyResult::Failure to tell the user what went wrong on.
*/
void slotStopWaitForReplyWindow(const LtsWidgets::LtsProgressDialogHelper::ReplyResult &replyResult = ReplyResult::Close /* say nothing, just close */,
const QString &replyString = QString());
private:
QPointer<LtsFramelessDialog> m_waitDlg;
QWidget *m_parentWidget;
QPointer<QLabel> m_textLabel;
signals:
/**
* @brief accepted is emitted when accept() was called (e.g. by clicking okay)
*/
void accepted();
private slots:
void accept();
};
}