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 "GUIDialogBoxBase.h" 12 #include "utils/Variant.h" 13 14 namespace KODI 15 { 16 namespace MESSAGING 17 { 18 namespace HELPERS 19 { 20 struct DialogYesNoMessage; 21 } 22 } 23 } 24 25 class CGUIDialogYesNo : 26 public CGUIDialogBoxBase 27 { 28 public: 29 explicit CGUIDialogYesNo(int overrideId = -1); 30 ~CGUIDialogYesNo(void) override; 31 bool OnMessage(CGUIMessage& message) override; 32 bool OnBack(int actionID) override; 33 34 void Reset(); 35 int GetResult() const; 36 37 enum TimeOut 38 { 39 NO_TIMEOUT = 0 40 }; 41 42 /*! \brief Show a yes-no dialog, then wait for user to dismiss it. 43 \param heading Localized label id or string for the heading of the dialog 44 \param line0 Localized label id or string for line 1 of the dialog message 45 \param line1 Localized label id or string for line 2 of the dialog message 46 \param line2 Localized label id or string for line 3 of the dialog message 47 \param bCanceled Holds true if the dialog was canceled otherwise false 48 \return true if user selects Yes, otherwise false if user selects No. 49 */ 50 static bool ShowAndGetInput(const CVariant& heading, 51 const CVariant& line0, 52 const CVariant& line1, 53 const CVariant& line2, 54 bool& bCanceled); 55 56 /*! \brief Show a yes-no dialog, then wait for user to dismiss it. 57 \param heading Localized label id or string for the heading of the dialog 58 \param line0 Localized label id or string for line 1 of the dialog message 59 \param line1 Localized label id or string for line 2 of the dialog message 60 \param line2 Localized label id or string for line 3 of the dialog message 61 \param iNoLabel Localized label id or string for the no button 62 \param iYesLabel Localized label id or string for the yes button 63 \return true if user selects Yes, otherwise false if user selects No. 64 */ 65 static bool ShowAndGetInput(const CVariant& heading, 66 const CVariant& line0, 67 const CVariant& line1, 68 const CVariant& line2, 69 const CVariant& noLabel = "", 70 const CVariant& yesLabel = ""); 71 72 /*! \brief Show a yes-no dialog, then wait for user to dismiss it. 73 \param heading Localized label id or string for the heading of the dialog 74 \param line0 Localized label id or string for line 1 of the dialog message 75 \param line1 Localized label id or string for line 2 of the dialog message 76 \param line2 Localized label id or string for line 3 of the dialog message 77 \param bCanceled Holds true if the dialog was canceled otherwise false 78 \param iNoLabel Localized label id or string for the no button 79 \param iYesLabel Localized label id or string for the yes button 80 \param autoCloseTime Time in ms before the dialog becomes automatically closed 81 \return true if user selects Yes, otherwise false if user selects No. 82 */ 83 static bool ShowAndGetInput(const CVariant& heading, 84 const CVariant& line0, 85 const CVariant& line1, 86 const CVariant& line2, 87 bool& bCanceled, 88 const CVariant& noLabel, 89 const CVariant& yesLabel, 90 unsigned int autoCloseTime); 91 92 /*! \brief Show a yes-no dialog, then wait for user to dismiss it. 93 \param heading Localized label id or string for the heading of the dialog 94 \param text Localized label id or string for the dialog message 95 \return true if user selects Yes, otherwise false if user selects No. 96 */ 97 static bool ShowAndGetInput(const CVariant& heading, const CVariant& text); 98 99 /*! \brief Show a yes-no dialog, then wait for user to dismiss it. 100 \param heading Localized label id or string for the heading of the dialog 101 \param text Localized label id or string for the dialog message 102 \param bCanceled Holds true if the dialog was canceled otherwise false 103 \param iNoLabel Localized label id or string for the no button 104 \param iYesLabel Localized label id or string for the yes button 105 \param autoCloseTime Time in ms before the dialog becomes automatically closed 106 \return true if user selects Yes, otherwise false if user selects No. 107 */ 108 static bool ShowAndGetInput(const CVariant& heading, 109 const CVariant& text, 110 bool& bCanceled, 111 const CVariant& noLabel, 112 const CVariant& yesLabel, 113 unsigned int autoCloseTime); 114 115 /*! \brief Show a yes-no dialog with 3rd custom button, then wait for user to dismiss it. 116 \param heading Localized label id or string for the heading of the dialog 117 \param text Localized label id or string for the dialog message 118 \param noLabel Localized label id or string for the no button 119 \param yesLabel Localized label id or string for the yes button 120 \param customLabel Localized label id or string for the custom button 121 \param autoCloseTime Time in ms before the dialog becomes automatically closed 122 \return -1 for cancelled, 0 for No, 1 for Yes and 2 for custom button 123 */ 124 static int ShowAndGetInput(const CVariant& heading, 125 const CVariant& text, 126 const CVariant& noLabel, 127 const CVariant& yesLabel, 128 const CVariant& customLabel, 129 unsigned int autoCloseTime); 130 131 /*! 132 \brief Open a Yes/No dialog and wait for input 133 134 \param[in] options a struct of type DialogYesNoMessage containing 135 the options to set for this dialog. 136 137 \returns -1 for cancelled, 0 for No and 1 for Yes 138 \sa KODI::MESSAGING::HELPERS::DialogYesNoMessage 139 */ 140 int ShowAndGetInput(const KODI::MESSAGING::HELPERS::DialogYesNoMessage& options); 141 142 protected: 143 void OnInitWindow() override; 144 int GetDefaultLabelID(int controlId) const override; 145 146 bool m_bCanceled; 147 bool m_bCustom; 148 }; 149