2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "DialogHelper.h"
11 #include "ServiceBroker.h"
12 #include "messaging/ApplicationMessenger.h"
23 DialogResponse
ShowYesNoDialogText(CVariant heading
, CVariant text
, CVariant noLabel
, CVariant yesLabel
, uint32_t autoCloseTimeout
)
25 return ShowYesNoCustomDialog(std::move(heading
), std::move(text
), std::move(noLabel
),
26 std::move(yesLabel
), "", autoCloseTimeout
);
29 DialogResponse
ShowYesNoCustomDialog(CVariant heading
, CVariant text
, CVariant noLabel
, CVariant yesLabel
, CVariant customLabel
, uint32_t autoCloseTimeout
)
31 DialogYesNoMessage options
;
32 options
.heading
= std::move(heading
);
33 options
.text
= std::move(text
);
34 options
.noLabel
= std::move(noLabel
);
35 options
.yesLabel
= std::move(yesLabel
);
36 options
.customLabel
= std::move(customLabel
);
37 options
.autoclose
= autoCloseTimeout
;
39 switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO
, -1, -1,
40 static_cast<void*>(&options
)))
43 return DialogResponse::CHOICE_CANCELLED
;
45 return DialogResponse::CHOICE_NO
;
47 return DialogResponse::CHOICE_YES
;
49 return DialogResponse::CHOICE_CUSTOM
;
51 //If we get here someone changed the return values without updating this code
54 //This is unreachable code but we need to return something to suppress warnings about
56 return DialogResponse::CHOICE_CANCELLED
;
59 DialogResponse
ShowYesNoDialogLines(CVariant heading
, CVariant line0
, CVariant line1
, CVariant line2
,
60 CVariant noLabel
, CVariant yesLabel
, uint32_t autoCloseTimeout
)
62 DialogYesNoMessage options
;
63 options
.heading
= std::move(heading
);
64 options
.lines
[0] = std::move(line0
);
65 options
.lines
[1] = std::move(line1
);
66 options
.lines
[2] = std::move(line2
);
67 options
.noLabel
= std::move(noLabel
);
68 options
.yesLabel
= std::move(yesLabel
);
69 options
.customLabel
= "";
70 options
.autoclose
= autoCloseTimeout
;
72 switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO
, -1, -1,
73 static_cast<void*>(&options
)))
76 return DialogResponse::CHOICE_CANCELLED
;
78 return DialogResponse::CHOICE_NO
;
80 return DialogResponse::CHOICE_YES
;
82 return DialogResponse::CHOICE_CUSTOM
;
84 //If we get here someone changed the return values without updating this code
87 //This is unreachable code but we need to return something to suppress warnings about
89 return DialogResponse::CHOICE_CANCELLED
;