Skip to content

Commit

Permalink
OSD: Use defines for default window names
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-kendall committed Oct 27, 2020
1 parent 7d206c9 commit e9bd4c3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 56 deletions.
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/deletemap.cpp
Expand Up @@ -209,24 +209,24 @@ void DeleteMap::UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)

QHash<QString,float> posMap;
posMap.insert("position", (float)((double)frame/(double)total));
osd->SetValues("osd_program_editor", posMap, kOSDTimeout_None);
osd->SetText("osd_program_editor", infoMap, kOSDTimeout_None);
osd->SetValues(OSD_WIN_PROGEDIT, posMap, kOSDTimeout_None);
osd->SetText(OSD_WIN_PROGEDIT, infoMap, kOSDTimeout_None);
if (m_changed || total != m_cachedTotalForOSD)
osd->SetRegions("osd_program_editor", m_deleteMap, total);
osd->SetRegions(OSD_WIN_PROGEDIT, m_deleteMap, total);
m_changed = false;
m_cachedTotalForOSD = total;
}

void DeleteMap::UpdateOSD(int64_t timecode, OSD *osd)
{
osd->SetGraph("osd_program_editor", "audiograph", timecode);
osd->SetGraph(OSD_WIN_PROGEDIT, "audiograph", timecode);
}

/// Set the edit mode and optionally hide the edit mode OSD.
void DeleteMap::SetEditing(bool edit, OSD *osd)
{
if (osd && !edit)
osd->HideWindow("osd_program_editor");
osd->HideWindow(OSD_WIN_PROGEDIT);
m_editing = edit;
}

Expand Down
20 changes: 10 additions & 10 deletions mythtv/libs/libmythtv/mythplayeroverlayui.cpp
Expand Up @@ -46,12 +46,12 @@ void MythPlayerOverlayUI::UpdateOSDPosition()
m_osdLock.lock();
if (m_osd)
{
if (m_osd->IsWindowVisible("osd_status"))
if (m_osd->IsWindowVisible(OSD_WIN_STATUS))
{
osdInfo info;
UpdateSliderInfo(info);
m_osd->SetText("osd_status", info.text, kOSDTimeout_Ignore);
m_osd->SetValues("osd_status", info.values, kOSDTimeout_Ignore);
m_osd->SetText(OSD_WIN_STATUS, info.text, kOSDTimeout_Ignore);
m_osd->SetValues(OSD_WIN_STATUS, info.values, kOSDTimeout_Ignore);
}
else
{
Expand All @@ -73,7 +73,7 @@ void MythPlayerOverlayUI::UpdateOSDMessage(const QString& Message, OSDTimeout Ti
{
InfoMap map;
map.insert("message_text", Message);
m_osd->SetText("osd_message", map, Timeout);
m_osd->SetText(OSD_WIN_MESSAGE, map, Timeout);
}
m_osdLock.unlock();
}
Expand All @@ -86,8 +86,8 @@ void MythPlayerOverlayUI::SetOSDStatus(const QString& title, OSDTimeout timeout)
osdInfo info;
UpdateSliderInfo(info);
info.text.insert("title", title);
m_osd->SetText("osd_status", info.text, timeout);
m_osd->SetValues("osd_status", info.values, timeout);
m_osd->SetText(OSD_WIN_STATUS, info.text, timeout);
m_osd->SetValues(OSD_WIN_STATUS, info.values, timeout);
}
m_osdLock.unlock();
}
Expand All @@ -97,11 +97,11 @@ void MythPlayerOverlayUI::UpdateOSDStatus(osdInfo &Info, int Type, OSDTimeout Ti
m_osdLock.lock();
if (m_osd)
{
m_osd->ResetWindow("osd_status");
m_osd->SetValues("osd_status", Info.values, Timeout);
m_osd->SetText("osd_status", Info.text, Timeout);
m_osd->ResetWindow(OSD_WIN_STATUS);
m_osd->SetValues(OSD_WIN_STATUS, Info.values, Timeout);
m_osd->SetText(OSD_WIN_STATUS, Info.text, Timeout);
if (Type != kOSDFunctionalType_Default)
m_osd->SetFunctionalWindow("osd_status", static_cast<OSDFunctionalType>(Type));
m_osd->SetFunctionalWindow(OSD_WIN_STATUS, static_cast<OSDFunctionalType>(Type));
}
m_osdLock.unlock();
}
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/mythplayerui.cpp
Expand Up @@ -28,7 +28,7 @@ MythPlayerUI::MythPlayerUI(MythMainWindow* MainWindow, TV* Tv,
{
m_osdLock.lock();
if (m_osd)
m_osd->HideWindow("osd_message");
m_osd->HideWindow(OSD_WIN_MESSAGE);
m_osdLock.unlock();
});

