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")
108 bool match1 = KeepSubs &&
113 it.value() == Except;
114 if (!(match1 || match2))
121 static const std::array<const QString,7> s_defaultWindows {
125 for (
const auto & window : s_defaultWindows)
131 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded window %1").arg(window));
156 if (Map.contains(
"position"))
164 bar->
SetUsed(Map.value(
"position"));
168 if (Map.contains(
"relposition"))
176 bar->
SetUsed(Map.value(
"relposition"));
193 if (Map.contains(
"position"))
213 if (Map.contains(
"numstars"))
219 if (Map.contains(
"tvstate"))
225 if (Map.contains(
"videocodec"))
231 if (Map.contains(
"videodescrip"))
237 if (Map.contains(
"audiocodec"))
243 if (Map.contains(
"audiochannels"))
249 if (Map.contains(
"chanid"))
256 uint chanid = Map[
"chanid"].toUInt();
258 if (Map.contains(
"iconpath"))
259 iconpath = Map[
"iconpath"];
263 if (!iconpath.isEmpty())
275 if (Map.contains(
"channelgroup"))
280 textArea->
SetText(Map[
"channelgroup"]);
284 if (Map.contains(
"inetref"))
287 if (cover && Map.contains(
"coverartpath"))
289 QString coverpath = Map[
"coverartpath"];
294 if (fanart && Map.contains(
"fanartpath"))
296 QString fanartpath = Map[
"fanartpath"];
301 if (banner && Map.contains(
"bannerpath"))
303 QString bannerpath = Map[
"bannerpath"];
308 if (screenshot && Map.contains(
"screenshotpath"))
310 QString screenshotpath = Map[
"screenshotpath"];
312 screenshot->
Load(
false);
315 if (Map.contains(
"nightmode"))
321 if (Map.contains(
"mediatype"))
332 qint64 startts = Map[
"startts"].toLongLong();
333 qint64 endts = Map[
"endts"].toLongLong();
339 else if (endts < nowts)
345 qint64 duration = endts - startts;
347 bar->
SetUsed(
static_cast<int>(1000 * (nowts - startts) / duration));
360 auto *edit = qobject_cast<MythChannelOverlay*>(
m_dialog);
385 if (Map.empty() || Total < 1)
391 long long start = -1;
394 for (
auto it = Map.begin(); it != Map.end(); ++it)
399 start =
static_cast<long long>(it.key());
409 end =
static_cast<long long>(it.key());
413 start = end =
static_cast<long long>(it.key());
419 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deleteMap discontinuity");
424 if (start >=0 && end >= 0)
426 bar->
AddRegion((
static_cast<double>(start) /
static_cast<double>(Total)),
427 (
static_cast<double>(end) /
static_cast<double>(Total)));
432 if (start > -1 && end < 0)
433 bar->
AddRegion(
static_cast<double>(start) /
static_cast<double>(Total), 1.0);
438void OSD::SetGraph(
const QString &Window,
const QString &Graph, std::chrono::milliseconds Timecode)
458 bool visible =
false;
462 for (
auto * screen : std::as_const(
m_children))
464 if (screen->IsVisible())
471 auto left = std::chrono::milliseconds(now.msecsTo(expires));
478 QList<MythScreenType*> notifications;
480 QList<MythScreenType*>::iterator it2 = notifications.begin();
481 while (it2 != notifications.end())
485 LOG(VB_GUI, LOG_DEBUG,
LOC +
"Creating OSD Notification");
490 if (!(*it2)->Create())
492 it2 = notifications.erase(it2);
497 if ((*it2)->IsVisible())
509 auto left = std::chrono::milliseconds(now.msecsTo(expires));
522 for (
auto * screen : std::as_const(
m_children))
524 if (screen->IsVisible())
527 screen->SetAlpha(255);
528 screen->ResetNeedsRedraw();
531 for (
auto * notif : std::as_const(notifications))
533 if (notif->IsVisible())
536 notif->SetAlpha(255);
537 notif->ResetNeedsRedraw();
547 bool quitDialog =
false;
548 QStringList hideWindows {};
554 if (it.value() < now)
571 for (
const auto& window : std::as_const(hideWindows))
576 std::chrono::milliseconds CustomTimeout)
590 std::chrono::milliseconds CustomTimeout)
592 std::chrono::milliseconds time { 0ms };
593 if (CustomTimeout != 0ms)
594 time = CustomTimeout;
596 time =
m_timeouts[
static_cast<size_t>(Timeout)];
601 if ((time > 0ms) && win)
606 else if ((time < 0ms) && win)
619 uint64_t seconds = now.secsTo(expire);
621 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
626 QString replace = QCoreApplication::translate(
"(Common)",
628 static_cast<int>(seconds));
629 dialog->SetText(newtext.replace(
"%d", replace));
633 auto *cdialog = qobject_cast<MythConfirmationDialog*>(
m_dialog);
636 QString replace = QString::number(seconds);
637 cdialog->SetMessage(newtext.replace(
"%d", replace));
656 if (screen !=
nullptr)
684 emit
HideOSD(m_functionalType);
686 m_functionalType = Type;
703 bool visible = valid && screen && screen->
IsVisible(
false);
704 if (!valid || !visible)
706 emit
HideOSD(m_functionalType);
717 return m_dialog->objectName() == Window;
756 DialogAddButton(B.m_text, B.m_data, B.m_menu, B.m_current); });
760void OSD::DialogShow(
const QString &Window,
const QString &Text, std::chrono::milliseconds UpdateFor)
771 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
775 dialog->SetText(Text);
792 dialog =
new MythDialogBox(Text,
nullptr, Window.toLatin1().constData(),
false,
true);
799 auto *dbox = qobject_cast<MythDialogBox*>(
m_dialog);
801 dbox->SetReturnEvent(
m_tv, Window);
802 auto *cbox = qobject_cast<MythConfirmationDialog*>(
m_dialog);
805 cbox->SetReturnEvent(
m_tv, Window);
806 cbox->SetData(
"DIALOG_CONFIRM_X_X");
834 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
837 dialog->SetBackAction(Text, Data);
839 dialog->SetExitAction(Text, Data);
845 auto *dialog = qobject_cast<MythDialogBox*>(
m_dialog);
847 dialog->AddButtonV(Text, std::move(Data), Menu, Current);
852 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.