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();
|
const QString html = nwReply->readAll().trimmed();
|
||||||
if (html.isEmpty()) { return; }
|
if (html.isEmpty()) { return; }
|
||||||
ui->te_LatestNews->setHtml(html);
|
ui->tbr_LatestNews->setHtml(html);
|
||||||
constexpr qint64 newNews = 72 * 3600 * 1000;
|
constexpr qint64 newNews = 72 * 3600 * 1000;
|
||||||
const qint64 deltaT = CNetworkUtils::lastModifiedSinceNow(nwReply.data());
|
const qint64 deltaT = CNetworkUtils::lastModifiedSinceNow(nwReply.data());
|
||||||
if (deltaT > 0 && deltaT < newNews)
|
if (deltaT > 0 && deltaT < newNews)
|
||||||
@@ -175,6 +175,19 @@ void CSwiftLauncher::loadLatestNews()
|
|||||||
sGui->getFromNetwork(newsUrl, { this, &CSwiftLauncher::ps_displayLatestNews});
|
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()
|
void CSwiftLauncher::initDBusGui()
|
||||||
{
|
{
|
||||||
ui->cb_DBusServerAddress->addItem("127.0.0.1");
|
ui->cb_DBusServerAddress->addItem("127.0.0.1");
|
||||||
@@ -348,6 +361,7 @@ void CSwiftLauncher::ps_loadedUpdateInfo(bool success)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->loadLatestNews();
|
this->loadLatestNews();
|
||||||
|
this->loadAbout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::ps_changedUpdateInfoCache()
|
void CSwiftLauncher::ps_changedUpdateInfoCache()
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ protected:
|
|||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
//! Display latest news
|
||||||
void ps_displayLatestNews(QNetworkReply *reply);
|
void ps_displayLatestNews(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -110,9 +111,13 @@ private:
|
|||||||
//! Log display
|
//! Log display
|
||||||
void initLogDisplay();
|
void initLogDisplay();
|
||||||
|
|
||||||
//! latest news
|
//! Latest news
|
||||||
|
//! \sa CSwiftLauncher::ps_displayLatestNews
|
||||||
void loadLatestNews();
|
void loadLatestNews();
|
||||||
|
|
||||||
|
//! Load credits and legal info
|
||||||
|
void loadAbout();
|
||||||
|
|
||||||
//! Start the core
|
//! Start the core
|
||||||
void startSwiftCore();
|
void startSwiftCore();
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QToolBox" name="tb_Launcher">
|
<widget class="QToolBox" name="tb_Launcher">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="tabSpacing">
|
<property name="tabSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
@@ -93,11 +93,11 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Latest news</string>
|
<string>Latest &news</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="vl_LatestNews">
|
<layout class="QVBoxLayout" name="vl_LatestNews">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="te_LatestNews">
|
<widget class="QTextBrowser" name="tbr_LatestNews">
|
||||||
<property name="documentTitle">
|
<property name="documentTitle">
|
||||||
<string>Latest news</string>
|
<string>Latest news</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -107,6 +107,9 @@
|
|||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Latest news will go here</string>
|
<string>Latest news will go here</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -121,7 +124,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Window type</string>
|
<string>&Window type</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gl_WindowType">
|
<layout class="QGridLayout" name="gl_WindowType">
|
||||||
<item row="1" column="1" alignment="Qt::AlignHCenter">
|
<item row="1" column="1" alignment="Qt::AlignHCenter">
|
||||||
@@ -186,7 +189,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Core mode</string>
|
<string>&Core mode</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gl_CoreMode" columnstretch="10,14,14">
|
<layout class="QGridLayout" name="gl_CoreMode" columnstretch="10,14,14">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
@@ -430,7 +433,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Check for updates</string>
|
<string>Check for &updates</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="vl_Updates">
|
<layout class="QVBoxLayout" name="vl_Updates">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
@@ -591,7 +594,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="pg_CreditsLicense">
|
<widget class="QWidget" name="pg_About">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@@ -601,21 +604,27 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Credits and License</string>
|
<string>&About (credits and license)</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="vl_Credits">
|
<layout class="QVBoxLayout" name="vl_Credits">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="te_CreditsLicense">
|
<widget class="QTextBrowser" name="tbr_About">
|
||||||
|
<property name="documentTitle">
|
||||||
|
<string>About swift</string>
|
||||||
|
</property>
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="html">
|
<property name="html">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<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; }
|
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;">
|
</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>
|
<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>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user