-
Notifications
You must be signed in to change notification settings - Fork 15
/
error_dialog.h
40 lines (35 loc) · 941 Bytes
/
error_dialog.h
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
#ifndef _COMMANDER_ERROR_DIALOG_
#define _COMMANDER_ERROR_DIALOG_
#include <string>
#include <vector>
#include "def.h"
#include "dialog.h"
enum class ErrorDialogResult
{
ABORT,
CONTINUE
};
inline ErrorDialogResult ErrorDialog(
const std::string &title, const std::string &error, bool is_last = true)
{
CDialog dlg{title};
dlg.setBorderColor({COLOR_BORDER_ERROR});
dlg.addLabel(error);
std::vector<ErrorDialogResult> options { ErrorDialogResult::ABORT };
const auto add_option = [&](std::string text, ErrorDialogResult value) {
dlg.addOption(text);
options.push_back(value);
};
if (!is_last)
{
add_option("Continue", ErrorDialogResult::CONTINUE);
add_option("Abort", ErrorDialogResult::ABORT);
}
else
{
add_option("OK", ErrorDialogResult::ABORT);
}
dlg.init();
return options[dlg.execute()];
}
#endif // _COMMANDER_ERROR_DIALOG_