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