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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "DialogHelper.h"
#include "ServiceBroker.h"
#include "messaging/ApplicationMessenger.h"
#include <cassert>
#include <utility>
namespace KODI
{
namespace MESSAGING
{
namespace HELPERS
{
DialogResponse ShowYesNoDialogText(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, uint32_t autoCloseTimeout)
{
return ShowYesNoCustomDialog(std::move(heading), std::move(text), std::move(noLabel),
std::move(yesLabel), "", autoCloseTimeout);
}
DialogResponse ShowYesNoCustomDialog(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, uint32_t autoCloseTimeout)
{
DialogYesNoMessage options;
options.heading = std::move(heading);
options.text = std::move(text);
options.noLabel = std::move(noLabel);
options.yesLabel = std::move(yesLabel);
options.customLabel = std::move(customLabel);
options.autoclose = autoCloseTimeout;
switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO, -1, -1,
static_cast<void*>(&options)))
{
case -1:
return DialogResponse::CHOICE_CANCELLED;
case 0:
return DialogResponse::CHOICE_NO;
case 1:
return DialogResponse::CHOICE_YES;
case 2:
return DialogResponse::CHOICE_CUSTOM;
default:
//If we get here someone changed the return values without updating this code
assert(false);
}
//This is unreachable code but we need to return something to suppress warnings about
//no return
return DialogResponse::CHOICE_CANCELLED;
}
DialogResponse ShowYesNoDialogLines(CVariant heading, CVariant line0, CVariant line1, CVariant line2,
CVariant noLabel, CVariant yesLabel, uint32_t autoCloseTimeout)
{
DialogYesNoMessage options;
options.heading = std::move(heading);
options.lines[0] = std::move(line0);
options.lines[1] = std::move(line1);
options.lines[2] = std::move(line2);
options.noLabel = std::move(noLabel);
options.yesLabel = std::move(yesLabel);
options.customLabel = "";
options.autoclose = autoCloseTimeout;
switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO, -1, -1,
static_cast<void*>(&options)))
{
case -1:
return DialogResponse::CHOICE_CANCELLED;
case 0:
return DialogResponse::CHOICE_NO;
case 1:
return DialogResponse::CHOICE_YES;
case 2:
return DialogResponse::CHOICE_CUSTOM;
default:
//If we get here someone changed the return values without updating this code
assert(false);
}
//This is unreachable code but we need to return something to suppress warnings about
//no return
return DialogResponse::CHOICE_CANCELLED;
}
}
}
}
|