MythTV  master
mythnotificationcenter.cpp
Go to the documentation of this file.
1 //
2 // mythnotificationcenter.cpp
3 // MythTV
4 //
5 // Created by Jean-Yves Avenard on 25/06/13.
6 // Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
7 //
8 
9 // Qt headers
10 #include <QCoreApplication>
11 #include <QEvent>
12 #include <QObject>
13 #include <QThread>
14 #include <QTimer>
15 
16 // MythTV headers
18 #include "libmythbase/mythdate.h"
19 
20 #include "mythmainwindow.h"
21 #include "mythnotificationcenter.h"
23 #include "mythpainter.h"
24 #include "mythscreenstack.h"
25 #include "mythscreentype.h"
26 #include "mythuiimage.h"
27 #include "mythuiprogressbar.h"
28 #include "mythuitext.h"
29 
30 #define LOC QString("NotificationCenter: ")
31 
32 static constexpr int8_t HGAP { 5 };
33 static constexpr std::chrono::milliseconds DEFAULT_DURATION { 5s };
34 
36 
38  (QEvent::Type) QEvent::registerEventType();
39 
41 
43  bool deleteScreen)
44 {
45  if (!screen || screen->IsDeleting())
46  return;
47 
48  bool poppedFullscreen = screen->IsFullscreen();
49 
50  screen->aboutToHide();
51 
52  if (m_children.isEmpty())
53  return;
54 
55  MythMainWindow *mainwindow = GetMythMainWindow();
56 
57  screen->setParent(nullptr);
58  if (allowFade && m_doTransitions && !mainwindow->IsExitingToMain())
59  {
60  screen->SetFullscreen(false);
61  if (deleteScreen)
62  {
63  screen->SetDeleting(true);
64  m_toDelete.push_back(screen);
65  }
66  screen->AdjustAlpha(1, -kFadeVal);
67  }
68  else
69  {
70  for (int i = 0; i < m_children.size(); ++i)
71  {
72  if (m_children.at(i) == screen)
73  {
74  m_children.remove(i);
75  break;
76  }
77  }
78  if (deleteScreen)
79  screen->deleteLater();
80 
81  screen = nullptr;
82  }
83 
84  m_topScreen = nullptr;
85 
87 
88  // If we're fading it, we still want to draw it.
89  if (screen && !m_drawOrder.contains(screen))
90  m_drawOrder.push_back(screen);
91 
92  if (!m_children.isEmpty())
93  {
94  for (auto *draw : qAsConst(m_drawOrder))
95  {
96  if (draw != screen && !draw->IsDeleting())
97  {
98  m_topScreen = draw;
99  draw->SetAlpha(255);
100  if (poppedFullscreen)
101  draw->aboutToShow();
102  }
103  }
104  }
105 
106  if (m_topScreen)
107  {
109  }
110  else
111  {
112  // Screen still needs to be redrawn if we have popped the last screen
113  // off the popup stack, or similar
114  if (mainwindow->GetMainStack())
115  {
116  MythScreenType *mainscreen = mainwindow->GetMainStack()->GetTopScreen();
117  if (mainscreen)
118  mainscreen->SetRedraw();
119  }
120  }
121 }
122 
124 {
125  if (m_children.isEmpty())
126  return nullptr;
127  // The top screen is the only currently displayed first, if there's a
128  // fullscreen notification displayed, it's the last one
129  MythScreenType *top = m_children.front();
130  QVector<MythScreenType *>::const_iterator it = m_children.end() - 1;
131 
132  // loop from last to 2nd
133  for (; it != m_children.begin(); --it)
134  {
135  auto *s = qobject_cast<MythNotificationScreen *>(*it);
136  if (!s)
137  {
138  // if for whatever reason it's not a notification on our screen
139  // it will be dropped as we don't know how it appears
140  top = s;
141  continue;
142  }
143  if (s->m_fullscreen)
144  {
145  top = s;
146  break;
147  }
148  }
149  return top;
150 }
151 
153 
155  int id)
156  : MythScreenType(stack, "mythnotification"), m_id(id),
157  m_timer(new QTimer(this))
158 {
159  // Set timer if need be
162 }
163 
165  MythNotification &notification)
166  : MythScreenType(stack, "mythnotification"), m_id(notification.GetId()),
167  m_duration(notification.GetDuration()),
168  m_timer(new QTimer(this))
169 {
170  SetNotification(notification);
172 }
173 
175  const MythNotificationScreen &s)
176  : MythScreenType(stack, "mythnotification"),
177  m_id(s.m_id),
178  m_image(s.m_image),
179  m_imagePath(s.m_imagePath),
180  m_title(s.m_title),
181  m_origin(s.m_origin),
182  m_description(s.m_description),
183  m_extra(s.m_extra),
184  m_duration(s.m_duration),
185  m_progress(s.m_progress),
186  m_progresstext(s.m_progresstext),
187  m_fullscreen(s.m_fullscreen),
188  m_content(s.m_content),
189  m_update(s.m_content), // so all fields are initialised regardless of notification type
190  m_type(s.m_type),
191  m_timer(new QTimer(this)),
192  m_style(s.m_style)
193 {
195 }
196 
198 {
199  m_timer->stop();
200  LOG(VB_GUI, LOG_DEBUG, LOC + "MythNotificationScreen dtor");
201  // We can't rely on Exiting() default MythScreenType signal as
202  // by the time it is emitted, the destructor would have already been called
203  // making the members unusable
204  emit ScreenDeleted();
205 }
206 
208 {
209  bool update = false;
210  m_update = kNone;
211 
212  m_type = notification.type();
213 
218  {
219  m_update |= kImage;
220  update = false;
221  }
222  else if (m_type == MythNotification::Update)
223  {
224  update = true;
225  }
226  else
227  {
228  update = false;
229  }
230 
231  auto *img = dynamic_cast<MythImageNotification*>(&notification);
232  if (img)
233  {
234  QString path = img->GetImagePath();
235 
236  m_update |= kImage;
237 
238  if (path.isNull())
239  {
240  UpdateArtwork(img->GetImage());
241  }
242  else
243  {
244  UpdateArtwork(path);
245  }
246  }
247 
248  auto *play = dynamic_cast<MythPlaybackNotification*>(&notification);
249  if (play)
250  {
251  UpdatePlayback(play->GetProgress(), play->GetProgressText());
252 
253  m_update |= kDuration;
254  }
255 
256  auto *media = dynamic_cast<MythMediaNotification*>(&notification);
257  if (media && m_imagePath.isEmpty() && m_image.isNull())
258  {
259  m_update |= kNoArtwork;
260  }
261 
262  if (!notification.GetMetaData().isEmpty())
263  {
264  UpdateMetaData(notification.GetMetaData());
265  m_update |= kMetaData;
266  }
267  else if (!update)
268  {
269  // A new notification, will always update the metadata field
270  m_update |= kMetaData;
271  }
272 
273  if (!notification.GetStyle().isEmpty())
274  {
275  m_style = notification.GetStyle();
276  m_update |= kStyle;
277  }
278 
279  if (!update)
280  {
282  m_fullscreen = notification.GetFullScreen();
283  }
284 
285  m_duration = notification.GetDuration();
286  m_visibility = notification.GetVisibility();
287  if (!m_visibility)
288  {
289  // no visibility is all visibility to get around QVariant always making 0 the default
290  m_visibility = ~0;
291  }
292  m_priority = notification.GetPriority();
293 
294  // Set timer if need be
296 
297  // We need to re-run init
298  m_refresh = true;
299 }
300 
302 {
303  bool foundtheme = false;
304 
305  // Load the theme for this screen
306  // The xml file containing the screen definition is airplay-ui.xml in this
307  // example, the name of the screen in the xml is airplaypicture. This
308  // should make sense when you look at the xml below
309 
310  QString theme;
311  if (m_fullscreen)
312  {
313  theme = "notification-full";
314  }
315  else if (m_content & kImage)
316  {
317  theme = "notification-image";
318  }
319  else
320  {
321  theme = "notification";
322  }
323 
324  QString theme_attempt = theme + (m_style.isEmpty() ? "" : "-" + m_style);
325 
326  // See if we have an alternative theme available as defined in the notification
327  foundtheme = LoadWindowFromXML("notification-ui.xml", theme_attempt, this);
328  if (!foundtheme && theme_attempt != theme)
329  {
330  // if not, default to the main one
331  foundtheme = LoadWindowFromXML("notification-ui.xml", theme, this);
332  }
333 
334  if (!foundtheme) // If we cannot load the theme for any reason ...
335  return false;
336 
337  m_artworkImage = dynamic_cast<MythUIImage*>(GetChild("image"));
338  m_titleText = dynamic_cast<MythUIText*>(GetChild("title"));
339  m_originText = dynamic_cast<MythUIText*>(GetChild("origin"));
340  m_descriptionText = dynamic_cast<MythUIText*>(GetChild("description"));
341  m_extraText = dynamic_cast<MythUIText*>(GetChild("extra"));
342  m_progresstextText = dynamic_cast<MythUIText*>(GetChild("progress_text"));
343  m_progressBar = dynamic_cast<MythUIProgressBar*>(GetChild("progress"));
344  m_errorState = dynamic_cast<MythUIStateType*>(GetChild("errorstate"));
345  m_mediaState = dynamic_cast<MythUIStateType*>(GetChild("mediastate"));
346 
347  SetErrorState();
348 
349  if (m_mediaState && (m_update & kImage))
350  {
351  m_mediaState->DisplayState((m_content & kNoArtwork) ? "noartwork" : "ok");
352  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Create: Set media state to %1").arg((m_content & kNoArtwork) ? "noartwork" : "ok"));
353  }
354 
355  // store original position
357  m_created = true;
358 
360  {
361  // Visibility will be set automatically during video playback
362  // so can be ignored here
363  SetVisible(false);
364  }
365 
366  // We need to re-run init
367  m_refresh = true;
368 
369  return true;
370 }
371 
376 {
377  if (!m_refresh) // nothing got changed so far, return
378  return;
379 
380  AdjustYPosition();
381 
382  if (m_artworkImage && (m_update & kImage))
383  {
384  if (!m_imagePath.isNull())
385  {
386  // We have a path to the image, use it
388  m_artworkImage->Load();
389  }
390  else if (!m_image.isNull())
391  {
392  // We don't have a path to the image, but the image itself
394  img->Assign(m_image);
395  m_artworkImage->SetImage(img);
396  img->DecrRef();
397  }
398  else
399  {
400  // Will default to displaying whatever placeholder image is defined
401  // in the xml by the themer, means we can show _something_ rather than
402  // a big empty hole. Generally you always want to call Reset() in
403  // these circumstances
405  }
406  }
407 
408  if (m_update != kNone)
409  {
410  InfoMap tmap;
411 
412  tmap["title"] = m_title;
413  if (m_update & kImage)
414  {
415  tmap["image"] = m_imagePath;
416  }
417  tmap["origin"] = m_origin;
418  tmap["description"] = m_description;
419  tmap["extra"] = m_extra;
420  if (m_update & kDuration)
421  {
422  tmap["progress_text"] = m_progresstext;
423  tmap["progress"] = QString("%1").arg((int)(m_progress * 100));
424  }
425  SetTextFromMap(tmap);
426  }
427 
428  if (m_update & kMetaData)
429  {
430  if (m_titleText && m_title.isNull())
431  {
432  m_titleText->Reset();
433  }
434  if (m_originText && m_origin.isNull())
435  {
436  m_originText->Reset();
437  }
438  if (m_descriptionText && m_description.isNull())
439  {
441  }
442  if (m_extraText && m_extra.isNull())
443  {
444  m_extraText->Reset();
445  }
446  }
447 
448  if (m_update & kDuration)
449  {
450  if (m_progresstextText && m_progresstext.isEmpty())
451  {
453  }
454  if (m_progressBar)
455  {
456  if (m_progress >= 0)
457  {
459  m_progressBar->SetTotal(100);
461  }
462  else
463  {
464  // Same as above, calling Reset() allows for a sane, themer defined
465  //default to be displayed
466  m_progressBar->Reset();
467  }
468  }
469  }
470 
471  if (m_progressBar)
472  {
474 
475  }
476 
477  SetErrorState();
478 
479  if (m_mediaState && (m_update & kImage))
480  {
481  m_mediaState->DisplayState((m_update & kNoArtwork) ? "noartwork" : "ok");
482  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Init: Set media state to %1").arg((m_update & kNoArtwork) ? "noartwork" : "ok"));
483  }
484 
485  // No field will be refreshed the next time unless specified otherwise
486  m_update = kNone;
487 
488  if (GetScreenStack() && !m_added)
489  {
490  GetScreenStack()->AddScreen(this);
491  m_added = true;
492  }
493  m_refresh = false;
494 }
495 
497 {
498  if (!m_errorState)
499  return;
500 
501  const char *state = "ok";
502 
504  {
505  state = "error";
506  }
507  else if (m_type == MythNotification::Warning)
508  {
509  state = "warning";
510  }
511  else if (m_type == MythNotification::Check)
512  {
513  state = "check";
514  }
515  else if (m_type == MythNotification::Busy)
516  {
517  state = "busy";
518  }
519  else
520  {
521  state = "ok";
522  }
523  LOG(VB_GUI, LOG_DEBUG, LOC + QString("SetErrorState: Set error state to %1").arg(state));
524  m_errorState->DisplayState(state);
525 }
526 
531 void MythNotificationScreen::UpdateArtwork(const QImage &image)
532 {
533  m_image = image;
534  // We need to re-run init
535  m_refresh = true;
536 }
537 
542 void MythNotificationScreen::UpdateArtwork(const QString &image)
543 {
544  m_imagePath = image;
545  // We need to re-run init
546  m_refresh = true;
547 }
548 
556 {
557  QString tmp;
558 
559  tmp = data["minm"];
560  if (!(tmp.isNull() && (m_update & kMetaData)))
561  {
562  m_title = tmp;
563  }
564  tmp = data["asar"];
565  if (!(tmp.isNull() && (m_update & kMetaData)))
566  {
567  m_origin = tmp;
568  }
569  tmp = data["asal"];
570  if (!(tmp.isNull() && (m_update & kMetaData)))
571  {
572  m_description = tmp;
573  }
574  tmp = data["asfm"];
575  if (!(tmp.isNull() && (m_update & kMetaData)))
576  {
577  m_extra = tmp;
578  }
579  // We need to re-run init
580  m_refresh = true;
581 }
582 
587 void MythNotificationScreen::UpdatePlayback(float progress, const QString &text)
588 {
590  m_progresstext = text;
591  // We need to re-run init
592  m_refresh = true;
593 }
594 
599 {
600  // check if anything has changed
601  m_refresh = !(
602  m_id == s.m_id &&
603  m_image == s.m_image &&
604  m_imagePath == s.m_imagePath &&
605  m_title == s.m_title &&
606  m_origin == s.m_origin &&
608  m_extra == s.m_extra &&
609  m_duration == s.m_duration &&
610  m_progress == s.m_progress &&
612  m_content == s.m_content &&
613  m_fullscreen == s.m_fullscreen &&
614  m_expiry == s.m_expiry &&
615  m_index == s.m_index &&
616  m_style == s.m_style &&
617  m_visibility == s.m_visibility &&
618  m_priority == s.m_priority &&
619  m_type == s.m_type
620  );
621 
622  if (m_refresh)
623  {
624  m_id = s.m_id;
625  m_image = s.m_image;
627  m_title = s.m_title;
628  m_origin = s.m_origin;
630  m_extra = s.m_extra;
634  m_content = s.m_content;
636  m_expiry = s.m_expiry;
637  m_index = s.m_index;
638  m_style = s.m_style;
641  m_type = s.m_type;
642  }
643 
644  m_update = m_content; // so all fields are initialised regardless of notification type
645 }
646 
652 {
653  MythPoint point = m_position;
654  point.setY(m_position.getY().toInt() + (GetHeight() + HGAP) * m_index);
655 
656  if (point == GetPosition())
657  return;
658 
659  SetPosition(point);
660  // We need to re-run init
661  m_refresh = true;
662 }
663 
665 {
666  if (set)
667  {
668  m_index = by;
669  }
670  else
671  {
672  m_index += by;
673  }
674  AdjustYPosition();
675 }
676 
681 {
682  if (index != m_index)
683  {
684  m_refresh = true;
685  m_index = index;
686  }
687 }
688 
690 {
691  return GetArea().getHeight().toInt();
692 }
693 
695 {
696  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Screen id %1 \"%2\" expired")
697  .arg(m_id).arg(m_title));
698  // delete screen
699  GetScreenStack()->PopScreen(this, true, true);
700 }
701 
702 void MythNotificationScreen::SetSingleShotTimer(std::chrono::seconds s, bool update)
703 {
704  // only registered application can display non-expiring notification
705  if (m_id > 0 && s < 0s)
706  return;
707 
708  std::chrono::milliseconds ms = s;
709  ms = ms <= DEFAULT_DURATION ? DEFAULT_DURATION : ms;
710 
711  if (!update)
712  {
714  }
715  m_expiry = MythDate::current().addMSecs(ms.count());
716 
717  m_timer->stop();
718  m_timer->setSingleShot(true);
719  m_timer->start(ms);
720  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Screen %1 expires at %2")
721  .arg(m_id).arg(m_expiry.toString("mm:ss")));
722 
723 }
724 
725 // Public event handling
727 {
728  QStringList actions;
729  bool handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);
730 
731  for (int i = 0; i < actions.size() && !handled; i++)
732  {
733  QString action = actions[i];
734 
735  if (action == "ESCAPE")
736  {
737  if (MythDate::current() < m_creation.addMSecs(MIN_LIFE))
738  return true; // was updated less than 1s ago, ignore
739  }
740  }
741  if (!handled)
742  {
743  handled = MythScreenType::keyPressEvent(event);
744  }
745  return handled;
746 }
747 
749 
751 {
753  "mythnotificationcenter",
754  this);
756 }
757 
759 {
760  const bool isGuiThread =
761  QThread::currentThread() == QCoreApplication::instance()->thread();
762 
763  if (!isGuiThread)
764  {
765  LOG(VB_GENERAL, LOG_ERR, LOC + "Destructor not called from GUI thread");
766  }
767 
768  QMutexLocker lock(&m_lock);
769 
773 
774  // Delete all outstanding queued notifications
775  for (MythNotification *n : qAsConst(m_notifications))
776  {
777  delete n;
778  }
779  m_notifications.clear();
780 
781  delete m_screenStack;
783 }
784 
790 {
791  auto *screen = qobject_cast<MythNotificationScreen*>(sender());
792  if (screen == nullptr)
793  return;
794 
795  bool duefordeletion = m_deletedScreens.contains(screen);
796 
797  LOG(VB_GUI, LOG_DEBUG, LOC +
798  QString("ScreenDeleted: Entering (%1)").arg(duefordeletion));
799  // Check that screen wasn't about to be deleted
800  if (duefordeletion)
801  {
802  m_deletedScreens.removeAll(screen);
803  }
804 
805  int n = m_screens.indexOf(screen);
806  if (n >= 0)
807  {
808  int num = m_screens.removeAll(screen);
809  LOG(VB_GUI, LOG_DEBUG, LOC +
810  QString("%1 screen removed from screens list").arg(num));
812  }
813  else
814  {
815  LOG(VB_GUI, LOG_DEBUG, LOC +
816  QString("Screen[%1] not found in screens list").arg(screen->m_id));
817  }
818 
819  // remove the converted equivalent screen if any
820  if (m_converted.contains(screen))
821  {
822  delete m_converted[screen];
823  }
824  m_converted.remove(screen);
825 
826  // search if an application had registered for it
827  if (m_registrations.contains(screen->m_id))
828  {
829  if (!duefordeletion)
830  {
831  if (!m_screenStack)
832  {
833  // we're in the middle of being deleted
834  m_registrations.remove(screen->m_id);
835  m_unregistered.remove(screen->m_id);
836  }
837  else
838  {
839  // don't remove the id from the list, as the application is still registered
840  // re-create the screen
841  auto *newscreen =
844  m_registrations[screen->m_id] = newscreen;
845  // Screen was deleted, add it to suspended list
846  m_suspended.append(screen->m_id);
847  LOG(VB_GUI, LOG_DEBUG, LOC +
848  "ScreenDeleted: Suspending registered screen");
849  }
850  }
851  else
852  {
853  LOG(VB_GUI, LOG_DEBUG, LOC +
854  "ScreenDeleted: Deleting registered screen");
855  }
856  }
857 }
858 
860 {
861  m_screenStack = nullptr;
862 }
863 
864 bool NCPrivate::Queue(const MythNotification &notification)
865 {
866  QMutexLocker lock(&m_lock);
867 
868  int id = notification.GetId();
869  void *parent = notification.GetParent();
870 
871  if (id > 0)
872  {
873  // quick sanity check to ensure the right caller is attempting
874  // to register a notification
875  if (!m_registrations.contains(id) || m_clients[id] != parent)
876  {
877  LOG(VB_GENERAL, LOG_DEBUG, LOC +
878  QString("Queue: 0x%1, not registered for id (%2)")
879  .arg((size_t)parent, QT_POINTER_SIZE, 16, QChar('0'))
880  .arg(id));
881  }
882  else
883  {
884  // check if notification card has been suspended, in which case
885  // refuse all notification updates
886  if (m_suspended.contains(id))
887  {
888  if (notification.type() == MythNotification::Update)
889  return false;
890  // got something else than an update, remove it from the
891  // suspended list
892  m_suspended.removeAll(id);
893  }
894  }
895  }
896  auto *tmp = dynamic_cast<MythNotification*>(notification.clone());
897  if (tmp == nullptr)
898  return false;
899  m_notifications.append(tmp);
900 
901  // Tell the GUI thread we have new notifications to process
902  QCoreApplication::postEvent(
904 
905  return true;
906 }
907 
909 {
910  QMutexLocker lock(&m_lock);
911 
913 
914  for (MythNotification *n : qAsConst(m_notifications))
915  {
916  int id = n->GetId();
917  bool created = false;
918  MythNotificationScreen *screen = nullptr;
919 
920  if (id > 0)
921  {
922  screen = m_registrations[id];
923  }
924  if (!screen)
925  {
926  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Creating screen %1, \"%2\"")
927  .arg(id).arg(n->GetDescription()));
928 
929  // We have a registration, but no screen. Create one and display it
930  screen = CreateScreen(n);
931  if (!screen) // Reads screen definition from xml, and constructs screen
932  {
933  LOG(VB_GENERAL, LOG_ERR, LOC +
934  QString("ProcessQueue: couldn't create required screen"));
935  delete n;
936  continue; // something is wrong ; ignore
937  }
938  if (id > 0)
939  {
940  m_registrations[id] = screen;
941  }
942  created = true;
943  }
944  else
945  {
946  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Using screen %1, \"%2\"")
947  .arg(id).arg(screen->m_title));
948  screen->SetNotification(*n);
949  }
950 
951  // if the screen got allocated, but did't read theme yet, do it now
952  if (screen && !screen->m_created)
953  {
954  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Reloading screen %1, \"%2\"")
955  .arg(id).arg(screen->m_title));
956 
957 
958  if (!screen->Create())
959  {
960  delete screen;
961  delete n;
962  continue;
963  }
964  created = true;
965  }
966 
967  if (created || !m_screens.contains(screen))
968  {
969  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Inserting screen %1").arg(id));
970 
971  int pos = InsertScreen(screen);
972  // adjust vertical positions
974  }
975 
976  screen->doInit();
977  delete n;
978  }
979  m_notifications.clear();
980 
982 }
983 
989 {
990  MythNotificationScreen *screen = nullptr;
991 
992  if (n)
993  {
994  screen = new MythNotificationScreen(m_screenStack, *n);
995  }
996  else
997  {
998  screen = new MythNotificationScreen(m_screenStack, id);
999  }
1000 
1001  if (!screen->Create()) // Reads screen definition from xml, and constructs screen
1002  {
1003  // If we can't create the screen then we can't display it, so delete
1004  // and abort
1005  delete screen;
1006  return nullptr;
1007  }
1009  return screen;
1010 }
1011 
1012 int NCPrivate::Register(void *from)
1013 {
1014  QMutexLocker lock(&m_lock);
1015 
1016  if (!from)
1017  return -1;
1018 
1019  m_currentId++;
1020  m_registrations.insert(m_currentId, nullptr);
1021  m_clients.insert(m_currentId, from);
1022 
1023  return m_currentId;
1024 }
1025 
1026 void NCPrivate::UnRegister(void *from, int id, bool closeimemdiately)
1027 {
1028  QMutexLocker lock(&m_lock);
1029 
1030  if (!m_registrations.contains(id))
1031  {
1032  LOG(VB_GENERAL, LOG_ERR, LOC +
1033  QString("UnRegister: 0x%1, no such registration (%2)")
1034  .arg((size_t)from, QT_POINTER_SIZE, 16, QChar('0'))
1035  .arg(id));
1036  return;
1037  }
1038 
1039  if (m_clients[id] != from)
1040  {
1041  LOG(VB_GENERAL, LOG_ERR, LOC +
1042  QString("UnRegister: 0x%1, not registered for id (%2")
1043  .arg((size_t)from, QT_POINTER_SIZE, 16, QChar('0'))
1044  .arg(id));
1045  }
1046 
1047  // queue the de-registration
1048  m_unregistered[id] = closeimemdiately;
1049 
1050  m_clients.remove(id);
1051 
1052  // Tell the GUI thread we have something to process
1053  QCoreApplication::postEvent(
1055 }
1056 
1058 {
1059  for (auto *registration : qAsConst(m_registrations))
1060  {
1061  if (registration)
1062  {
1063  m_deletedScreens.append(registration);
1064  }
1065  }
1066  m_registrations.clear();
1067 }
1068 
1070 {
1071  // delete all screens waiting to be deleted
1072  while(!m_deletedScreens.isEmpty())
1073  {
1074  MythNotificationScreen *screen = m_deletedScreens.last();
1075  // we remove the screen from the list before deleting the screen
1076  // so the MythScreenType::Exiting() signal won't process it a second time
1077  m_deletedScreens.removeLast();
1078  if (m_screenStack == nullptr &&
1080  {
1081  // our screen stack got deleted already and all its children
1082  // would have been marked for deletion during the
1083  // ScreenStack destruction but not yet deleted as the event loop may
1084  // not be running; so we can leave the screen alone.
1085  // However for clarity, call deleteLater()
1086  // as it is safe to call deleteLater more than once
1087  screen->deleteLater();
1088  }
1089  else if (screen->GetScreenStack() == m_screenStack)
1090  {
1091  screen->GetScreenStack()->PopScreen(screen, true, true);
1092  }
1093  else if (screen->GetScreenStack() == nullptr)
1094  {
1095  // this screen was never added to a screen stack, delete it now
1096  delete screen;
1097  }
1098  }
1099 }
1100 
1102 {
1103  bool needdelete = false;
1104 
1105  for (auto it = m_unregistered.begin(); it != m_unregistered.end(); ++it)
1106  {
1107  int id = it.key();
1108  bool closeimemdiately = it.value();
1109  MythNotificationScreen *screen = nullptr;
1110 
1111  if (m_registrations.contains(id))
1112  {
1113  screen = m_registrations[id];
1114  if (screen != nullptr && !m_suspended.contains(id))
1115  {
1116  // mark the screen for deletion if no timer is set
1117  if (screen->m_duration <= 0s || closeimemdiately)
1118  {
1119  m_deletedScreens.append(screen);
1120  needdelete = true;
1121  }
1122  }
1123  m_registrations.remove(id);
1124  }
1125 
1126  if (m_suspended.contains(id))
1127  {
1128  // screen had been suspended, delete suspended screen
1129  delete screen;
1130  m_suspended.removeAll(id);
1131  }
1132  }
1133  m_unregistered.clear();
1134 
1135  if (needdelete)
1136  {
1137  DeleteAllScreens();
1138  }
1139 }
1140 
1146 {
1147  QList<MythNotificationScreen*>::iterator it = m_screens.begin();
1148  QList<MythNotificationScreen*>::iterator itend = m_screens.end();
1149 
1150 // if (screen->m_id > 0)
1151 // {
1152 // // we want a permanent screen; add it after the existing one
1153 // for (; it != itend; ++it)
1154 // {
1155 // if ((*it)->m_id <= 0 ||
1156 // (*it)->m_id > screen->m_id)
1157 // break; // reached the temporary screens
1158 // }
1159 // // it points to where we want to insert item
1160 // }
1161 // else
1162  {
1163  it = itend;
1164  }
1165  it = m_screens.insert(it, screen);
1166 
1167  return it - m_screens.begin();
1168 }
1169 
1175 {
1176  QList<MythNotificationScreen*>::iterator it = m_screens.begin();
1177  QList<MythNotificationScreen*>::iterator itend = m_screens.end();
1178 
1179  for (; it != itend; ++it)
1180  {
1181  if (*it == screen)
1182  break;
1183  }
1184 
1185  if (it != itend)
1186  {
1187  it = m_screens.erase(it);
1188  }
1189 
1190  return it - m_screens.begin();
1191 }
1192 
1197 {
1198  QList<MythNotificationScreen*>::iterator it = m_screens.begin();
1199  QList<MythNotificationScreen*>::iterator itend = m_screens.end();
1200 
1201  int position = 0;
1202 
1203  for (; it != itend; ++it)
1204  {
1205  if ((*it)->IsVisible())
1206  {
1207  (*it)->AdjustIndex(position++, true);
1208  }
1209  else
1210  {
1211  (*it)->AdjustIndex(position, true);
1212  }
1213  if ((*it)->m_fullscreen)
1214  {
1215  position = 0;
1216  continue;
1217  }
1218  }
1219 }
1220 
1221 void NCPrivate::GetNotificationScreens(QList<MythScreenType*> &_screens)
1222 {
1223  QList<MythScreenType*> list;
1224  QVector<MythScreenType*> screens;
1225 
1226  if (!m_screenStack)
1227  return;
1228 
1230 
1231  QMutexLocker lock(&m_lock);
1232 
1233  m_screenStack->GetScreenList(screens);
1234 
1235  int position = 0;
1236  for (auto *item : qAsConst(screens))
1237  {
1238  auto *screen = qobject_cast<MythNotificationScreen*>(item);
1239  if (screen)
1240  {
1241  if ((screen->m_visibility & MythNotification::kPlayback) == 0)
1242  continue;
1243 
1244  MythNotificationScreen *newscreen = nullptr;
1245 
1246  if (!m_converted.contains(screen))
1247  {
1248  // screen hasn't been created, return it
1249  newscreen = new MythNotificationScreen(nullptr, *screen);
1250  // CreateScreen can never fail, no need to test return value
1251  m_converted[screen] = newscreen;
1252  }
1253  else
1254  {
1255  newscreen = m_converted[screen];
1256  // Copy new content in case it has changed
1257  newscreen->UpdateFrom(*screen);
1258  }
1259  newscreen->SetVisible(true);
1260  newscreen->SetIndex(position++);
1261  if (screen->m_fullscreen)
1262  {
1263  position = 0;
1264  }
1265  list.append(newscreen);
1266  }
1267  else
1268  {
1269  list.append(item);
1270  }
1271  }
1272  _screens = list;
1273 }
1274 
1276 {
1277  return m_screens.size();
1278 }
1279 
1281 {
1282  return m_notifications.size();
1283 }
1284 
1286 {
1287  QMutexLocker lock(&m_lock);
1288 
1289  if (m_screens.isEmpty())
1290  return false;
1291 
1292  // The top screen is the only currently displayed first, if there's a
1293  // fullscreen notification displayed, it's the last one
1294  MythNotificationScreen *top = m_screens.front();
1295  QList<MythNotificationScreen *>::const_iterator it = m_screens.cend() - 1;
1296 
1297  // loop from last to 2nd
1298  for (; it != m_screens.cbegin(); --it)
1299  {
1300  MythNotificationScreen *s = *it;
1301 
1302  if (s->m_fullscreen)
1303  {
1304  top = s;
1305  break;
1306  }
1307  }
1308 
1309  if (MythDate::current() < top->m_creation.addMSecs(MIN_LIFE))
1310  return false;
1311 
1312  // simulate time-out
1313  top->ProcessTimer();
1314  return true;
1315 }
1316 
1318 
1320 {
1321  return GetNotificationCenter();
1322 }
1323 
1325  : d(new NCPrivate())
1326 {
1327  const bool isGuiThread =
1328  QThread::currentThread() == QCoreApplication::instance()->thread();
1329 
1330  if (!isGuiThread)
1331  {
1332  LOG(VB_GENERAL, LOG_ERR, LOC + "Constructor not called from GUI thread");
1333  }
1334 }
1335 
1337 {
1338  const bool isGuiThread =
1339  QThread::currentThread() == QCoreApplication::instance()->thread();
1340 
1341  if (!isGuiThread)
1342  {
1343  LOG(VB_GENERAL, LOG_ERR, LOC + "Destructor not called from GUI thread");
1344  }
1345 
1346  delete d;
1347  d = nullptr;
1348 }
1349 
1351 {
1352  return d->Queue(notification);
1353 }
1354 
1356 {
1357  const bool isGuiThread =
1358  QThread::currentThread() == QCoreApplication::instance()->thread();
1359 
1360  if (!isGuiThread)
1361  {
1362  LOG(VB_GENERAL, LOG_ERR, LOC + "ProcessQueue not called from GUI thread");
1363  return;
1364  }
1365 
1366  d->ProcessQueue();
1367 }
1368 
1370 {
1371  return d->Register(from);
1372 }
1373 
1374 void MythNotificationCenter::UnRegister(void *from, int id, bool closeimemdiately)
1375 {
1376  d->UnRegister(from, id, closeimemdiately);
1377 }
1378 
1380 {
1381  const auto *s = qobject_cast<const MythNotificationScreen*>(screen);
1382  if (!s)
1383  return {};
1384  return s->m_expiry;
1385 }
1386 
1388 {
1389  const auto *s = qobject_cast<const MythNotificationScreen*>(screen);
1390  if (!s)
1391  return true;
1392  return s->m_created;
1393 }
1394 
1395 void MythNotificationCenter::GetNotificationScreens(QList<MythScreenType*> &_screens)
1396 {
1397  d->GetNotificationScreens(_screens);
1398 }
1399 
1401 {
1402  auto *s = qobject_cast<MythNotificationScreen*>(screen);
1403  if (!s)
1404  return;
1405 
1406  if (s->m_created)
1407  {
1408  s->doInit();
1409  }
1410 }
1411 
1413 {
1414  return d->DisplayedNotifications();
1415 }
1416 
1418 {
1419  return d->QueuedNotifications();
1420 }
1421 
1423 {
1424  return d->RemoveFirst();
1425 }
1426 
1427 void ShowNotificationError(const QString &msg,
1428  const QString &from,
1429  const QString &detail,
1430  const VNMask visibility,
1431  const MythNotification::Priority priority)
1432 {
1433  ShowNotification(true, msg, from, detail,
1434  QString(), QString(), QString(), -1, -1s, false,
1435  visibility, priority);
1436 }
1437 
1438 void ShowNotification(const QString &msg,
1439  const QString &from,
1440  const QString &detail,
1441  const VNMask visibility,
1442  const MythNotification::Priority priority)
1443 {
1444  ShowNotification(false, msg, from, detail,
1445  QString(), QString(), QString(), -1, -1s, false,
1446  visibility, priority);
1447 }
1448 
1450  const QString &msg,
1451  const QString &origin,
1452  const QString &detail,
1453  const QString &image,
1454  const QString &extra,
1455  const QString &progress_text, float progress,
1456  std::chrono::seconds duration,
1457  bool fullscreen,
1458  const VNMask visibility,
1459  const MythNotification::Priority priority,
1460  const QString &style)
1461 {
1463  msg, origin, detail, image, extra, progress_text, progress,
1464  duration, fullscreen, visibility, priority, style);
1465 }
1466 
1467 void ShowNotification(MythNotification::Type type,
1468  const QString &msg,
1469  const QString &origin,
1470  const QString &detail,
1471  const QString &image,
1472  const QString &extra,
1473  const QString &progress_text, float progress,
1474  std::chrono::seconds duration,
1475  bool fullscreen,
1476  const VNMask visibility,
1477  const MythNotification::Priority priority,
1478  const QString &style)
1479 {
1480  if (!GetNotificationCenter())
1481  return;
1482 
1483  MythNotification *n = nullptr;
1484  DMAP data;
1485 
1486  data["minm"] = msg;
1487  data["asar"] = origin.isNull() ? QCoreApplication::translate("(Common)",
1488  "MythTV") : origin;
1489  data["asal"] = detail;
1490  data["asfm"] = extra;
1491 
1492  if (type == MythNotification::Error ||
1496  {
1497  n = new MythNotification(type, data);
1498  if (duration != 0s &&
1501  {
1502  // default duration for those type of notifications is 10s
1503  duration = 10s;
1504  }
1505  }
1506  else
1507  {
1508  if (!image.isEmpty())
1509  {
1510  if (progress >= 0)
1511  {
1512  n = new MythMediaNotification(type,
1513  image, data,
1514  progress, progress_text);
1515  }
1516  else
1517  {
1518  n = new MythImageNotification(type, image, data);
1519  }
1520  }
1521  else if (progress >= 0)
1522  {
1524  progress, progress_text, data);
1525  }
1526  else
1527  {
1528  n = new MythNotification(type, data);
1529  }
1530  }
1531  n->SetDuration(duration);
1532  n->SetFullScreen(fullscreen);
1533  n->SetPriority(priority);
1534  n->SetVisibility(visibility);
1535  n->SetStyle(style);
1536 
1538  delete n;
1539 }
MythNotificationScreen::m_update
uint32_t m_update
Definition: mythnotificationcenter_private.h:215
MythNotificationCenter::ScreenExpiryTime
static QDateTime ScreenExpiryTime(const MythScreenType *screen)
Return when the given screen is going to expire will return an invalid QDateTime if screen isn't a My...
Definition: mythnotificationcenter.cpp:1379
MythScreenStack::m_doTransitions
bool m_doTransitions
Definition: mythscreenstack.h:61
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:315
MythNotificationScreen::UpdateFrom
void UpdateFrom(const MythNotificationScreen &s)
Copy metadata from another notification.
Definition: mythnotificationcenter.cpp:598
MythNotificationScreen::GetHeight
int GetHeight(void)
Definition: mythnotificationcenter.cpp:689
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
MythNotificationScreen::m_origin
QString m_origin
Definition: mythnotificationcenter_private.h:205
mythuitext.h
mythuiprogressbar.h
MythNotificationCenter::ProcessQueue
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
Definition: mythnotificationcenter.cpp:1355
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MythNotificationCenter::RemoveFirst
bool RemoveFirst(void)
Will remove the oldest notification from the stack return true if a screen was removed; or false if n...
Definition: mythnotificationcenter.cpp:1422
NCPrivate::m_deletedScreens
QList< MythNotificationScreen * > m_deletedScreens
Definition: mythnotificationcenter_private.h:136
MythUIText::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitext.cpp:82
error
static void error(const char *str,...)
Definition: vbi.cpp:36
ShowNotificationError
void ShowNotificationError(const QString &msg, const QString &from, const QString &detail, const VNMask visibility, const MythNotification::Priority priority)
convenience utility to display error message as notification
Definition: mythnotificationcenter.cpp:1427
MythNotificationScreen::m_errorState
MythUIStateType * m_errorState
Definition: mythnotificationcenter_private.h:224
MythImageNotification::GetImagePath
QString GetImagePath() const
Definition: mythnotification.h:143
MythNotification::Busy
static Type Busy
Definition: mythnotification.h:38
ShowNotification
void ShowNotification(const QString &msg, const QString &from, const QString &detail, const VNMask visibility, const MythNotification::Priority priority)
Definition: mythnotificationcenter.cpp:1438
NCPrivate::ScreenStackDeleted
void ScreenStackDeleted(void)
Definition: mythnotificationcenter.cpp:859
MythNotificationScreen::m_expiry
QDateTime m_expiry
Definition: mythnotificationcenter_private.h:227
MythNotificationScreen::m_descriptionText
MythUIText * m_descriptionText
Definition: mythnotificationcenter_private.h:220
MythNotificationCenter::QueuedNotifications
int QueuedNotifications(void) const
Returns number of notifications currently queued.
Definition: mythnotificationcenter.cpp:1417
NCPrivate::RemoveFirst
bool RemoveFirst(void)
Will remove the oldest notification from the stack return true if a screen was removed; or false if n...
Definition: mythnotificationcenter.cpp:1285
MythNotificationCenter::d
NCPrivate * d
Definition: mythnotificationcenter.h:122
MythNotification::SetDuration
void SetDuration(std::chrono::seconds Duration)
Contains a duration during which the notification will be displayed for. The duration is informative ...
Definition: mythnotification.cpp:136
MythNotificationCenter::Register
int Register(void *from)
An application can register in which case it will be assigned a reusable screen, which can be modifie...
Definition: mythnotificationcenter.cpp:1369
MythNotificationScreen::m_position
MythPoint m_position
Definition: mythnotificationcenter_private.h:229
progress
bool progress
Definition: mythcommflag.cpp:69
NCPrivate::m_currentId
int m_currentId
Definition: mythnotificationcenter_private.h:142
MythUIProgressBar::SetStart
void SetStart(int value)
Definition: mythuiprogressbar.cpp:63
MythNotificationCenter::GetNotificationScreens
void GetNotificationScreens(QList< MythScreenType * > &screens)
Return the list of notification screens being currently displayed.
Definition: mythnotificationcenter.cpp:1395
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:133
NCPrivate::QueuedNotifications
int QueuedNotifications(void) const
Returns number of notifications currently queued.
Definition: mythnotificationcenter.cpp:1280
mythscreenstack.h
MythNotificationScreenStack::PopScreen
void PopScreen(MythScreenType *screen, bool allowFade=true, bool deleteScreen=true) override
Definition: mythnotificationcenter.cpp:42
MythPainter::GetFormatImage
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
Definition: mythpainter.cpp:540
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:969
NCPrivate::DeleteAllRegistrations
void DeleteAllRegistrations(void)
Definition: mythnotificationcenter.cpp:1057
MythNotificationScreenStack::CheckDeletes
void CheckDeletes()
Definition: mythnotificationcenter_private.h:253
MythNotificationScreen::kDuration
@ kDuration
Definition: mythnotificationcenter_private.h:187
MythNotification::GetDuration
std::chrono::seconds GetDuration() const
Definition: mythnotification.h:105
MythUIProgressBar::SetUsed
void SetUsed(int value)
Definition: mythuiprogressbar.cpp:69
mythnotificationcenter_private.h
MythScreenStack
Definition: mythscreenstack.h:16
MythUIType::GetPainter
virtual MythPainter * GetPainter(void)
Definition: mythuitype.cpp:1421
NCPrivate::Register
int Register(void *from)
An application can register in which case it will be assigned a reusable screen, which can be modifie...
Definition: mythnotificationcenter.cpp:1012
MythNotification::SetPriority
void SetPriority(Priority nPriority)
Reserved for future use, not implemented at this stage.
Definition: mythnotification.cpp:162
MythNotificationScreen::m_timer
QTimer * m_timer
Definition: mythnotificationcenter_private.h:230
MythNotification
Definition: mythnotification.h:29
MIN_LIFE
#define MIN_LIFE
Definition: mythnotificationcenter_private.h:31
MythNotificationScreen::m_added
bool m_added
Definition: mythnotificationcenter_private.h:212
NCPrivate::Queue
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
Definition: mythnotificationcenter.cpp:864
MythNotificationScreen::m_progresstext
QString m_progresstext
Definition: mythnotificationcenter_private.h:210
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythNotificationScreen::kImage
@ kImage
Definition: mythnotificationcenter_private.h:186
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
MythNotificationScreen::SetNotification
void SetNotification(MythNotification &notification)
Definition: mythnotificationcenter.cpp:207
MythNotification::SetVisibility
void SetVisibility(VNMask nVisibility)
Define a bitmask of Visibility.
Definition: mythnotification.cpp:154
NCPrivate::DeleteUnregistered
void DeleteUnregistered(void)
Definition: mythnotificationcenter.cpp:1101
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:646
MythNotification::GetFullScreen
bool GetFullScreen() const
Definition: mythnotification.h:102
NCPrivate::m_screens
QList< MythNotificationScreen * > m_screens
Definition: mythnotificationcenter_private.h:135
MythNotificationScreen::m_extra
QString m_extra
Definition: mythnotificationcenter_private.h:207
MythNotification::SetStyle
void SetStyle(const QString &sStyle)
Contains an alternative notification style. Should a style be defined, the Notification Center will a...
Definition: mythnotification.cpp:146
NCPrivate::m_clients
QMap< int, void * > m_clients
Definition: mythnotificationcenter_private.h:140
mythuiimage.h
MythImageNotification
Definition: mythnotification.h:131
MythNotificationScreen::m_visibility
VNMask m_visibility
Definition: mythnotificationcenter_private.h:232
MythScreenStack::m_children
QVector< MythScreenType * > m_children
Definition: mythscreenstack.h:56
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
NCPrivate::m_converted
QMap< MythNotificationScreen *, MythNotificationScreen * > m_converted
Definition: mythnotificationcenter_private.h:143
NCPrivate::RefreshScreenPosition
void RefreshScreenPosition(int from=0)
Re-position screens on display.
Definition: mythnotificationcenter.cpp:1196
NCPrivate::m_lock
QMutex m_lock
Definition: mythnotificationcenter_private.h:141
MythScreenStack::m_drawOrder
QVector< MythScreenType * > m_drawOrder
Definition: mythscreenstack.h:57
MythNotificationScreen::m_title
QString m_title
Definition: mythnotificationcenter_private.h:204
NCPrivate
Definition: mythnotificationcenter_private.h:33
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
MythUIType::GetArea
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:884
NCPrivate::NCPrivate
NCPrivate(void)
Definition: mythnotificationcenter.cpp:750
NCPrivate::m_screenStack
MythNotificationScreenStack * m_screenStack
Definition: mythnotificationcenter_private.h:133
DEFAULT_DURATION
static constexpr std::chrono::milliseconds DEFAULT_DURATION
Definition: mythnotificationcenter.cpp:33
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythNotificationScreen::m_fullscreen
bool m_fullscreen
Definition: mythnotificationcenter_private.h:211
MythScreenStack::GetScreenList
void GetScreenList(QVector< MythScreenType * > &screens)
Definition: mythscreenstack.cpp:198
MythNotificationCenter::MythNotificationCenter
MythNotificationCenter(void)
Definition: mythnotificationcenter.cpp:1324
MythNotificationScreen::m_type
MythNotification::Type m_type
Definition: mythnotificationcenter_private.h:216
MythNotificationScreen::m_index
int m_index
Definition: mythnotificationcenter_private.h:228
MythNotification::kPlayback
@ kPlayback
Definition: mythnotification.h:78
mythdate.h
MythUIType::SetAlpha
void SetAlpha(int newalpha)
Definition: mythuitype.cpp:945
MythNotificationScreenStack::kFadeVal
static const int kFadeVal
Definition: mythnotificationcenter_private.h:264
MythUIProgressBar::SetTotal
void SetTotal(int value)
Definition: mythuiprogressbar.cpp:81
MythNotificationScreen::kMetaData
@ kMetaData
Definition: mythnotificationcenter_private.h:188
NCPrivate::ProcessQueue
void ProcessQueue(void)
ProcessQueue will be called by the GUI event handler and will process all queued MythNotifications an...
Definition: mythnotificationcenter.cpp:908
MythNotificationScreen::m_duration
std::chrono::seconds m_duration
Definition: mythnotificationcenter_private.h:208
MythNotification::SetFullScreen
void SetFullScreen(bool FullScreen)
A notification may request to be displayed in full screen, this request may not be fullfilled should ...
Definition: mythnotification.cpp:107
NCPrivate::~NCPrivate
~NCPrivate() override
Definition: mythnotificationcenter.cpp:758
MythNotificationScreen::m_originText
MythUIText * m_originText
Definition: mythnotificationcenter_private.h:219
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1104
MythNotificationScreen::m_mediaState
MythUIStateType * m_mediaState
Definition: mythnotificationcenter_private.h:225
MythUIProgressBar::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuiprogressbar.cpp:16
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
MythUIType::SetPosition
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
Definition: mythuitype.cpp:532
MythNotificationScreen::~MythNotificationScreen
~MythNotificationScreen() override
Definition: mythnotificationcenter.cpp:197
MythNotification::GetPriority
Priority GetPriority() const
Definition: mythnotification.h:108
MythNotificationCenter::~MythNotificationCenter
virtual ~MythNotificationCenter()
Definition: mythnotificationcenter.cpp:1336
VNMask
unsigned int VNMask
Definition: mythnotification.h:27
MythNotificationScreen
Definition: mythnotificationcenter_private.h:146
MythUIType::AdjustAlpha
void AdjustAlpha(int mode, int alphachange, int minalpha=0, int maxalpha=255)
Definition: mythuitype.cpp:927
MythNotificationScreen::m_progresstextText
MythUIText * m_progresstextText
Definition: mythnotificationcenter_private.h:222
MythNotification::clone
MythEvent * clone() const override
Definition: mythnotification.cpp:76
MythNotificationScreenStack::GetTopScreen
MythScreenType * GetTopScreen(void) const override
Definition: mythnotificationcenter.cpp:123
MythUIType::GetPosition
virtual MythPoint GetPosition(void) const
Definition: mythuitype.cpp:563
MythNotificationCenter::DisplayedNotifications
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
Definition: mythnotificationcenter.cpp:1412
MythPoint::setY
void setY(const QString &sY)
Definition: mythrect.cpp:540
MythImage::DecrRef
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:52
MythUIComposite::SetTextFromMap
virtual void SetTextFromMap(const InfoMap &infoMap)
Definition: mythuicomposite.cpp:9
MythNotification::Priority
Priority
Definition: mythnotification.h:58
MythNotification::Check
static Type Check
Definition: mythnotification.h:37
mythpainter.h
MythNotificationScreen::UpdatePlayback
void UpdatePlayback(float progress, const QString &text)
Update playback position information.
Definition: mythnotificationcenter.cpp:587
MythNotification::GetParent
void * GetParent() const
Definition: mythnotification.h:101
MythNotificationScreen::m_progress
float m_progress
Definition: mythnotificationcenter_private.h:209
MythMediaNotification
Definition: mythnotification.h:180
MythNotification::New
static Type New
Definition: mythnotification.h:32
NCPrivate::InsertScreen
int InsertScreen(MythNotificationScreen *screen)
Insert screen into list of screens.
Definition: mythnotificationcenter.cpp:1145
MythNotificationScreen::kNoArtwork
@ kNoArtwork
Definition: mythnotificationcenter_private.h:190
MythNotificationScreen::m_id
int m_id
Definition: mythnotificationcenter_private.h:201
NCPrivate::RemoveScreen
int RemoveScreen(MythNotificationScreen *screen)
Remove screen from list of screens.
Definition: mythnotificationcenter.cpp:1174
MythNotificationScreen::MythNotificationScreen
MythNotificationScreen(MythScreenStack *stack, int id=-1)
Definition: mythnotificationcenter.cpp:154
NCPrivate::m_originalScreenStack
MythNotificationScreenStack * m_originalScreenStack
Definition: mythnotificationcenter_private.h:132
MythNotificationScreen::kStyle
@ kStyle
Definition: mythnotificationcenter_private.h:189
MythScreenType::GetScreenStack
MythScreenStack * GetScreenStack() const
Definition: mythscreentype.cpp:217
MythNotificationScreen::m_refresh
bool m_refresh
Definition: mythnotificationcenter_private.h:234
NCPrivate::UnRegister
void UnRegister(void *from, int id, bool closeimemdiately=false)
Unregister the client.
Definition: mythnotificationcenter.cpp:1026
MythNotificationScreen::AdjustYPosition
void AdjustYPosition(void)
Update Y position of the screen All children elements will be relocated.
Definition: mythnotificationcenter.cpp:651
HGAP
static constexpr int8_t HGAP
Definition: mythnotificationcenter.cpp:32
NCPrivate::CreateScreen
MythNotificationScreen * CreateScreen(MythNotification *notification, int id=-1)
CreateScreen will create a MythNotificationScreen instance.
Definition: mythnotificationcenter.cpp:988
MythNotificationScreenStack
Definition: mythnotificationcenter_private.h:239
MythNotificationScreen::m_image
QImage m_image
Definition: mythnotificationcenter_private.h:202
NCPrivate::DeleteAllScreens
void DeleteAllScreens(void)
Definition: mythnotificationcenter.cpp:1069
MythNotificationScreen::m_progressBar
MythUIProgressBar * m_progressBar
Definition: mythnotificationcenter_private.h:223
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:404
MythScreenType::doInit
void doInit(void)
Definition: mythscreentype.cpp:365
mythcorecontext.h
MythNotificationScreen::m_style
QString m_style
Definition: mythnotificationcenter_private.h:231
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:695
MythScreenStack::m_toDelete
QVector< MythScreenType * > m_toDelete
Definition: mythscreenstack.h:67
NCPrivate::m_registrations
QMap< int, MythNotificationScreen * > m_registrations
Definition: mythnotificationcenter_private.h:137
MythNotificationScreen::m_priority
MythNotification::Priority m_priority
Definition: mythnotificationcenter_private.h:233
MythImage
Definition: mythimage.h:36
MythNotificationScreen::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythnotificationcenter.cpp:726
NCPrivate::m_suspended
QList< int > m_suspended
Definition: mythnotificationcenter_private.h:138
MythScreenType::IsDeleting
bool IsDeleting(void) const
Definition: mythscreentype.cpp:256
MythNotificationScreen::AdjustIndex
void AdjustIndex(int by, bool set=false)
Definition: mythnotificationcenter.cpp:664
MythNotificationScreen::m_extraText
MythUIText * m_extraText
Definition: mythnotificationcenter_private.h:221
MythNotificationScreen::m_description
QString m_description
Definition: mythnotificationcenter_private.h:206
LOC
#define LOC
Definition: mythnotificationcenter.cpp:30
MythNotification::GetMetaData
DMAP GetMetaData() const
Definition: mythnotification.h:104
MythNotificationScreen::SetIndex
void SetIndex(int index)
set index, without recalculating coordinates
Definition: mythnotificationcenter.cpp:680
MythNotificationScreen::m_content
uint32_t m_content
Definition: mythnotificationcenter_private.h:214
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1108
NCPrivate::GetNotificationScreens
void GetNotificationScreens(QList< MythScreenType * > &screens)
Return the list of notification screens being currently displayed.
Definition: mythnotificationcenter.cpp:1221
GetNotificationCenter
MythNotificationCenter * GetNotificationCenter(void)
Definition: mythmainwindow.cpp:122
MythNotificationCenter::UnRegister
void UnRegister(void *from, int id, bool closeimemdiately=false)
Unregister the client.
Definition: mythnotificationcenter.cpp:1374
MythScreenStack::PopScreen
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
Definition: mythscreenstack.cpp:84
MythNotificationCenter::UpdateScreen
static void UpdateScreen(MythScreenType *screen)
Will call ::doInit() if the screen is a MythNotificationScreen and ::Create() has been called for it ...
Definition: mythnotificationcenter.cpp:1400
MythScreenStack::m_topScreen
MythScreenType * m_topScreen
Definition: mythscreenstack.h:59
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
NCPrivate::DisplayedNotifications
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
Definition: mythnotificationcenter.cpp:1275
build_compdb.action
action
Definition: build_compdb.py:9
MythNotificationCenterEvent
Definition: mythnotificationcenter.h:25
MythNotification::GetStyle
QString GetStyle() const
Definition: mythnotification.h:106
MythMainWindow::IsExitingToMain
bool IsExitingToMain() const
Definition: mythmainwindow.cpp:1032
MythUIImage::SetImage
void SetImage(MythImage *img)
Should not be used unless absolutely necessary since it bypasses the image caching and threaded loade...
Definition: mythuiimage.cpp:749
MythNotification::Warning
static Type Warning
Definition: mythnotification.h:36
MythNotificationScreen::ScreenDeleted
void ScreenDeleted()
MythNotification::GetId
int GetId() const
Definition: mythnotification.h:100
MythNotificationScreen::kNone
@ kNone
Definition: mythnotificationcenter_private.h:185
MythNotificationScreen::UpdateMetaData
void UpdateMetaData(const DMAP &data)
Read some DMAP tag to extract title, artist, album and file format.
Definition: mythnotificationcenter.cpp:555
MythNotificationScreen::m_imagePath
QString m_imagePath
Definition: mythnotificationcenter_private.h:203
MythNotificationScreen::Init
void Init(void) override
Update the various fields of a MythNotificationScreen.
Definition: mythnotificationcenter.cpp:375
MythNotificationCenter::GetInstance
static MythNotificationCenter * GetInstance(void)
returns the MythNotificationCenter singleton
Definition: mythnotificationcenter.cpp:1319
MythNotificationScreen::ProcessTimer
void ProcessTimer(void)
Definition: mythnotificationcenter.cpp:694
MythNotificationScreen::m_titleText
MythUIText * m_titleText
Definition: mythnotificationcenter_private.h:218
MythScreenType::aboutToHide
virtual void aboutToHide(void)
Definition: mythscreentype.cpp:222
MythScreenType::SetDeleting
void SetDeleting(bool deleting)
Definition: mythscreentype.cpp:261
MythScreenStack::RecalculateDrawOrder
virtual void RecalculateDrawOrder(void)
Definition: mythscreenstack.cpp:233
MythNotificationScreen::m_artworkImage
MythUIImage * m_artworkImage
Definition: mythnotificationcenter_private.h:217
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MythNotificationScreen::SetErrorState
void SetErrorState(void) const
Definition: mythnotificationcenter.cpp:496
MythRect::getHeight
QString getHeight(void) const
Definition: mythrect.cpp:377
MythImage::Assign
void Assign(const QImage &img)
Definition: mythimage.cpp:77
MythNotificationCenter
Definition: mythnotificationcenter.h:40
DMAP
QMap< QString, QString > DMAP
Definition: mythnotification.h:26
NCPrivate::ScreenDeleted
void ScreenDeleted(void)
Remove screen from screens list.
Definition: mythnotificationcenter.cpp:789
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:677
MythUIProgressBar::SetVisible
void SetVisible(bool visible) override
Definition: mythuiprogressbar.cpp:196
NCPrivate::m_unregistered
QMap< int, bool > m_unregistered
Definition: mythnotificationcenter_private.h:139
MythNotificationScreen::UpdateArtwork
void UpdateArtwork(const QImage &image)
Update artwork image.
Definition: mythnotificationcenter.cpp:531
MythPoint::getY
QString getY(void) const
Definition: mythrect.cpp:566
mythmainwindow.h
mythnotificationcenter.h
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:50
MythUIType::SetRedraw
void SetRedraw(void)
Definition: mythuitype.cpp:308
MythScreenType::IsFullscreen
bool IsFullscreen(void) const
Definition: mythscreentype.cpp:103
MythNotification::Update
static Type Update
Definition: mythnotification.h:33
MythNotificationScreen::SetSingleShotTimer
void SetSingleShotTimer(std::chrono::seconds s, bool update=false)
Definition: mythnotificationcenter.cpp:702
MythNotification::Error
static Type Error
Definition: mythnotification.h:35
MythMainWindow
Definition: mythmainwindow.h:28
MythUIStateType
This widget is used for grouping other widgets for display when a particular named state is called....
Definition: mythuistatetype.h:22
MythNotificationScreen::m_created
bool m_created
Definition: mythnotificationcenter_private.h:213
MythNotificationCenter::ScreenCreated
static bool ScreenCreated(const MythScreenType *screen)
Return true if ::Create() has been called on screen.
Definition: mythnotificationcenter.cpp:1387
mythscreentype.h
MythNotification::GetVisibility
VNMask GetVisibility() const
Definition: mythnotification.h:107
MythUIStateType::DisplayState
bool DisplayState(const QString &name)
Definition: mythuistatetype.cpp:84
NCPrivate::m_notifications
QList< MythNotification * > m_notifications
Definition: mythnotificationcenter_private.h:134
MythNotificationScreen::m_creation
QDateTime m_creation
Definition: mythnotificationcenter_private.h:226
MythNotificationCenterEvent::kEventType
static Type kEventType
Definition: mythnotificationcenter.h:30
MythNotificationScreen::Create
bool Create(void) override
Definition: mythnotificationcenter.cpp:301
MythPlaybackNotification
Definition: mythnotification.h:153
MythScreenType::SetFullscreen
void SetFullscreen(bool full)
Definition: mythscreentype.cpp:108
MythScreenStack::GetTopScreen
virtual MythScreenType * GetTopScreen(void) const
Definition: mythscreenstack.cpp:180
MythPoint
Wrapper around QPoint allowing us to handle percentage and other relative values for positioning in m...
Definition: mythrect.h:88
MythNotificationCenter::Queue
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
Definition: mythnotificationcenter.cpp:1350