Esempio n. 1
0
/*
 * 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);
  }
}
Esempio n. 2
0
/*
 * 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);
  }
}