Expand Down Expand Up @@ -856,8 +856,8 @@ void MythPlayerUI::UpdateOSDDebug()
{
InfoMap infoMap;
GetPlaybackData(infoMap);
m_osd->ResetWindow("osd_debug");
m_osd->SetText("osd_debug", infoMap, kOSDTimeout_None);
m_osd->ResetWindow(OSD_WIN_DEBUG);
m_osd->SetText(OSD_WIN_DEBUG, infoMap, kOSDTimeout_None);
}
m_osdLock.unlock();
}
Expand All @@ -874,7 +874,7 @@ void MythPlayerUI::ChangeOSDDebug()
if (enable)
UpdateOSDDebug();
else
m_osd->HideWindow("osd_debug");
m_osd->HideWindow(OSD_WIN_DEBUG);
m_osdDebug = enable;
}
m_osdLock.unlock();
Expand Down
16 changes: 8 additions & 8 deletions mythtv/libs/libmythtv/osd.cpp
Expand Up @@ -296,7 +296,7 @@ void OSD::HideAll(bool KeepSubs, MythScreenType* Except, bool DropNotification)
{
it.next();
if (Except && Except->objectName() == OSD_DLG_NAVIGATE
&& it.value()->objectName() == "osd_status")
&& it.value()->objectName() == OSD_WIN_STATUS)
continue;
bool match1 = KeepSubs &&
(it.key() == OSD_WIN_SUBTITLE ||
Expand All @@ -312,8 +312,8 @@ void OSD::HideAll(bool KeepSubs, MythScreenType* Except, bool DropNotification)
void OSD::LoadWindows()
{
static const std::array<const QString,7> s_defaultWindows {
"osd_message", "osd_input", "program_info", "browse_info", "osd_status",
"osd_program_editor", "osd_debug"};
OSD_WIN_MESSAGE, OSD_WIN_INPUT, OSD_WIN_PROGINFO, OSD_WIN_BROWSE,
OSD_WIN_STATUS, OSD_WIN_PROGEDIT, OSD_WIN_DEBUG };

for (const auto & window : s_defaultWindows)
{
Expand All @@ -325,11 +325,11 @@ void OSD::LoadWindows()
m_children.insert(window, win);

// Update player for window visibility
if (window == "browse_info")
if (window == OSD_WIN_BROWSE)
connect(win, &MythOSDWindow::VisibilityChanged, m_player, &MythPlayerUI::BrowsingChanged);
if (window == "osd_program_editor")
if (window == OSD_WIN_PROGEDIT)
connect(win, &MythOSDWindow::VisibilityChanged, m_player, &MythPlayerUI::EditingChanged);
if (window == "osd_debug")
if (window == OSD_WIN_DEBUG)
connect(win, &MythOSDWindow::VisibilityChanged, m_player, &MythPlayerUI::OSDDebugVisibilityChanged);
}
else
Expand Down Expand Up @@ -804,8 +804,8 @@ void OSD::SetExpiry(const QString &Window, enum OSDTimeout Timeout,
{
// Keep status and nav timeouts in sync
if (Window == OSD_DLG_NAVIGATE)
SetExpiryPriv("osd_status", Timeout, CustomTimeout);
else if (Window == "osd_status" && IsWindowVisible(OSD_DLG_NAVIGATE))
SetExpiryPriv(OSD_WIN_STATUS, Timeout, CustomTimeout);
else if (Window == OSD_WIN_STATUS && IsWindowVisible(OSD_DLG_NAVIGATE))
SetExpiryPriv(OSD_DLG_NAVIGATE, Timeout, CustomTimeout);
}
}
Expand Down
8 changes: 8 additions & 0 deletions mythtv/libs/libmythtv/osd.h
Expand Up @@ -36,6 +36,14 @@
#define OSD_WIN_INTERACT "bb_OSD_INTERACTIVE"
#define OSD_WIN_BDOVERLAY "bb_OSD_BDOVERLAY"

#define OSD_WIN_MESSAGE "osd_message"
#define OSD_WIN_INPUT "osd_input"
#define OSD_WIN_PROGINFO "program_info"
#define OSD_WIN_STATUS "osd_status"
#define OSD_WIN_DEBUG "osd_debug"
#define OSD_WIN_BROWSE "browse_info"
#define OSD_WIN_PROGEDIT "osd_program_editor"

#define kOSDFadeTime 1000

class TV;
Expand Down
56 changes: 28 additions & 28 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -98,7 +98,7 @@
ReturnOSDLock(); }

