30#define LOC QString("OSD: ")
54 int newstretch =
static_cast<int>(lroundf(FontAspect * 100));
69 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to load any windows.");
73 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded OSD: size %1x%2 offset %3+%4")
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));
157 if (Map.contains(
"position"))
165 bar->
SetUsed(Map.value(
"position"));
169 if (Map.contains(
"relposition"))
177 bar->
SetUsed(Map.value(
"relposition"));
194 if (Map.contains(
"position"))
214 if (Map.contains(
"numstars"))
220 if (Map.contains(
"tvstate"))
226 if (Map.contains(
"videocodec"))
232 if (Map.contains(
"videodescrip"))
238 if (Map.contains(
"audiocodec"))
244 if (Map.contains(
"audiochannels"))
250 if (Map.contains(
"chanid"))
257 uint chanid = Map[
"chanid"].toUInt();
259 if (Map.contains(
"iconpath"))
260 iconpath = Map[
"iconpath"];
264 if (!iconpath.isEmpty())
276 if (Map.contains(
"channelgroup"))
281 textArea->
SetText(Map[
"channelgroup"]);
285 if (Map.contains(
"inetref"))
288 if (cover && Map.contains(
"coverartpath"))
290 QString coverpath = Map[
"coverartpath"];
295 if (fanart && Map.contains(
"fanartpath"))
297 QString fanartpath = Map[
"fanartpath"];
302 if (banner && Map.contains(
"bannerpath"))
304 QString bannerpath = Map[
"bannerpath"];
309 if (screenshot && Map.contains(
"screenshotpath"))
311 QString screenshotpath = Map[
"screenshotpath"];
313 screenshot->
Load(
false);
316 if (Map.contains(
"nightmode"))
322 if (Map.contains(
"mediatype"))
333 qint64 startts = Map[
"startts"].toLongLong();
334 qint64 endts = Map[
"endts"].toLongLong();
340 else if (endts < nowts)
346 qint64 duration = endts - startts;
348 bar->
SetUsed(
static_cast<int>(1000 * (nowts - startts) / duration));
361 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
386 if (Map.empty() || Total < 1)
392 long long start = -1;
395 for (
auto it = Map.begin(); it != Map.end(); ++it)
400 start =
static_cast<long long>(it.key());
410 end =
static_cast<long long>(it.key());
414 start = end =
static_cast<long long>(it.key());
420 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deleteMap discontinuity");
425 if (start >=0 && end >= 0)
427 bar->
AddRegion((
static_cast<double>(start) /
static_cast<double>(Total)),
428 (
static_cast<double>(end) /
static_cast<double>(Total)));
433 if (start > -1 && end < 0)
434 bar->
AddRegion(
static_cast<double>(start) /
static_cast<double>(Total), 1.0);
439void OSD::SetGraph(
const QString &Window,
const QString &Graph, std::chrono::milliseconds Timecode)
459 bool visible =
false;
463 for (
auto * screen : std::as_const(
m_children))
465 if (screen->IsVisible())
472 auto left = std::chrono::milliseconds(now.msecsTo(expires));
479 QList<MythScreenType*> notifications;
481 QList<MythScreenType*>::iterator it2 = notifications.begin();
482 while (it2 != notifications.end())
486 LOG(VB_GUI, LOG_DEBUG,
LOC +
"Creating OSD Notification");
491 if (!(*it2)->Create())
493 it2 = notifications.erase(it2);
498 if ((*it2)->IsVisible())
510 auto left = std::chrono::milliseconds(now.msecsTo(expires));
523 for (
auto * screen : std::as_const(
m_children))
525 if (screen->IsVisible())
528 screen->SetAlpha(255);
529 screen->ResetNeedsRedraw();
532 for (
auto * notif : std::as_const(notifications))
534 if (notif->IsVisible())
537 notif->SetAlpha(255);
538 notif->ResetNeedsRedraw();
548 bool quitDialog =
false;
549 QStringList hideWindows {};
555 if (it.value() < now)
572 for (
const auto& window : std::as_const(hideWindows))
577 std::chrono::milliseconds CustomTimeout)
591 std::chrono::milliseconds CustomTimeout)
593 std::chrono::milliseconds time { 0ms };
594 if (CustomTimeout != 0ms)
595 time = CustomTimeout;
597 time =
m_timeouts[
static_cast<size_t>(Timeout)];
602 if ((time > 0ms) && win)
607 else if ((time < 0ms) && win)
620 uint64_t seconds = now.secsTo(expire);
622 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
627 QString replace = QCoreApplication::translate(
"(Common)",
629 static_cast<int>(seconds));
630 dialog->SetText(newtext.replace(
"%d", replace));
634 auto *cdialog = qobject_cast<MythConfirmationDialog*>(
m_dialog);
637 QString replace = QString::number(seconds);
638 cdialog->SetMessage(newtext.replace(
"%d", replace));
657 if (screen !=
nullptr)
685 emit
HideOSD(m_functionalType);
687 m_functionalType = Type;
704 bool visible = valid && screen && screen->
IsVisible(
false);
705 if (!valid || !visible)
707 emit
HideOSD(m_functionalType);
718 return m_dialog->objectName() == Window;
757 DialogAddButton(B.m_text, B.m_data, B.m_menu, B.m_current); });
761void OSD::DialogShow(
const QString &Window,
const QString &Text, std::chrono::milliseconds UpdateFor)
772 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
776 dialog->SetText(Text);
793 dialog =
new MythDialogBox(Text,
nullptr, Window.toLatin1().constData(),
false,
true);
800 auto *dbox = qobject_cast<MythDialogBox*>(
m_dialog);
802 dbox->SetReturnEvent(
m_tv, Window);
803 auto *cbox = qobject_cast<MythConfirmationDialog*>(
m_dialog);
806 cbox->SetReturnEvent(
m_tv, Window);
807 cbox->SetData(
"DIALOG_CONFIRM_X_X");
835 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
838 dialog->SetBackAction(Text, Data);
840 dialog->SetExitAction(Text, Data);
846 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
848 dialog->AddButtonV(Text, std::move(Data), Menu, Current);
853 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 DoPulse(const QDateTime &now, const QDateTime &expire)
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.