refs #609, replaced QWebEngine

This commit is contained in:
Klaus Basan
2016-03-01 19:56:17 +01:00
committed by Mathew Sutcliffe
parent 3b0267b9fe
commit 5c83c65b8f
3 changed files with 59 additions and 38 deletions

View File

@@ -26,10 +26,6 @@
#include <QShortcut>
#include <qcompilerdetection.h>
#ifndef Q_CC_MINGW
#include <QtWebEngineWidgets/QWebEngineView>
#endif
using namespace BlackGui;
using namespace BlackCore;
using namespace BlackCore::Data;
@@ -98,6 +94,16 @@ void CSwiftLauncher::mouseMoveEvent(QMouseEvent *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)
{
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
@@ -106,6 +112,11 @@ void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
void CSwiftLauncher::init()
{
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->setTextInteractionFlags(Qt::TextBrowserInteraction);
this->ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
@@ -131,22 +142,12 @@ void CSwiftLauncher::initStyleSheet()
this->setStyleSheet(s);
}
void CSwiftLauncher::displayLatestNews()
void CSwiftLauncher::loadLatestNews()
{
#ifndef Q_CC_MINGW
CFailoverUrlList newsUrls(sGui->getGlobalSetup().swiftLatestNewsUrls());
QUrl newUrl(newsUrls.obtainNextWorkingUrl());
Q_UNUSED(newUrl);
/** Qt bug
QWebEngineView *view = new QWebEngineView(this->ui->pg_LatestNews);
if (view->url() != newUrl)
{
view->load(newUrl));
}
view->show();
**/
#endif
const CUrl newsUrl(newsUrls.obtainNextWorkingUrl());
if (newsUrl.isEmpty()) { return; }
sGui->getFromNetwork(newsUrl, { this, &CSwiftLauncher::ps_displayLatestNews});
}
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->displayLatestNews();
this->loadLatestNews();
}
void CSwiftLauncher::ps_changedCache()

View File

@@ -12,14 +12,16 @@
#ifndef SWIFTLAUNCHER_H
#define SWIFTLAUNCHER_H
#include <QDialog>
#include <QScopedPointer>
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/enableforframelesswindow.h"
#include "blackgui/mainwindowaccess.h"
#include "blackcore/data/globalsetup.h"
#include "blackcore/data/updateinfo.h"
#include "blackcore/coremodeenums.h"
#include "blackcore/settings/network.h"
#include "blackgui/enableforframelesswindow.h"
#include "blackgui/overlaymessagesframe.h"
#include <QDialog>
#include <QScopedPointer>
#include <QNetworkReply>
namespace Ui { class CSwiftLauncher; }
@@ -31,7 +33,8 @@ namespace Ui { class CSwiftLauncher; }
*/
class CSwiftLauncher :
public QDialog,
public BlackGui::CEnableForFramelessWindow
public BlackGui::CEnableForFramelessWindow,
public BlackGui::IMainWindowAccess
{
Q_OBJECT
@@ -58,12 +61,15 @@ protected:
//! \copydoc QDialog::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override;
private slots:
void ps_displayLatestNews(QNetworkReply *reply);
private:
QScopedPointer<Ui::CSwiftLauncher> ui;
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache
QString m_executable;
QStringList m_executableArgs;
BlackMisc::CSetting<BlackCore::Settings::Network::DBusServerAddress> m_dbusServerAddress { this };
BlackMisc::CSetting<BlackCore::Settings::Network::DBusServerAddress> m_dbusServerAddress { this }; //!< DBus address
QString m_executable;
QStringList m_executableArgs;
//! Get core mode
BlackCore::CoreModes::CoreMode getCoreMode() const;
@@ -90,7 +96,7 @@ private:
void initLogDisplay();
//! latest news
void displayLatestNews();
void loadLatestNews();
//! Start the core
void startSwiftCore();

View File

@@ -89,13 +89,27 @@
<x>0</x>
<y>0</y>
<width>355</width>
<height>306</height>
<height>301</height>
</rect>
</property>
<attribute name="label">
<string>Latest news</string>
</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 class="QWidget" name="pg_WindowType">
<property name="geometry">
@@ -103,7 +117,7 @@
<x>0</x>
<y>0</y>
<width>355</width>
<height>306</height>
<height>301</height>
</rect>
</property>
<attribute name="label">
@@ -167,8 +181,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>355</width>
<height>306</height>
<width>341</width>
<height>309</height>
</rect>
</property>
<attribute name="label">
@@ -393,7 +407,7 @@
<x>0</x>
<y>0</y>
<width>355</width>
<height>306</height>
<height>301</height>
</rect>
</property>
<attribute name="label">
@@ -489,7 +503,7 @@
<x>0</x>
<y>0</y>
<width>355</width>
<height>306</height>
<height>301</height>
</rect>
</property>
<attribute name="label">
@@ -505,8 +519,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Credits will go here&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.875pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8.25pt;&quot;&gt;Credits will go here&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
@@ -537,7 +551,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>355</width>
<height>113</height>
<height>112</height>
</rect>
</property>
<attribute name="label">