void Weather::setupPage() { m_srcMan->stopTimers(); m_nextpage_Timer->stop(); m_srcMan->clearSources(); m_srcMan->findScripts(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); ScreenSetup *ssetup = new ScreenSetup(mainStack, "weatherscreensetup", m_srcMan); connect(ssetup, SIGNAL(Exiting()), this, SLOT(setupScreens())); if (ssetup->Create()) { clearScreens(); mainStack->AddScreen(ssetup); } else { delete ssetup; } m_firstRun = true; }
static void WeatherCallback(void *data, QString &selection) { (void) data; MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); if (selection == "SETTINGS_GENERAL") { GlobalSetup *gsetup = new GlobalSetup(mainStack, "weatherglobalsetup"); if (gsetup->Create()) mainStack->AddScreen(gsetup); else delete gsetup; } else if (selection == "SETTINGS_SCREEN") { ScreenSetup *ssetup = new ScreenSetup(mainStack, "weatherscreensetup", srcMan); if (ssetup->Create()) mainStack->AddScreen(ssetup); else delete ssetup; } else if (selection == "SETTINGS_SOURCE") { SourceSetup *srcsetup = new SourceSetup(mainStack, "weathersourcesetup"); if (srcsetup->Create()) mainStack->AddScreen(srcsetup); else delete srcsetup; } }
bool Weather::SetupScreens() { // Delete any existing screens clearScreens(); m_paused = false; m_pauseText->Hide(); // Refresh sources m_srcMan->clearSources(); m_srcMan->findScriptsDB(); m_srcMan->setupSources(); MSqlQuery db(MSqlQuery::InitCon()); QString query = "SELECT screen_id, container, units, draworder FROM weatherscreens " " WHERE hostname = :HOST ORDER BY draworder;"; db.prepare(query); db.bindValue(":HOST", gCoreContext->GetHostName()); if (!db.exec()) { MythDB::DBError("Selecting weather screens.", db); return false; } if (!db.size()) { if (m_firstSetup) { // If no screens exist, run the setup MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); ScreenSetup *ssetup = new ScreenSetup(mainStack, "weatherscreensetup", m_srcMan); connect(ssetup, SIGNAL(Exiting()), this, SLOT(setupScreens())); if (ssetup->Create()) { mainStack->AddScreen(ssetup); } else { delete ssetup; } m_firstSetup = false; } else { Close(); } } else { while (db.next()) { int id = db.value(0).toInt(); QString container = db.value(1).toString(); units_t units = db.value(2).toUInt(); uint draworder = db.value(3).toUInt(); ScreenListInfo &screenListInfo = m_allScreens[container]; WeatherScreen *ws = WeatherScreen::loadScreen(m_weatherStack, &screenListInfo, id); if (!ws->Create()) { delete ws; continue; } ws->setUnits(units); ws->setInUse(true); m_screens.insert(draworder, ws); connect(ws, SIGNAL(screenReady(WeatherScreen *)), this, SLOT(screenReady(WeatherScreen *))); m_srcMan->connectScreen(id, ws); } if( m_screens.empty() ) { // We rejected every screen... sit on this and rotate. LOG(VB_GENERAL, LOG_ERR, "No weather screens left, aborting."); m_nextpage_Timer->stop(); if( m_updatedText ) { m_updatedText->SetText(tr("None of the configured screens are complete in this theme (missing copyright information).")); m_updatedText->Show(); return true; } return false; } m_srcMan->startTimers(); m_srcMan->doUpdate(true); } return true; }