mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
refs #609, replaced QWebEngine
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3b0267b9fe
commit
5c83c65b8f
@@ -26,10 +26,6 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <qcompilerdetection.h>
|
#include <qcompilerdetection.h>
|
||||||
|
|
||||||
#ifndef Q_CC_MINGW
|
|
||||||
#include <QtWebEngineWidgets/QWebEngineView>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackCore::Data;
|
using namespace BlackCore::Data;
|
||||||
@@ -98,6 +94,16 @@ void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
|
|||||||
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
|
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(reply);
|
||||||
|
if (nwReply->error() == QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
const QString html = nwReply->readAll().trimmed();
|
||||||
|
this->ui->te_LatestNews->setHtml(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||||
@@ -106,6 +112,11 @@ void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
|||||||
void CSwiftLauncher::init()
|
void CSwiftLauncher::init()
|
||||||
{
|
{
|
||||||
sGui->initMainApplicationWindow(this);
|
sGui->initMainApplicationWindow(this);
|
||||||
|
|
||||||
|
this->m_mwaOverlayFrame = this->ui->fr_SwiftLauncherMain;
|
||||||
|
this->m_mwaStatusBar = nullptr;
|
||||||
|
this->m_mwaLogComponent = this->ui->fr_SwiftLauncherLog;
|
||||||
|
|
||||||
this->ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText);
|
this->ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText);
|
||||||
this->ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
this->ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
this->ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
|
this->ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
|
||||||
@@ -131,22 +142,12 @@ void CSwiftLauncher::initStyleSheet()
|
|||||||
this->setStyleSheet(s);
|
this->setStyleSheet(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::displayLatestNews()
|
void CSwiftLauncher::loadLatestNews()
|
||||||
{
|
{
|
||||||
#ifndef Q_CC_MINGW
|
|
||||||
CFailoverUrlList newsUrls(sGui->getGlobalSetup().swiftLatestNewsUrls());
|
CFailoverUrlList newsUrls(sGui->getGlobalSetup().swiftLatestNewsUrls());
|
||||||
QUrl newUrl(newsUrls.obtainNextWorkingUrl());
|
const CUrl newsUrl(newsUrls.obtainNextWorkingUrl());
|
||||||
|
if (newsUrl.isEmpty()) { return; }
|
||||||
Q_UNUSED(newUrl);
|
sGui->getFromNetwork(newsUrl, { this, &CSwiftLauncher::ps_displayLatestNews});
|
||||||
/** Qt bug
|
|
||||||
QWebEngineView *view = new QWebEngineView(this->ui->pg_LatestNews);
|
|
||||||
if (view->url() != newUrl)
|
|
||||||
{
|
|
||||||
view->load(newUrl));
|
|
||||||
}
|
|
||||||
view->show();
|
|
||||||
**/
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::initDBusGui()
|
void CSwiftLauncher::initDBusGui()
|
||||||
@@ -313,7 +314,7 @@ void CSwiftLauncher::ps_loadedSetup(bool success)
|
|||||||
this->ui->lbl_NewVersionUrl->setText(hl.arg(urlStr).arg(urlStr).arg(latestVersion));
|
this->ui->lbl_NewVersionUrl->setText(hl.arg(urlStr).arg(urlStr).arg(latestVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->displayLatestNews();
|
this->loadLatestNews();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::ps_changedCache()
|
void CSwiftLauncher::ps_changedCache()
|
||||||
|
|||||||
@@ -12,14 +12,16 @@
|
|||||||
#ifndef SWIFTLAUNCHER_H
|
#ifndef SWIFTLAUNCHER_H
|
||||||
#define SWIFTLAUNCHER_H
|
#define SWIFTLAUNCHER_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include "blackgui/overlaymessagesframe.h"
|
||||||
#include <QScopedPointer>
|
#include "blackgui/enableforframelesswindow.h"
|
||||||
|
#include "blackgui/mainwindowaccess.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/updateinfo.h"
|
#include "blackcore/data/updateinfo.h"
|
||||||
#include "blackcore/coremodeenums.h"
|
#include "blackcore/coremodeenums.h"
|
||||||
#include "blackcore/settings/network.h"
|
#include "blackcore/settings/network.h"
|
||||||
#include "blackgui/enableforframelesswindow.h"
|
#include <QDialog>
|
||||||
#include "blackgui/overlaymessagesframe.h"
|
#include <QScopedPointer>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
namespace Ui { class CSwiftLauncher; }
|
namespace Ui { class CSwiftLauncher; }
|
||||||
|
|
||||||
@@ -31,7 +33,8 @@ namespace Ui { class CSwiftLauncher; }
|
|||||||
*/
|
*/
|
||||||
class CSwiftLauncher :
|
class CSwiftLauncher :
|
||||||
public QDialog,
|
public QDialog,
|
||||||
public BlackGui::CEnableForFramelessWindow
|
public BlackGui::CEnableForFramelessWindow,
|
||||||
|
public BlackGui::IMainWindowAccess
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -58,12 +61,15 @@ protected:
|
|||||||
//! \copydoc QDialog::mouseMoveEvent
|
//! \copydoc QDialog::mouseMoveEvent
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ps_displayLatestNews(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSwiftLauncher> ui;
|
QScopedPointer<Ui::CSwiftLauncher> ui;
|
||||||
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache
|
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache
|
||||||
QString m_executable;
|
BlackMisc::CSetting<BlackCore::Settings::Network::DBusServerAddress> m_dbusServerAddress { this }; //!< DBus address
|
||||||
QStringList m_executableArgs;
|
QString m_executable;
|
||||||
BlackMisc::CSetting<BlackCore::Settings::Network::DBusServerAddress> m_dbusServerAddress { this };
|
QStringList m_executableArgs;
|
||||||
|
|
||||||
//! Get core mode
|
//! Get core mode
|
||||||
BlackCore::CoreModes::CoreMode getCoreMode() const;
|
BlackCore::CoreModes::CoreMode getCoreMode() const;
|
||||||
@@ -90,7 +96,7 @@ private:
|
|||||||
void initLogDisplay();
|
void initLogDisplay();
|
||||||
|
|
||||||
//! latest news
|
//! latest news
|
||||||
void displayLatestNews();
|
void loadLatestNews();
|
||||||
|
|
||||||
//! Start the core
|
//! Start the core
|
||||||
void startSwiftCore();
|
void startSwiftCore();
|
||||||
|
|||||||
@@ -89,13 +89,27 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>355</width>
|
||||||
<height>306</height>
|
<height>301</height>
|
||||||
</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>
|
||||||
|
<widget class="QTextEdit" name="te_LatestNews">
|
||||||
|
<property name="documentTitle">
|
||||||
|
<string>Latest news</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Latest news will go here</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="pg_WindowType">
|
<widget class="QWidget" name="pg_WindowType">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@@ -103,7 +117,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>355</width>
|
||||||
<height>306</height>
|
<height>301</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -167,8 +181,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>341</width>
|
||||||
<height>306</height>
|
<height>309</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -393,7 +407,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>355</width>
|
||||||
<height>306</height>
|
<height>301</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -489,7 +503,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>355</width>
|
||||||
<height>306</height>
|
<height>301</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -505,8 +519,8 @@
|
|||||||
<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" /><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:8.25pt; 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;">Credits will go here</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>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -537,7 +551,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>355</width>
|
<width>355</width>
|
||||||
<height>113</height>
|
<height>112</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
|
|||||||
Reference in New Issue
Block a user