mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
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:
committed by
Mathew Sutcliffe
parent
8df2fa462f
commit
c5b4b01a90
@@ -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()
|
||||
|
||||
@@ -73,6 +73,7 @@ protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private slots:
|
||||
//! Display latest news
|
||||
void ps_displayLatestNews(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
@@ -110,9 +111,13 @@ private:
|
||||
//! Log display
|
||||
void initLogDisplay();
|
||||
|
||||
//! latest news
|
||||
//! Latest news
|
||||
//! \sa CSwiftLauncher::ps_displayLatestNews
|
||||
void loadLatestNews();
|
||||
|
||||
//! Load credits and legal info
|
||||
void loadAbout();
|
||||
|
||||
//! Start the core
|
||||
void startSwiftCore();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<item>
|
||||
<widget class="QToolBox" name="tb_Launcher">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="tabSpacing">
|
||||
<number>6</number>
|
||||
@@ -93,11 +93,11 @@
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Latest news</string>
|
||||
<string>Latest &news</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_LatestNews">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_LatestNews">
|
||||
<widget class="QTextBrowser" name="tbr_LatestNews">
|
||||
<property name="documentTitle">
|
||||
<string>Latest news</string>
|
||||
</property>
|
||||
@@ -107,6 +107,9 @@
|
||||
<property name="placeholderText">
|
||||
<string>Latest news will go here</string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -121,7 +124,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Window type</string>
|
||||
<string>&Window type</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gl_WindowType">
|
||||
<item row="1" column="1" alignment="Qt::AlignHCenter">
|
||||
@@ -186,7 +189,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Core mode</string>
|
||||
<string>&Core mode</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gl_CoreMode" columnstretch="10,14,14">
|
||||
<property name="leftMargin">
|
||||
@@ -430,7 +433,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Check for updates</string>
|
||||
<string>Check for &updates</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Updates">
|
||||
<property name="leftMargin">
|
||||
@@ -591,7 +594,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pg_CreditsLicense">
|
||||
<widget class="QWidget" name="pg_About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -601,21 +604,27 @@
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Credits and License</string>
|
||||
<string>&About (credits and license)</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Credits">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_CreditsLicense">
|
||||
<widget class="QTextBrowser" name="tbr_About">
|
||||
<property name="documentTitle">
|
||||
<string>About swift</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<html><head><meta name="qrichtext" content="1" /><title>About swift</title><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.875pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8.25pt;">Credits will go here</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user