From be933ef2241d79558f91796cc5b3a161f72ebf9c Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 19 Oct 2020 00:52:24 +0200 Subject: sync with upstream --- .../kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h | 188 +++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h') diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h new file mode 100644 index 0000000..6e6e069 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h @@ -0,0 +1,188 @@ +/* + * 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. + */ + +#pragma once + +#include "../../AddonBase.h" +#include "../../c-api/gui/dialogs/yes_no.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No +/// @ingroup cpp_kodi_gui_dialogs +/// @{ +/// @brief @cpp_namespace{ kodi::gui::dialogs::YesNo } +/// **Yes / No dialog**\n +/// The Yes / No dialog can be used to inform the user about questions and get +/// the answer. +/// +/// In order to achieve a line break is a \\n directly in the text or +/// in the "./resources/language/resource.language.??_??/strings.po" +/// to call with std::string kodi::general::GetLocalizedString(...);. +/// +/// It has the header @ref YesNo.h "#include " +/// be included to enjoy it. +/// +namespace YesNo +{ +//============================================================================== +/// @ingroup cpp_kodi_gui_dialogs_YesNo +/// @brief Use dialog to get numeric new password with one text string shown +/// everywhere and cancel return field. +/// +/// @param[in] heading Dialog heading +/// @param[in] text Multi-line text +/// @param[out] canceled Return value about cancel button +/// @param[in] noLabel [opt] label to put on the no button +/// @param[in] yesLabel [opt] label to put on the yes button +/// @return Returns True if 'Yes' was pressed, else False +/// +/// @note It is preferred to only use this as it is actually a multi-line text. +/// +/// +///------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// bool canceled = false; +/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( +/// "Yes / No test call", // The Header +/// "You has opened Yes / No dialog for test\n\nIs this OK for you?", +/// canceled, // return value about cancel button +/// "Not really", // No label, is optional and if empty "No" +/// "Ohhh yes"); // Yes label, also optional and if empty "Yes" +/// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", +/// ret ? "yes" : "no", +/// canceled ? "canceled" : "not canceled"); +/// ~~~~~~~~~~~~~ +/// +inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& text, + bool& canceled, + const std::string& noLabel = "", + const std::string& yesLabel = "") +{ + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, + noLabel.c_str(), yesLabel.c_str()); +} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @ingroup cpp_kodi_gui_dialogs_YesNo +/// @brief Use dialog to get numeric new password with separated line strings. +/// +/// @param[in] heading Dialog heading +/// @param[in] line0 Line #0 text +/// @param[in] line1 Line #1 text +/// @param[in] line2 Line #2 text +/// @param[in] noLabel [opt] label to put on the no button +/// @param[in] yesLabel [opt] label to put on the yes button +/// @return Returns True if 'Yes' was pressed, else False +/// +/// +///------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( +/// "Yes / No test call", // The Header +/// "You has opened Yes / No dialog for test", +/// "", +/// "Is this OK for you?", +/// "Not really", // No label, is optional and if empty "No" +/// "Ohhh yes"); // Yes label, also optional and if empty "Yes" +/// fprintf(stderr, "You has called Yes/No, returned '%s'\n", +/// ret ? "yes" : "no"); +/// ~~~~~~~~~~~~~ +/// +inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + const std::string& noLabel = "", + const std::string& yesLabel = "") +{ + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(), + line2.c_str(), noLabel.c_str(), yesLabel.c_str()); +} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @ingroup cpp_kodi_gui_dialogs_YesNo +/// @brief Use dialog to get numeric new password with separated line strings +/// and cancel return field. +/// +/// @param[in] heading Dialog heading +/// @param[in] line0 Line #0 text +/// @param[in] line1 Line #1 text +/// @param[in] line2 Line #2 text +/// @param[out] canceled Return value about cancel button +/// @param[in] noLabel [opt] label to put on the no button +/// @param[in] yesLabel [opt] label to put on the yes button +/// @return Returns True if 'Yes' was pressed, else False +/// +/// +///------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// bool canceled = false; +/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( +/// "Yes / No test call", // The Header +/// "You has opened Yes / No dialog for test", +/// "", +/// "Is this OK for you?", +/// canceled, // return value about cancel button +/// "Not really", // No label, is optional and if empty "No" +/// "Ohhh yes"); // Yes label, also optional and if empty "Yes" +/// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", +/// ret ? "yes" : "no", +/// canceled ? "canceled" : "not canceled"); +/// ~~~~~~~~~~~~~ +/// +inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + bool& canceled, + const std::string& noLabel = "", + const std::string& yesLabel = "") +{ + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo + ->show_and_get_input_line_button_text( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(), + line2.c_str(), &canceled, noLabel.c_str(), yesLabel.c_str()); +} +//------------------------------------------------------------------------------ +}; // namespace YesNo +/// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ + +#endif /* __cplusplus */ -- cgit v1.2.3