Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
ExtendedProgress.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/extended_progress.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
58class ATTR_DLL_LOCAL CExtendedProgress
59{
60public:
61 //============================================================================
67 explicit CExtendedProgress(const std::string& title = "")
68 {
69 using namespace ::kodi::addon;
70 m_DialogHandle =
71 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(
72 CPrivateBase::m_interface->toKodi->kodiBase, title.c_str());
73 if (!m_DialogHandle)
75 "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!");
76 }
77 //----------------------------------------------------------------------------
78
79 //============================================================================
84 {
85 using namespace ::kodi::addon;
86 if (m_DialogHandle)
87 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(
88 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
89 }
90 //----------------------------------------------------------------------------
91
92 //============================================================================
98 std::string Title() const
99 {
100 using namespace ::kodi::addon;
101 std::string text;
102 char* strMsg = CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(
103 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
104 if (strMsg != nullptr)
105 {
106 if (std::strlen(strMsg))
107 text = strMsg;
108 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
109 strMsg);
110 }
111 return text;
112 }
113 //----------------------------------------------------------------------------
114
115 //============================================================================
121 void SetTitle(const std::string& title)
122 {
123 using namespace ::kodi::addon;
124 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(
125 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str());
126 }
127 //----------------------------------------------------------------------------
128
129 //============================================================================
135 std::string Text() const
136 {
137 using namespace ::kodi::addon;
138 std::string text;
139 char* strMsg = CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(
140 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
141 if (strMsg != nullptr)
142 {
143 if (std::strlen(strMsg))
144 text = strMsg;
145 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
146 strMsg);
147 }
148 return text;
149 }
150 //----------------------------------------------------------------------------
151
152 //============================================================================
158 void SetText(const std::string& text)
159 {
160 using namespace ::kodi::addon;
161 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(
162 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str());
163 }
164 //----------------------------------------------------------------------------
165
166 //============================================================================
172 bool IsFinished() const
173 {
174 using namespace ::kodi::addon;
175 return CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(
176 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
177 }
178 //----------------------------------------------------------------------------
179
180 //============================================================================
185 {
186 using namespace ::kodi::addon;
187 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(
188 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
189 }
190 //----------------------------------------------------------------------------
191
192 //============================================================================
198 float Percentage() const
199 {
200 using namespace ::kodi::addon;
201 return CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(
202 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle);
203 }
204 //----------------------------------------------------------------------------
205
206 //============================================================================
212 void SetPercentage(float percentage)
213 {
214 using namespace ::kodi::addon;
215 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(
216 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
217 }
218 //----------------------------------------------------------------------------
219
220 //============================================================================
227 void SetProgress(int currentItem, int itemCount)
228 {
229 using namespace ::kodi::addon;
230 CPrivateBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(
231 CPrivateBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount);
232 }
233 //----------------------------------------------------------------------------
234
235private:
236 KODI_GUI_HANDLE m_DialogHandle;
237};
238
239} /* namespace dialogs */
240} /* namespace gui */
241} /* namespace kodi */
242
243#endif /* __cplusplus */
Definition ExtendedProgress.h:59
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
CExtendedProgress(const std::string &title="")
Definition ExtendedProgress.h:67
void MarkFinished()
Mark progress finished.
Definition ExtendedProgress.h:184
void SetTitle(const std::string &title)
To set the title of dialog.
Definition ExtendedProgress.h:121
void SetPercentage(float percentage)
To set the current progress position as percent.
Definition ExtendedProgress.h:212
std::string Title() const
Get the used title.
Definition ExtendedProgress.h:98
void SetText(const std::string &text)
To set the used text information string.
Definition ExtendedProgress.h:158
std::string Text() const
Get the used text information string.
Definition ExtendedProgress.h:135
~CExtendedProgress()
Definition ExtendedProgress.h:83
void SetProgress(int currentItem, int itemCount)
To set progress position with predefined places.
Definition ExtendedProgress.h:227
float Percentage() const
Get the current progress position as percent.
Definition ExtendedProgress.h:198
bool IsFinished() const
To ask dialog is finished.
Definition ExtendedProgress.h:172
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938