#define SetOSDMessage(MESSAGE) \
SetOSDText("osd_message", "message_text", MESSAGE, kOSDTimeout_Med)
SetOSDText(OSD_WIN_MESSAGE, "message_text", MESSAGE, kOSDTimeout_Med)

#define HideOSDWindow(WINDOW) { \
OSD *osd = GetOSDL(); \
Expand Down Expand Up @@ -2617,7 +2617,7 @@ void TV::timerEvent(QTimerEvent *Event)
if (HasQueuedChannel())
{
OSD *osd = GetOSDL();
if (osd && !osd->IsWindowVisible("osd_input"))
if (osd && !osd->IsWindowVisible(OSD_WIN_INPUT))
{
ReturnOSDLock();
CommitQueuedInput();
Expand Down Expand Up @@ -3877,7 +3877,7 @@ bool TV::ActiveHandleAction(const QStringList &Actions,
if (m_asInputMode)
{
ClearInputQueues(true);
SetOSDText("osd_input", "osd_number_entry", tr("Seek:"), kOSDTimeout_Med);
SetOSDText(OSD_WIN_INPUT, "osd_number_entry", tr("Seek:"), kOSDTimeout_Med);
m_asInputMode = false;
if (m_asInputTimerId)
{
Expand Down Expand Up @@ -5852,7 +5852,7 @@ QString TV::GetQueuedChanNum() const
void TV::ClearInputQueues(bool Hideosd)
{
if (Hideosd)
HideOSDWindow("osd_input");
HideOSDWindow(OSD_WIN_INPUT);

m_queuedInput = "";
m_queuedChanNum = "";
Expand Down Expand Up @@ -5896,7 +5896,7 @@ void TV::AddKeyToInputQueue(char Key)
{
inputStr = tr("Seek:", "seek to location") + " " + inputStr;
}
SetOSDText("osd_input", "osd_number_entry", inputStr, kOSDTimeout_Med);
SetOSDText(OSD_WIN_INPUT, "osd_number_entry", inputStr, kOSDTimeout_Med);

// Commit the channel if it is complete and smart changing is enabled.
if (commitSmart)
Expand Down Expand Up @@ -6018,7 +6018,7 @@ bool TV::CommitQueuedInput()
if (chanid)
BrowseChannel(channum);

HideOSDWindow("osd_input");
HideOSDWindow(OSD_WIN_INPUT);
}
else if (GetQueuedChanID() || !channum.isEmpty())
{
Expand Down Expand Up @@ -6073,7 +6073,7 @@ void TV::ChangeChannel(ChannelChangeDirection Direction)

if (ContextIsPaused(__FILE__, __LINE__))
{
HideOSDWindow("osd_status");
HideOSDWindow(OSD_WIN_STATUS);
MythMainWindow::DisableScreensaver();
}

Expand Down Expand Up @@ -6236,7 +6236,7 @@ void TV::ChangeChannel(uint Chanid, const QString &Channum)

if (ContextIsPaused(__FILE__, __LINE__))
{
HideOSDWindow("osd_status");
HideOSDWindow(OSD_WIN_STATUS);
MythMainWindow::DisableScreensaver();
}

Expand Down Expand Up @@ -6275,7 +6275,7 @@ void TV::ChangeChannel(const ChannelInfoList &Options)
if (chanid && !channum.isEmpty() && IsTunablePriv(chanid))
{
// hide the channel number, activated by certain signal monitors
HideOSDWindow("osd_input");
HideOSDWindow(OSD_WIN_INPUT);
m_queuedInput = channum;
m_queuedChanNum = channum;
m_queuedChanID = chanid;
Expand All @@ -6292,7 +6292,7 @@ void TV::ShowPreviousChannel()
LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Previous channel number '%1'").arg(channum));
if (channum.isEmpty())
return;
SetOSDText("osd_input", "osd_number_entry", channum, kOSDTimeout_Med);
SetOSDText(OSD_WIN_INPUT, "osd_number_entry", channum, kOSDTimeout_Med);
}

void TV::PopPreviousChannel(bool ImmediateChange)
Expand Down Expand Up @@ -6322,7 +6322,7 @@ void TV::PopPreviousChannel(bool ImmediateChange)
if (ImmediateChange)
{
// Turn off OSD Channel Num so the channel changes right away
HideOSDWindow("osd_input");
HideOSDWindow(OSD_WIN_INPUT);
}
}

Expand Down Expand Up @@ -6366,16 +6366,16 @@ void TV::ToggleOSD(bool IncludeStatusOSD)
bool hideAll = false;
bool showStatus = false;
bool paused = ContextIsPaused(__FILE__, __LINE__);
bool is_status_disp = osd->IsWindowVisible("osd_status");
bool has_prog_info = osd->HasWindow("program_info");
bool is_prog_info_disp = osd->IsWindowVisible("program_info");
bool is_status_disp = osd->IsWindowVisible(OSD_WIN_STATUS);
bool has_prog_info = osd->HasWindow(OSD_WIN_PROGINFO);
bool is_prog_info_disp = osd->IsWindowVisible(OSD_WIN_PROGINFO);

ReturnOSDLock();

if (is_status_disp)
{
if (has_prog_info)
UpdateOSDProgInfo("program_info");
UpdateOSDProgInfo(OSD_WIN_PROGINFO);
else
hideAll = true;
}
Expand All @@ -6390,7 +6390,7 @@ void TV::ToggleOSD(bool IncludeStatusOSD)
else
{
if (has_prog_info)
UpdateOSDProgInfo("program_info");
UpdateOSDProgInfo(OSD_WIN_PROGINFO);
}

if (hideAll || showStatus)
Expand Down Expand Up @@ -6447,11 +6447,11 @@ void TV::UpdateOSDStatus(osdInfo &Info, int Type, OSDTimeout Timeout)
OSD *osd = GetOSDL();
if (osd)
{
osd->ResetWindow("osd_status");
osd->SetValues("osd_status", Info.values, Timeout);
emit ChangeOSDText("osd_status", Info.text, Timeout);
osd->ResetWindow(OSD_WIN_STATUS);
osd->SetValues(OSD_WIN_STATUS, Info.values, Timeout);
emit ChangeOSDText(OSD_WIN_STATUS, Info.text, Timeout);
if (Type != kOSDFunctionalType_Default)
osd->SetFunctionalWindow("osd_status", static_cast<OSDFunctionalType>(Type));
osd->SetFunctionalWindow(OSD_WIN_STATUS, static_cast<OSDFunctionalType>(Type));
}
ReturnOSDLock();
}
Expand Down Expand Up @@ -6639,7 +6639,7 @@ void TV::UpdateOSDSignal(const QStringList &List)
sigDesc = msg;

infoMap["description"] = sigDesc;
emit ChangeOSDText("program_info", infoMap, kOSDTimeout_Med);
emit ChangeOSDText(OSD_WIN_PROGINFO, infoMap, kOSDTimeout_Med);

m_playerContext.m_lastSignalMsg.clear();
m_playerContext.m_lastSignalMsgTime.start();
Expand Down Expand Up @@ -7477,7 +7477,7 @@ void TV::customEvent(QEvent *Event)
if (Event->type() == MythEvent::kUpdateBrowseInfoEventType)
{
auto *b = reinterpret_cast<UpdateBrowseInfoEvent*>(Event);
emit ChangeOSDText("browse_info", b->m_im, kOSDTimeout_None);
emit ChangeOSDText(OSD_WIN_BROWSE, b->m_im, kOSDTimeout_None);
return;
}

Expand Down Expand Up @@ -7881,10 +7881,10 @@ void TV::QuickRecord()
recinfo.GetPathname(), "Screenshots");
}

emit ChangeOSDText("browse_info", infoMap, kOSDTimeout_Med);
emit ChangeOSDText(OSD_WIN_BROWSE, infoMap, kOSDTimeout_Med);
InfoMap map;
map.insert("message_text", tr("Record"));
emit ChangeOSDText("osd_message", map, kOSDTimeout_Med);
emit ChangeOSDText(OSD_WIN_MESSAGE, map, kOSDTimeout_Med);
return;
}

Expand Down Expand Up @@ -8068,7 +8068,7 @@ void TV::ShowOSDCutpoint(const QString &Type)

InfoMap map;
map.insert("title", tr("Edit"));
emit ChangeOSDText("osd_program_editor", map, kOSDTimeout_None);
emit ChangeOSDText(OSD_WIN_PROGEDIT, map, kOSDTimeout_None);
}
}

