2018-11-03 18:07:45 +01:00
|
|
|
#ifndef SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H
|
|
|
|
#define SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H
|
2017-08-20 01:20:47 +02:00
|
|
|
|
|
|
|
#include "./internalerror.h"
|
|
|
|
#include "./textviewdialog.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QLabel)
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2018-11-03 18:07:45 +01:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT InternalErrorsDialog : public TextViewDialog {
|
2017-08-20 01:20:47 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-03 18:07:45 +01:00
|
|
|
~InternalErrorsDialog() override;
|
|
|
|
static InternalErrorsDialog *instance();
|
2021-03-24 14:40:59 +01:00
|
|
|
static bool hasInstance();
|
2017-08-20 01:20:47 +02:00
|
|
|
static void addError(InternalError &&newError);
|
2021-10-09 01:14:33 +02:00
|
|
|
static void addError(const QString &message = QString(), const QUrl &url = QUrl(), const QByteArray &response = QByteArray());
|
2017-08-20 01:20:47 +02:00
|
|
|
|
2017-09-05 00:24:52 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void errorsCleared();
|
|
|
|
|
2017-08-20 01:20:47 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
static void showInstance();
|
|
|
|
static void clearErrors();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void internalAddError(const InternalError &error);
|
|
|
|
void updateStatusLabel();
|
|
|
|
|
|
|
|
private:
|
2018-11-03 18:07:45 +01:00
|
|
|
InternalErrorsDialog();
|
2017-08-20 01:20:47 +02:00
|
|
|
|
|
|
|
const QString m_request;
|
|
|
|
const QString m_response;
|
|
|
|
QLabel *const m_statusLabel;
|
2018-11-03 18:07:45 +01:00
|
|
|
static InternalErrorsDialog *s_instance;
|
2017-08-20 01:20:47 +02:00
|
|
|
static std::vector<InternalError> s_internalErrors;
|
|
|
|
};
|
|
|
|
|
2018-11-03 18:07:45 +01:00
|
|
|
inline InternalErrorsDialog *InternalErrorsDialog::instance()
|
2017-08-20 01:20:47 +02:00
|
|
|
{
|
2018-11-03 18:07:45 +01:00
|
|
|
return s_instance ? s_instance : (s_instance = new InternalErrorsDialog);
|
2017-08-20 01:20:47 +02:00
|
|
|
}
|
|
|
|
|
2021-03-24 14:40:59 +01:00
|
|
|
inline bool InternalErrorsDialog::hasInstance()
|
|
|
|
{
|
|
|
|
return s_instance != nullptr;
|
|
|
|
}
|
|
|
|
|
2018-11-03 18:07:45 +01:00
|
|
|
inline void InternalErrorsDialog::showInstance()
|
2017-08-20 01:20:47 +02:00
|
|
|
{
|
|
|
|
instance()->show();
|
|
|
|
}
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace QtGui
|
2017-08-20 01:20:47 +02:00
|
|
|
|
2018-11-03 18:07:45 +01:00
|
|
|
#endif // SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H
|