Пример #1
0
/*
 * 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);
}
Пример #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)
{
  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);
  }
}
Пример #3
0
//-----------------------------------------------------------------------------
QWidget* QmitkCmdLineModuleGui::getGui()
{
  if (!d->m_TopLevelWidget)
  {
    // Construct additional widgets to contain full GUI.
    QWidget *aboutBoxContainerWidget = new QWidget();

    ctkCollapsibleGroupBox *aboutBox = new ctkCollapsibleGroupBox(aboutBoxContainerWidget);
    aboutBox->setTitle("About");

    QTextBrowser *aboutBrowser = new QTextBrowser(aboutBox);
    aboutBrowser->setReadOnly(true);
    aboutBrowser->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    aboutBrowser->setOpenExternalLinks(true);
    aboutBrowser->setOpenLinks(true);

    QVBoxLayout *aboutLayout = new QVBoxLayout(aboutBox);
    aboutLayout->addWidget(aboutBrowser);

    QVBoxLayout *aboutBoxContainerWidgetLayout = new QVBoxLayout(aboutBoxContainerWidget);
    aboutBoxContainerWidgetLayout->addWidget(aboutBox);

    QWidget *helpBoxContainerWidget = new QWidget();

    ctkCollapsibleGroupBox *helpBox = new ctkCollapsibleGroupBox();
    helpBox->setTitle("Help");

    QTextBrowser *helpBrowser = new QTextBrowser(helpBox);
    helpBrowser->setReadOnly(true);
    helpBrowser->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    helpBrowser->setOpenExternalLinks(true);
    helpBrowser->setOpenLinks(true);

    QVBoxLayout *helpLayout = new QVBoxLayout(helpBox);
    helpLayout->addWidget(helpBrowser);

    QVBoxLayout *helpBoxContainerWidgetLayout = new QVBoxLayout(helpBoxContainerWidget);
    helpBoxContainerWidgetLayout->addWidget(helpBox);

    QObject* guiHandle = this->guiHandle();
    QWidget* generatedGuiWidgets = qobject_cast<QWidget*>(guiHandle);

    QWidget *topLevelWidget = new QWidget();

    QGridLayout *topLevelLayout = new QGridLayout(topLevelWidget);
    topLevelLayout->setContentsMargins(0,0,0,0);
    topLevelLayout->setSpacing(0);
    topLevelLayout->addWidget(aboutBoxContainerWidget, 0, 0);
    topLevelLayout->addWidget(helpBoxContainerWidget, 1, 0);
    topLevelLayout->addWidget(generatedGuiWidgets, 2, 0);

    ctkCmdLineModuleDescription description = this->moduleReference().description();

    QString helpString = "";

    if (!description.title().isEmpty())
    {
      QString titleHtml = "<h1>" + description.title() + "</h1>";
      helpString += titleHtml;
    }

    if (!description.description().isEmpty())
    {
      QString descriptionHtml = "<p>" + description.description() + "</p>";
      helpString += descriptionHtml;
    }

    if (!description.documentationURL().isEmpty())
    {
      QString docUrlHtml = "<p>For more information please see <a href=\"" + description.documentationURL()
          + "\">" + description.documentationURL() + "</a></p>";
      helpString += docUrlHtml;
    }

    QString aboutString = "";

    if (!description.title().isEmpty())
    {
      QString titleHtml = "<h1>" + description.title() + "</h1>";
      aboutString += titleHtml;
    }

    if (!description.contributor().isEmpty())
    {
      QString contributorHtml = "<h2>Contributed By</h2><p>" + description.contributor() + "</p>";
      aboutString += contributorHtml;
    }

    if (!description.license().isEmpty())
    {
      QString licenseHtml = "<h2>License</h2><p>" + description.license() + "</p>";
      aboutString += licenseHtml;
    }

    if (!description.acknowledgements().isEmpty())
    {
      QString acknowledgementsHtml = "<h2>Acknowledgements</h2><p>" + description.acknowledgements() + "</p>";
      aboutString += acknowledgementsHtml;
    }

    helpBrowser->clear();
    helpBrowser->setHtml(helpString);
    helpBox->setCollapsed(true);

    aboutBrowser->clear();
    aboutBrowser->setHtml(aboutString);
    aboutBox->setCollapsed(true);

    d->m_TopLevelWidget.reset(topLevelWidget);
  }

  return d->m_TopLevelWidget.data();
}