/* * At last we have to just show the retrivied news html */ void MainWindow::showDistroNews(QString distroRSSXML, bool searchForLatestNews) { QString html; if (distroRSSXML.count() >= 200) { if (distroRSSXML.at(0)=='*') { /* If this is an updated RSS, we must warn the user! And if the main window is hidden... */ if (isHidden()) { show(); } ui->twProperties->setTabText(ctn_TABINDEX_NEWS, "** " + StrConstants::getTabNewsName() + " **"); if (m_gotoNewsTab) { ui->twProperties->setCurrentIndex(ctn_TABINDEX_NEWS); } } else { if(searchForLatestNews) { ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); } } //First, we have to parse the raw RSS XML... html = utils::parseDistroNews(); } else { if(searchForLatestNews) ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); html = distroRSSXML; } //Now that we have the html table code, let's put it into TextBrowser's News tab QTextBrowser *text = ui->twProperties->widget(ctn_TABINDEX_NEWS)->findChild<QTextBrowser*>("textBrowser"); if (text) { text->clear(); text->setHtml(html); } if (m_gotoNewsTab) { clearTabOutput(); } if (searchForLatestNews && m_gotoNewsTab) { changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS); } ui->actionGetNews->setEnabled(true); }
/* * This is the high level method that orquestrates the Distro RSS News printing in tabNews * * boolean parameter searchForLatestNews: * controls whether this method tries to connect to the remote RSS News Feed (default is true) * boolean parameter gotoNewsTab: * controls whether this method must set the mainwindow focus to NewsTab (default is true) */ void MainWindow::refreshDistroNews(bool searchForLatestNews, bool gotoNewsTab) { ui->actionGetNews->setEnabled(false); m_gotoNewsTab = gotoNewsTab; if (searchForLatestNews) { LinuxDistro distro = UnixCommand::getLinuxDistro(); if (gotoNewsTab) { clearTabOutput(); } if (gotoNewsTab && distro == ectn_VOID) { writeToTabOutput("<b>" + StrConstants::getSearchingForBSDNews().arg("Void Linux") + "</b>"); } /* * Here, we retrieve BSD's latest news without * blocking OctoPkg main interface. */ QFuture<QString> f; f = QtConcurrent::run(getLatestDistroNews); g_fwDistroNews.setFuture(f); connect(&g_fwDistroNews, SIGNAL(finished()), this, SLOT(postRefreshDistroNews())); } else { QString distroRSSXML = utils::retrieveDistroNews(searchForLatestNews); showDistroNews(distroRSSXML, false); } }
/* * This is the high level method that orquestrates the Distro RSS News printing in tabNews * * boolean parameter searchForLatestNews: * controls whether this method tries to connect to the remote RSS News Feed (default is true) * boolean parameter gotoNewsTab: * controls whether this method must set the mainwindow focus to NewsTab (default is true) */ void MainWindow::refreshDistroNews(bool searchForLatestNews, bool gotoNewsTab) { qApp->processEvents(); if (searchForLatestNews) { LinuxDistro distro = UnixCommand::getLinuxDistro(); clearTabOutput(); if (distro == ectn_ARCHLINUX || distro == ectn_ARCHBANGLINUX) { writeToTabOutputExt("<b>" + StrConstants::getSearchingForDistroNews().arg("Arch Linux") + "</b>"); } else if (distro == ectn_CHAKRA) { writeToTabOutputExt("<b>" + StrConstants::getSearchingForDistroNews().arg("Chakra") + "</b>"); } else if (distro == ectn_MANJAROLINUX) { writeToTabOutputExt("<b>" + StrConstants::getSearchingForDistroNews().arg("Manjaro Linux") + "</b>"); } qApp->processEvents(); } CPUIntensiveComputing *cic = new CPUIntensiveComputing; QString distroRSSXML = retrieveDistroNews(searchForLatestNews); delete cic; QString html; if (distroRSSXML.count() >= 200) { if (distroRSSXML.at(0)=='*') { /* If this is an updated RSS, we must warn the user! And if the main window is hidden... */ if (isHidden()) { show(); } ui->twProperties->setTabText(ctn_TABINDEX_NEWS, "** " + StrConstants::getTabNewsName() + " **"); if (gotoNewsTab) { ui->twProperties->setCurrentIndex(ctn_TABINDEX_NEWS); } } else { if(searchForLatestNews) { ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); } } //First, we have to parse the raw RSS XML... html = parseDistroNews(); } else { if(searchForLatestNews) ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); html = distroRSSXML; } //Now that we have the html table code, let's put it into TextBrowser's News tab QTextBrowser *text = ui->twProperties->widget(ctn_TABINDEX_NEWS)->findChild<QTextBrowser*>("textBrowser"); if (text) { text->clear(); text->setHtml(html); } clearTabOutput(); qApp->processEvents(); if (searchForLatestNews && gotoNewsTab) { _changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS); } }
/* * This is the high level method that orquestrates the Distro RSS News printing in tabNews * * boolean parameter searchForLatestNews: * controls whether this method tries to connect to the remote RSS News Feed (default is true) * boolean parameter gotoNewsTab: * controls whether this method must set the mainwindow focus to NewsTab (default is true) */ void MainWindow::refreshDistroNews(bool searchForLatestNews, bool gotoNewsTab) { ui->actionGetNews->setEnabled(false); m_gotoNewsTab = gotoNewsTab; if (searchForLatestNews) { LinuxDistro distro = UnixCommand::getLinuxDistro(); if (gotoNewsTab) { clearTabOutput(); } if (gotoNewsTab && (distro == ectn_ARCHLINUX || distro == ectn_ARCHBANGLINUX || distro == ectn_MOOOSLINUX)) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("Arch Linux") + "</b>"); } else if (gotoNewsTab && distro == ectn_CHAKRA) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("Chakra") + "</b>"); } else if (gotoNewsTab && distro == ectn_KAOS) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("KaOS") + "</b>"); } else if (gotoNewsTab && distro == ectn_MANJAROLINUX) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("Manjaro Linux") + "</b>"); } else if (gotoNewsTab && distro == ectn_NETRUNNER) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("Netrunner Rolling") + "</b>"); } else if (gotoNewsTab && distro == ectn_PARABOLA) { writeToTabOutput("<b>" + StrConstants::getSearchingForDistroNews().arg("Parabola GNU/Linux-libre") + "</b>"); } /* * Here, we retrieve distro's latest news without * blocking Octopi main interface. */ QFuture<QString> f; f = QtConcurrent::run(getLatestDistroNews); g_fwDistroNews.setFuture(f); connect(&g_fwDistroNews, SIGNAL(finished()), this, SLOT(postRefreshDistroNews())); } else { QString distroRSSXML = utils::retrieveDistroNews(searchForLatestNews); showDistroNews(distroRSSXML, false); } }