Expand Down Expand Up @@ -8513,7 +8513,7 @@ void TV::OSDDialogEvent(int Result, const QString& Text, QString Action)

// Turn off OSD Channel Num so the channel
// changes right away
HideOSDWindow("osd_input");
HideOSDWindow(OSD_WIN_INPUT);
}
}
}
Expand Down Expand Up @@ -9539,7 +9539,7 @@ void TV::PlaybackMenuShow(const MythTVMenu &Menu, const QDomNode &Node, const QD
// hack to unhide the editbar
InfoMap map;
map.insert("title", tr("Edit"));
emit ChangeOSDText("osd_program_editor", map, kOSDTimeout_None);
emit ChangeOSDText(OSD_WIN_PROGEDIT, map, kOSDTimeout_None);
}
}
PlaybackMenuDeinit(Menu);
Expand Down Expand Up @@ -10004,7 +10004,7 @@ void TV::UnpauseLiveTV(bool Quietly)

if (m_playerContext.HasPlayer() && !Quietly)
{
UpdateOSDProgInfo("program_info");
UpdateOSDProgInfo(OSD_WIN_PROGINFO);
UpdateLCD();
m_playerContext.PushPreviousChannel();
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/tvbrowsehelper.cpp
Expand Up @@ -131,7 +131,7 @@ void TVBrowseHelper::BrowseEnd(bool ChangeChannel)

OSD* osd = m_parent->GetOSDL();
if (osd)
osd->HideWindow("browse_info");
osd->HideWindow(OSD_WIN_BROWSE);
m_parent->ReturnOSDLock();

if (ChangeChannel)
Expand Down

0 comments on commit e9bd4c3

Please sign in to comment.