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);
385 if (Map.empty() || Total < 1)
391 long long start = -1;
394 QMapIterator<uint64_t, MarkTypes> it(Map);
401 start =
static_cast<long long>(it.key());
411 end =
static_cast<long long>(it.key());
415 start = end =
static_cast<long long>(it.key());
421 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deleteMap discontinuity");
426 if (start >=0 && end >= 0)
428 bar->
AddRegion((
static_cast<double>(start) /
static_cast<double>(Total)),
429 (
static_cast<double>(end) /
static_cast<double>(Total)));
434 if (start > -1 && end < 0)
435 bar->
AddRegion(
static_cast<double>(start) /
static_cast<double>(Total), 1.0);
440 void OSD::SetGraph(
const QString &Window,
const QString &Graph, std::chrono::milliseconds Timecode)
460 bool visible =
false;
466 if (screen->IsVisible())
473 auto left = std::chrono::milliseconds(now.msecsTo(expires));
480 QList<MythScreenType*> notifications;
482 QList<MythScreenType*>::iterator it2 = notifications.begin();
483 while (it2 != notifications.end())
487 LOG(VB_GUI, LOG_DEBUG,
LOC +
"Creating OSD Notification");
492 if (!(*it2)->Create())
494 it2 = notifications.erase(it2);
499 if ((*it2)->IsVisible())
511 auto left = std::chrono::milliseconds(now.msecsTo(expires));
526 if (screen->IsVisible())
529 screen->SetAlpha(255);
530 screen->ResetNeedsRedraw();
533 for (
auto * notif : qAsConst(notifications))
535 if (notif->IsVisible())
538 notif->SetAlpha(255);
539 notif->ResetNeedsRedraw();
549 QMutableHashIterator<MythScreenType*, QDateTime> it(
m_expireTimes);
553 if (it.value() < now)
565 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
570 QString replace = QCoreApplication::translate(
"(Common)",
572 static_cast<int>(now.secsTo(it.value())));
573 dialog->SetText(newtext.replace(
"%d", replace));
575 auto *cdialog = qobject_cast<MythConfirmationDialog*>(
m_dialog);
578 QString replace = QString::number(now.secsTo(it.value()));
579 cdialog->SetMessage(newtext.replace(
"%d", replace));
588 std::chrono::milliseconds CustomTimeout)
602 std::chrono::milliseconds CustomTimeout)
604 std::chrono::milliseconds time { 0ms };
605 if (CustomTimeout != 0ms)
606 time = CustomTimeout;
608 time =
m_timeouts[
static_cast<size_t>(Timeout)];
613 if ((time > 0ms) && win)
618 else if ((time < 0ms) && win)
639 if (screen !=
nullptr)
667 emit
HideOSD(m_functionalType);
669 m_functionalType = Type;
686 bool visible = valid && screen && screen->
IsVisible(
false);
687 if (!valid || !visible)
689 emit
HideOSD(m_functionalType);
700 return m_dialog->objectName() == Window;
739 DialogAddButton(B.m_text, B.m_data, B.m_menu, B.m_current); });
743 void OSD::DialogShow(
const QString &Window,
const QString &Text, std::chrono::milliseconds UpdateFor)
754 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
758 dialog->SetText(Text);
775 dialog =
new MythDialogBox(Text,
nullptr, Window.toLatin1(),
false,
true);
782 auto *dbox = qobject_cast<MythDialogBox*>(
m_dialog);
784 dbox->SetReturnEvent(
m_tv, Window);
785 auto *cbox = qobject_cast<MythConfirmationDialog*>(
m_dialog);
788 cbox->SetReturnEvent(
m_tv, Window);
789 cbox->SetData(
"DIALOG_CONFIRM_X_X");
817 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
820 dialog->SetBackAction(Text, Data);
822 dialog->SetExitAction(Text, Data);
828 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
830 dialog->AddButtonV(Text, std::move(Data), Menu, Current);
835 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
@ kOSDFunctionalType_Default
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 *)
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)