29#define LOC QString("OSD: ")
53 int newstretch =
static_cast<int>(lroundf(FontAspect * 100));
68 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to load any windows.");
72 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded OSD: size %1x%2 offset %3+%4")
103 QMutableMapIterator<QString, MythScreenType*> it(
m_children);
110 bool match1 = KeepSubs &&
115 it.value() == Except;
116 if (!(match1 || match2))
123 static const std::array<const QString,7> s_defaultWindows {
127 for (
const auto & window : s_defaultWindows)
133 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded window %1").arg(window));
146 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to load window %1").arg(window));
159 if (Map.contains(
"position"))
167 bar->
SetUsed(Map.value(
"position"));
171 if (Map.contains(
"relposition"))
179 bar->
SetUsed(Map.value(
"relposition"));
196 if (Map.contains(
"position"))
216 if (Map.contains(
"numstars"))
222 if (Map.contains(
"tvstate"))
228 if (Map.contains(
"videocodec"))
234 if (Map.contains(
"videodescrip"))
240 if (Map.contains(
"audiocodec"))
246 if (Map.contains(
"audiochannels"))
252 if (Map.contains(
"chanid"))
259 uint chanid = Map[
"chanid"].toUInt();
261 if (Map.contains(
"iconpath"))
262 iconpath = Map[
"iconpath"];
266 if (!iconpath.isEmpty())
278 if (Map.contains(
"channelgroup"))
283 textArea->
SetText(Map[
"channelgroup"]);
287 if (Map.contains(
"inetref"))
290 if (cover && Map.contains(
"coverartpath"))
292 QString coverpath = Map[
"coverartpath"];
297 if (fanart && Map.contains(
"fanartpath"))
299 QString fanartpath = Map[
"fanartpath"];
304 if (banner && Map.contains(
"bannerpath"))
306 QString bannerpath = Map[
"bannerpath"];
311 if (screenshot && Map.contains(
"screenshotpath"))
313 QString screenshotpath = Map[
"screenshotpath"];
315 screenshot->
Load(
false);
318 if (Map.contains(
"nightmode"))
324 if (Map.contains(
"mediatype"))
335 qint64 startts = Map[
"startts"].toLongLong();
336 qint64 endts = Map[
"endts"].toLongLong();
342 else if (endts < nowts)
348 qint64 duration = endts - startts;
350 bar->
SetUsed(
static_cast<int>(1000 * (nowts - startts) / duration));
363 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
388 if (Map.empty() || Total < 1)
394 long long start = -1;
397 QMapIterator<uint64_t, MarkTypes> it(Map);
404 start =
static_cast<long long>(it.key());
414 end =
static_cast<long long>(it.key());
418 start = end =
static_cast<long long>(it.key());
424 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deleteMap discontinuity");
429 if (start >=0 && end >= 0)
431 bar->
AddRegion((
static_cast<double>(start) /
static_cast<double>(Total)),
432 (
static_cast<double>(end) /
static_cast<double>(Total)));
437 if (start > -1 && end < 0)
438 bar->
AddRegion(
static_cast<double>(start) /
static_cast<double>(Total), 1.0);
443void OSD::SetGraph(
const QString &Window,
const QString &Graph, std::chrono::milliseconds Timecode)
463 bool visible =
false;
467 for (
auto * screen : std::as_const(
m_children))
469 if (screen->IsVisible())
476 auto left = std::chrono::milliseconds(now.msecsTo(expires));
483 QList<MythScreenType*> notifications;
485 QList<MythScreenType*>::iterator it2 = notifications.begin();
486 while (it2 != notifications.end())
490 LOG(VB_GUI, LOG_DEBUG,
LOC +
"Creating OSD Notification");
495 if (!(*it2)->Create())
497 it2 = notifications.erase(it2);
502 if ((*it2)->IsVisible())
514 auto left = std::chrono::milliseconds(now.msecsTo(expires));
527 for (
auto * screen : std::as_const(
m_children))
529 if (screen->IsVisible())
532 screen->SetAlpha(255);
533 screen->ResetNeedsRedraw();
536 for (
auto * notif : std::as_const(notifications))
538 if (notif->IsVisible())
541 notif->SetAlpha(255);
542 notif->ResetNeedsRedraw();
552 QMutableHashIterator<MythScreenType*, QDateTime> it(
m_expireTimes);
556 if (it.value() < now)
568 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
573 QString replace = QCoreApplication::translate(
"(Common)",
575 static_cast<int>(now.secsTo(it.value())));
576 dialog->SetText(newtext.replace(
"%d", replace));
578 auto *cdialog = qobject_cast<MythConfirmationDialog*>(
m_dialog);
581 QString replace = QString::number(now.secsTo(it.value()));
582 cdialog->SetMessage(newtext.replace(
"%d", replace));
591 std::chrono::milliseconds CustomTimeout)
605 std::chrono::milliseconds CustomTimeout)
607 std::chrono::milliseconds time { 0ms };
608 if (CustomTimeout != 0ms)
609 time = CustomTimeout;
611 time =
m_timeouts[
static_cast<size_t>(Timeout)];
616 if ((time > 0ms) && win)
621 else if ((time < 0ms) && win)
642 if (screen !=
nullptr)
670 emit
HideOSD(m_functionalType);
672 m_functionalType = Type;
689 bool visible = valid && screen && screen->
IsVisible(
false);
690 if (!valid || !visible)
692 emit
HideOSD(m_functionalType);
703 return m_dialog->objectName() == Window;
742 DialogAddButton(B.m_text, B.m_data, B.m_menu, B.m_current); });
746void OSD::DialogShow(
const QString &Window,
const QString &Text, std::chrono::milliseconds UpdateFor)
757 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
761 dialog->SetText(Text);
778 dialog =
new MythDialogBox(Text,
nullptr, Window.toLatin1(),
false,
true);
785 auto *dbox = qobject_cast<MythDialogBox*>(
m_dialog);
787 dbox->SetReturnEvent(
m_tv, Window);
788 auto *cbox = qobject_cast<MythConfirmationDialog*>(
m_dialog);
791 cbox->SetReturnEvent(
m_tv, Window);
792 cbox->SetData(
"DIALOG_CONFIRM_X_X");
820 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
823 dialog->SetBackAction(Text, Data);
825 dialog->SetExitAction(Text, Data);
831 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
833 dialog->AddButtonV(Text, std::move(Data), Menu, Current);
838 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
MythImage * GetImage(std::chrono::milliseconds Timecode) const
static QString GetIcon(uint chanid)
Dialog asking for user confirmation.
QString GetMasterHostPrefix(const QString &storageGroup=QString(), const QString &path=QString())
Basic menu dialog, message and a list of options.
A custom event that represents a mouse gesture.
MythNotificationCenter * GetCurrentNotificationCenter()
static void UpdateScreen(MythScreenType *screen)
Will call ::doInit() if the screen is a MythNotificationScreen and ::Create() has been called for it ...
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...
static bool ScreenCreated(const MythScreenType *screen)
Return true if ::Create() has been called on screen.
void GetNotificationScreens(QList< MythScreenType * > &screens)
Return the list of notification screens being currently displayed.
int DisplayedNotifications(void) const
Returns number of notifications currently displayed.
bool RemoveFirst(void)
Will remove the oldest notification from the stack return true if a screen was removed; or false if n...
std::vector< MythOSDDialogButton > m_buttons
std::chrono::milliseconds m_timeout
virtual void Begin(QPaintDevice *)
const AudioOutputGraph & GetAudioGraph() const
void EditingChanged(bool Editing)
void BrowsingChanged(bool Browsing)
void OSDDebugVisibilityChanged(bool Visible)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Screen in which all other widgets are contained and rendered.
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
virtual bool Create(void)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void SetTextFromMap(const InfoMap &infoMap)
A narrow purpose widget used to represent cut positions and regions when editing a video.
void SetEditPosition(double position)
void AddRegion(double start, double end)
Image widget, displays a single image or multiple images in sequence.
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void Reset(void) override
Reset the image back to the default defined in the theme.
void SetVisible(bool visible) override
This widget is used for grouping other widgets for display when a particular named state is called.
bool DisplayState(const QString &name)
All purpose text widget, displays a text string.
virtual void SetText(const QString &text)
bool IsVisible(bool recurse=false) const
void VisibilityChanged(bool Visible)
virtual void SetVisible(bool visible)
virtual void SetArea(const MythRect &rect)
void SetPainter(MythPainter *painter)
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
void SetExpiryPriv(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout)
void SetValues(const QString &Window, const QHash< QString, int > &Map, OSDTimeout Timeout)
QDateTime m_nextPulseUpdate
QString m_functionalWindow
bool DialogVisible(const QString &Window=QString())
void ResetWindow(const QString &Window)
void DialogAddButton(const QString &Text, QVariant Data, bool Menu=false, bool Current=false)
std::chrono::milliseconds m_fadeTime
bool Init(QRect Rect, float FontAspect) override
bool DialogHandleGesture(MythGestureEvent *Event)
void HideOSD(OSDFunctionalType Type)
void DialogGetText(InfoMap &Map)
void RemoveWindow(const QString &Window)
bool DialogHandleKeypress(QKeyEvent *Event)
void IsOSDVisible(bool &Visible)
void SetExpiry(const QString &Window, enum OSDTimeout Timeout, std::chrono::milliseconds CustomTimeout=0ms)
void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total)
QString m_pulsedDialogText
void ShowDialog(const MythOSDDialogData &Data)
Show a dialog menu, removing any existing dialog.
void SetFunctionalWindow(const QString &Window, enum OSDFunctionalType Type)
void PositionWindow(MythScreenType *Window)
bool IsWindowVisible(const QString &Window)
OSD(MythMainWindow *MainWindow, TV *Tv, MythPlayerUI *Player, MythPainter *Painter)
void DialogShow(const QString &Window, const QString &Text="", std::chrono::milliseconds UpdateFor=0ms)
MythScreenType * m_dialog
void Embed(bool Embedding)
void DialogBack(const QString &Text="", const QVariant &Data=0, bool Exit=false)
void HideWindow(const QString &Window) override
std::array< std::chrono::milliseconds, 4 > m_timeouts
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void HideAll(bool KeepSubs=true, MythScreenType *Except=nullptr, bool DropNotification=false)
void SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode)
QHash< MythScreenType *, QDateTime > m_expireTimes
void ChangeOSDDialog(const MythOSDDialogData &Data)
void IsOSDVisible(bool &Visible)
void ChangeOSDText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void HandleOSDClosed(int OSDType)
static constexpr const char * OSD_WIN_SUBTITLE
static constexpr const char * OSD_WIN_TELETEXT
static constexpr const char * OSD_WIN_INTERACT
static constexpr const char * OSD_WIN_BDOVERLAY
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QHash< QString, QString > InfoMap
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static constexpr const char * OSD_WIN_BROWSE
static constexpr const char * OSD_DLG_EDITOR
static constexpr const char * OSD_WIN_PROGINFO
static constexpr const char * OSD_WIN_STATUS
@ kOSDFunctionalType_Default
static constexpr const char * OSD_DLG_CONFIRM
static constexpr const char * OSD_WIN_INPUT
static constexpr const char * OSD_WIN_PROGEDIT
static constexpr const char * OSD_DLG_NAVIGATE
static constexpr const char * OSD_WIN_MESSAGE
static constexpr const char * OSD_WIN_DEBUG
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.