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