xbmc
GUIDialogProgress.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 "GUIDialogBoxBase.h"
12 #include "IProgressCallback.h"
13 
14 #include <array>
15 
18 {
19 public:
20  CGUIDialogProgress(void);
21  ~CGUIDialogProgress(void) override;
22 
23  void Reset();
24  void Open(const std::string &param = "");
25  bool OnMessage(CGUIMessage& message) override;
26  bool OnBack(int actionID) override;
27  void OnWindowLoaded() override;
28  void Progress();
29  bool IsCanceled() const { return m_iChoice == CHOICE_CANCELED; }
30  void SetPercentage(int iPercentage);
31  int GetPercentage() const { return m_percentage; }
32  void ShowProgressBar(bool bOnOff);
33 
34  void ShowChoice(int iChoice, const CVariant& label);
35 
36  static constexpr int CHOICE_NONE = -2;
37  static constexpr int CHOICE_CANCELED = -1;
38  int GetChoice() const;
39 
47  bool Wait(int progresstime = 10);
48 
54  bool WaitOnEvent(CEvent& event);
55 
56  // Implements IProgressCallback
57  void SetProgressMax(int iMax) override;
58  void SetProgressAdvance(int nSteps=1) override;
59  bool Abort() override;
60 
61  void SetCanCancel(bool bCanCancel);
62 
63 protected:
64  void OnInitWindow() override;
65  int GetDefaultLabelID(int controlId) const override;
66  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
67 
68  bool m_bCanCancel;
69 
70  int m_iCurrent;
71  int m_iMax;
72  int m_percentage;
73  bool m_showProgress;
74 
75  std::array<bool, DIALOG_MAX_CHOICES> m_supportedChoices = {};
76  int m_iChoice = CHOICE_NONE;
77 
78 private:
79  void UpdateControls();
80 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
bool WaitOnEvent(CEvent &event)
Wait on an event or for the progress dialog to be canceled, while regularly rendering to allow for po...
Definition: GUIDialogProgress.cpp:207
bool Wait(int progresstime=10)
Wait for the progress dialog to be closed or canceled, while regularly rendering to allow for pointer...
Definition: GUIDialogProgress.cpp:198
Definition: Variant.h:31
void OnInitWindow() override
Called on window open.
Definition: GUIDialogProgress.cpp:263
Definition: IProgressCallback.h:11
Definition: GUIMessage.h:365
Definition: GUIDialogProgress.h:16
Definition: GUIDialogBoxBase.h:27