File: internalerrorsdialog.h

package info (click to toggle)
syncthingtray 1.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,804 kB
  • sloc: cpp: 31,085; xml: 1,694; java: 570; sh: 81; javascript: 53; makefile: 25
file content (59 lines) | stat: -rw-r--r-- 1,468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H
#define SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H

#include "./internalerror.h"
#include "./textviewdialog.h"

#include <vector>

QT_FORWARD_DECLARE_CLASS(QLabel)

namespace QtGui {

class SYNCTHINGWIDGETS_EXPORT InternalErrorsDialog : public TextViewDialog {
    Q_OBJECT
public:
    ~InternalErrorsDialog() override;
    static InternalErrorsDialog *instance();
    static bool hasInstance();
    static void addError(InternalError &&newError);
    static void addError(const QString &message = QString(), const QUrl &url = QUrl(), const QByteArray &response = QByteArray());

Q_SIGNALS:
    void errorsCleared();

public Q_SLOTS:
    static void showInstance();
    static void clearErrors();

private Q_SLOTS:
    void internalAddError(const InternalError &error);
    void updateStatusLabel();

private:
    InternalErrorsDialog();

    const QString m_request;
    const QString m_response;
    QLabel *const m_statusLabel;
    static InternalErrorsDialog *s_instance;
    static std::vector<InternalError> s_internalErrors;
};

inline InternalErrorsDialog *InternalErrorsDialog::instance()
{
    return s_instance ? s_instance : (s_instance = new InternalErrorsDialog);
}

inline bool InternalErrorsDialog::hasInstance()
{
    return s_instance != nullptr;
}

inline void InternalErrorsDialog::showInstance()
{
    instance()->show();
}
} // namespace QtGui

#endif // SYNCTHINGWIDGETS_INTERNAL_ERRORS_DIALOG_H