void MythScreenStack::AddScreen(MythScreenType *screen, bool allowFade) { if (!screen) return; m_DoInit = false; MythScreenType *old = m_topScreen; if (old) old->aboutToHide(); m_Children.push_back(screen); if (allowFade && m_DoTransitions) { m_newTop = screen; DoNewFadeTransition(); } else { if (parent()) reinterpret_cast<MythMainWindow *>(parent())->update(); RecalculateDrawOrder(); if (!screen->IsInitialized()) m_DoInit = true; } screen->aboutToShow(); m_topScreen = screen; emit topScreenChanged(m_topScreen); }
void MythScreenStack::RecalculateDrawOrder(void) { m_DrawOrder.clear(); if (m_Children.isEmpty()) return; QVector<MythScreenType *>::Iterator it; for (it = m_Children.begin(); it != m_Children.end(); ++it) { MythScreenType *screen = (*it); if (screen->IsFullscreen()) m_DrawOrder.clear(); m_DrawOrder.push_back(screen); } if (m_DrawOrder.isEmpty()) { MythScreenType *screen = GetTopScreen(); if (screen) m_DrawOrder.push_back(screen); } }
void EditStreamMetadata::searchClicked(void ) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); MythScreenType *screen = new SearchStream(mainStack, this); if (screen->Create()) mainStack->AddScreen(screen); else delete screen; }
void BookmarkManager::slotBookmarkClicked(MythUIButtonListItem *item) { if (!item) return; Bookmark *site = qVariantValue<Bookmark*>(item->GetData()); if (!site) return; m_savedBookmark = *site; QString cmd = gCoreContext->GetSetting("WebBrowserCommand", "Internal"); QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0"); QStringList urls; urls.append(site->url); if (cmd.toLower() == "internal") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); MythScreenType *mythbrowser; if (urls[0].startsWith("mythflash://")) mythbrowser = new MythFlashPlayer(mainStack, urls); else mythbrowser = new MythBrowser(mainStack, urls); if (mythbrowser->Create()) { connect(mythbrowser, SIGNAL(Exiting()), SLOT(slotBrowserClosed())); mainStack->AddScreen(mythbrowser); } else delete mythbrowser; } else { cmd.replace("%ZOOM%", zoom); cmd.replace("%URL%", urls.join(" ")); cmd.replace("&","\\&"); cmd.replace(";","\\;"); GetMythMainWindow()->AllowInput(false); myth_system(cmd, kMSDontDisableDrawing); GetMythMainWindow()->AllowInput(true); // we need to reload the bookmarks incase the user added/deleted // any while in MythBrowser ReloadBookmarks(); } }
void OSD::SetGraph(const QString &window, const QString &graph, int64_t timecode) { MythScreenType *win = GetWindow(window); if (!win) return; MythUIImage *image = dynamic_cast<MythUIImage* >(win->GetChild(graph)); if (!image) return; MythImage* mi = m_parent->GetAudioGraph().GetImage(timecode); if (mi) image->SetImage(mi); }
void StreamView::editStream(void) { MythUIButtonListItem *item = m_streamList->GetItemCurrent(); if (item) { Metadata *mdata = qVariantValue<Metadata*> (item->GetData()); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); MythScreenType *screen = new EditStreamMetadata(mainStack, this, mdata); if (screen->Create()) mainStack->AddScreen(screen); else delete screen; } }
void OSD::SetValues(const QString &window, const QHash<QString,float> &map, OSDTimeout timeout) { MythScreenType *win = GetWindow(window); if (!win) return; bool found = false; if (map.contains("position")) { MythUIEditBar *edit = dynamic_cast<MythUIEditBar *> (win->GetChild("editbar")); if (edit) edit->SetEditPosition(map.value("position")); } if (found) SetExpiry(window, timeout); }
void OSD::SetValues(const QString &window, const QHash<QString,int> &map, OSDTimeout timeout) { MythScreenType *win = GetWindow(window); if (!win) return; bool found = false; if (map.contains("position")) { MythUIProgressBar *bar = dynamic_cast<MythUIProgressBar *> (win->GetChild("position")); if (bar) { bar->SetVisible(true); bar->SetStart(0); bar->SetTotal(1000); bar->SetUsed(map.value("position")); found = true; } } if (map.contains("relposition")) { MythUIProgressBar *bar = dynamic_cast<MythUIProgressBar *> (win->GetChild("relposition")); if (bar) { bar->SetVisible(true); bar->SetStart(0); bar->SetTotal(1000); bar->SetUsed(map.value("relposition")); found = true; } } if (found) SetExpiry(window, timeout); }
void StreamView::customEvent(QEvent *event) { bool handled = true; if (event->type() == MusicPlayerEvent::PlayedTracksChangedEvent) { if (gPlayer->getPlayedTracksList().count()) updateTrackInfo(gPlayer->getCurrentMetadata()); // add the new track to the list if (m_playedTracksList && gPlayer->getPlayedTracksList().count()) { Metadata *mdata = gPlayer->getPlayedTracksList().last(); MythUIButtonListItem *item = new MythUIButtonListItem(m_playedTracksList, "", qVariantFromValue(mdata), 0); MetadataMap metadataMap; mdata->toMap(metadataMap); item->SetTextFromMap(metadataMap); item->SetFontState("normal"); item->DisplayState("default", "playstate"); item->SetImage(mdata->getAlbumArtFile()); m_playedTracksList->SetItemCurrent(item); } } else if (event->type() == MusicPlayerEvent::TrackChangeEvent) { MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event); if (!mpe) return; int trackNo = mpe->TrackID; if (m_streamList) { if (m_currentTrack >= 0 && m_currentTrack < m_streamList->GetCount()) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("normal"); item->DisplayState("default", "playstate"); } } if (trackNo >= 0 && trackNo < m_streamList->GetCount()) { if (m_currentTrack == m_streamList->GetCurrentPos()) m_streamList->SetItemCurrent(trackNo); MythUIButtonListItem *item = m_streamList->GetItemAt(trackNo); if (item) { item->SetFontState("running"); item->DisplayState("playing", "playstate"); } } } m_currentTrack = trackNo; updateTrackInfo(gPlayer->getCurrentMetadata()); } else if (event->type() == OutputEvent::Playing) { if (gPlayer->isPlaying()) { if (m_streamList) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("running"); item->DisplayState("playing", "playstate"); } } } // pass it on to the default handler in MusicCommon handled = false; } else if (event->type() == OutputEvent::Stopped) { if (m_streamList) { MythUIButtonListItem *item = m_streamList->GetItemAt(m_currentTrack); if (item) { item->SetFontState("normal"); item->DisplayState("stopped", "playstate"); } } // pass it on to the default handler in MusicCommon handled = false; } else if (event->type() == OutputEvent::Buffering) { } else if (event->type() == MythEvent::MythEventMessage) { MythEvent *me = (MythEvent *)event; QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts); if (tokens.isEmpty()) return; if (tokens[0] == "DOWNLOAD_FILE") { QStringList args = me->ExtraDataList(); if (tokens[1] == "UPDATE") { } else if (tokens[1] == "FINISHED") { QString url = args[0]; int fileSize = args[2].toInt(); int errorCode = args[4].toInt(); QString filename = args[1]; if ((errorCode != 0) || (fileSize == 0)) LOG(VB_GENERAL, LOG_ERR, QString("StreamView: failed to download radio icon from '%1'").arg(url)); else { for (int x = 0; x < m_streamList->GetCount(); x++) { MythUIButtonListItem *item = m_streamList->GetItemAt(x); Metadata *mdata = qVariantValue<Metadata*> (item->GetData()); if (mdata && mdata->LogoUrl() == url) item->SetImage(filename); } } } } } else if (event->type() == DecoderHandlerEvent::OperationStart) { DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event); if (!dhe) return; if (dhe->getMessage() && m_bufferStatus) { m_bufferStatus->SetText(*dhe->getMessage()); } } else if (event->type() == DecoderHandlerEvent::BufferStatus) { DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event); if (!dhe) return; int available, maxSize; dhe->getBufferStatus(&available, &maxSize); if (m_bufferStatus) { QString status = QString("%1%").arg((int)(100.0 / ((double)maxSize / (double)available))); m_bufferStatus->SetText(status); } if (m_bufferProgress) { m_bufferProgress->SetTotal(maxSize); m_bufferProgress->SetUsed(available); } } else if (event->type() == DecoderHandlerEvent::OperationStop) { if (m_bufferStatus) m_bufferStatus->SetText(""); } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = static_cast<DialogCompletionEvent*>(event); // make sure the user didn't ESCAPE out of the menu if (dce->GetResult() < 0) return; QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "streammenu") { if (resulttext == tr("Add Stream")) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); MythScreenType *screen = new EditStreamMetadata(mainStack, this, NULL); if (screen->Create()) mainStack->AddScreen(screen); else delete screen; } else if (resulttext == tr("Remove Stream")) { removeStream(); } else if (resulttext == tr("Edit Stream")) { editStream(); } } else handled = false; } else handled = false; if (!handled) MusicCommon::customEvent(event); }
void MythScreenStack::PopScreen(MythScreenType *screen, bool allowFade, bool deleteScreen) { if (!screen || screen->IsDeleting()) return; screen->aboutToHide(); if (m_Children.isEmpty()) return; MythMainWindow *mainwindow = GetMythMainWindow(); screen->setParent(0); if ((screen == m_topScreen) && allowFade && m_DoTransitions && !mainwindow->IsExitingToMain()) { screen->SetFullscreen(false); if (deleteScreen) { screen->SetDeleting(true); m_ToDelete.push_back(screen); } screen->AdjustAlpha(1, -kFadeVal); } else { for (int i = 0; i < m_Children.size(); ++i) { if (m_Children.at(i) == screen) m_Children.remove(i); } if (deleteScreen) delete screen; screen = NULL; mainwindow->update(); if (mainwindow->IsExitingToMain()) { QCoreApplication::postEvent( mainwindow, new QEvent(MythEvent::kExitToMainMenuEventType)); } } m_topScreen = NULL; RecalculateDrawOrder(); // If we're fading it, we still want to draw it. if (screen) m_DrawOrder.push_back(screen); if (!m_Children.isEmpty()) { QVector<MythScreenType *>::Iterator it; for (it = m_DrawOrder.begin(); it != m_DrawOrder.end(); ++it) { if (*it != screen && !(*it)->IsDeleting()) { m_topScreen = (*it); (*it)->SetAlpha(255); (*it)->aboutToShow(); } } } if (m_topScreen) { m_topScreen->SetRedraw(); if (!allowFade || !m_DoTransitions) emit topScreenChanged(m_topScreen); } else { // Screen still needs to be redrawn if we have popped the last screen // off the popup stack, or similar MythScreenType *mainscreen = mainwindow->GetMainStack()->GetTopScreen(); if (mainscreen) mainscreen->SetRedraw(); if (!allowFade || !m_DoTransitions) emit topScreenChanged(NULL); } }
void MythNotificationScreenStack::PopScreen(MythScreenType *screen, bool allowFade, bool deleteScreen) { if (!screen || screen->IsDeleting()) return; bool poppedFullscreen = screen->IsFullscreen(); screen->aboutToHide(); if (m_Children.isEmpty()) return; MythMainWindow *mainwindow = GetMythMainWindow(); screen->setParent(0); if (allowFade && m_DoTransitions && !mainwindow->IsExitingToMain()) { screen->SetFullscreen(false); if (deleteScreen) { screen->SetDeleting(true); m_ToDelete.push_back(screen); } screen->AdjustAlpha(1, -kFadeVal); } else { for (int i = 0; i < m_Children.size(); ++i) { if (m_Children.at(i) == screen) { m_Children.remove(i); break; } } if (deleteScreen) screen->deleteLater(); screen = NULL; } m_topScreen = NULL; RecalculateDrawOrder(); // If we're fading it, we still want to draw it. if (screen && !m_DrawOrder.contains(screen)) m_DrawOrder.push_back(screen); if (!m_Children.isEmpty()) { QVector<MythScreenType *>::Iterator it; for (it = m_DrawOrder.begin(); it != m_DrawOrder.end(); ++it) { if (*it != screen && !(*it)->IsDeleting()) { m_topScreen = (*it); (*it)->SetAlpha(255); if (poppedFullscreen) (*it)->aboutToShow(); } } } if (m_topScreen) { m_topScreen->SetRedraw(); } else { // Screen still needs to be redrawn if we have popped the last screen // off the popup stack, or similar if (mainwindow->GetMainStack()) { MythScreenType *mainscreen = mainwindow->GetMainStack()->GetTopScreen(); if (mainscreen) mainscreen->SetRedraw(); } } }
void OSD::SetRegions(const QString &window, frm_dir_map_t &map, long long total) { MythScreenType *win = GetWindow(window); if (!win) return; MythUIEditBar *bar = dynamic_cast<MythUIEditBar*>(win->GetChild("editbar")); if (!bar) return; bar->ClearRegions(); if (!map.size() || total < 1) { bar->Display(); return; } long long start = -1; long long end = -1; bool first = true; QMapIterator<uint64_t, MarkTypes> it(map); while (it.hasNext()) { bool error = false; it.next(); if (it.value() == MARK_CUT_START) { start = it.key(); if (end > -1) error = true; } else if (it.value() == MARK_CUT_END) { if (first) start = 0; if (start < 0) error = true; end = it.key(); } else if (it.value() == MARK_PLACEHOLDER) { start = end = it.key(); } first = false; if (error) { LOG(VB_GENERAL, LOG_ERR, LOC + "deleteMap discontinuity"); start = -1; end = -1; } if (start >=0 && end >= 0) { bar->AddRegion((float)((double)start/(double)total), (float)((double)end/(double)total)); start = -1; end = -1; } } if (start > -1 && end < 0) bar->AddRegion((float)((double)start/(double)total), 1.0f); bar->Display(); }
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("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 OSD::DialogShow(const QString &window, const QString &text, int updatefor) { if (m_Dialog) { QString current = m_Dialog->objectName(); if (current != window) { DialogQuit(); } else { MythDialogBox *dialog = dynamic_cast<MythDialogBox*>(m_Dialog); if (dialog) dialog->Reset(); DialogSetText(text); } } if (!m_Dialog) { OverrideUIScale(); MythScreenType *dialog; if (window == OSD_DLG_EDITOR) dialog = new ChannelEditor(m_ParentObject, window.toLatin1()); else if (window == OSD_DLG_CONFIRM) dialog = new MythConfirmationDialog(NULL, text, false); else dialog = new MythDialogBox(text, NULL, window.toLatin1(), false, true); dialog->SetPainter(m_CurrentPainter); if (dialog->Create()) { PositionWindow(dialog); m_Dialog = dialog; MythDialogBox *dbox = dynamic_cast<MythDialogBox*>(m_Dialog); if (dbox) dbox->SetReturnEvent(m_ParentObject, window); MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog); if (cbox) { cbox->SetReturnEvent(m_ParentObject, window); cbox->SetData("DIALOG_CONFIRM_X_X"); } m_Children.insert(window, m_Dialog); } else { RevertUIScale(); delete dialog; return; } RevertUIScale(); } if (updatefor) { m_NextPulseUpdate = MythDate::current(); m_PulsedDialogText = text; SetExpiry(window, kOSDTimeout_None, updatefor); } DialogBack(); HideAll(true, m_Dialog); m_Dialog->SetVisible(true); }
void ProgLister::ShowChooseViewMenu(void) { MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythScreenType *screen = NULL; bool connect_string = true; switch (m_type) { case plChannel: case plCategory: case plMovies: case plNewListings: case plStoredSearch: { if (m_viewList.empty()) return; QString msg; switch (m_type) { case plMovies: msg = tr("Select Rating"); break; case plChannel: msg = tr("Select Channel"); break; case plCategory: msg = tr("Select Category"); break; case plNewListings: msg = tr("Select List"); break; case plStoredSearch: msg = QString("%1\n%2") .arg(tr("Select a search stored from")) .arg(tr("Custom Record")); break; } screen = new MythUISearchDialog( popupStack, msg, m_viewTextList, true, ""); break; } case plTitleSearch: case plKeywordSearch: case plPeopleSearch: screen = new PhrasePopup( popupStack, this, m_searchType, m_viewTextList, (m_curView >= 0) ? m_viewList[m_curView] : QString()); break; case plPowerSearch: screen = new PowerSearchPopup( popupStack, this, m_searchType, m_viewTextList, (m_curView >= 0) ? m_viewList[m_curView] : QString()); break; case plTime: screen = new TimePopup(popupStack, this); connect_string = false; break; } if (!screen) return; if (!screen->Create()) { delete screen; return; } if (connect_string) { connect(screen, SIGNAL(haveResult( QString)), this, SLOT( SetViewFromList(QString))); } else { connect(screen, SIGNAL(haveResult( QDateTime)), this, SLOT( SetViewFromTime(QDateTime))); } popupStack->AddScreen(screen); }