-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.cpp
75 lines (61 loc) · 1.23 KB
/
error.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2022-present Contributors to the jobman project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/mikaelsundell/jobman
#include "error.h"
#include <QPointer>
// generated files
#include "ui_error.h"
class ErrorPrivate : public QObject
{
Q_OBJECT
public:
ErrorPrivate();
void init();
public:
QPointer<Error> dialog;
QScopedPointer<Ui_Error> ui;
};
ErrorPrivate::ErrorPrivate()
{
}
void
ErrorPrivate::init()
{
// ui
ui.reset(new Ui_Error());
ui->setupUi(dialog);
// connect
connect(ui->close, &QPushButton::clicked, this, [this]() {
dialog->done(QDialog::Accepted);
});
}
#include "error.moc"
Error::Error(QWidget* parent)
: QDialog(parent)
, p(new ErrorPrivate())
{
p->dialog = this;
p->init();
}
Error::~Error()
{
}
void
Error::setTitle(const QString& title)
{
p->ui->title->setText(title);
}
void
Error::setError(const QString& error)
{
p->ui->error->setPlainText(error);
}
bool
Error::showError(QWidget* parent, const QString& title, const QString& error)
{
Error dialog(parent);
dialog.setTitle(title);
dialog.setError(error);
const int result = dialog.exec();
return result == QDialog::Accepted;
}