summaryrefslogtreecommitdiffstats
path: root/xbmc/dialogs/GUIDialogCache.h
blob: 3166cbe8ab383e44197bdc8f5e5756e03af0dd62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "filesystem/IFileTypes.h"
#include "threads/SystemClock.h"
#include "threads/Thread.h"

#include <string>

class CGUIDialogProgress;

class CGUIDialogCache : public CThread, public XFILE::IFileCallback
{
public:
  CGUIDialogCache(std::chrono::milliseconds delay = std::chrono::milliseconds(100),
                  const std::string& strHeader = "",
                  const std::string& strMsg = "");
  ~CGUIDialogCache() override;
  void SetHeader(const std::string& strHeader);
  void SetHeader(int nHeader);
  void SetMessage(const std::string& strMessage);
  bool IsCanceled() const;
  void ShowProgressBar(bool bOnOff);
  void SetPercentage(int iPercentage);

  void Close(bool bForceClose = false);

  void Process() override;
  bool OnFileCallback(void* pContext, int ipercent, float avgSpeed) override;

protected:

  void OpenDialog();

  XbmcThreads::EndTime<> m_endtime;
  CGUIDialogProgress* m_pDlg;
  std::string m_strHeader;
  std::string m_strLinePrev;
  std::string m_strLinePrev2;
  bool bSentCancel;
};