1 /* 2 * Copyright (C) 2012-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 "guilib/GUIDialog.h" 12 13 #include <string> 14 #include <vector> 15 16 class CGUIDialogProgressBarHandle 17 { 18 public: CGUIDialogProgressBarHandle(const std::string & strTitle)19 explicit CGUIDialogProgressBarHandle(const std::string &strTitle) : 20 m_fPercentage(0), 21 m_strTitle(strTitle), 22 m_bFinished(false) {} 23 virtual ~CGUIDialogProgressBarHandle(void) = default; 24 Title(void)25 const std::string &Title(void) { return m_strTitle; } 26 void SetTitle(const std::string &strTitle); 27 28 std::string Text(void) const; 29 void SetText(const std::string &strText); 30 IsFinished(void)31 bool IsFinished(void) const { return m_bFinished; } MarkFinished(void)32 void MarkFinished(void) { m_bFinished = true; } 33 Percentage(void)34 float Percentage(void) const { return m_fPercentage;} SetPercentage(float fPercentage)35 void SetPercentage(float fPercentage) { m_fPercentage = fPercentage; } 36 void SetProgress(int currentItem, int itemCount); 37 38 private: 39 mutable CCriticalSection m_critSection; 40 float m_fPercentage; 41 std::string m_strTitle; 42 std::string m_strText; 43 bool m_bFinished; 44 }; 45 46 class CGUIDialogExtendedProgressBar : public CGUIDialog 47 { 48 public: 49 CGUIDialogExtendedProgressBar(void); 50 ~CGUIDialogExtendedProgressBar(void) override = default; 51 bool OnMessage(CGUIMessage& message) override; 52 void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override; 53 54 CGUIDialogProgressBarHandle *GetHandle(const std::string &strTitle); 55 56 protected: 57 void UpdateState(unsigned int currentTime); 58 59 CCriticalSection m_critSection; 60 unsigned int m_iCurrentItem; 61 unsigned int m_iLastSwitchTime; 62 std::vector<CGUIDialogProgressBarHandle *> m_handles; 63 }; 64