mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #921, moved distribution info UI into an own component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
cbf69d9847
commit
83a80bf739
@@ -15,8 +15,8 @@
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackcore/context/contextapplicationproxy.h"
|
||||
#include "blackcore/setupreader.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QBitmap>
|
||||
#include <QTimer>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopServices>
|
||||
#include <QShortcut>
|
||||
@@ -33,7 +34,6 @@ using namespace BlackConfig;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Components;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Application;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackCore::Data;
|
||||
using namespace BlackMisc;
|
||||
@@ -47,7 +47,6 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->init();
|
||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CSwiftLauncher::ps_loadSetup);
|
||||
connect(ui->tb_SwiftCore, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed);
|
||||
connect(ui->tb_SwiftMappingTool, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed);
|
||||
connect(ui->tb_SwiftGui, &QPushButton::pressed, this, &CSwiftLauncher::ps_startButtonPressed);
|
||||
@@ -55,14 +54,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
|
||||
connect(ui->tb_BackToMain, &QToolButton::pressed, this, &CSwiftLauncher::ps_showMainPage);
|
||||
connect(ui->tb_ConfigurationWizard, &QToolButton::pressed, this, &CSwiftLauncher::ps_startWizard);
|
||||
connect(ui->tb_Launcher, &QToolBox::currentChanged, this, &CSwiftLauncher::ps_tabChanged);
|
||||
|
||||
// use version signal as trigger for completion
|
||||
connect(sGui, &CApplication::updateInfoAvailable, this, &CSwiftLauncher::ps_loadedUpdateInfo);
|
||||
QTimer::singleShot(10 * 1000, this, [ = ]
|
||||
{
|
||||
if (m_updateInfoLoaded) { return; }
|
||||
this->ps_loadedUpdateInfo(true); // failover
|
||||
});
|
||||
connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::distributionInfoAvailable, this, &CSwiftLauncher::ps_distributionInfoAvailable);
|
||||
|
||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(ps_showLogPage()));
|
||||
ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this));
|
||||
@@ -138,6 +130,20 @@ void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply)
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_distributionInfoAvailable(bool success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
this->setHeaderInfo(ui->comp_DistributionInfo->getNewVersionAvailable());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setHeaderInfo("");
|
||||
}
|
||||
this->loadLatestNews();
|
||||
this->loadAbout();
|
||||
}
|
||||
|
||||
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||
@@ -151,17 +157,9 @@ void CSwiftLauncher::init()
|
||||
m_mwaStatusBar = nullptr;
|
||||
m_mwaLogComponent = ui->comp_SwiftLauncherLog;
|
||||
|
||||
ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText);
|
||||
ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
|
||||
|
||||
ui->wi_NewVersionAvailable->setVisible(false);
|
||||
ui->wi_NoNewVersion->setVisible(true);
|
||||
|
||||
this->initStyleSheet();
|
||||
this->initLogDisplay();
|
||||
this->initDBusGui();
|
||||
this->initVersion();
|
||||
|
||||
ui->lbl_HeaderInfo->setVisible(false);
|
||||
ui->sw_SwiftLauncher->setCurrentWidget(ui->pg_SwiftLauncherMain);
|
||||
@@ -195,6 +193,7 @@ void CSwiftLauncher::loadAbout()
|
||||
// 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(QLatin1String("href=\"./"), "href=\"" + legalDir);
|
||||
@@ -212,17 +211,12 @@ void CSwiftLauncher::initDBusGui()
|
||||
connect(ui->rb_DBusSystem, &QRadioButton::clicked, this, &CSwiftLauncher::ps_dbusServerModeSelected);
|
||||
|
||||
// normally no system Bus on Windows
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::isShippedVersion())
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::isStableBranch())
|
||||
{
|
||||
ui->rb_DBusSystem->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftLauncher::initVersion()
|
||||
{
|
||||
ui->le_CurrentVersion->setText(sGui->versionStringDevBetaInfo());
|
||||
}
|
||||
|
||||
void CSwiftLauncher::initLogDisplay()
|
||||
{
|
||||
CLogHandler::instance()->install(true);
|
||||
@@ -236,6 +230,16 @@ void CSwiftLauncher::initLogDisplay()
|
||||
ui->comp_SwiftLauncherLog->filterUseRadioButtonDescriptiveIcons(false);
|
||||
}
|
||||
|
||||
void CSwiftLauncher::setHeaderInfo(const QString &newVersionAvailable)
|
||||
{
|
||||
ui->lbl_HeaderInfo->setVisible(!newVersionAvailable.isEmpty());
|
||||
if (!newVersionAvailable.isEmpty())
|
||||
{
|
||||
ui->lbl_HeaderInfo->setText("New version '" + newVersionAvailable + "' available");
|
||||
ui->lbl_HeaderInfo->setStyleSheet("background: red; color: yellow;");
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftLauncher::startSwiftCore()
|
||||
{
|
||||
this->saveSetup();
|
||||
@@ -394,55 +398,6 @@ QString CSwiftLauncher::toCmdLine(const QString &exe, const QStringList &exeArgs
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_loadSetup()
|
||||
{
|
||||
if (!ui->le_LatestVersion->text().isEmpty())
|
||||
{
|
||||
ui->le_LatestVersion->setText("");
|
||||
const CStatusMessageList msgs(sApp->requestReloadOfSetupAndVersion());
|
||||
this->ps_appendLogMessages(msgs);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_loadedUpdateInfo(bool success)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
CLogMessage(this).warning("Loading setup or version information failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_updateInfoLoaded = true;
|
||||
const CUpdateInfo updateInfo(m_updateInfo.get());
|
||||
const QString latestVersion(updateInfo.getLatestVersion()) ; // need to get this from somewhere
|
||||
CFailoverUrlList downloadUrls(updateInfo.getDownloadUrls());
|
||||
const bool newVersionAvailable = CVersion::isNewerVersion(latestVersion) && !downloadUrls.isEmpty();
|
||||
ui->wi_NewVersionAvailable->setVisible(newVersionAvailable);
|
||||
ui->wi_NoNewVersion->setVisible(!newVersionAvailable);
|
||||
ui->le_LatestVersion->setText(latestVersion);
|
||||
ui->le_Channel->setText(updateInfo.getChannel());
|
||||
ui->lbl_HeaderInfo->setVisible(newVersionAvailable);
|
||||
ui->lbl_HeaderInfo->setText("New version " + latestVersion + " available");
|
||||
ui->lbl_HeaderInfo->setStyleSheet("background: red; color: yellow;");
|
||||
|
||||
if (!downloadUrls.isEmpty())
|
||||
{
|
||||
const CUrl downloadUrl(downloadUrls.obtainNextUrl());
|
||||
const QString urlStr(downloadUrl.toQString());
|
||||
const QString hl("<a href=\"%1\"><img src=\":/own/icons/own/drophere16.png\"></a>");
|
||||
ui->lbl_NewVersionUrl->setText(hl.arg(urlStr));
|
||||
ui->lbl_NewVersionUrl->setToolTip("Download " + latestVersion);
|
||||
}
|
||||
|
||||
this->loadLatestNews();
|
||||
this->loadAbout();
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_changedUpdateInfoCache()
|
||||
{
|
||||
this->ps_loadedUpdateInfo(true);
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_startButtonPressed()
|
||||
{
|
||||
QObject *sender = QObject::sender();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackgui/enableforframelesswindow.h"
|
||||
#include "blackgui/mainwindowaccess.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackcore/data/updateinfo.h"
|
||||
#include "blackcore/data/launchersetup.h"
|
||||
#include "blackcore/coremodeenums.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
@@ -78,15 +77,14 @@ protected:
|
||||
private:
|
||||
QScopedPointer<Ui::CSwiftLauncher> ui;
|
||||
QScopedPointer<BlackGui::Components::CConfigurationWizard> m_wizard;
|
||||
BlackMisc::CData<BlackCore::Data::TUpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache
|
||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_setup { this }; //!< setup, i.e. last user selection
|
||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_setup { this }; //!< setup, i.e. last user selection
|
||||
|
||||
QString m_executable;
|
||||
QStringList m_executableArgs;
|
||||
QTimer m_checkTimer { this };
|
||||
int m_startCoreWaitCycles = 0;
|
||||
int m_startMappingToolWaitCycles = 0;
|
||||
int m_startGuiWaitCycles = 0;
|
||||
bool m_updateInfoLoaded = false;
|
||||
|
||||
//! Get core mode
|
||||
BlackCore::CoreModes::CoreMode getCoreMode() const;
|
||||
@@ -106,12 +104,12 @@ private:
|
||||
//! combobox for DBus
|
||||
void initDBusGui();
|
||||
|
||||
//! Version string
|
||||
void initVersion();
|
||||
|
||||
//! Log display
|
||||
void initLogDisplay();
|
||||
|
||||
//! Set header info
|
||||
void setHeaderInfo(const QString &newVersionAvailable);
|
||||
|
||||
//! Latest news
|
||||
//! \sa CSwiftLauncher::ps_displayLatestNews
|
||||
void loadLatestNews();
|
||||
@@ -147,17 +145,11 @@ private:
|
||||
static QString toCmdLine(const QString &exe, const QStringList &exeArgs);
|
||||
|
||||
private slots:
|
||||
//! Load latest version
|
||||
void ps_loadSetup();
|
||||
|
||||
//! Loaded latest version
|
||||
void ps_loadedUpdateInfo(bool success);
|
||||
|
||||
//! Display latest news
|
||||
void ps_displayLatestNews(QNetworkReply *reply);
|
||||
|
||||
//! Cache values have been changed
|
||||
void ps_changedUpdateInfoCache();
|
||||
//! Distribution info is available
|
||||
void ps_distributionInfoAvailable(bool success);
|
||||
|
||||
//! Start button pressed
|
||||
void ps_startButtonPressed();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_SwiftLauncherMain">
|
||||
<layout class="QVBoxLayout" name="wl_SwiftLauncherMainPage">
|
||||
@@ -457,7 +457,7 @@
|
||||
<property name="title">
|
||||
<string>Software</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Version">
|
||||
<layout class="QVBoxLayout" name="vl_Software">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
@@ -470,109 +470,13 @@
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QWidget" name="wi_NoNewVersion" native="true">
|
||||
<layout class="QVBoxLayout" name="vl_NoNewVersion">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_NoNewVersion">
|
||||
<property name="text">
|
||||
<string>You are running the latest version!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QWidget" name="wi_NewVersionAvailable" native="true">
|
||||
<layout class="QVBoxLayout" name="vl_NewVersionAvailable">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_NewVersion">
|
||||
<property name="text">
|
||||
<string>New version available</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_Channel">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_CurrentVersion">
|
||||
<property name="text">
|
||||
<string>This version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_LatestVersion">
|
||||
<property name="text">
|
||||
<string>Latest version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Channel">
|
||||
<property name="text">
|
||||
<string>Channel:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_CurrentVersion">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_LatestVersion">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pb_CheckForUpdates">
|
||||
<property name="text">
|
||||
<string>check again</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="lbl_NewVersionUrl">
|
||||
<property name="text">
|
||||
<string>URL goes here</string>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -611,7 +515,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>376</width>
|
||||
<height>189</height>
|
||||
<height>199</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_DataUpdatesScrollArea">
|
||||
@@ -933,6 +837,12 @@ p, li { white-space: pre-wrap; }
|
||||
<header>blackgui/components/infobarwebreadersstatussmallcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDistributionInfoComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/distributioninfocomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../blackmisc/blackmisc.qrc"/>
|
||||
|
||||
Reference in New Issue
Block a user