예제 #1
0
void ContactWidget::sLaunchWebaddr()
{
  QUrl tmpurl(_webaddr->text());

  if (QDesktopServices::openUrl(tmpurl))
    return;

  if(tmpurl.scheme().isEmpty())
  {
    tmpurl.setScheme("http");
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  if (tmpurl.scheme() == "http" &&
      tmpurl.host().isEmpty() && ! tmpurl.path().isEmpty())
  {
    tmpurl.setHost(tmpurl.path());
    tmpurl.setPath("");
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  if (tmpurl.scheme() == "http" && ! tmpurl.host().startsWith("www."))
  {
    tmpurl.setHost("www." + tmpurl.host());
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  qWarning("%s::sLaunchWebaddr() could not open %s",
           qPrintable(objectName()), qPrintable(tmpurl.toString()));
}
예제 #2
0
void ContactCluster::openUrl(QString url)
{
  QUrl tmpurl(url);

  if (QDesktopServices::openUrl(tmpurl))
    return;

  if(tmpurl.scheme().isEmpty())
  {
    tmpurl.setScheme("http");
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  if (tmpurl.scheme() == "http" &&
      tmpurl.host().isEmpty() && ! tmpurl.path().isEmpty())
  {
    tmpurl.setHost(tmpurl.path());
    tmpurl.setPath("");
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  if (tmpurl.scheme() == "http" && ! tmpurl.host().startsWith("www."))
  {
    tmpurl.setHost("www." + tmpurl.host());
    if (QDesktopServices::openUrl(tmpurl))
      return;
  }

  qWarning("%s::openUrl(%s) could not open %s",
           qPrintable(objectName()), qPrintable(url),
           qPrintable(tmpurl.toString()));
}