kodi
GUIDialogKaiToast.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 "guilib/GUIDialog.h"
12 
13 #include <queue>
14 
15 #define TOAST_DISPLAY_TIME 5000L // default 5 seconds
16 #define TOAST_MESSAGE_TIME 1000L // minimal message time 1 second
17 
19 {
20 public:
21  CGUIDialogKaiToast(void);
22  ~CGUIDialogKaiToast(void) override;
23 
24  enum eMessageType { Default = 0, Info, Warning, Error };
25 
26  struct Notification
27  {
28  std::string caption;
29  std::string description;
30  std::string imagefile;
31  eMessageType eType;
32  unsigned int displayTime;
33  unsigned int messageTime;
34  bool withSound;
35  };
36 
37  typedef std::queue<Notification> TOASTQUEUE;
38 
39  static void QueueNotification(eMessageType eType, const std::string& aCaption, const std::string& aDescription, unsigned int displayTime = TOAST_DISPLAY_TIME, bool withSound = true, unsigned int messageTime = TOAST_MESSAGE_TIME);
40  static void QueueNotification(const std::string& aCaption, const std::string& aDescription);
41  static void QueueNotification(const std::string& aImageFile, const std::string& aCaption, const std::string& aDescription, unsigned int displayTime = TOAST_DISPLAY_TIME, bool withSound = true, unsigned int messageTime = TOAST_MESSAGE_TIME);
42  bool DoWork();
43 
44  bool OnMessage(CGUIMessage& message) override;
45  void FrameMove() override;
46  void ResetTimer();
47 
48 protected:
49  static void AddToQueue(const std::string& aImageFile, const eMessageType eType, const std::string& aCaption, const std::string& aDescription, unsigned int displayTime, bool withSound, unsigned int messageTime);
50 
51  unsigned int m_timer;
52 
53  unsigned int m_toastDisplayTime;
54  unsigned int m_toastMessageTime;
55 
56  static TOASTQUEUE m_notifications;
57  static CCriticalSection m_critical;
58 };
Definition: GUIDialogKaiToast.h:26
void FrameMove() override
Main update function, called every frame prior to rendering Any window that requires updating on a fr...
Definition: GUIDialogKaiToast.cpp:160
Definition: GUIDialog.h:35
Definition: GUIMessage.h:365
Definition: GUIDialogKaiToast.h:18