diff options
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h new file mode 100644 index 0000000..d242a56 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h | |||
| @@ -0,0 +1,244 @@ | |||
| 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 "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/progress.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @brief @cpp_class{ kodi::gui::dialogs::CProgress } | ||
| 27 | /// **Progress dialog shown in center**\n | ||
| 28 | /// The with @ref Progress.h "#include <kodi/gui/dialogs/Progress.h>" | ||
| 29 | /// given class are basically used to create Kodi's progress dialog with named | ||
| 30 | /// text fields. | ||
| 31 | /// | ||
| 32 | /// **Example:** | ||
| 33 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 34 | /// #include <kodi/gui/dialogs/Progress.h> | ||
| 35 | /// | ||
| 36 | /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; | ||
| 37 | /// progress->SetHeading("Test progress"); | ||
| 38 | /// progress->SetLine(1, "line 1"); | ||
| 39 | /// progress->SetLine(2, "line 2"); | ||
| 40 | /// progress->SetLine(3, "line 3"); | ||
| 41 | /// progress->SetCanCancel(true); | ||
| 42 | /// progress->ShowProgressBar(true); | ||
| 43 | /// progress->Open(); | ||
| 44 | /// for (unsigned int i = 0; i < 100; i += 10) | ||
| 45 | /// { | ||
| 46 | /// progress->SetPercentage(i); | ||
| 47 | /// sleep(1); | ||
| 48 | /// } | ||
| 49 | /// delete progress; | ||
| 50 | /// ~~~~~~~~~~~~~ | ||
| 51 | /// | ||
| 52 | class ATTRIBUTE_HIDDEN CProgress | ||
| 53 | { | ||
| 54 | public: | ||
| 55 | //============================================================================ | ||
| 56 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 57 | /// @brief Construct a new dialog | ||
| 58 | /// | ||
| 59 | CProgress() | ||
| 60 | { | ||
| 61 | using namespace ::kodi::addon; | ||
| 62 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog( | ||
| 63 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 64 | if (!m_DialogHandle) | ||
| 65 | kodi::Log(ADDON_LOG_FATAL, | ||
| 66 | "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); | ||
| 67 | } | ||
| 68 | //---------------------------------------------------------------------------- | ||
| 69 | |||
| 70 | //============================================================================ | ||
| 71 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 72 | /// @brief Destructor | ||
| 73 | /// | ||
| 74 | ~CProgress() | ||
| 75 | { | ||
| 76 | using namespace ::kodi::addon; | ||
| 77 | if (m_DialogHandle) | ||
| 78 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( | ||
| 79 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 80 | } | ||
| 81 | //---------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //============================================================================ | ||
| 84 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 85 | /// @brief To open the dialog | ||
| 86 | /// | ||
| 87 | void Open() | ||
| 88 | { | ||
| 89 | using namespace ::kodi::addon; | ||
| 90 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( | ||
| 91 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 92 | } | ||
| 93 | //---------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //============================================================================ | ||
| 96 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 97 | /// @brief Set the heading title of dialog | ||
| 98 | /// | ||
| 99 | /// @param[in] heading Title string to use | ||
| 100 | /// | ||
| 101 | void SetHeading(const std::string& heading) | ||
| 102 | { | ||
| 103 | using namespace ::kodi::addon; | ||
| 104 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( | ||
| 105 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 106 | } | ||
| 107 | //---------------------------------------------------------------------------- | ||
| 108 | |||
| 109 | //============================================================================ | ||
| 110 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 111 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 112 | /// | ||
| 113 | /// @param[in] iLine Line number | ||
| 114 | /// @param[in] line Text string | ||
| 115 | /// | ||
| 116 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 117 | { | ||
| 118 | using namespace ::kodi::addon; | ||
| 119 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( | ||
| 120 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 121 | } | ||
| 122 | //---------------------------------------------------------------------------- | ||
| 123 | |||
| 124 | //============================================================================ | ||
| 125 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 126 | /// @brief To enable and show cancel button on dialog | ||
| 127 | /// | ||
| 128 | /// @param[in] canCancel if true becomes it shown | ||
| 129 | /// | ||
| 130 | void SetCanCancel(bool canCancel) | ||
| 131 | { | ||
| 132 | using namespace ::kodi::addon; | ||
| 133 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( | ||
| 134 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 135 | } | ||
| 136 | //---------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //============================================================================ | ||
| 139 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 140 | /// @brief To check dialog for clicked cancel button | ||
| 141 | /// | ||
| 142 | /// @return True if canceled | ||
| 143 | /// | ||
| 144 | bool IsCanceled() const | ||
| 145 | { | ||
| 146 | using namespace ::kodi::addon; | ||
| 147 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( | ||
| 148 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 149 | } | ||
| 150 | //---------------------------------------------------------------------------- | ||
| 151 | |||
| 152 | //============================================================================ | ||
| 153 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 154 | /// @brief Get the current progress position as percent | ||
| 155 | /// | ||
| 156 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 157 | /// | ||
| 158 | void SetPercentage(int percentage) | ||
| 159 | { | ||
| 160 | using namespace ::kodi::addon; | ||
| 161 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( | ||
| 162 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 163 | } | ||
| 164 | //---------------------------------------------------------------------------- | ||
| 165 | |||
| 166 | //============================================================================ | ||
| 167 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 168 | /// @brief To set the current progress position as percent | ||
| 169 | /// | ||
| 170 | /// @return Current Position used from 0 to 100 | ||
| 171 | /// | ||
| 172 | int GetPercentage() const | ||
| 173 | { | ||
| 174 | using namespace ::kodi::addon; | ||
| 175 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( | ||
| 176 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 177 | } | ||
| 178 | //---------------------------------------------------------------------------- | ||
| 179 | |||
| 180 | //============================================================================ | ||
| 181 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 182 | /// @brief To show or hide progress bar dialog | ||
| 183 | /// | ||
| 184 | /// @param[in] onOff If true becomes it shown | ||
| 185 | /// | ||
| 186 | void ShowProgressBar(bool onOff) | ||
| 187 | { | ||
| 188 | using namespace ::kodi::addon; | ||
| 189 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( | ||
| 190 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 191 | } | ||
| 192 | //---------------------------------------------------------------------------- | ||
| 193 | |||
| 194 | //============================================================================ | ||
| 195 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 196 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 197 | /// | ||
| 198 | /// @param[in] max Biggest usable position to use | ||
| 199 | /// | ||
| 200 | void SetProgressMax(int max) | ||
| 201 | { | ||
| 202 | using namespace ::kodi::addon; | ||
| 203 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( | ||
| 204 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 205 | } | ||
| 206 | //---------------------------------------------------------------------------- | ||
| 207 | |||
| 208 | //============================================================================ | ||
| 209 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 210 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 211 | /// | ||
| 212 | /// @param[in] steps Step size to increase, default is 1 | ||
| 213 | /// | ||
| 214 | void SetProgressAdvance(int steps = 1) | ||
| 215 | { | ||
| 216 | using namespace ::kodi::addon; | ||
| 217 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( | ||
| 218 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 219 | } | ||
| 220 | //---------------------------------------------------------------------------- | ||
| 221 | |||
| 222 | //============================================================================ | ||
| 223 | /// @ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 224 | /// @brief To check progress was canceled on work | ||
| 225 | /// | ||
| 226 | /// @return True if aborted | ||
| 227 | /// | ||
| 228 | bool Abort() | ||
| 229 | { | ||
| 230 | using namespace ::kodi::addon; | ||
| 231 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( | ||
| 232 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 233 | } | ||
| 234 | //---------------------------------------------------------------------------- | ||
| 235 | |||
| 236 | private: | ||
| 237 | KODI_GUI_HANDLE m_DialogHandle; | ||
| 238 | }; | ||
| 239 | |||
| 240 | } /* namespace dialogs */ | ||
| 241 | } /* namespace gui */ | ||
| 242 | } /* namespace kodi */ | ||
| 243 | |||
| 244 | #endif /* __cplusplus */ | ||
