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