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