diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h | 410 |
1 files changed, 212 insertions, 198 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h index 417d5db..5a49b70 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h | |||
| @@ -18,218 +18,232 @@ namespace gui | |||
| 18 | namespace dialogs | 18 | namespace dialogs |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | 22 | /// |
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress | 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress |
| 24 | /// \ingroup cpp_kodi_gui | 24 | /// \ingroup cpp_kodi_gui |
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } | 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } |
| 26 | /// **Progress dialog shown for background work** | 26 | /// **Progress dialog shown for background work** |
| 27 | /// | ||
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | ||
| 29 | /// given class are basically used to create Kodi's extended progress. | ||
| 30 | /// | ||
| 31 | /// | ||
| 32 | /// -------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// **Example:** | ||
| 35 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 36 | /// #include <kodi/gui/dialogs/ExtendedProgress.h> | ||
| 37 | /// | ||
| 38 | /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); | ||
| 39 | /// ext_progress->SetText("Test progress"); | ||
| 40 | /// for (unsigned int i = 0; i < 50; i += 10) | ||
| 41 | /// { | ||
| 42 | /// ext_progress->SetProgress(i, 100); | ||
| 43 | /// sleep(1); | ||
| 44 | /// } | ||
| 45 | /// | ||
| 46 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | ||
| 47 | /// ext_progress->SetText("Test progress - Step 2"); | ||
| 48 | /// | ||
| 49 | /// for (unsigned int i = 50; i < 100; i += 10) | ||
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// delete ext_progress; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | ||
| 57 | class ATTRIBUTE_HIDDEN CExtendedProgress | ||
| 58 | { | ||
| 59 | public: | ||
| 60 | //========================================================================== | ||
| 27 | /// | 61 | /// |
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 29 | /// given class are basically used to create Kodi's extended progress. | 63 | /// Construct a new dialog |
| 30 | /// | 64 | /// |
| 65 | /// @param[in] title Title string | ||
| 31 | /// | 66 | /// |
| 32 | /// -------------------------------------------------------------------------- | 67 | explicit CExtendedProgress(const std::string& title = "") |
| 68 | { | ||
| 69 | using namespace ::kodi::addon; | ||
| 70 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog( | ||
| 71 | CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 72 | if (!m_DialogHandle) | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, | ||
| 74 | "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 33 | /// | 79 | /// |
| 34 | /// **Example:** | 80 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 35 | /// ~~~~~~~~~~~~~{.cpp} | 81 | /// Destructor |
| 36 | /// #include <kodi/gui/dialogs/ExtendedProgress.h> | ||
| 37 | /// | 82 | /// |
| 38 | /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); | 83 | ~CExtendedProgress() |
| 39 | /// ext_progress->SetText("Test progress"); | 84 | { |
| 40 | /// for (unsigned int i = 0; i < 50; i += 10) | 85 | using namespace ::kodi::addon; |
| 41 | /// { | 86 | if (m_DialogHandle) |
| 42 | /// ext_progress->SetProgress(i, 100); | 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( |
| 43 | /// sleep(1); | 88 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 44 | /// } | 89 | } |
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //========================================================================== | ||
| 45 | /// | 93 | /// |
| 46 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | 94 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 47 | /// ext_progress->SetText("Test progress - Step 2"); | 95 | /// @brief Get the used title |
| 48 | /// | 96 | /// |
| 49 | /// for (unsigned int i = 50; i < 100; i += 10) | 97 | /// @return Title string |
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// delete ext_progress; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | 98 | /// |
| 57 | class CExtendedProgress | 99 | std::string Title() const |
| 58 | { | 100 | { |
| 59 | public: | 101 | using namespace ::kodi::addon; |
| 60 | //========================================================================== | 102 | std::string text; |
| 61 | /// | 103 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title( |
| 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 104 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 63 | /// Construct a new dialog | 105 | if (strMsg != nullptr) |
| 64 | /// | ||
| 65 | /// @param[in] title Title string | ||
| 66 | /// | ||
| 67 | explicit CExtendedProgress(const std::string& title = "") | ||
| 68 | { | ||
| 69 | using namespace ::kodi::addon; | ||
| 70 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 71 | if (!m_DialogHandle) | ||
| 72 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 73 | } | ||
| 74 | //-------------------------------------------------------------------------- | ||
| 75 | |||
| 76 | //========================================================================== | ||
| 77 | /// | ||
| 78 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 79 | /// Destructor | ||
| 80 | /// | ||
| 81 | ~CExtendedProgress() | ||
| 82 | { | ||
| 83 | using namespace ::kodi::addon; | ||
| 84 | if (m_DialogHandle) | ||
| 85 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 92 | /// @brief Get the used title | ||
| 93 | /// | ||
| 94 | /// @return Title string | ||
| 95 | /// | ||
| 96 | std::string Title() const | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | std::string text; | ||
| 100 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 101 | if (strMsg != nullptr) | ||
| 102 | { | ||
| 103 | if (std::strlen(strMsg)) | ||
| 104 | text = strMsg; | ||
| 105 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 106 | } | ||
| 107 | return text; | ||
| 108 | } | ||
| 109 | //-------------------------------------------------------------------------- | ||
| 110 | |||
| 111 | //========================================================================== | ||
| 112 | /// | ||
| 113 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 114 | /// @brief To set the title of dialog | ||
| 115 | /// | ||
| 116 | /// @param[in] title Title string | ||
| 117 | /// | ||
| 118 | void SetTitle(const std::string& title) | ||
| 119 | { | ||
| 120 | using namespace ::kodi::addon; | ||
| 121 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 122 | } | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //========================================================================== | ||
| 126 | /// | ||
| 127 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 128 | /// @brief Get the used text information string | ||
| 129 | /// | ||
| 130 | /// @return Text string | ||
| 131 | /// | ||
| 132 | std::string Text() const | ||
| 133 | { | ||
| 134 | using namespace ::kodi::addon; | ||
| 135 | std::string text; | ||
| 136 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 137 | if (strMsg != nullptr) | ||
| 138 | { | ||
| 139 | if (std::strlen(strMsg)) | ||
| 140 | text = strMsg; | ||
| 141 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 142 | } | ||
| 143 | return text; | ||
| 144 | } | ||
| 145 | //-------------------------------------------------------------------------- | ||
| 146 | |||
| 147 | //========================================================================== | ||
| 148 | /// | ||
| 149 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 150 | /// @brief To set the used text information string | ||
| 151 | /// | ||
| 152 | /// @param[in] text information text to set | ||
| 153 | /// | ||
| 154 | void SetText(const std::string& text) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 158 | } | ||
| 159 | //-------------------------------------------------------------------------- | ||
| 160 | |||
| 161 | //========================================================================== | ||
| 162 | /// | ||
| 163 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 164 | /// @brief To ask dialog is finished | ||
| 165 | /// | ||
| 166 | /// @return True if on end | ||
| 167 | /// | ||
| 168 | bool IsFinished() const | ||
| 169 | { | ||
| 170 | using namespace ::kodi::addon; | ||
| 171 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //========================================================================== | ||
| 176 | /// | ||
| 177 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 178 | /// @brief Mark progress finished | ||
| 179 | /// | ||
| 180 | void MarkFinished() | ||
| 181 | { | ||
| 182 | using namespace ::kodi::addon; | ||
| 183 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 184 | } | ||
| 185 | //-------------------------------------------------------------------------- | ||
| 186 | |||
| 187 | //========================================================================== | ||
| 188 | /// | ||
| 189 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 190 | /// @brief Get the current progress position as percent | ||
| 191 | /// | ||
| 192 | /// @return Position | ||
| 193 | /// | ||
| 194 | float Percentage() const | ||
| 195 | { | ||
| 196 | using namespace ::kodi::addon; | ||
| 197 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 204 | /// @brief To set the current progress position as percent | ||
| 205 | /// | ||
| 206 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 207 | /// | ||
| 208 | void SetPercentage(float percentage) | ||
| 209 | { | 106 | { |
| 210 | using namespace ::kodi::addon; | 107 | if (std::strlen(strMsg)) |
| 211 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | 108 | text = strMsg; |
| 109 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 110 | strMsg); | ||
| 212 | } | 111 | } |
| 213 | //-------------------------------------------------------------------------- | 112 | return text; |
| 214 | 113 | } | |
| 215 | //========================================================================== | 114 | //-------------------------------------------------------------------------- |
| 216 | /// | 115 | |
| 217 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 116 | //========================================================================== |
| 218 | /// @brief To set progress position with predefined places | 117 | /// |
| 219 | /// | 118 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 220 | /// @param[in] currentItem Place position to use | 119 | /// @brief To set the title of dialog |
| 221 | /// @param[in] itemCount Amount of used places | 120 | /// |
| 222 | /// | 121 | /// @param[in] title Title string |
| 223 | void SetProgress(int currentItem, int itemCount) | 122 | /// |
| 123 | void SetTitle(const std::string& title) | ||
| 124 | { | ||
| 125 | using namespace ::kodi::addon; | ||
| 126 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( | ||
| 127 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 134 | /// @brief Get the used text information string | ||
| 135 | /// | ||
| 136 | /// @return Text string | ||
| 137 | /// | ||
| 138 | std::string Text() const | ||
| 139 | { | ||
| 140 | using namespace ::kodi::addon; | ||
| 141 | std::string text; | ||
| 142 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text( | ||
| 143 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 144 | if (strMsg != nullptr) | ||
| 224 | { | 145 | { |
| 225 | using namespace ::kodi::addon; | 146 | if (std::strlen(strMsg)) |
| 226 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | 147 | text = strMsg; |
| 148 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 149 | strMsg); | ||
| 227 | } | 150 | } |
| 228 | //-------------------------------------------------------------------------- | 151 | return text; |
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 158 | /// @brief To set the used text information string | ||
| 159 | /// | ||
| 160 | /// @param[in] text information text to set | ||
| 161 | /// | ||
| 162 | void SetText(const std::string& text) | ||
| 163 | { | ||
| 164 | using namespace ::kodi::addon; | ||
| 165 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( | ||
| 166 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | ||
| 175 | /// @return True if on end | ||
| 176 | /// | ||
| 177 | bool IsFinished() const | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( | ||
| 181 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 182 | } | ||
| 183 | //-------------------------------------------------------------------------- | ||
| 184 | |||
| 185 | //========================================================================== | ||
| 186 | /// | ||
| 187 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 188 | /// @brief Mark progress finished | ||
| 189 | /// | ||
| 190 | void MarkFinished() | ||
| 191 | { | ||
| 192 | using namespace ::kodi::addon; | ||
| 193 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( | ||
| 194 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 195 | } | ||
| 196 | //-------------------------------------------------------------------------- | ||
| 197 | |||
| 198 | //========================================================================== | ||
| 199 | /// | ||
| 200 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 201 | /// @brief Get the current progress position as percent | ||
| 202 | /// | ||
| 203 | /// @return Position | ||
| 204 | /// | ||
| 205 | float Percentage() const | ||
| 206 | { | ||
| 207 | using namespace ::kodi::addon; | ||
| 208 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage( | ||
| 209 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 210 | } | ||
| 211 | //-------------------------------------------------------------------------- | ||
| 229 | 212 | ||
| 230 | private: | 213 | //========================================================================== |
| 231 | void* m_DialogHandle; | 214 | /// |
| 232 | }; | 215 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 216 | /// @brief To set the current progress position as percent | ||
| 217 | /// | ||
| 218 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 219 | /// | ||
| 220 | void SetPercentage(float percentage) | ||
| 221 | { | ||
| 222 | using namespace ::kodi::addon; | ||
| 223 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( | ||
| 224 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 225 | } | ||
| 226 | //-------------------------------------------------------------------------- | ||
| 227 | |||
| 228 | //========================================================================== | ||
| 229 | /// | ||
| 230 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 231 | /// @brief To set progress position with predefined places | ||
| 232 | /// | ||
| 233 | /// @param[in] currentItem Place position to use | ||
| 234 | /// @param[in] itemCount Amount of used places | ||
| 235 | /// | ||
| 236 | void SetProgress(int currentItem, int itemCount) | ||
| 237 | { | ||
| 238 | using namespace ::kodi::addon; | ||
| 239 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( | ||
| 240 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | ||
| 241 | } | ||
| 242 | //-------------------------------------------------------------------------- | ||
| 243 | |||
| 244 | private: | ||
| 245 | void* m_DialogHandle; | ||
| 246 | }; | ||
| 233 | 247 | ||
| 234 | } /* namespace dialogs */ | 248 | } /* namespace dialogs */ |
| 235 | } /* namespace gui */ | 249 | } /* namespace gui */ |
