From 5c83c65b8f9d73d7b258b3521b51589ab68b3eef Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 1 Mar 2016 19:56:17 +0100 Subject: [PATCH] refs #609, replaced QWebEngine --- src/swiftlauncher/swiftlauncher.cpp | 39 +++++++++++++++-------------- src/swiftlauncher/swiftlauncher.h | 24 +++++++++++------- src/swiftlauncher/swiftlauncher.ui | 34 +++++++++++++++++-------- 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 0194040fc..2b65019f2 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -26,10 +26,6 @@ #include #include -#ifndef Q_CC_MINGW -#include -#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 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() diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index 495e34431..81a082d41 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -12,14 +12,16 @@ #ifndef SWIFTLAUNCHER_H #define SWIFTLAUNCHER_H -#include -#include +#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 +#include +#include 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; BlackMisc::CData m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache - QString m_executable; - QStringList m_executableArgs; - BlackMisc::CSetting m_dbusServerAddress { this }; + BlackMisc::CSetting 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(); diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index 3c16f4ac4..e9393328f 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -89,13 +89,27 @@ 0 0 355 - 306 + 301 Latest news - + + + + + Latest news + + + true + + + Latest news will go here + + + + @@ -103,7 +117,7 @@ 0 0 355 - 306 + 301 @@ -167,8 +181,8 @@ 0 0 - 355 - 306 + 341 + 309 @@ -393,7 +407,7 @@ 0 0 355 - 306 + 301 @@ -489,7 +503,7 @@ 0 0 355 - 306 + 301 @@ -505,8 +519,8 @@ <!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"> 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;"> -<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> +</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> @@ -537,7 +551,7 @@ p, li { white-space: pre-wrap; } 0 0 355 - 113 + 112