Go to the documentation of this file.
28 #define LOC QString("OSD: ")
52 int newstretch =
static_cast<int>(lroundf(FontAspect * 100));
67 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to load any windows.");
71 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded OSD: size %1x%2 offset %3+%4")
102 QMutableMapIterator<QString, MythScreenType*> it(
m_children);
109 bool match1 = KeepSubs &&
114 it.value() == Except;
115 if (!(match1 || match2))
122 static const std::array<const QString,7> s_defaultWindows {
126 for (
const auto & window : s_defaultWindows)
132 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded window %1").arg(window));
145 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to load window %1").arg(window));
158 if (Map.contains(
"position"))
166 bar->
SetUsed(Map.value(
"position"));
170 if (Map.contains(
"relposition"))
178 bar->
SetUsed(Map.value(
"relposition"));
195 if (Map.contains(
"position"))
215 if (Map.contains(
"numstars"))
221 if (Map.contains(
"tvstate"))
227 if (Map.contains(
"videocodec"))
233 if (Map.contains(
"videodescrip"))
239 if (Map.contains(
"audiocodec"))
245 if (Map.contains(
"audiochannels"))
251 if (Map.contains(
"chanid"))
258 uint chanid = Map[
"chanid"].toUInt();
260 if (Map.contains(
"iconpath"))
261 iconpath = Map[
"iconpath"];
265 if (!iconpath.isEmpty())
277 if (Map.contains(
"channelgroup"))
282 textArea->
SetText(Map[
"channelgroup"]);
286 if (Map.contains(
"inetref"))
289 if (cover && Map.contains(
"coverartpath"))
291 QString coverpath = Map[
"coverartpath"];
296 if (fanart && Map.contains(
"fanartpath"))
298 QString fanartpath = Map[
"fanartpath"];
303 if (banner && Map.contains(
"bannerpath"))
305 QString bannerpath = Map[
"bannerpath"];
310 if (screenshot && Map.contains(
"screenshotpath"))
312 QString screenshotpath = Map[
"screenshotpath"];
314 screenshot->
Load(
false);
317 if (Map.contains(
"nightmode"))
323 if (Map.contains(
"mediatype"))
334 qint64 startts = Map[
"startts"].toLongLong();
335 qint64 endts = Map[
"endts"].toLongLong();
341 else if (endts < nowts)
347 qint64 duration = endts - startts;
349 bar->
SetUsed(
static_cast<int>(1000 * (nowts - startts) / duration));
362 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
387 if (Map.empty() || Total < 1)
393 long long start = -1;
396 QMapIterator<uint64_t, MarkTypes> it(Map);
403 start =
static_cast<long long>(it.key());
413 end =
static_cast<long long>(it.key());
417 start = end =
static_cast<long long>(it.key());
423 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deleteMap discontinuity");
428 if (start >=0 && end >= 0)
430 bar->
AddRegion((
static_cast<double>(start) /
static_cast<double>(Total)),
431 (
static_cast<double>(end) /
static_cast<double>(Total)));
436 if (start > -1 && end < 0)
437 bar->
AddRegion(
static_cast<double>(start) /
static_cast<double>(Total), 1.0);
442 void OSD::SetGraph(
const QString &Window,
const QString &Graph, std::chrono::milliseconds Timecode)
462 bool visible =
false;
466 for (
auto * screen : std::as_const(
m_children))
468 if (screen->IsVisible())
475 auto left = std::chrono::milliseconds(now.msecsTo(expires));
482 QList<MythScreenType*> notifications;
484 QList<MythScreenType*>::iterator it2 = notifications.begin();
485 while (it2 != notifications.end())
489 LOG(VB_GUI, LOG_DEBUG,
LOC +
"Creating OSD Notification");
494 if (!(*it2)->Create())
496 it2 = notifications.erase(it2);
501 if ((*it2)->IsVisible())
513 auto left = std::chrono::milliseconds(now.msecsTo(expires));
526 for (
auto * screen : std::as_const(
m_children))
528 if (screen->IsVisible())
531 screen->SetAlpha(255);
532 screen->ResetNeedsRedraw();
535 for (
auto * notif : std::as_const(notifications))
537 if (notif->IsVisible())
540 notif->SetAlpha(255);
541 notif->ResetNeedsRedraw();
551 QMutableHashIterator<MythScreenType*, QDateTime> it(
m_expireTimes);
555 if (it.value() < now)
567 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
572 QString replace = QCoreApplication::translate(
"(Common)",
574 static_cast<int>(now.secsTo(it.value())));
575 dialog->SetText(newtext.replace(
"%d", replace));
577 auto *cdialog = qobject_cast<MythConfirmationDialog*>(
m_dialog);
580 QString replace = QString::number(now.secsTo(it.value()));
581 cdialog->SetMessage(newtext.replace(
"%d", replace));
590 std::chrono::milliseconds CustomTimeout)
604 std::chrono::milliseconds CustomTimeout)
606 std::chrono::milliseconds time { 0ms };
607 if (CustomTimeout != 0ms)
608 time = CustomTimeout;
610 time =
m_timeouts[
static_cast<size_t>(Timeout)];
615 if ((time > 0ms) && win)
620 else if ((time < 0ms) && win)
641 if (screen !=
nullptr)
669 emit
HideOSD(m_functionalType);
671 m_functionalType = Type;
688 bool visible = valid && screen && screen->
IsVisible(
false);
689 if (!valid || !visible)
691 emit
HideOSD(m_functionalType);
702 return m_dialog->objectName() == Window;
741 DialogAddButton(B.m_text, B.m_data, B.m_menu, B.m_current); });
745 void OSD::DialogShow(
const QString &Window,
const QString &Text, std::chrono::milliseconds UpdateFor)
756 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
760 dialog->SetText(Text);
777 dialog =
new MythDialogBox(Text,
nullptr, Window.toLatin1(),
false,
true);
784 auto *dbox = qobject_cast<MythDialogBox*>(
m_dialog);
786 dbox->SetReturnEvent(
m_tv, Window);
787 auto *cbox = qobject_cast<MythConfirmationDialog*>(
m_dialog);
790 cbox->SetReturnEvent(
m_tv, Window);
791 cbox->SetData(
"DIALOG_CONFIRM_X_X");
819 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
822 dialog->SetBackAction(Text, Data);
824 dialog->SetExitAction(Text, Data);
830 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
832 dialog->AddButtonV(Text, std::move(Data), Menu, Current);
837 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
void DialogAddButton(const QString &Text, QVariant Data, bool Menu=false, bool Current=false)
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...
QHash< MythScreenType *, QDateTime > m_expireTimes
void DialogGetText(InfoMap &Map)
bool DialogVisible(const QString &Window=QString())
static constexpr const char * OSD_WIN_BROWSE
static constexpr const char * OSD_WIN_BDOVERLAY
Image widget, displays a single image or multiple images in sequence.
bool RemoveFirst(void)
Will remove the oldest notification from the stack return true if a screen was removed; or false if n...
static constexpr const char * OSD_WIN_TELETEXT
static void error(const char *str,...)
std::chrono::milliseconds m_fadeTime
void ChangeOSDDialog(const MythOSDDialogData &Data)
void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout)
void ShowDialog(const MythOSDDialogData &Data)
Show a dialog menu, removing any existing dialog.
bool IsWindowVisible(const QString &Window)
void ChangeOSDText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void GetNotificationScreens(QList< MythScreenType * > &screens)
Return the list of notification screens being currently displayed.
bool DialogHandleGesture(MythGestureEvent *Event)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
void BrowsingChanged(bool Browsing)
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
static constexpr const char * OSD_WIN_INTERACT
A narrow purpose widget used to represent cut positions and regions when editing a video.
void SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode)
void ResetWindow(const QString &Window)
virtual bool Create(void)
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
static constexpr const char * OSD_DLG_CONFIRM
virtual void SetArea(const MythRect &rect)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void HideAll(bool KeepSubs=true, MythScreenType *Except=nullptr, bool DropNotification=false)
Screen in which all other widgets are contained and rendered.
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void EditingChanged(bool Editing)
QString m_functionalWindow
void Reset(void) override
Reset the image back to the default defined in the theme.
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
void DialogShow(const QString &Window, const QString &Text="", std::chrono::milliseconds UpdateFor=0ms)
static constexpr const char * OSD_WIN_MESSAGE
void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total)
static constexpr const char * OSD_WIN_PROGEDIT
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
void RemoveWindow(const QString &Window)
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
QHash< QString, QString > InfoMap
void OSDDebugVisibilityChanged(bool Visible)
static constexpr const char * OSD_WIN_STATUS
static constexpr const char * OSD_WIN_PROGINFO
MythImage * GetImage(std::chrono::milliseconds Timecode) const
void HideOSD(OSDFunctionalType Type)
OSD(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, MythPainter *Painter)
Basic menu dialog, message and a list of options.
void AddRegion(double start, double end)
static constexpr const char * OSD_WIN_DEBUG
void SetPainter(MythPainter *painter)
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
virtual void SetTextFromMap(const InfoMap &infoMap)
std::chrono::milliseconds m_timeout
void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type)
void HandleOSDClosed(int OSDType)
static constexpr const char * OSD_DLG_NAVIGATE
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static constexpr const char * OSD_WIN_INPUT
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
static constexpr const char * OSD_DLG_EDITOR
bool Init(QRect Rect, float FontAspect) override
const AudioOutputGraph & GetAudioGraph() const
QString m_pulsedDialogText
MythNotificationCenter * GetCurrentNotificationCenter()
std::vector< MythOSDDialogButton > m_buttons
static QString GetIcon(uint chanid)
All purpose text widget, displays a text string.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Dialog asking for user confirmation. Ok and optional Cancel button.
void SetEditPosition(double position)
MythScreenType * m_dialog
static constexpr const char * OSD_WIN_SUBTITLE
virtual void SetText(const QString &text)
virtual void SetVisible(bool visible)
static void UpdateScreen(MythScreenType *screen)
Will call ::doInit() if the screen is a MythNotificationScreen and ::Create() has been called for it ...
void HideWindow(const QString &Window) override
void PositionWindow(MythScreenType *Window)
void DialogBack(const QString &Text="", const QVariant &Data=0, bool Exit=false)
void SetValues(const QString &Window, const QHash< QString, int > &Map, OSDTimeout Timeout)
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
bool DialogHandleKeypress(QKeyEvent *Event)
A custom event that represents a mouse gesture.
QDateTime m_nextPulseUpdate
QString GetMasterHostPrefix(const QString &storageGroup=QString(), const QString &path=QString())
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
std::array< std::chrono::milliseconds, 4 > m_timeouts
void VisibilityChanged(bool Visible)
void SetVisible(bool visible) override
void IsOSDVisible(bool &Visible)
void Embed(bool Embedding)
bool IsVisible(bool recurse=false) const
void SetExpiry(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout=0ms)
virtual void Begin(QPaintDevice *)
@ kOSDFunctionalType_Default
This widget is used for grouping other widgets for display when a particular named state is called....
static bool ScreenCreated(const MythScreenType *screen)
Return true if ::Create() has been called on screen.
bool DisplayState(const QString &name)
void IsOSDVisible(bool &Visible)