refs #883, display of news/about

* use QTextBrowser, external links will be opened in browser
* display about in credits tabs
* added shortcuts for tabs

Remark: Gives us a first (not perfect) version of news/about in launcher
This commit is contained in:
Klaus Basan
2017-02-15 23:43:16 +01:00
committed by Mathew Sutcliffe
parent 8df2fa462f
commit c5b4b01a90
3 changed files with 40 additions and 12 deletions

View File

@@ -116,7 +116,7 @@ void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply)
{
const QString html = nwReply->readAll().trimmed();
if (html.isEmpty()) { return; }
ui->te_LatestNews->setHtml(html);
ui->tbr_LatestNews->setHtml(html);
constexpr qint64 newNews = 72 * 3600 * 1000;
const qint64 deltaT = CNetworkUtils::lastModifiedSinceNow(nwReply.data());
if (deltaT > 0 && deltaT < newNews)
@@ -175,6 +175,19 @@ void CSwiftLauncher::loadLatestNews()
sGui->getFromNetwork(newsUrl, { this, &CSwiftLauncher::ps_displayLatestNews});
}
void CSwiftLauncher::loadAbout()
{
// workaround:
// 1) Only reading as HTML gives proper formatting
// 2) Reading the file resource fails (likely because of the style sheet)
static const QString html = CFileUtils::readFileToString(CBuildConfig::getAboutFileLocation());
static const QString legalDir = sGui->getGlobalSetup().getLegalDirectoryUrl().getFullUrl();
// make links absolute
static const QString htmlFixed = QString(html).
replace(QLatin1Literal("href=\"./"), "href=\"" + legalDir);
ui->tbr_About->setHtml(htmlFixed);
}
void CSwiftLauncher::initDBusGui()
{
ui->cb_DBusServerAddress->addItem("127.0.0.1");
@@ -348,6 +361,7 @@ void CSwiftLauncher::ps_loadedUpdateInfo(bool success)
}
this->loadLatestNews();
this->loadAbout();
}
void CSwiftLauncher::ps_changedUpdateInfoCache()