void MythQtPainter::DrawText(const QRect &r, const QString &msg, int flags, const MythFontProperties &font, int alpha, const QRect &boundRect) { if (!painter) { VERBOSE(VB_IMPORTANT, "FATAL ERROR: DrawText called with no painter"); return; } (void)alpha; painter->setOpacity(static_cast<float>(alpha) / 255.0); painter->setFont(font.face()); if (font.hasShadow()) { QPoint shadowOffset; QColor shadowColor; int shadowAlpha; font.GetShadow(shadowOffset, shadowColor, shadowAlpha); shadowColor.setAlpha(shadowAlpha); QRect a = r; a.translate(shadowOffset.x(), shadowOffset.y()); painter->setPen(shadowColor); painter->drawText(a, flags, msg); } if (font.hasOutline() && alpha > 128) { QColor outlineColor; int outlineSize, outlineAlpha; font.GetOutline(outlineColor, outlineSize, outlineAlpha); if (GetMythMainWindow()->GetUIScreenRect().height() > 700) outlineSize = 1; painter->setPen(outlineColor); QRect a = r; a.translate(0 - outlineSize, 0 - outlineSize); painter->drawText(a, flags, msg); for (int i = (0 - outlineSize + 1); i <= outlineSize; i++) { a.translate(1, 0); painter->drawText(a, flags, msg); } for (int i = (0 - outlineSize + 1); i <= outlineSize; i++) { a.translate(0, 1); painter->drawText(a, flags, msg); } for (int i = (0 - outlineSize + 1); i <= outlineSize; i++) { a.translate(-1, 0); painter->drawText(a, flags, msg); } for (int i = (0 - outlineSize + 1); i <= outlineSize; i++) { a.translate(0, -1); painter->drawText(a, flags, msg); } } painter->setPen(QPen(font.GetBrush(), 0)); painter->drawText(r, flags, msg); painter->setOpacity(1.0); }
bool MythUITextEdit::keyPressEvent(QKeyEvent *e) { m_lastKeyPress.restart(); QStringList actions; bool handled = false; handled = GetMythMainWindow()->TranslateKeyPress("Global", e, actions, false); if (!handled && InsertCharacter(e->text())) handled = true; for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "LEFT") { if (!MoveCursor(MoveLeft)) handled = false; } else if (action == "RIGHT") { if (!MoveCursor(MoveRight)) handled = false; } else if (action == "DELETE") { RemoveCharacter(m_Position+1); } else if (action == "BACKSPACE") { RemoveCharacter(m_Position); } else if (action == "SELECT" && e->key() != Qt::Key_Space && GetMythDB()->GetNumSetting("UseVirtualKeyboard", 1) == 1) { MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIVirtualKeyboard *kb = new MythUIVirtualKeyboard(popupStack, this); if (kb->Create()) { //connect(kb, SIGNAL(keyPress(QString)), SLOT(keyPress(QString))); popupStack->AddScreen(kb); } else delete kb; } else if (action == "CUT") { CutTextToClipboard(); } else if (action == "COPY") { CopyTextToClipboard(); } else if (action == "PASTE") { PasteTextFromClipboard(); } else handled = false; } return handled; }
void LocationDialog::doSearch() { QString busymessage = tr("Searching..."); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIBusyDialog *busyPopup = new MythUIBusyDialog(busymessage, popupStack, "mythweatherbusydialog"); if (busyPopup->Create()) { popupStack->AddScreen(busyPopup, false); } else { delete busyPopup; busyPopup = NULL; } QMap<ScriptInfo *, QStringList> result_cache; int numresults = 0; clearResults(); QString searchingresults = tr("Searching... Results: %1"); m_resultsText->SetText(searchingresults.arg(0)); qApp->processEvents(); QList<ScriptInfo *> sources; // if a screen makes it this far, theres at least one source for it m_sourceManager->findPossibleSources(m_types, sources); QString search = m_locationEdit->GetText(); ScriptInfo *si; for (int x = 0; x < sources.size(); x++) { si = sources.at(x); if (!result_cache.contains(si)) { QStringList results = m_sourceManager->getLocationList(si, search); result_cache[si] = results; numresults += results.size(); m_resultsText->SetText(searchingresults.arg(numresults)); qApp->processEvents(); } } QMap<ScriptInfo *, QStringList>::iterator it; for (it = result_cache.begin(); it != result_cache.end(); ++it) { si = it.key(); QStringList results = it.value(); QString name = si->name; QStringList::iterator rit; for (rit = results.begin(); rit != results.end(); ++rit) { QStringList tmp = (*rit).split("::"); if (tmp.size() < 2) { LOG(VB_GENERAL, LOG_WARNING, QString("Invalid line in Location Search reponse " "from %1: %2") .arg(name).arg(*rit)); continue; } QString resultstring = QString("%1 (%2)").arg(tmp[1]).arg(name); MythUIButtonListItem *item = new MythUIButtonListItem(m_locationList, resultstring); ResultListInfo *ri = new ResultListInfo; ri->idstr = tmp[0]; ri->src = si; item->SetData(qVariantFromValue(ri)); qApp->processEvents(); } } if (busyPopup) { busyPopup->Close(); busyPopup = NULL; } m_resultsText->SetText(tr("Search Complete. Results: %1").arg(numresults)); if (numresults) SetFocusWidget(m_locationList); }
/** * \brief Creates a dialog displaying current recording status and options * available */ void ScheduleCommon::ShowRecordingDialog(const RecordingInfo& recinfo) { QString message = recinfo.toString(ProgramInfo::kTitleSubtitle, " - "); message += "\n\n"; message += toDescription(recinfo.GetRecordingStatus(), recinfo.GetRecordingRuleType(), recinfo.GetRecordingStartTime()); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythDialogBox *menuPopup = new MythDialogBox(message, popupStack, "recOptionPopup", true); if (menuPopup->Create()) { menuPopup->SetReturnEvent(this, "schedulerecording"); QDateTime now = MythDate::current(); if (recinfo.GetRecordingStartTime() < now && recinfo.GetRecordingEndTime() > now) { if (recinfo.GetRecordingStatus() != rsRecording && recinfo.GetRecordingStatus() != rsTuning && recinfo.GetRecordingStatus() != rsOtherRecording && recinfo.GetRecordingStatus() != rsOtherTuning) menuPopup->AddButton(tr("Restart recording this showing"), qVariantFromValue(recinfo)); else menuPopup->AddButton(tr("Stop recording this showing"), qVariantFromValue(recinfo)); } if (recinfo.GetRecordingEndTime() > now) { if (recinfo.GetRecordingRuleType() != kSingleRecord && recinfo.GetRecordingRuleType() != kOverrideRecord) { if (recinfo.GetRecordingStartTime() > now) { menuPopup->AddButton(tr("Don't record this showing"), qVariantFromValue(recinfo)); } const RecordingDupMethodType dupmethod = recinfo.GetDuplicateCheckMethod(); if (recinfo.GetRecordingStatus() != rsRecording && recinfo.GetRecordingStatus() != rsTuning && recinfo.GetRecordingStatus() != rsOtherRecording && recinfo.GetRecordingStatus() != rsOtherTuning && recinfo.GetRecordingRuleType() != kOneRecord && !((recinfo.GetFindID() == 0 || !IsFindApplicable(recinfo)) && recinfo.GetCategoryType() == "series" && recinfo.GetProgramID().contains(QRegExp("0000$"))) && ((!(dupmethod & kDupCheckNone) && !recinfo.GetProgramID().isEmpty() && (recinfo.GetFindID() != 0 || !IsFindApplicable(recinfo))) || ((dupmethod & kDupCheckSub) && !recinfo.GetSubtitle().isEmpty()) || ((dupmethod & kDupCheckDesc) && !recinfo.GetDescription().isEmpty()) || ((dupmethod & kDupCheckSubThenDesc) && (!recinfo.GetSubtitle().isEmpty() || !recinfo.GetDescription().isEmpty())) )) { menuPopup->AddButton(tr("Never record this episode"), qVariantFromValue(recinfo)); } } if (recinfo.GetRecordingRuleType() != kOverrideRecord && recinfo.GetRecordingRuleType() != kDontRecord) { if (recinfo.GetRecordingStatus() == rsRecording || recinfo.GetRecordingStatus() == rsTuning || recinfo.GetRecordingStatus() == rsOtherRecording || recinfo.GetRecordingStatus() == rsOtherTuning) { menuPopup->AddButton(tr("Edit options for this showing"), qVariantFromValue(recinfo)); } else { if (recinfo.GetRecordingRuleType() != kSingleRecord) { menuPopup->AddButton(tr("Override this showing with options"), qVariantFromValue(recinfo)); } } } if (recinfo.GetRecordingRuleType() == kOverrideRecord || recinfo.GetRecordingRuleType() == kDontRecord) { if (recinfo.GetRecordingStatus() == rsRecording || recinfo.GetRecordingStatus() == rsTuning || recinfo.GetRecordingStatus() == rsOtherRecording || recinfo.GetRecordingStatus() == rsOtherTuning) { menuPopup->AddButton(tr("Edit options for this showing"), qVariantFromValue(recinfo)); } else { menuPopup->AddButton(tr("Edit override options"), qVariantFromValue(recinfo)); menuPopup->AddButton(tr("Delete override rule"), qVariantFromValue(recinfo)); } } } if (recinfo.GetRecordingRuleType() != kOverrideRecord && recinfo.GetRecordingRuleType() != kDontRecord) { menuPopup->AddButton(tr("Edit recording options"), qVariantFromValue(recinfo)); menuPopup->AddButton(tr("Delete recording rule"), qVariantFromValue(recinfo)); } popupStack->AddScreen(menuPopup); } else delete menuPopup; }
void ProgFinder::customEvent(QEvent *event) { if ((MythEvent::Type)(event->type()) == MythEvent::MythEventMessage) { MythEvent *me = (MythEvent *)event; QString message = me->Message(); if (message == "SCHEDULE_CHANGE") { if (GetFocusWidget() == m_timesList) { ProgramInfo *curPick = m_showData[m_timesList->GetCurrentPos()]; if (curPick) selectShowData(curPick->GetTitle(), m_timesList->GetCurrentPos()); } } } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "menu") { if (resulttext == tr("Clear Search")) { m_searchStr.clear(); if (m_searchText) m_searchText->SetText(m_searchStr); updateShowList(); SetFocusWidget(m_showList); } else if (resulttext == tr("Edit Search")) { MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); SearchInputDialog *textInput = new SearchInputDialog(popupStack, m_searchStr); if (textInput->Create()) { textInput->SetReturnEvent(this, "searchtext"); popupStack->AddScreen(textInput); } } else if (resulttext == tr("Toggle Record")) { quickRecord(); } else if (resulttext == tr("Program Details")) { details(); } else if (resulttext == tr("Upcoming")) { upcoming(); } else if (resulttext == tr("Custom Edit")) { customEdit(); } else if (resulttext == tr("Program Guide")) { showGuide(); } } else if (resultid == "searchtext") { m_searchStr = resulttext; if (m_searchText) m_searchText->SetText(m_searchStr); updateShowList(); SetFocusWidget(m_showList); } else ScheduleCommon::customEvent(event); } }
/** \brief keyboard/LIRC event handler. * * This translates key presses through the "Main Menu" context into MythTV * actions and then handles them as appropriate. */ bool MythThemedMenu::keyPressEvent(QKeyEvent *event) { if (m_ignorekeys) return false; m_ignorekeys = true; MythUIType *type = GetFocusWidget(); if (type && type->keyPressEvent(event)) { m_ignorekeys = false; return true; } QStringList actions; bool handled = false; handled = GetMythMainWindow()->TranslateKeyPress("Main Menu", event, actions); for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "ESCAPE" || action == "EXIT" || action == "EXITPROMPT") { bool callbacks = m_state->m_callback; bool lastScreen = (GetMythMainWindow()->GetMainStack() ->TotalScreens() == 1); QString menuaction = "UPMENU"; QString selExit = "EXITING_APP_PROMPT"; if (action == "EXIT") selExit = "EXITING_APP"; if (!m_allocedstate) handleAction(menuaction); else if (m_state->m_killable) { m_wantpop = true; if (callbacks) { QString sel = "EXITING_MENU"; m_state->m_callback(m_state->m_callbackdata, sel); } if (lastScreen) { if (callbacks) m_state->m_callback(m_state->m_callbackdata, selExit); QCoreApplication::exit(); } } else if ((action == "EXIT" || action == "EXITPROMPT" || (action == "ESCAPE" && (QCoreApplication::applicationName() == MYTH_APPNAME_MYTHTV_SETUP))) && lastScreen) { if (callbacks) m_state->m_callback(m_state->m_callbackdata, selExit); else { QCoreApplication::exit(); m_wantpop = true; } } } else if (action == "HELP") { aboutScreen(); } else if (action == "EJECT") { handleAction(action); } else handled = false; } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; m_ignorekeys = false; if (m_wantpop) m_ScreenStack->PopScreen(); return handled; }
/** \brief Handle a MythTV action for the Menus. * * \param action single action to be handled * \return true if the action is not to EXEC another program */ bool MythThemedMenu::handleAction(const QString &action, const QString &password) { MythUIMenuCallbacks *cbs = GetMythUI()->GetMenuCBs(); if (!password.isEmpty() && !checkPinCode(password)) return true; if (action.left(5) == "EXEC ") { QString rest = action.right(action.length() - 5); if (cbs && cbs->exec_program) cbs->exec_program(rest); return false; } else if (action.left(7) == "EXECTV ") { QString rest = action.right(action.length() - 7).trimmed(); if (cbs && cbs->exec_program_tv) cbs->exec_program_tv(rest); } else if (action.left(5) == "MENU ") { QString menu = action.right(action.length() - 5); MythScreenStack *stack = GetScreenStack(); MythThemedMenu *newmenu = new MythThemedMenu("", menu, stack, menu, false, m_state); if (newmenu->foundTheme()) stack->AddScreen(newmenu); else delete newmenu; } else if (action.left(6) == "UPMENU") { m_wantpop = true; } else if (action.left(12) == "CONFIGPLUGIN") { QString rest = action.right(action.length() - 13); if (cbs && cbs->configplugin) cbs->configplugin(rest); } else if (action.left(6) == "PLUGIN") { QString rest = action.right(action.length() - 7); if (cbs && cbs->plugin) cbs->plugin(rest); } else if (action.left(8) == "SHUTDOWN") { if (m_allocedstate) { m_wantpop = true; } } else if (action.left(5) == "EJECT") { if (cbs && cbs->eject) cbs->eject(); } else if (action.left(5) == "JUMP ") { QString rest = action.right(action.length() - 5); GetMythMainWindow()->JumpTo(rest, false); } else if (action.left(6) == "MEDIA ") { // the format is MEDIA HANDLER URL // TODO: allow spaces in the url QStringList list = action.simplified().split(' '); if (list.size() >= 3) GetMythMainWindow()->HandleMedia(list[1], list[2]); } else { m_selection = action; if (m_state->m_callback) m_state->m_callback(m_state->m_callbackdata, m_selection); else LOG(VB_GENERAL, LOG_ERR, "Unknown menu action: " + action); } return true; }
int MythUIType::NormX(const int x) { return GetMythMainWindow()->NormX(x); }
int MythUIType::NormY(const int y) { return GetMythMainWindow()->NormY(y); }
StartPrompterPrivate() { stk = GetMythMainWindow()->GetStack("popup stack"); }
void VideoOutputOpenGL::PrepareFrame(VideoFrame *buffer, FrameScanType t, OSD *osd) { if (!gl_context) return; OpenGLLocker ctx_lock(gl_context); if (!buffer) { buffer = vbuffers.GetScratchFrame(); if (m_deinterlacing && !IsBobDeint()) t = kScan_Interlaced; } gl_context_lock.lock(); framesPlayed = buffer->frameNumber + 1; gl_context_lock.unlock(); gl_context->BindFramebuffer(0); if (db_letterbox_colour == kLetterBoxColour_Gray25) gl_context->SetBackground(127, 127, 127, 255); else gl_context->SetBackground(0, 0, 0, 255); gl_context->ClearFramebuffer(); MythMainWindow *mwnd = GetMythMainWindow(); if (gl_context->IsShared() && mwnd && window.IsEmbedding()) { if (mwnd->GetPaintWindow()) mwnd->GetPaintWindow()->setMask(QRegion()); mwnd->draw(); } if (gl_videochain) { gl_videochain->SetVideoRect(vsz_enabled ? vsz_desired_display_rect : window.GetDisplayVideoRect(), window.GetVideoRect()); gl_videochain->PrepareFrame(buffer->top_field_first, t, m_deinterlacing, framesPlayed); } if (gl_pipchains.size()) { QMap<MythPlayer*,OpenGLVideo*>::iterator it = gl_pipchains.begin(); for (; it != gl_pipchains.end(); ++it) { if (gl_pip_ready[it.key()]) { bool active = gl_pipchain_active == *it; (*it)->PrepareFrame(buffer->top_field_first, t, m_deinterlacing, framesPlayed, active); } } } if (m_visual && gl_painter && !window.IsEmbedding()) m_visual->Draw(GetTotalOSDBounds(), gl_painter, NULL); if (osd && gl_painter && !window.IsEmbedding()) osd->DrawDirect(gl_painter, GetTotalOSDBounds().size(), true); gl_context->Flush(false); if (vbuffers.GetScratchFrame() == buffer) vbuffers.SetLastShownFrameToScratch(); }
void ChannelEditor::customEvent(QEvent *event) { if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid= dce->GetId(); int buttonnum = dce->GetResult(); if (resultid == "channelopts") { switch (buttonnum) { case 0 : edit(m_channelList->GetItemCurrent()); break; case 1 : del(); break; } } else if (resultid == "delsingle" && buttonnum == 1) { MythUIButtonListItem *item = qVariantValue<MythUIButtonListItem *>(dce->GetData()); if (!item) return; uint chanid = item->GetData().toUInt(); if (chanid && ChannelUtil::DeleteChannel(chanid)) m_channelList->RemoveItem(item); } else if (resultid == "delall" && buttonnum == 1) { bool del_all = m_sourceFilter == FILTER_ALL; bool del_nul = m_sourceFilter == FILTER_UNASSIGNED; MSqlQuery query(MSqlQuery::InitCon()); if (del_all) { query.prepare("TRUNCATE TABLE channel"); } else if (del_nul) { query.prepare("SELECT sourceid " "FROM videosource " "GROUP BY sourceid"); if (!query.exec() || !query.isActive()) { MythDB::DBError("ChannelEditor Delete Channels", query); return; } QString tmp = ""; while (query.next()) tmp += "'" + query.value(0).toString() + "',"; if (tmp.isEmpty()) { query.prepare("TRUNCATE TABLE channel"); } else { tmp = tmp.left(tmp.length() - 1); query.prepare(QString("DELETE FROM channel " "WHERE sourceid NOT IN (%1)").arg(tmp)); } } else { query.prepare("DELETE FROM channel " "WHERE sourceid = :SOURCEID"); query.bindValue(":SOURCEID", m_sourceFilter); } if (!query.exec()) MythDB::DBError("ChannelEditor Delete Channels", query); fillList(); } else if (resultid == "iconimportopt") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); ImportIconsWizard *iconwizard; QString channelname = dce->GetData().toString(); switch (buttonnum) { case 0 : // Import all icons iconwizard = new ImportIconsWizard(mainStack, false); break; case 1 : // Rescan for missing iconwizard = new ImportIconsWizard(mainStack, true); break; case 2 : // Import a single channel icon iconwizard = new ImportIconsWizard(mainStack, true, channelname); break; default: return; } if (iconwizard->Create()) { connect(iconwizard, SIGNAL(Exiting()), SLOT(fillList())); mainStack->AddScreen(iconwizard); } else delete iconwizard; } } }
bool Play() const override // VideoPlayProc { return GetMythMainWindow()->HandleMedia(m_handler, m_mrl, m_plot, m_title, m_subtitle, m_director, m_season, m_episode, m_inetref, m_length, m_year, m_id, true); }
void PlaylistEditorView::customEvent(QEvent *event) { if (event->type() == MusicPlayerEvent::MetadataChangedEvent) { // TODO: this could be more efficient reloadTree(); } else if (event->type() == MusicPlayerEvent::AlbumArtChangedEvent) { // TODO: this could be more efficient reloadTree(); } else if (event->type() == MusicPlayerEvent::TrackRemovedEvent) { updateSelectedTracks(); } else if (event->type() == MusicPlayerEvent::TrackAddedEvent) { updateSelectedTracks(); } else if (event->type() == MusicPlayerEvent::AllTracksRemovedEvent) { updateSelectedTracks(); } else if (event->type() == MusicPlayerEvent::PlaylistChangedEvent) { //TODO should just update the relevent playlist here reloadTree(); } 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 == "smartplaylistmenu") { if (GetFocusWidget() != m_playlistTree) return; MythGenericTree *node = m_playlistTree->GetCurrentNode(); if (!node) return; MusicGenericTree *mnode = dynamic_cast<MusicGenericTree*>(node); if (!mnode) return; if (resulttext == tr("New Smart Playlist")) { QString category; if (mnode->getAction() == "smartplaylistcategory") category = mnode->getString(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); SmartPlaylistEditor* editor = new SmartPlaylistEditor(mainStack); if (!editor->Create()) { delete editor; return; } editor->newSmartPlaylist(category); connect(editor, SIGNAL(smartPLChanged(const QString&, const QString&)), this, SLOT(smartPLChanged(QString, QString))); mainStack->AddScreen(editor); } else if (resulttext == tr("Remove Smart Playlist"))
static void handleMedia(MythMediaDevice *cd) { // if the music player is already playing ignore the event if (gPlayer->isPlaying()) { LOG(VB_GENERAL, LOG_NOTICE, "Got a media changed event but ignoring since " "the music player is already playing"); return; } else LOG(VB_GENERAL, LOG_NOTICE, "Got a media changed event"); // Note that we should deal with other disks that may contain music. // e.g. MEDIATYPE_MMUSIC or MEDIATYPE_MIXED if (!cd) return; if (cd->isUsable()) { QString newDevice; #ifdef Q_OS_MAC newDevice = cd->getMountPath(); #else newDevice = cd->getDevicePath(); #endif if (gCDdevice.length() && gCDdevice != newDevice) { // In the case of multiple audio CDs, clear the old stored device // so the user has to choose (via MediaMonitor::defaultCDdevice()) gCDdevice = QString::null; LOG(VB_MEDIA, LOG_INFO, "MythMusic: Forgetting existing CD"); } else { gCDdevice = newDevice; LOG(VB_MEDIA, LOG_INFO, "MythMusic: Storing CD device " + gCDdevice); } } else { gCDdevice = QString::null; return; } GetMythMainWindow()->JumpTo("Main Menu"); if (gCoreContext->GetNumSetting("AutoPlayCD", 0)) { // Empty the playlist to ensure CD is played first if (gMusicData->all_music) gMusicData->all_music->clearCDData(); if (gMusicData->all_playlists) gMusicData->all_playlists->clearCDList(); runMusicPlayback(); } else mythplugin_run(); }
bool MythUITextEdit::keyPressEvent(QKeyEvent *event) { m_lastKeyPress.restart(); QStringList actions; bool handled = false; handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions, false); Qt::KeyboardModifiers modifiers = event->modifiers(); int keynum = event->key(); if (keynum >= Qt::Key_Shift && keynum <= Qt::Key_CapsLock) return false; QString character; // Compose key handling // Enter composition mode if ((modifiers & Qt::GroupSwitchModifier) && (keynum >= Qt::Key_Dead_Grave) && (keynum <= Qt::Key_Dead_Horn)) { m_composeKey = keynum; handled = true; } else if (m_composeKey > 0) // 'Compose' the key { if (gDeadKeyMap.isEmpty()) LoadDeadKeys(gDeadKeyMap); LOG(VB_GUI, LOG_DEBUG, QString("Compose key: %1 Key: %2").arg(QString::number(m_composeKey, 16)).arg(QString::number(keynum, 16))); if (gDeadKeyMap.contains(keyCombo(m_composeKey, keynum))) { int keycode = gDeadKeyMap.value(keyCombo(m_composeKey, keynum)); //QKeyEvent key(QEvent::KeyPress, keycode, modifiers); character = QChar(keycode); if (modifiers & Qt::ShiftModifier) character = character.toUpper(); else character = character.toLower(); LOG(VB_GUI, LOG_DEBUG, QString("Found match for dead-key combo - %1").arg(character)); } m_composeKey = 0; } if (character.isEmpty()) character = event->text(); if (!handled && InsertCharacter(character)) handled = true; for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "LEFT") { MoveCursor(MoveLeft); } else if (action == "RIGHT") { MoveCursor(MoveRight); } else if (action == "DELETE") { RemoveCharacter(m_Position + 1); } else if (action == "BACKSPACE") { RemoveCharacter(m_Position); } else if (action == "SELECT" && keynum != Qt::Key_Space && GetMythDB()->GetNumSetting("UseVirtualKeyboard", 1) == 1) { MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIVirtualKeyboard *kb = new MythUIVirtualKeyboard(popupStack, this); if (kb->Create()) { //connect(kb, SIGNAL(keyPress(QString)), SLOT(keyPress(QString))); popupStack->AddScreen(kb); } else delete kb; } else if (action == "CUT") { CutTextToClipboard(); } else if (action == "COPY") { CopyTextToClipboard(); } else if (action == "PASTE") { PasteTextFromClipboard(); } else handled = false; } return handled; }
void ScanWizard::SetPage(const QString &pageTitle) { LOG(VB_CHANSCAN, LOG_INFO, QString("SetPage(%1)").arg(pageTitle)); if (pageTitle != ChannelScannerGUI::kTitle) { scannerPane->quitScanning(); return; } QMap<QString,QString> start_chan; DTVTunerType parse_type = DTVTunerType::kTunerTypeUnknown; uint cardid = configPane->GetCardID(); QString inputname = configPane->GetInputName(); uint sourceid = configPane->GetSourceID(); int scantype = configPane->GetScanType(); bool do_scan = true; LOG(VB_CHANSCAN, LOG_INFO, LOC + "SetPage(): " + QString("type(%1) cardid(%2) inputname(%3)") .arg(scantype).arg(cardid).arg(inputname)); if (scantype == ScanTypeSetting::DVBUtilsImport) { scannerPane->ImportDVBUtils(sourceid, lastHWCardType, configPane->GetFilename()); } else if (scantype == ScanTypeSetting::NITAddScan_DVBT) { start_chan = configPane->GetStartChan(); parse_type = DTVTunerType::kTunerTypeDVBT; } else if (scantype == ScanTypeSetting::NITAddScan_DVBS) { start_chan = configPane->GetStartChan(); parse_type = DTVTunerType::kTunerTypeDVBS1; } else if (scantype == ScanTypeSetting::NITAddScan_DVBS2) { start_chan = configPane->GetStartChan(); parse_type = DTVTunerType::kTunerTypeDVBS2; } else if (scantype == ScanTypeSetting::NITAddScan_DVBC) { start_chan = configPane->GetStartChan(); parse_type = DTVTunerType::kTunerTypeDVBC; } else if (scantype == ScanTypeSetting::IPTVImport) { do_scan = false; scannerPane->ImportM3U(cardid, inputname, sourceid); } else if ((scantype == ScanTypeSetting::FullScan_ATSC) || (scantype == ScanTypeSetting::FullTransportScan) || (scantype == ScanTypeSetting::TransportScan) || (scantype == ScanTypeSetting::CurrentTransportScan) || (scantype == ScanTypeSetting::FullScan_DVBC) || (scantype == ScanTypeSetting::FullScan_DVBT) || (scantype == ScanTypeSetting::FullScan_Analog)) { ; } else if (scantype == ScanTypeSetting::ExistingScanImport) { do_scan = false; uint scanid = configPane->GetScanID(); ScanDTVTransportList transports = LoadScan(scanid); ChannelImporter ci(true, true, true, true, false, configPane->DoFreeToAirOnly(), configPane->GetServiceRequirements()); ci.Process(transports); } else { do_scan = false; LOG(VB_CHANSCAN, LOG_ERR, LOC + "SetPage(): " + QString("type(%1) src(%2) cardid(%3) not handled") .arg(scantype).arg(sourceid).arg(cardid)); MythPopupBox::showOkPopup( GetMythMainWindow(), tr("ScanWizard"), tr("Programmer Error, see console")); } // Just verify what we get from the UI... DTVMultiplex tuning; if ((parse_type != DTVTunerType::kTunerTypeUnknown) && !tuning.ParseTuningParams( parse_type, start_chan["frequency"], start_chan["inversion"], start_chan["symbolrate"], start_chan["fec"], start_chan["polarity"], start_chan["coderate_hp"], start_chan["coderate_lp"], start_chan["constellation"], start_chan["trans_mode"], start_chan["guard_interval"], start_chan["hierarchy"], start_chan["modulation"], start_chan["bandwidth"], start_chan["mod_sys"], start_chan["rolloff"])) { MythPopupBox::showOkPopup( GetMythMainWindow(), tr("ScanWizard"), tr("Error parsing parameters")); do_scan = false; } if (do_scan) { QString table_start, table_end; configPane->GetFrequencyTableRange(table_start, table_end); scannerPane->Scan( configPane->GetScanType(), configPane->GetCardID(), configPane->GetInputName(), configPane->GetSourceID(), configPane->DoIgnoreSignalTimeout(), configPane->DoFollowNIT(), configPane->DoTestDecryption(), configPane->DoFreeToAirOnly(), configPane->GetServiceRequirements(), // stuff needed for particular scans configPane->GetMultiplex(), start_chan, configPane->GetFrequencyStandard(), configPane->GetModulation(), configPane->GetFrequencyTable(), table_start, table_end); } }
void MythFontProperties::SetPixelSize(float size) { QSize baseSize = GetMythUI()->GetBaseSize(); m_relativeSize = size / (float)(baseSize.height()); m_face.setPixelSize(GetMythMainWindow()->NormY((int)(size + 0.5f))); }
/** \brief Parses the element's tags and set the ThemeButton's type, * text, depends, and action, then adds the button. * * \param element DOM element describing features of the themeButton */ void MythThemedMenu::parseThemeButton(QDomElement &element) { QString type; QString text; QStringList action; QString alttext; QString description; QString password; bool addit = true; for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) { QDomElement info = child.toElement(); if (!info.isNull()) { if (info.tagName() == "type") { type = getFirstText(info); } else if (info.tagName() == "text") { if (text.isEmpty() && info.attribute("lang","").isEmpty()) { text = qApp->translate("ThemeUI", parseText(info).toUtf8(), NULL, QCoreApplication::UnicodeUTF8); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguageAndVariant()) { text = parseText(info); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguage()) { text = parseText(info); } } else if (info.tagName() == "alttext") { if (alttext.isEmpty() && info.attribute("lang","").isEmpty()) { alttext = qApp->translate("ThemeUI", parseText(info).toUtf8(), NULL, QCoreApplication::UnicodeUTF8); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguageAndVariant()) { alttext = parseText(info); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguage()) { alttext = parseText(info); } } else if (info.tagName() == "action") { action += getFirstText(info); } else if (info.tagName() == "depends") { addit = findDepends(getFirstText(info)); } else if (info.tagName() == "dependssetting") { addit = GetMythDB()->GetNumSetting(getFirstText(info)); } else if (info.tagName() == "dependjumppoint") { addit = GetMythMainWindow()->DestinationExists( getFirstText(info)); } else if (info.tagName() == "dependswindow") { QString xmlFile = info.attribute("xmlfile", ""); QString windowName = getFirstText(info); if (xmlFile.isEmpty() || windowName.isEmpty()) addit = false; else addit = XMLParseBase::WindowExists(xmlFile, windowName); } else if (info.tagName() == "description") { if (description.isEmpty() && info.attribute("lang","").isEmpty()) { description = qApp->translate("ThemeUI", getFirstText(info).toUtf8(), NULL, QCoreApplication::UnicodeUTF8); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguageAndVariant()) { description = getFirstText(info); } else if (info.attribute("lang","").toLower() == gCoreContext->GetLanguage()) { description = getFirstText(info); } } else if (info.tagName() == "password") { password = getFirstText(info); } else { LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Unknown tag %1 in button") .arg(info.tagName())); } } } if (text.isEmpty()) { LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'text' in button"); return; } if (action.empty()) { LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Missing 'action' in button"); return; } if (addit) addButton(type, text, alttext, action, description, password); }
void MythFontProperties::Rescale(void) { QRect rect = GetMythMainWindow()->GetUIScreenRect(); Rescale(rect.height()); }
void BackendConnectionManager::customEvent(QEvent *event) { bool reconnect = false; uint reconnect_timeout = 5000; if ((MythEvent::Type)(event->type()) == MythEvent::MythEventMessage) { MythEvent *me = (MythEvent *)event; QString message = me->Message(); if (message == "BACKEND_SOCKETS_CLOSED") { if (!m_reconnecting) { reconnect = true; reconnect_timeout = 500; } } else if (message == "RECONNECT_SUCCESS") { delete m_reconnecting; m_reconnecting = NULL; if (m_first_time && !checkTimeZone()) { // Check for different time zones, // different offsets, different times LOG(VB_GENERAL, LOG_ERR, "The time and/or time zone settings on this " "system do not match those in use on the master " "backend. Please ensure all frontend and backend " "systems are configured to use the same time " "zone and have the current time properly set."); LOG(VB_GENERAL, LOG_ERR, "Unable to run with invalid time settings. Exiting."); MythScreenStack *popupStack = GetMythMainWindow()-> GetStack("popup stack"); QString message = tr("Your frontend and backend are configured " "in different timezones. You must " "correct this mismatch to continue."); MythConfirmationDialog *error = new MythConfirmationDialog( popupStack, message, false); if (error->Create()) { QObject::connect(error, SIGNAL(haveResult(bool)), qApp, SLOT(quit())); popupStack->AddScreen(error); } else { delete error; delete popupStack; qApp->exit(GENERIC_EXIT_INVALID_TIMEZONE); } } m_first_time = false; } else if (message == "RECONNECT_FAILURE") { delete m_reconnecting; m_reconnecting = NULL; reconnect = true; } } if (reconnect) { if (!m_reconnect_timer) { m_reconnect_timer = new QTimer(this); m_reconnect_timer->setSingleShot(true); connect(m_reconnect_timer, SIGNAL(timeout()), this, SLOT(ReconnectToBackend())); } m_reconnect_timer->start(reconnect_timeout); } }
bool WelcomeDialog::keyPressEvent(QKeyEvent *event) { if (GetFocusWidget()->keyPressEvent(event)) return true; bool handled = false; QStringList actions; handled = GetMythMainWindow()->TranslateKeyPress("Welcome", event, actions); for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "ESCAPE") { return true; // eat escape key } else if (action == "MENU") { showMenu(); } else if (action == "NEXTVIEW") { Close(); } else if (action == "INFO") { MythWelcomeSettings settings; if (kDialogCodeAccepted == settings.exec()) { RemoteSendMessage("CLEAR_SETTINGS_CACHE"); updateStatus(); updateScreen(); m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat", "dddd\\ndd MMM yyyy"); m_dateFormat.replace("\\n", "\n"); } } else if (action == "SHOWSETTINGS") { MythShutdownSettings settings; if (kDialogCodeAccepted == settings.exec()) RemoteSendMessage("CLEAR_SETTINGS_CACHE"); } else if (action == "0") { QString mythshutdown_status = m_installDir + "/bin/mythshutdown --status 0"; QString mythshutdown_unlock = m_installDir + "/bin/mythshutdown --unlock"; QString mythshutdown_lock = m_installDir + "/bin/mythshutdown --lock"; QByteArray tmp = mythshutdown_status.toAscii(); int statusCode = system(tmp.constData()); if (WIFEXITED(statusCode)) statusCode = WEXITSTATUS(statusCode); // is shutdown locked by a user if (statusCode & 16) { myth_system(mythshutdown_unlock); } else { myth_system(mythshutdown_lock); } updateStatusMessage(); updateScreen(); } else if (action == "STARTXTERM") { QString cmd = gCoreContext->GetSetting("MythShutdownXTermCmd", ""); if (!cmd.isEmpty()) myth_system(cmd); } else if (action == "STARTSETUP") { QString mythtv_setup = m_installDir + "/bin/mythtv-setup"; myth_system(mythtv_setup); } else handled = false; } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; return handled; }
/** * \brief Creates a dialog displaying current recording status and options * available */ void ScheduleCommon::ShowNotRecordingDialog(const RecordingInfo& recinfo) { QString timeFormat = gCoreContext->GetSetting("TimeFormat", "h:mm AP"); QString message = recinfo.toString(ProgramInfo::kTitleSubtitle, " - "); message += "\n\n"; message += toDescription(recinfo.GetRecordingStatus(), recinfo.GetRecordingRuleType(), recinfo.GetRecordingStartTime()); if (recinfo.GetRecordingStatus() == rsConflict || recinfo.GetRecordingStatus() == rsLaterShowing) { vector<ProgramInfo *> *confList = RemoteGetConflictList(&recinfo); if (!confList->empty()) { message += " "; message += tr("The following programs will be recorded instead:"); message += "\n"; } uint maxi = 0; for (; confList->begin() != confList->end() && maxi < 4; maxi++) { ProgramInfo *p = *confList->begin(); message += QString("%1 - %2 %3\n") .arg(p->GetRecordingStartTime() .toLocalTime().toString(timeFormat)) .arg(p->GetRecordingEndTime() .toLocalTime().toString(timeFormat)) .arg(p->toString(ProgramInfo::kTitleSubtitle, " - ")); delete p; confList->erase(confList->begin()); } message += "\n"; while (!confList->empty()) { delete confList->back(); confList->pop_back(); } delete confList; } MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythDialogBox *menuPopup = new MythDialogBox(message, popupStack, "notRecOptionPopup", true); if (menuPopup->Create()) { menuPopup->SetReturnEvent(this, "schedulenotrecording"); QDateTime now = MythDate::current(); if ((recinfo.GetRecordingStartTime() < now) && (recinfo.GetRecordingEndTime() > now) && (recinfo.GetRecordingStatus() != rsDontRecord) && (recinfo.GetRecordingStatus() != rsNotListed)) { menuPopup->AddButton(tr("Restart recording this showing"), qVariantFromValue(recinfo)); } if (recinfo.GetRecordingEndTime() > now) { if ((recinfo.GetRecordingRuleType() != kSingleRecord && recinfo.GetRecordingRuleType() != kOverrideRecord) && (recinfo.GetRecordingStatus() == rsDontRecord || recinfo.GetRecordingStatus() == rsPreviousRecording || recinfo.GetRecordingStatus() == rsCurrentRecording || recinfo.GetRecordingStatus() == rsEarlierShowing || recinfo.GetRecordingStatus() == rsNeverRecord || recinfo.GetRecordingStatus() == rsRepeat || recinfo.GetRecordingStatus() == rsInactive || recinfo.GetRecordingStatus() == rsLaterShowing)) { menuPopup->AddButton(tr("Record this showing anyway"), qVariantFromValue(recinfo)); if (recinfo.GetRecordingStatus() == rsPreviousRecording || recinfo.GetRecordingStatus() == rsNeverRecord) { menuPopup->AddButton(tr("Forget previous recording"), qVariantFromValue(recinfo)); } } if (recinfo.GetRecordingRuleType() != kOverrideRecord && recinfo.GetRecordingRuleType() != kDontRecord) { if (recinfo.GetRecordingRuleType() != kSingleRecord && recinfo.GetRecordingStatus() != rsPreviousRecording && recinfo.GetRecordingStatus() != rsCurrentRecording && recinfo.GetRecordingStatus() != rsNeverRecord && recinfo.GetRecordingStatus() != rsNotListed) { if (recinfo.GetRecordingStartTime() > now) { menuPopup->AddButton(tr("Don't record this showing"), qVariantFromValue(recinfo)); } const RecordingDupMethodType dupmethod = recinfo.GetDuplicateCheckMethod(); if (recinfo.GetRecordingRuleType() != kOneRecord && !((recinfo.GetFindID() == 0 || !IsFindApplicable(recinfo)) && recinfo.GetCategoryType() == "series" && recinfo.GetProgramID().contains(QRegExp("0000$"))) && ((!(dupmethod & kDupCheckNone) && !recinfo.GetProgramID().isEmpty() && (recinfo.GetFindID() != 0 || !IsFindApplicable(recinfo))) || ((dupmethod & kDupCheckSub) && !recinfo.GetSubtitle().isEmpty()) || ((dupmethod & kDupCheckDesc) && !recinfo.GetDescription().isEmpty()) || ((dupmethod & kDupCheckSubThenDesc) && (!recinfo.GetSubtitle().isEmpty() || !recinfo.GetDescription().isEmpty())) )) { menuPopup->AddButton(tr("Never record this episode"), qVariantFromValue(recinfo)); } } if (recinfo.GetRecordingRuleType() != kSingleRecord && recinfo.GetRecordingRuleType() != kOneRecord && recinfo.GetRecordingStatus() != rsNotListed) { menuPopup->AddButton(tr("Override this showing with options"), qVariantFromValue(recinfo)); } menuPopup->AddButton(tr("Edit recording options"), qVariantFromValue(recinfo)); menuPopup->AddButton(tr("Delete recording rule"), qVariantFromValue(recinfo)); } if (recinfo.GetRecordingRuleType() == kOverrideRecord || recinfo.GetRecordingRuleType() == kDontRecord) { menuPopup->AddButton(tr("Edit override options"), qVariantFromValue(recinfo)); menuPopup->AddButton(tr("Delete override rule"), qVariantFromValue(recinfo)); } } popupStack->AddScreen(menuPopup); } else delete menuPopup; }
AudioTest::AudioTest(QString main, QString passthrough, int channels, AudioOutputSettings settings) : VerticalConfigurationGroup(false, true, false, false), m_frontleft(NULL), m_frontright(NULL), m_center(NULL), m_surroundleft(NULL), m_surroundright(NULL), m_rearleft(NULL), m_rearright(NULL), m_lfe(NULL), m_button(NULL), m_hd(NULL), m_main(main), m_passthrough(passthrough), m_settings(settings), m_quality(false) { m_channels = gCoreContext->GetNumSetting("TestingChannels", channels); setLabel(QObject::tr("Audio Configuration Testing")); m_at = new AudioTestThread(this, m_main, m_passthrough, m_channels, m_settings, m_quality); if (!m_at->result().isEmpty()) { QString msg = main + QObject::tr(" is invalid or not " "useable."); MythPopupBox::showOkPopup( GetMythMainWindow(), QObject::tr("Warning"), msg); return; } m_button = new TransButtonSetting("start"); m_button->setLabel(QObject::tr("Test All")); m_button->setHelpText(QObject::tr("Start all channels test")); connect(m_button, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); ConfigurationGroup *frontgroup = new HorizontalConfigurationGroup(false, false); ConfigurationGroup *middlegroup = new HorizontalConfigurationGroup(false, false); ConfigurationGroup *reargroup = new HorizontalConfigurationGroup(false, false); m_frontleft = new TransButtonSetting("0"); m_frontleft->setLabel(QObject::tr("Front Left")); connect(m_frontleft, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); m_frontright = new TransButtonSetting(m_channels == 2 ? "1" : "2"); m_frontright->setLabel(QObject::tr("Front Right")); connect(m_frontright, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); frontgroup->addChild(m_frontleft); switch(m_channels) { case 8: m_rearleft = new TransButtonSetting("5"); m_rearleft->setLabel(QObject::tr("Rear Left")); connect(m_rearleft, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); reargroup->addChild(m_rearleft); case 7: m_rearright = new TransButtonSetting("4"); m_rearright->setLabel(QObject::tr(m_channels == 8 ? "Rear Right" : "Rear Center")); connect(m_rearright, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); reargroup->addChild(m_rearright); case 6: m_lfe = new TransButtonSetting(m_channels == 6 ? "5" : m_channels == 7 ? "6" : "7"); m_lfe->setLabel(QObject::tr("LFE")); connect(m_lfe, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); case 5: m_surroundleft = new TransButtonSetting(m_channels == 6 ? "4" : m_channels == 7 ? "5" : "6"); m_surroundleft->setLabel(QObject::tr("Surround Left")); connect(m_surroundleft, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); m_surroundright = new TransButtonSetting("3"); m_surroundright->setLabel(QObject::tr("Surround Right")); connect(m_surroundright, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); m_center = new TransButtonSetting("1"); m_center->setLabel(QObject::tr("Center")); connect(m_center, SIGNAL(pressed(QString)), this, SLOT(toggle(QString))); frontgroup->addChild(m_center); middlegroup->addChild(m_surroundleft); if (m_lfe) middlegroup->addChild(m_lfe); middlegroup->addChild(m_surroundright); case 2: break; } frontgroup->addChild(m_frontright); addChild(frontgroup); addChild(middlegroup); addChild(reargroup); addChild(m_button); m_hd = new TransCheckBoxSetting(); m_hd->setLabel(QObject::tr("Use Highest Quality Mode")); m_hd->setHelpText(QObject::tr("Use the highest audio quality settings " "supported by your audio card. This will be " "a good place to start troubleshooting " "potential errors")); addChild(m_hd); connect(m_hd, SIGNAL(valueChanged(QString)), this, SLOT(togglequality())); }
/** \brief Creates a new NetEditorBase Screen * \param parent Pointer to the screen stack * \param name The name of the window */ NetEditorBase::NetEditorBase(MythScreenStack *parent, const QString &name) : MythScreenType(parent, name) { m_popupStack = GetMythMainWindow()->GetStack("popup stack"); }
/** \fn GalleryWidget::keyPressEvent(QKeyEvent *) * \brief Translates the keypresses and keys bound to the * plugin to specific actions within the plugin * \param event The pressed key * \return True if key was used, otherwise false */ bool GalleryWidget::keyPressEvent(QKeyEvent *event) { if (GetFocusWidget()->keyPressEvent(event)) return true; bool handled = false; QStringList actions; handled = GetMythMainWindow()->TranslateKeyPress("Images", event, actions); for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "LEFT") ShowPrevFile(); else if (action == "RIGHT") ShowNextFile(); else if (action == "INFO") ShowFileDetails(); else if (action == "MENU") MenuMain(); else if (action == "PLAY") { // If no slideshow is active and the user presses the play // button then start a normal slideshow. But if a slideshow // is already running then start or pause it. if (m_slideShowType == kNoSlideShow) StartNormalSlideShow(); else { if (m_timer->isActive()) PauseSlideShow(); else ResumeSlideShow(); } } else if (action == "PAUSE") PauseSlideShow(); else if (action == "STOP") StopSlideShow(); else if (action == "ROTRIGHT") { m_gvh->SetFileOrientation(kFileRotateCW); LoadFile(); } else if (action == "ROTLEFT") { m_gvh->SetFileOrientation(kFileRotateCCW); LoadFile(); } else if (action == "FLIPHORIZONTAL") { m_gvh->SetFileOrientation(kFileFlipHorizontal); LoadFile(); } else if (action == "FLIPVERTICAL") { m_gvh->SetFileOrientation(kFileFlipVertical); LoadFile(); } else if (action == "ZOOMIN") { m_gvh->SetFileZoom(kFileZoomIn); LoadFile(); } else if (action == "ZOOMOUT") { m_gvh->SetFileZoom(kFileZoomOut); LoadFile(); } else if (action == "ESCAPE") { if (m_infoVisible) HideFileDetails(); else handled = false; } } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; return handled; }
void ScreenSetup::doListSelect(MythUIButtonListItem *selected) { if (!selected) return; QString txt = selected->GetText(); if (GetFocusWidget() == m_activeList) { ScreenListInfo *si = selected->GetData().value<ScreenListInfo *>(); QString label = tr("Manipulate Screen"); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythDialogBox *menuPopup = new MythDialogBox(label, popupStack, "screensetupmenupopup"); if (menuPopup->Create()) { popupStack->AddScreen(menuPopup); menuPopup->SetReturnEvent(this, "options"); menuPopup->AddButton(tr("Move Up"), qVariantFromValue(selected)); menuPopup->AddButton(tr("Move Down"), qVariantFromValue(selected)); menuPopup->AddButton(tr("Remove"), qVariantFromValue(selected)); menuPopup->AddButton(tr("Change Location"), qVariantFromValue(selected)); if (si->hasUnits) menuPopup->AddButton(tr("Change Units"), qVariantFromValue(selected)); menuPopup->AddButton(tr("Cancel"), qVariantFromValue(selected)); } else { delete menuPopup; } } else if (GetFocusWidget() == m_inactiveList) { ScreenListInfo *si = selected->GetData().value<ScreenListInfo *>(); QStringList type_strs; TypeListMap::iterator it = si->types.begin(); TypeListMap types; for (; it != si->types.end(); ++it) { types.insert(it.key(), TypeListInfo(*it)); type_strs << it.key(); } bool hasUnits = si->hasUnits; QList<ScriptInfo *> tmp; if (m_sourceManager->findPossibleSources(type_strs, tmp)) { if (!m_inactiveList->GetCount()) { //m_inactiveList->SetActive(false); NextPrevWidgetFocus(true); } if (hasUnits) showUnitsPopup(selected->GetText(), si); else doLocationDialog(si); } else LOG(VB_GENERAL, LOG_ERR, "Screen cannot be used, not all required " "data is supplied by existing sources"); } }
static void MusicCallback(void *data, QString &selection) { (void) data; QString sel = selection.toLower(); if (sel == "music_create_playlist") startDatabaseTree(); else if (sel == "music_play") startPlayback(); else if (sel == "music_rip") { startRipper(); } else if (sel == "music_import") { startImport(); } else if (sel == "settings_scan") { runScan(); } else if (sel == "settings_general") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); GeneralSettings *gs = new GeneralSettings(mainStack, "general settings"); if (gs->Create()) mainStack->AddScreen(gs); else delete gs; } else if (sel == "settings_player") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); PlayerSettings *ps = new PlayerSettings(mainStack, "player settings"); if (ps->Create()) mainStack->AddScreen(ps); else delete ps; } else if (sel == "settings_rating") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); RatingSettings *rs = new RatingSettings(mainStack, "rating settings"); if (rs->Create()) mainStack->AddScreen(rs); else delete rs; } else if (sel == "settings_visualization") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); VisualizationSettings *vs = new VisualizationSettings(mainStack, "visualization settings"); if (vs->Create()) mainStack->AddScreen(vs); else delete vs; } else if (sel == "settings_import") { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); ImportSettings *is = new ImportSettings(mainStack, "import settings"); if (is->Create()) mainStack->AddScreen(is); else delete is; } }
static void loadMusic() { // only do this once if (gMusicData->initialized) return; MSqlQuery count_query(MSqlQuery::InitCon()); bool musicdata_exists = false; if (count_query.exec("SELECT COUNT(*) FROM music_songs;")) { if(count_query.next() && 0 != count_query.value(0).toInt()) { musicdata_exists = true; } } QString startdir = gCoreContext->GetSetting("MusicLocation"); startdir = QDir::cleanPath(startdir); if (!startdir.isEmpty() && !startdir.endsWith("/")) startdir += "/"; gMusicData->musicDir = startdir; Decoder::SetLocationFormatUseTags(); // Only search music files if a directory was specified & there // is no data in the database yet (first run). Otherwise, user // can choose "Setup" option from the menu to force it. if (!gMusicData->musicDir.isEmpty() && !musicdata_exists) { FileScanner *fscan = new FileScanner(); fscan->SearchDir(startdir); delete fscan; } MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); QString message = QObject::tr("Loading Music. Please wait ..."); MythUIBusyDialog *busy = new MythUIBusyDialog(message, popupStack, "musicscanbusydialog"); if (busy->Create()) popupStack->AddScreen(busy, false); else busy = NULL; // Set the various track formatting modes Metadata::setArtistAndTrackFormats(); AllMusic *all_music = new AllMusic(); // Load all playlists into RAM (once!) PlaylistContainer *all_playlists = new PlaylistContainer( all_music, gCoreContext->GetHostName()); gMusicData->all_playlists = all_playlists; gMusicData->all_music = all_music; gMusicData->initialized = true; while (!gMusicData->all_playlists->doneLoading() || !gMusicData->all_music->doneLoading()) { qApp->processEvents(); usleep(50000); } gMusicData->all_playlists->postLoad(); gPlayer->loadPlaylist(); if (busy) busy->Close(); }
bool MythUIHelper::IsTopScreenInitialized(void) { return GetMythMainWindow()->GetMainStack()->GetTopScreen()->IsInitialized(); }