| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "utils/Variant.h" |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <string> |
| 15 |
|
| 16 |
namespace KODI |
| 17 |
{ |
| 18 |
namespace MESSAGING |
| 19 |
{ |
| 20 |
namespace HELPERS |
| 21 |
{ |
| 22 |
|
| 23 |
enum class DialogResponse : int |
| 24 |
{ |
| 25 |
CHOICE_CANCELLED, |
| 26 |
CHOICE_YES, |
| 27 |
CHOICE_NO, |
| 28 |
CHOICE_CUSTOM, |
| 29 |
}; |
| 30 |
|
| 31 |
/*! \struct DialogYesNoMessage DialogHelper.h "messaging/helpers/DialogHelper.h" |
| 32 |
\brief Payload sent for message TMSG_GUI_DIALOG_YESNO |
| 33 |
|
| 34 |
\sa ShowDialogText |
| 35 |
\sa ShowDialogLines |
| 36 |
*/ |
| 37 |
struct DialogYesNoMessage |
| 38 |
{ |
| 39 |
CVariant heading; //!< Heading to be displayed in the dialog box |
| 40 |
CVariant text; //!< Body text to be displayed, this is mutually exclusive with lines below |
| 41 |
std::array<CVariant, 3> lines; //!< Body text to be displayed, specified as three lines. This is mutually exclusive with the text above |
| 42 |
CVariant yesLabel; //!< Text to show on the yes button |
| 43 |
CVariant noLabel; //!< Text to show on the no button |
| 44 |
CVariant customLabel; //!< Text to show on the 3rd custom button |
| 45 |
uint32_t autoclose{0}; //!< Time in milliseconds before autoclosing the dialog, 0 means don't autoclose |
| 46 |
}; |
| 47 |
|
| 48 |
/*! |
| 49 |
\brief This is a helper method to send a threadmessage to open a Yes/No dialog box |
| 50 |
|
| 51 |
\param[in] heading The text to display as the dialog box header |
| 52 |
\param[in] text The text to display in the dialog body |
| 53 |
\param[in] noLabel The text to display on the No button |
| 54 |
defaults to No |
| 55 |
\param[in] yesLabel The text to display on the Yes button |
| 56 |
defaults to Yes |
| 57 |
\param[in] autoCloseTimeout The time before the dialog closes |
| 58 |
defaults to 0 show indefinitely |
| 59 |
\return -1 on cancelled, 0 on no and 1 on yes |
| 60 |
\sa ShowYesNoDialogLines |
| 61 |
\sa CGUIDialogYesNo::ShowAndGetInput |
| 62 |
\sa DialogYesNoMessage |
| 63 |
*/ |
| 64 |
DialogResponse ShowYesNoDialogText(CVariant heading, CVariant text, CVariant noLabel = CVariant(), |
| 65 |
CVariant yesLabel = CVariant(), uint32_t autoCloseTimeout = 0); |
| 66 |
|
| 67 |
/*! |
| 68 |
\brief This is a helper method to send a threadmessage to open a Yes/No dialog box with a custom button |
| 69 |
|
| 70 |
\param[in] heading The text to display as the dialog box header |
| 71 |
\param[in] text The text to display in the dialog body |
| 72 |
\param[in] noLabel The text to display on the No button |
| 73 |
defaults to No |
| 74 |
\param[in] yesLabel The text to display on the Yes button |
| 75 |
defaults to Yes |
| 76 |
\param[in] customLabel The text to display on the optional 3rd custom button |
| 77 |
defaults to empty and button not shown |
| 78 |
\param[in] autoCloseTimeout The time before the dialog closes |
| 79 |
defaults to 0 show indefinitely |
| 80 |
\return -1 on cancelled, 0 on no, 1 on yes and 2 on 3rd custom response |
| 81 |
\sa ShowYesNoDialogLines |
| 82 |
\sa CGUIDialogYesNo::ShowAndGetInput |
| 83 |
\sa DialogYesNoMessage |
| 84 |
*/ |
| 85 |
DialogResponse ShowYesNoCustomDialog(CVariant heading, CVariant text, CVariant noLabel = CVariant(), CVariant yesLabel = CVariant(), |
| 86 |
CVariant customLabel = CVariant(), uint32_t autoCloseTimeout = 0); |
| 87 |
|
| 88 |
/*! |
| 89 |
\brief This is a helper method to send a threadmessage to open a Yes/No dialog box |
| 90 |
|
| 91 |
\param[in] heading The text to display as the dialog box header |
| 92 |
\param[in] line0 The text to display on the first line |
| 93 |
\param[in] line1 The text to display on the second line |
| 94 |
\param[in] line2 The text to display on the third line |
| 95 |
\param[in] noLabel The text to display on the No button |
| 96 |
defaults to No |
| 97 |
\param[in] yesLabel The text to display on the Yes button |
| 98 |
defaults to Yes |
| 99 |
\param[in] autoCloseTimeout The time before the dialog closes |
| 100 |
defaults to 0 show indefinitely |
| 101 |
\return -1 on cancelled, 0 on no and 1 on yes |
| 102 |
\sa ShowYesNoDialogText |
| 103 |
\sa CGUIDialogYesNo::ShowAndGetInput |
| 104 |
\sa DialogYesNoMessage |
| 105 |
*/ |
| 106 |
DialogResponse ShowYesNoDialogLines(CVariant heading, CVariant line0, CVariant line1 = CVariant(), |
| 107 |
CVariant line2 = CVariant(), CVariant noLabel = CVariant(), |
| 108 |
CVariant yesLabel = CVariant(), uint32_t autoCloseTimeout = 0); |
| 109 |
|
| 110 |
} |
| 111 |
} |
| 112 |
} |