void AirPlayPictureScreen::Init(void) { if (m_airplayImage) { if (!m_imageFilename.isEmpty()) { m_airplayImage->SetFilename(m_imageFilename); // Absolute path, http or SG url m_airplayImage->Load(); // By default the image is loaded in a background thread, use LoadNow() to load in foreground } else { // Will default to displaying whatever placeholder image is defined // in the xml by the themer, means we can show _something_ rather than // a big empty hole. Generally you always want to call Reset() in // these circumstances m_airplayImage->Reset(); } } if (m_airplayText) { if (!m_imageDescription.isEmpty()) { m_airplayText->SetText(m_imageDescription); } else { // Same as above, calling Reset() allows for a sane, themer defined //default to be displayed m_airplayText->Reset(); } } }
void ChannelRecPriority::updateInfo(MythUIButtonListItem *item) { if (!item) return; ChannelInfo *channelItem = item->GetData().value<ChannelInfo *>(); if (!m_channelData.isEmpty() && channelItem) { QString rectype; if (m_iconImage) { QString iconUrl = gCoreContext->GetMasterHostPrefix("ChannelIcons", channelItem->icon); m_iconImage->SetFilename(iconUrl); m_iconImage->Load(); } InfoMap chanmap; channelItem->ToMap(chanmap); SetTextFromMap(chanmap); if (m_chanstringText) m_chanstringText->SetText(channelItem->GetFormatted(ChannelInfo::kChannelLong)); } MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_channelData.isEmpty()); }
bool MythTextInputDialog::Create(void) { if (!CopyWindowFromBase("MythTextInputDialog", this)) return false; MythUIText *messageText = NULL; MythUIButton *okButton = NULL; MythUIButton *cancelButton = NULL; bool err = false; UIUtilE::Assign(this, m_textEdit, "input", &err); UIUtilE::Assign(this, messageText, "message", &err); UIUtilE::Assign(this, okButton, "ok", &err); UIUtilW::Assign(this, cancelButton, "cancel"); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTextInputDialog'"); return false; } if (cancelButton) connect(cancelButton, SIGNAL(Clicked()), SLOT(Close())); connect(okButton, SIGNAL(Clicked()), SLOT(sendResult())); m_textEdit->SetFilter(m_filter); m_textEdit->SetText(m_defaultValue); m_textEdit->SetPassword(m_isPassword); messageText->SetText(m_message); BuildFocusList(); return true; }
void MythUIStateType::SetTextFromMap(const InfoMap &infoMap) { if (m_ObjectsByName.isEmpty() && m_ObjectsByState.isEmpty()) return; QMap<QString, MythUIType *>::Iterator i; for (i = m_ObjectsByName.begin(); i != m_ObjectsByName.end(); ++i) { MythUIType *type = i.value(); MythUIText *textType = dynamic_cast<MythUIText *> (type); if (textType) textType->SetTextFromMap(infoMap); MythUIComposite *group = dynamic_cast<MythUIComposite *> (type); if (group) group->SetTextFromMap(infoMap); } QMap<int, MythUIType *>::Iterator j; for (j = m_ObjectsByState.begin(); j != m_ObjectsByState.end(); ++j) { MythUIType *type = j.value(); MythUIText *textType = dynamic_cast<MythUIText *> (type); if (textType) textType->SetTextFromMap(infoMap); MythUIComposite *group = dynamic_cast<MythUIComposite *> (type); if (group) group->SetTextFromMap(infoMap); } }
bool PlotDialog::Create() { if (!LoadWindowFromXML("video-ui.xml", "descriptionpopup", this)) return false; MythUIText *plotText = nullptr; MythUIButton *okButton = nullptr; bool err = false; UIUtilE::Assign(this, plotText, "description", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'descriptionpopup'"); return false; } UIUtilW::Assign(this, okButton, "ok"); plotText->SetText(m_metadata->GetPlot()); if (okButton) connect(okButton, SIGNAL(Clicked()), SLOT(Close())); BuildFocusList(); return true; }
/** \fn RawSettingsEditor::Create(void) * \brief Creates the UI screen. */ bool RawSettingsEditor::Create(void) { if (!LoadWindowFromXML("settings-ui.xml", "rawsettingseditor", this)) return false; m_settingsList = dynamic_cast<MythUIButtonList *> (GetChild("settings")); m_saveButton = dynamic_cast<MythUIButton *> (GetChild("save")); m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel")); m_textLabel = dynamic_cast<MythUIText *> (GetChild("label-text")); if (!m_settingsList || !m_textLabel || !m_saveButton || !m_cancelButton) { LOG(VB_GENERAL, LOG_EMERG, "Theme is missing critical theme elements."); return false; } BuildFocusList(); MythUIText *text = dynamic_cast<MythUIText *> (GetChild("heading")); if (text) text->SetText(m_title); MythUIShape *shape = nullptr; for (int i = -8; i <= 8; i++) { text = dynamic_cast<MythUIText *> (GetChild(QString("value%1%2").arg(i >= 0? "+" : "").arg(i))); if (text) m_prevNextTexts[i] = text; shape = dynamic_cast<MythUIShape *> (GetChild(QString("shape%1%2").arg(i >= 0? "+" : "").arg(i))); if (shape) m_prevNextShapes[i] = shape; } m_settingValue = dynamic_cast<MythUITextEdit *> (GetChild("settingvalue")); connect(m_settingsList, SIGNAL(itemSelected(MythUIButtonListItem*)), SLOT(selectionChanged(MythUIButtonListItem*))); connect(m_settingValue, SIGNAL(LosingFocus()), SLOT(valueChanged())); connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(Save())); connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close())); LoadInBackground(); return true; }
bool ScreenSetup::Create() { bool foundtheme = false; // Load the theme for this screen foundtheme = LoadWindowFromXML("weather-ui.xml", "screen-setup", this); if (!foundtheme) return false; m_helpText = dynamic_cast<MythUIText *> (GetChild("helptxt")); m_activeList = dynamic_cast<MythUIButtonList *> (GetChild("activelist")); m_inactiveList = dynamic_cast<MythUIButtonList *> (GetChild("inactivelist")); m_finishButton = dynamic_cast<MythUIButton *> (GetChild("finishbutton")); MythUIText *activeheader = dynamic_cast<MythUIText *> (GetChild("activehdr")); if (activeheader) activeheader->SetText(tr("Active Screens")); MythUIText *inactiveheader = dynamic_cast<MythUIText *> (GetChild("inactivehdr")); if (inactiveheader) inactiveheader->SetText(tr("Inactive Screens")); if (!m_activeList || !m_inactiveList || !m_finishButton || !m_helpText) { LOG(VB_GENERAL, LOG_ERR, "Theme is missing required elements."); return false; } BuildFocusList(); connect(m_activeList, SIGNAL(itemSelected(MythUIButtonListItem *)), this, SLOT(updateHelpText())); connect(m_activeList, SIGNAL(itemClicked(MythUIButtonListItem *)), this, SLOT(doListSelect(MythUIButtonListItem *))); connect(m_inactiveList, SIGNAL(itemSelected(MythUIButtonListItem *)), this, SLOT(updateHelpText())); connect(m_inactiveList, SIGNAL(itemClicked(MythUIButtonListItem *)), this, SLOT(doListSelect(MythUIButtonListItem *))); SetFocusWidget(m_inactiveList); m_finishButton->SetText(tr("Finish")); connect(m_finishButton, SIGNAL(Clicked()), this, SLOT(saveData())); loadData(); return true; }
void ChannelRecPriority::updateList() { m_channelList->Reset(); QMap<QString, ChannelInfo*>::Iterator it; MythUIButtonListItem *item; for (it = m_sortedChannel.begin(); it != m_sortedChannel.end(); ++it) { ChannelInfo *chanInfo = *it; item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanInfo)); QString fontState = "default"; if (!m_visMap[chanInfo->chanid]) fontState = "disabled"; QString stringFormat = item->GetText(); if (stringFormat.isEmpty()) stringFormat = "<num> <sign> \"<name>\""; item->SetText(chanInfo->GetFormatted(stringFormat), fontState); item->SetText(chanInfo->chanstr, "channum", fontState); item->SetText(chanInfo->callsign, "callsign", fontState); item->SetText(chanInfo->channame, "name", fontState); item->SetText(QString().setNum(chanInfo->sourceid), "sourceid", fontState); item->SetText(chanInfo->sourcename, "sourcename", fontState); if (m_visMap[chanInfo->chanid]) item->DisplayState("normal", "status"); else item->DisplayState("disabled", "status"); item->SetImage(chanInfo->iconpath, "icon"); item->SetImage(chanInfo->iconpath); item->SetText(chanInfo->recpriority, "priority", fontState); if (m_currentItem == chanInfo) m_channelList->SetItemCurrent(item); } MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_channelData.isEmpty()); }
void ChannelRecPriority::updateList() { m_channelList->Reset(); QMap<QString, ChannelInfo*>::Iterator it; for (it = m_sortedChannel.begin(); it != m_sortedChannel.end(); ++it) { ChannelInfo *chanInfo = *it; MythUIButtonListItem *item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanInfo)); QString fontState = "default"; item->SetText(chanInfo->GetFormatted(ChannelInfo::kChannelLong), fontState); InfoMap infomap; chanInfo->ToMap(infomap); item->SetTextFromMap(infomap, fontState); item->DisplayState("normal", "status"); if (!chanInfo->icon.isEmpty()) { QString iconUrl = gCoreContext->GetMasterHostPrefix("ChannelIcons", chanInfo->icon); item->SetImage(iconUrl, "icon"); item->SetImage(iconUrl); } item->SetText(QString::number(chanInfo->recpriority), "priority", fontState); if (m_currentItem == chanInfo) m_channelList->SetItemCurrent(item); } // this textarea name is depreciated use 'nochannels_warning' instead MythUIText *noChannelsText = dynamic_cast<MythUIText*>(GetChild("norecordings_info")); if (!noChannelsText) noChannelsText = dynamic_cast<MythUIText*>(GetChild("nochannels_warning")); if (noChannelsText) noChannelsText->SetVisible(m_channelData.isEmpty()); }
void ChannelRecPriority::updateList() { m_channelList->Reset(); QMap<QString, ChannelInfo*>::Iterator it; MythUIButtonListItem *item; for (it = m_sortedChannel.begin(); it != m_sortedChannel.end(); ++it) { ChannelInfo *chanInfo = *it; item = new MythUIButtonListItem(m_channelList, "", qVariantFromValue(chanInfo)); QString fontState = "default"; if (!m_visMap[chanInfo->chanid]) fontState = "disabled"; item->SetText(chanInfo->GetFormatted(ChannelInfo::kChannelLong), fontState); InfoMap infomap; chanInfo->ToMap(infomap); item->SetTextFromMap(infomap, fontState); if (m_visMap[chanInfo->chanid]) item->DisplayState("normal", "status"); else item->DisplayState("disabled", "status"); item->SetImage(chanInfo->iconpath, "icon"); item->SetImage(chanInfo->iconpath); item->SetText(chanInfo->recpriority, "priority", fontState); if (m_currentItem == chanInfo) m_channelList->SetItemCurrent(item); } MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_channelData.isEmpty()); }
void SubtitleScreen::DrawTextSubtitles(QStringList &wrappedsubs, uint64_t start, uint64_t duration) { QFontMetrics font(*(gTextSubFont->GetFace())); int height = font.height() * (1 + PAD_HEIGHT); int pad_width = font.maxWidth() * PAD_WIDTH; int y = m_safeArea.height() - (height * wrappedsubs.size()); int centre = m_safeArea.width() / 2; QBrush bgfill = QBrush(QColor(0, 0, 0), Qt::SolidPattern); foreach (QString subtitle, wrappedsubs) { if (subtitle.isEmpty()) continue; int width = font.width(subtitle) + pad_width * 2; int x = centre - (width / 2) - pad_width; QRect rect(x, y, width, height); if (m_useBackground) { MythUIShape *shape = new MythUIShape(this, QString("tsubbg%1%2").arg(x).arg(y)); shape->SetFillBrush(bgfill); shape->SetArea(MythRect(rect)); if (duration > 0) m_expireTimes.insert(shape, start + duration); } MythUIText* text = new MythUIText(subtitle, *gTextSubFont, rect, rect, this, QString("tsub%1%2").arg(x).arg(y)); if (text) text->SetJustification(Qt::AlignCenter); y += height; LOG(VB_PLAYBACK, LOG_INFO, LOC + subtitle); m_refreshArea = true; if (duration > 0) { m_expireTimes.insert(text, start + duration); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Display text subtitle for %1 ms").arg(duration)); } } }
bool MythDialogBox::Create(void) { if (!CopyWindowFromBase("MythDialogBox", this)) return false; SetFullscreen(false); MythUIText *textarea = dynamic_cast<MythUIText *>(GetChild("messagearea")); buttonList = dynamic_cast<MythListButton *>(GetChild("list")); if (!textarea || !buttonList) return false; textarea->SetText(m_text); buttonList->SetActive(true); connect(buttonList, SIGNAL(itemClicked(MythListButtonItem*)), this, SLOT(Select(MythListButtonItem*))); return true; }
bool MythScreenType::SetFocusWidget(MythUIType *widget) { if (!widget || !widget->IsVisible()) { QMap<int, MythUIType *>::iterator it = m_FocusWidgetList.begin(); MythUIType *current; while (it != m_FocusWidgetList.end()) { current = *it; if (current->CanTakeFocus() && current->IsVisible()) { widget = current; break; } ++it; } } if (!widget) return false; if (m_CurrentFocusWidget == widget) return true; MythUIText *helpText = dynamic_cast<MythUIText *>(GetChild("helptext")); if (helpText) helpText->Reset(); if (m_CurrentFocusWidget) m_CurrentFocusWidget->LoseFocus(); m_CurrentFocusWidget = widget; m_CurrentFocusWidget->TakeFocus(); if (helpText && !widget->GetHelpText().isEmpty()) helpText->SetText(widget->GetHelpText()); return true; }
void IdleScreen::UpdateStatus(void) { QString state = "idle"; if (CheckConnectionToServer()) { if (m_secondsToShutdown >= 0) state = "shuttingdown"; else if (RemoteGetRecordingStatus()) state = "recording"; } else { state = "offline"; } m_statusState->DisplayState(state); MythUIType* shuttingdown = m_statusState->GetState("shuttingdown"); if (shuttingdown) { MythUIText *statusText = dynamic_cast<MythUIText *>(shuttingdown->GetChild("status")); if (statusText) { if (m_secondsToShutdown >= 0) { QString status = tr("Backend will shutdown in %n " "second(s).", "", m_secondsToShutdown); statusText->SetText(status); } else statusText->Reset(); } } }
static void DoSetTextFromMap(MythUIType *UItype, QHash<QString, QString> &infoMap) { QList<MythUIType *> *children = UItype->GetAllChildren(); MythUIText *textType; QMutableListIterator<MythUIType *> i(*children); while (i.hasNext()) { MythUIType *type = i.next(); if (!type->IsVisible()) continue; textType = dynamic_cast<MythUIText *> (type); if (textType && infoMap.contains(textType->objectName())) textType->SetTextFromMap(infoMap); MythUIGroup *group = dynamic_cast<MythUIGroup *> (type); if (group) DoSetTextFromMap(type, infoMap); } }
bool MythConfirmationDialog::Create(void) { if (!CopyWindowFromBase("MythConfirmationDialog", this)) return false; MythUIText *messageText = NULL; MythUIButton *okButton = NULL; MythUIButton *cancelButton = NULL; bool err = false; UIUtilE::Assign(this, messageText, "message", &err); UIUtilE::Assign(this, okButton, "ok", &err); UIUtilE::Assign(this, cancelButton, "cancel", &err); if (err) { VERBOSE(VB_IMPORTANT, "Cannot load screen 'MythConfirmationDialog'"); return false; } if (m_showCancel) { connect(cancelButton, SIGNAL(Clicked()), SLOT(Cancel())); } else cancelButton->SetVisible(false); connect(okButton, SIGNAL(Clicked()), SLOT(Confirm())); messageText->SetText(m_message); BuildFocusList(); SetFocusWidget(okButton); return true; }
void ChannelRecPriority::updateInfo(MythUIButtonListItem *item) { if (!item) return; ChannelInfo *channelItem = qVariantValue<ChannelInfo *>(item->GetData()); if (!m_channelData.isEmpty() && channelItem) { QString rectype; if (m_iconImage) { m_iconImage->SetFilename(channelItem->iconpath); m_iconImage->Load(); } if (m_chanstringText) m_chanstringText->SetText(channelItem->GetFormatted(m_longchannelformat)); if (m_callsignText) m_callsignText->SetText(channelItem->callsign); if (m_channumText) m_channumText->SetText(channelItem->chanstr); if (m_channameText) m_channameText->SetText(channelItem->channame); if (m_sourcenameText) m_sourcenameText->SetText(channelItem->sourcename); if (m_sourceidText) m_sourceidText->SetText(QString().setNum(channelItem->sourceid)); if (m_priorityText) m_priorityText->SetText(channelItem->recpriority); } MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_channelData.isEmpty()); }
void SubtitleScreen::Display708Strings(const CC708Window &win, int num, float aspect, vector<CC708String*> &list) { LOG(VB_VBI, LOG_INFO,LOC + QString("Display Win %1, Anchor_id %2, x_anch %3, y_anch %4, " "relative %5") .arg(num).arg(win.anchor_point).arg(win.anchor_horizontal) .arg(win.anchor_vertical).arg(win.relative_pos)); bool display = false; MythFontProperties *mythfont; uint max_row_width = 0; uint total_height = 0; uint i = 0; for (uint row = 0; (row < win.true_row_count) && (i < list.size()); row++) { uint row_width = 0, max_row_height = 0; for (; (i < list.size()) && list[i] && (list[i]->y <= row); i++) { if (list[i]->y < row) continue; mythfont = Get708Font(list[i]->attr); if (!mythfont) continue; QString text = list[i]->str.trimmed(); if (!text.isEmpty()) display = true; QFontMetrics font(*(mythfont->GetFace())); uint height = (uint)font.height() * (1 + PAD_HEIGHT); row_width += font.width(list[i]->str) + (font.maxWidth() * PAD_WIDTH * 2); max_row_height = max(max_row_height, height); } max_row_width = max(max_row_width, row_width); total_height += max_row_height; } if (!display) return; float xrange = win.relative_pos ? 100.0f : (aspect > 1.4f) ? 210.0f : 160.0f; float yrange = win.relative_pos ? 100.0f : 75.0f; float xmult = (float)m_safeArea.width() / xrange; float ymult = (float)m_safeArea.height() / yrange; uint anchor_x = (uint)(xmult * (float)win.anchor_horizontal); uint anchor_y = (uint)(ymult * (float)win.anchor_vertical); if (win.anchor_point % 3 == 1) anchor_x -= (((int)max_row_width) / 2); if (win.anchor_point % 3 == 2) anchor_x -= (int)max_row_width; if (win.anchor_point / 3 == 1) anchor_y -= (((int)total_height) / 2); if (win.anchor_point / 3 == 2) anchor_y -= (int)total_height; if (win.GetFillAlpha()) // TODO border? { QRect bg(anchor_x, anchor_y, max_row_width, total_height); QBrush fill(win.GetFillColor(), Qt::SolidPattern); MythUIShape *shape = new MythUIShape(this, QString("cc708bg%1").arg(num)); shape->SetFillBrush(fill); shape->SetArea(MythRect(bg)); m_708imageCache[num].append(shape); m_refreshArea = true; } i = 0; int y = anchor_y; for (uint row = 0; (row < win.true_row_count) && (i < list.size()); row++) { uint maxheight = 0; int x = anchor_x; bool first = true; for (; (i < list.size()) && list[i] && (list[i]->y <= row); i++) { bool last = ((i + 1) == list.size()); if (!last) last = (list[i + 1]->y > row); QString rawstring = list[i]->str; mythfont = Get708Font(list[i]->attr); if ((list[i]->y < row) || !mythfont || rawstring.isEmpty()) continue; QString trimmed = rawstring.trimmed(); if (!trimmed.size() && last) continue; QFontMetrics font(*(mythfont->GetFace())); uint height = (uint)font.height() * (1 + PAD_HEIGHT); maxheight = max(maxheight, height); uint spacewidth = font.width(QString(" ")); uint textwidth = font.width(trimmed); int leading = 0; int trailing = 0; if (trimmed.size() != rawstring.size()) { if (trimmed.size()) { leading = rawstring.indexOf(trimmed.at(0)); trailing = rawstring.size() - trimmed.size() - leading; } else { leading = rawstring.size(); } leading *= spacewidth; trailing *= spacewidth; } if (!leading) textwidth += spacewidth * PAD_WIDTH; if (!trailing) textwidth += spacewidth * PAD_WIDTH; bool background = list[i]->attr.GetBGAlpha(); QBrush bgfill = QBrush((list[i]->attr.GetBGColor(), Qt::SolidPattern)); if (leading && background && !first) { // draw background for leading space QRect space(x, y, leading, height); MythUIShape *shape = new MythUIShape(this, QString("cc708shape%1x%2lead").arg(row).arg(i)); shape->SetFillBrush(bgfill); shape->SetArea(MythRect(space)); m_708imageCache[num].append(shape); m_refreshArea = true; } x += leading; QRect rect(x, y, textwidth, height); if (trimmed.size() && textwidth && background) { MythUIShape *shape = new MythUIShape(this, QString("cc708shape%1x%2main").arg(row).arg(i)); shape->SetFillBrush(bgfill); shape->SetArea(MythRect(rect)); m_708imageCache[num].append(shape); m_refreshArea = true; } if (trimmed.size() && textwidth) { MythUIText *text = new MythUIText(list[i]->str, *mythfont, rect, rect, (MythUIType*)this, QString("cc708text%1x%2").arg(row).arg(i)); m_708imageCache[num].append(text); if (text) text->SetJustification(Qt::AlignCenter); m_refreshArea = true; } x += textwidth; if (trailing && background && !last) { // draw background for trailing space QRect space(x, y, trailing, height); MythUIShape *shape = new MythUIShape(this, QString("cc708shape%1x%2trail").arg(row).arg(i)); shape->SetFillBrush(bgfill); shape->SetArea(MythRect(space)); m_708imageCache[num].append(shape); m_refreshArea = true; } x += trailing; first = false; LOG(VB_VBI, LOG_INFO, QString("Win %1 row %2 String '%3'") .arg(num).arg(row).arg(list[i]->str)); } y += maxheight; } }
void MythUIText::CreateCopy(MythUIType *parent) { MythUIText *text = new MythUIText(parent, objectName()); text->CopyFrom(this); }
bool MythTimeInputDialog::Create() { if (!CopyWindowFromBase("MythTimeInputDialog", this)) return false; MythUIText *messageText = NULL; MythUIButton *okButton = NULL; bool err = false; UIUtilE::Assign(this, messageText, "message", &err); UIUtilE::Assign(this, m_dateList, "dates", &err); UIUtilE::Assign(this, m_timeList, "times", &err); UIUtilE::Assign(this, okButton, "ok", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTimeInputDialog'"); return false; } m_dateList->SetVisible(false); m_timeList->SetVisible(false); MythUIButtonListItem *item; // Date if (kNoDate != (m_resolution & 0xF)) { const QDate startdate(m_startTime.toLocalTime().date()); QDate date(startdate); int limit = 0; if (m_resolution & kFutureDates) { limit += m_rangeLimit; } if (m_resolution & kPastDates) { limit += m_rangeLimit; date = date.addDays(0-m_rangeLimit); } QString text; int flags; bool selected = false; for (int x = 0; x <= limit; x++) { selected = false; if (m_resolution & kDay) { date = date.addDays(1); flags = MythDate::kDateFull | MythDate::kSimplify; if (m_rangeLimit >= 356) flags |= MythDate::kAddYear; text = MythDate::toString(date, flags); if (date == startdate) selected = true; } else if (m_resolution & kMonth) { date = date.addMonths(1); text = date.toString("MMM yyyy"); if ((date.month() == startdate.month()) && (date.year() == startdate.year())) selected = true; } else if (m_resolution & kYear) { date = date.addYears(1); text = date.toString("yyyy"); if (date.year() == startdate.year()) selected = true; } item = new MythUIButtonListItem(m_dateList, text, NULL, false); item->SetData(QVariant(date)); if (selected) m_dateList->SetItemCurrent(item); } m_dateList->SetVisible(true); } // Time if (kNoTime != (m_resolution & 0xF0)) { QDate startdate(m_startTime.toLocalTime().date()); QTime starttime(m_startTime.toLocalTime().time()); QTime time(0,0,0); QString text; bool selected = false; int limit = (m_resolution & kMinutes) ? (60 * 24) : 24; for (int x = 0; x < limit; x++) { selected = false; if (m_resolution & kMinutes) { time = time.addSecs(60); QDateTime dt = QDateTime(startdate, time, Qt::LocalTime); text = MythDate::toString(dt, MythDate::kTime); if (time == starttime) selected = true; } else if (m_resolution & kHours) { time = time.addSecs(60*60); text = time.toString("hh:00"); if (time.hour() == starttime.hour()) selected = true; } item = new MythUIButtonListItem(m_timeList, text, NULL, false); item->SetData(QVariant(time)); if (selected) m_timeList->SetItemCurrent(item); } m_timeList->SetVisible(true); } if (messageText && !m_message.isEmpty()) messageText->SetText(m_message); connect(okButton, SIGNAL(Clicked()), SLOT(okClicked())); BuildFocusList(); return true; }
void SubtitleScreen::DisplayCC608Subtitles(void) { static const QColor clr[8] = { Qt::white, Qt::red, Qt::green, Qt::yellow, Qt::blue, Qt::magenta, Qt::cyan, Qt::white, }; if (!InitialiseFont(m_fontStretch) || !m_608reader) return; bool changed = false; if (m_player && m_player->GetVideoOutput()) { QRect oldsafe = m_safeArea; m_safeArea = m_player->GetVideoOutput()->GetSafeRect(); if (oldsafe != m_safeArea) changed = true; } else { return; } CC608Buffer* textlist = m_608reader->GetOutputText(changed); if (!changed) return; if (textlist) textlist->lock.lock(); DeleteAllChildren(); if (!textlist) return; if (textlist && textlist->buffers.empty()) { SetRedraw(); textlist->lock.unlock(); return; } vector<CC608Text*>::iterator i = textlist->buffers.begin(); bool teletextmode = (*i)->teletextmode; int xscale = teletextmode ? 40 : 36; int yscale = teletextmode ? 25 : 17; gTextSubFont->GetFace()->setPixelSize(m_safeArea.height() / (yscale * 1.2)); QFontMetrics font(*(gTextSubFont->GetFace())); QBrush bgfill = QBrush(QColor(0, 0, 0), Qt::SolidPattern); int height = font.height() * (1 + PAD_HEIGHT); int pad_width = font.maxWidth() * PAD_WIDTH; for (; i != textlist->buffers.end(); i++) { CC608Text *cc = (*i); if (cc && (cc->text != QString::null)) { int width = font.width(cc->text) + pad_width; int x = teletextmode ? cc->y : (cc->x + 3); int y = teletextmode ? cc->x : cc->y; x = (int)(((float)x / (float)xscale) * (float)m_safeArea.width()); y = (int)(((float)y / (float)yscale) * (float)m_safeArea.height()); QRect rect(x, y, width, height); if (!teletextmode && m_useBackground) { MythUIShape *shape = new MythUIShape(this, QString("cc608bg%1%2%3").arg(cc->x).arg(cc->y).arg(width)); shape->SetFillBrush(bgfill); QRect bgrect(x - pad_width, y, width + pad_width, height); shape->SetArea(MythRect(bgrect)); } gTextSubFont->SetColor(clr[min(max(0, cc->color), 7)]); MythUIText *text = new MythUIText( cc->text, *gTextSubFont, rect, rect, (MythUIType*)this, QString("cc608txt%1%2%3").arg(cc->x).arg(cc->y).arg(width)); if (text) text->SetJustification(Qt::AlignLeft); m_refreshArea = true; LOG(VB_VBI, LOG_INFO, QString("x %1 y %2 String: '%3'") .arg(cc->x).arg(cc->y).arg(cc->text)); } } textlist->lock.unlock(); }
void ViewScheduled::FillList() { m_schedulesList->Reset(); MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_recList.empty()); if (m_recList.empty()) return; ProgramList plist; if (!m_recgroupList.contains(m_currentGroup)) m_currentGroup = m_defaultGroup; plist = m_recgroupList[m_currentGroup]; ProgramList::iterator pit = plist.begin(); while (pit != plist.end()) { ProgramInfo *pginfo = *pit; if (!pginfo) { ++pit; continue; } QString state; const RecStatusType recstatus = pginfo->GetRecordingStatus(); if (recstatus == rsRecording) state = "running"; else if (recstatus == rsConflict || recstatus == rsOffLine || recstatus == rsTunerBusy || recstatus == rsFailed || recstatus == rsAborted || recstatus == rsMissed) state = "error"; else if (recstatus == rsWillRecord) { if ((m_curcard == 0 && m_curinput == 0) || pginfo->GetCardID() == m_curcard || pginfo->GetInputID() == m_curinput) { if (pginfo->GetRecordingPriority2() < 0) state = "warning"; else state = "normal"; } } else if (recstatus == rsRepeat || recstatus == rsOtherShowing || recstatus == rsNeverRecord || recstatus == rsDontRecord || (recstatus != rsDontRecord && recstatus <= rsEarlierShowing)) state = "disabled"; else state = "warning"; MythUIButtonListItem *item = new MythUIButtonListItem(m_schedulesList,"", qVariantFromValue(pginfo)); InfoMap infoMap; pginfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString rating = QString::number(pginfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); item->DisplayState(state, "status"); ++pit; } MythUIText *statusText = dynamic_cast<MythUIText*>(GetChild("status")); if (statusText) { if (m_conflictBool) { // Find first conflict and store in m_conflictDate field ProgramList::const_iterator it = plist.begin(); for (; it != plist.end(); ++it) { ProgramInfo &p = **it; if (p.GetRecordingStatus() == rsConflict) { m_conflictDate = p.GetRecordingStartTime().date(); break; } } // figure out caption based on m_conflictDate QString cstring = tr("Time Conflict"); QDate now = QDate::currentDate(); int daysToConflict = now.daysTo(m_conflictDate); if (daysToConflict == 0) cstring = tr("Conflict Today"); else if (daysToConflict > 0) cstring = QString(tr("Conflict %1")) .arg(m_conflictDate.toString(m_dateFormat)); statusText->SetText(cstring); } else statusText->SetText(tr("No Conflicts")); } MythUIText *filterText = dynamic_cast<MythUIText*>(GetChild("filter")); if (filterText) { if (m_showAll) filterText->SetText(tr("All")); else filterText->SetText(tr("Important")); } }
void ViewScheduled::FillList() { m_schedulesList->Reset(); MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_recList.empty()); if (m_recList.empty()) return; ProgramList plist; if (!m_recgroupList.contains(m_currentGroup)) m_currentGroup = m_defaultGroup; plist = m_recgroupList[m_currentGroup]; ProgramList::iterator pit = plist.begin(); while (pit != plist.end()) { ProgramInfo *pginfo = *pit; if (!pginfo) { ++pit; continue; } QString state; const RecStatus::Type recstatus = pginfo->GetRecordingStatus(); if (recstatus == RecStatus::Recording || recstatus == RecStatus::Tuning) state = "running"; else if (recstatus == RecStatus::Conflict || recstatus == RecStatus::Offline || recstatus == RecStatus::TunerBusy || recstatus == RecStatus::Failed || recstatus == RecStatus::Failing || recstatus == RecStatus::Aborted || recstatus == RecStatus::Missed) state = "error"; else if (recstatus == RecStatus::WillRecord || recstatus == RecStatus::Pending) { if (m_curinput == 0 || pginfo->GetInputID() == m_curinput) { if (pginfo->GetRecordingPriority2() < 0) state = "warning"; else state = "normal"; } } else if (recstatus == RecStatus::Repeat || recstatus == RecStatus::NeverRecord || recstatus == RecStatus::DontRecord || (recstatus != RecStatus::DontRecord && recstatus <= RecStatus::EarlierShowing)) state = "disabled"; else state = "warning"; MythUIButtonListItem *item = new MythUIButtonListItem(m_schedulesList,"", qVariantFromValue(pginfo)); InfoMap infoMap; pginfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString rating = QString::number(pginfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); item->DisplayState(state, "status"); ++pit; } MythUIText *statusText = dynamic_cast<MythUIText*>(GetChild("status")); if (statusText) { if (m_conflictBool) { // Find first conflict and store in m_conflictDate field ProgramList::const_iterator it = plist.begin(); for (; it != plist.end(); ++it) { ProgramInfo &p = **it; if (p.GetRecordingStatus() == RecStatus::Conflict) { m_conflictDate = p.GetRecordingStartTime() .toLocalTime().date(); break; } } // TODO: This can be templated instead of hardcoding // Conflict/No Conflict QString cstring = tr("Conflict %1") .arg(MythDate::toString(m_conflictDate, MythDate::kDateFull | MythDate::kSimplify)); statusText->SetText(cstring); } else statusText->SetText(tr("No Conflicts")); } MythUIText *filterText = dynamic_cast<MythUIText*>(GetChild("filter")); if (filterText) { if (m_showAll) filterText->SetText(tr("All")); else filterText->SetText(tr("Important")); } }
void OSD::SetText(const QString &window, const InfoMap &map, OSDTimeout timeout) { MythScreenType *win = GetWindow(window); if (!win) return; if (map.contains("numstars")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("ratingstate")); if (state) state->DisplayState(map["numstars"]); } if (map.contains("tvstate")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("tvstate")); if (state) state->DisplayState(map["tvstate"]); } if (map.contains("videocodec")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("videocodec")); if (state) state->DisplayState(map["videocodec"]); } if (map.contains("videodescrip")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("videodescrip")); if (state) state->DisplayState(map["videodescrip"]); } if (map.contains("audiocodec")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("audiocodec")); if (state) state->DisplayState(map["audiocodec"]); } if (map.contains("audiochannels")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("audiochannels")); if (state) state->DisplayState(map["audiochannels"]); } if (map.contains("chanid")) { MythUIImage *icon = dynamic_cast<MythUIImage *> (win->GetChild("iconpath")); if (icon) { icon->Reset(); uint chanid = map["chanid"].toUInt(); QString iconpath; if (map.contains("iconpath")) iconpath = map["iconpath"]; else iconpath = ChannelUtil::GetIcon(chanid); if (!iconpath.isEmpty()) { QString iconurl = gCoreContext->GetMasterHostPrefix("ChannelIcons", iconpath); icon->SetFilename(iconurl); icon->Load(false); } } } if (map.contains("channelgroup")) { MythUIText *textArea = dynamic_cast<MythUIText *> (win->GetChild("channelgroup")); if (textArea) { textArea->SetText(map["channelgroup"]); } } if (map.contains("inetref")) { MythUIImage *cover = dynamic_cast<MythUIImage *> (win->GetChild("coverart")); if (cover && map.contains("coverartpath")) { QString coverpath = map["coverartpath"]; cover->SetFilename(coverpath); cover->Load(false); } MythUIImage *fanart = dynamic_cast<MythUIImage *> (win->GetChild("fanart")); if (fanart && map.contains("fanartpath")) { QString fanartpath = map["fanartpath"]; fanart->SetFilename(fanartpath); fanart->Load(false); } MythUIImage *banner = dynamic_cast<MythUIImage *> (win->GetChild("banner")); if (banner && map.contains("bannerpath")) { QString bannerpath = map["bannerpath"]; banner->SetFilename(bannerpath); banner->Load(false); } MythUIImage *screenshot = dynamic_cast<MythUIImage *> (win->GetChild("screenshot")); if (screenshot && map.contains("screenshotpath")) { QString screenshotpath = map["screenshotpath"]; screenshot->SetFilename(screenshotpath); screenshot->Load(false); } } if (map.contains("nightmode")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("nightmode")); if (state) state->DisplayState(map["nightmode"]); } if (map.contains("mediatype")) { MythUIStateType *state = dynamic_cast<MythUIStateType *> (win->GetChild("mediatype")); if (state) state->DisplayState(map["mediatype"]); } MythUIProgressBar *bar = dynamic_cast<MythUIProgressBar *>(win->GetChild("elapsedpercent")); if (bar) { int startts = map["startts"].toInt(); int endts = map["endts"].toInt(); int nowts = MythDate::current().toTime_t(); if (startts > nowts) { bar->SetUsed(0); } else if (endts < nowts) { bar->SetUsed(1000); } else { int duration = endts - startts; if (duration > 0) bar->SetUsed(1000 * (nowts - startts) / duration); else bar->SetUsed(0); } bar->SetVisible(startts > 0); bar->SetStart(0); bar->SetTotal(1000); } win->SetVisible(true); if (win == m_Dialog) { ChannelEditor *edit = dynamic_cast<ChannelEditor*>(m_Dialog); if (edit) edit->SetText(map); } else win->SetTextFromMap(map); SetExpiry(window, timeout); }
void ProgramRecPriority::UpdateList() { if (!m_currentItem && !m_programList->IsEmpty()) m_currentItem = m_programList->GetItemCurrent()->GetData() .value<ProgramRecPriorityInfo*>(); m_programList->Reset(); vector<ProgramRecPriorityInfo*>::iterator it; MythUIButtonListItem *item; for (it = m_sortedProgram.begin(); it != m_sortedProgram.end(); ++it) { ProgramRecPriorityInfo *progInfo = *it; item = new MythUIButtonListItem(m_programList, "", qVariantFromValue(progInfo)); int progRecPriority = progInfo->GetRecordingPriority(); if ((progInfo->rectype == kSingleRecord || progInfo->rectype == kOverrideRecord || progInfo->rectype == kDontRecord) && !(progInfo->GetSubtitle()).trimmed().isEmpty()) { QString rating = QString::number(progInfo->GetStars(10)); item->DisplayState(rating, "ratingstate"); } else progInfo->subtitle.clear(); QString state; if (progInfo->recType == kDontRecord || (progInfo->recType != kTemplateRecord && progInfo->recstatus == RecStatus::Inactive)) state = "disabled"; else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0) state = "error"; else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0 || progInfo->recType == kTemplateRecord) state = "normal"; else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0) state = "running"; else state = "warning"; InfoMap infoMap; progInfo->ToMap(infoMap); item->SetTextFromMap(infoMap, state); QString subtitle; if (progInfo->subtitle != "(null)" && (progInfo->rectype == kSingleRecord || progInfo->rectype == kOverrideRecord || progInfo->rectype == kDontRecord)) { subtitle = progInfo->subtitle; } QString matchInfo; if (progInfo->GetRecordingStatus() == RecStatus::Inactive) { matchInfo = QString("%1 %2") .arg(m_listMatch[progInfo->GetRecordingRuleID()]) .arg(RecStatus::toString(progInfo->GetRecordingStatus(), progInfo->GetRecordingRuleType())); } else matchInfo = tr("Recording %1 of %2") .arg(m_recMatch[progInfo->GetRecordingRuleID()]) .arg(m_listMatch[progInfo->GetRecordingRuleID()]); subtitle = QString("(%1) %2").arg(matchInfo).arg(subtitle); item->SetText(subtitle, "scheduleinfo", state); item->SetText(QString::number(progRecPriority), "progpriority", state); item->SetText(QString::number(progRecPriority), "finalpriority", state); item->SetText(QString::number(progRecPriority), "recpriority", state); item->SetText(QString::number(progRecPriority), "recpriorityB", state); QString tempDateTime = MythDate::toString(progInfo->last_record, MythDate::kDateTimeFull | MythDate::kSimplify | MythDate::kAddYear); item->SetText(tempDateTime, "lastrecorded", state); QString tempDate = MythDate::toString(progInfo->last_record, MythDate::kDateFull | MythDate::kSimplify | MythDate::kAddYear); item->SetText(tempDate, "lastrecordeddate", state); QString tempTime = MythDate::toString( progInfo->last_record, MythDate::kTime); item->SetText(tempTime, "lastrecordedtime", state); QString channame = progInfo->channame; QString channum = progInfo->chanstr; QString callsign = progInfo->chansign; if (progInfo->recType != kSingleRecord && progInfo->recType != kOverrideRecord && progInfo->recType != kDontRecord && !(progInfo->GetRecordingRule()->m_filter & 1024) && progInfo->GetRecordingRule()->m_searchType != kManualSearch) { channame = tr("Any"); channum = tr("Any"); callsign = tr("Any"); } item->SetText(channame, "channel", state); item->SetText(channum, "channum", state); item->SetText(callsign, "callsign", state); QString profile = progInfo->profile; if ((profile == "Default") || (profile == "Live TV") || (profile == "High Quality") || (profile == "Low Quality")) profile = tr(profile.toUtf8().constData()); item->SetText(profile, "recordingprofile", state); item->DisplayState(state, "status"); if (m_currentItem == progInfo) m_programList->SetItemCurrent(item); } m_currentItem = NULL; MythUIText *norecordingText = dynamic_cast<MythUIText*> (GetChild("norecordings_info")); if (norecordingText) norecordingText->SetVisible(m_programData.isEmpty()); }