mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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
173
src/blackgui/components/distributioninfocomponent.cpp
Normal file
173
src/blackgui/components/distributioninfocomponent.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "distributioninfocomponent.h"
|
||||
#include "ui_distributioninfocomponent.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackCore::Application;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Db;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CDistributionInfoComponent::CDistributionInfoComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CDistributionInfoComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText);
|
||||
ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
|
||||
|
||||
// use version signal as trigger for completion
|
||||
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
|
||||
QTimer::singleShot(10 * 1000, this, [ = ]
|
||||
{
|
||||
// use has time out failover with cache data
|
||||
if (m_distributionsLoaded) { return; }
|
||||
this->ps_loadedDistributionInfo(true); // failover
|
||||
});
|
||||
|
||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_loadSetup);
|
||||
}
|
||||
|
||||
CDistributionInfoComponent::~CDistributionInfoComponent()
|
||||
{ }
|
||||
|
||||
void CDistributionInfoComponent::ps_loadSetup()
|
||||
{
|
||||
if (!ui->le_LatestVersion->text().isEmpty())
|
||||
{
|
||||
ui->le_LatestVersion->setText("");
|
||||
const CStatusMessageList msgs(sApp->requestReloadOfSetupAndVersion());
|
||||
CLogMessage::preformatted(msgs);
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_loadedDistributionInfo(bool success)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
CLogMessage(this).warning("Loading setup or distribution information failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_distributionsLoaded = true;
|
||||
this->ps_channelChanged();
|
||||
|
||||
// emit only after all has been set
|
||||
emit this->distributionInfoAvailable(success);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_changedDistributionCache()
|
||||
{
|
||||
this->ps_loadedDistributionInfo(true);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::saveSettings()
|
||||
{
|
||||
const QString channel = ui->cb_Channels->currentText();
|
||||
const QString currentPlatform = ui->cb_Platforms->currentText();
|
||||
const QStringList settings({ channel, currentPlatform });
|
||||
const CStatusMessage m = this->m_distributionSettings.setAndSave(settings);
|
||||
if (m.isFailure())
|
||||
{
|
||||
CLogMessage(this).preformatted(m);
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_channelChanged()
|
||||
{
|
||||
const CDistributionList distributions(m_distributionInfo.get());
|
||||
const QStringList channels = distributions.getChannels();
|
||||
const QStringList settings = m_distributionSettings.get();
|
||||
|
||||
// default value
|
||||
QString channel = ui->cb_Channels->currentText();
|
||||
if (channel.isEmpty()) { channel = settings.front(); }
|
||||
if (channel.isEmpty() && !channels.isEmpty()) { channel = channels.front(); }
|
||||
|
||||
// channels
|
||||
ui->cb_Channels->disconnect();
|
||||
ui->cb_Platforms->disconnect();
|
||||
ui->cb_Channels->clear();
|
||||
ui->cb_Channels->insertItems(0, channels);
|
||||
if (!channel.isEmpty()) { ui->cb_Channels->setCurrentText(channel); }
|
||||
|
||||
// current distribution
|
||||
const CDistribution currentDistribution = distributions.findByChannelOrDefault(channel);
|
||||
const QStringList platforms = currentDistribution.getPlatforms();
|
||||
m_currentDistribution = currentDistribution;
|
||||
ui->le_CurrentVersion->setText(CBuildConfig::getVersionString());
|
||||
|
||||
// platforms
|
||||
QString platform = ui->cb_Platforms->currentText();
|
||||
if (platform.isEmpty()) { platform = settings.last(); }
|
||||
if (platform.isEmpty()) { platform = currentDistribution.guessPlatform(); }
|
||||
|
||||
ui->cb_Platforms->clear();
|
||||
ui->cb_Platforms->insertItems(0, platforms);
|
||||
if (!platform.isEmpty()) { ui->cb_Platforms->setCurrentText(platform); }
|
||||
|
||||
// platform dependent stuff
|
||||
this->ps_platformChanged();
|
||||
connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_channelChanged);
|
||||
connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_platformChanged);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_platformChanged()
|
||||
{
|
||||
this->saveSettings();
|
||||
|
||||
// defaults
|
||||
ui->le_LatestVersion->clear();
|
||||
ui->lbl_NewVersionInfo->setText("Nothing new");
|
||||
ui->lbl_NewVersionInfo->setStyleSheet("background-color: green");
|
||||
ui->lbl_NewVersionUrl->clear();
|
||||
this->m_newVersionAvailable.clear();
|
||||
|
||||
const QString currentPlatform = ui->cb_Platforms->currentText();
|
||||
if (!currentPlatform.isEmpty())
|
||||
{
|
||||
const QVersionNumber latestVersion = m_currentDistribution.getQVersion(currentPlatform);
|
||||
const QString latestVersionStr = m_currentDistribution.getVersionString(currentPlatform);
|
||||
ui->le_LatestVersion->setText(latestVersionStr);
|
||||
ui->le_LatestVersion->setToolTip("");
|
||||
|
||||
CFailoverUrlList downloadUrls(m_currentDistribution.getDownloadUrls());
|
||||
const CUrl downloadUrl(downloadUrls.obtainNextUrl());
|
||||
const bool newer = CBuildConfig::getVersion() < latestVersion;
|
||||
if (newer)
|
||||
{
|
||||
ui->lbl_NewVersionInfo->setText("New version!");
|
||||
ui->lbl_NewVersionInfo->setToolTip("New version '" + latestVersionStr + "'");
|
||||
ui->lbl_NewVersionInfo->setStyleSheet("background-color: red");
|
||||
this->m_newVersionAvailable = latestVersionStr;
|
||||
}
|
||||
|
||||
if (!downloadUrl.isEmpty())
|
||||
{
|
||||
const QString urlStr(downloadUrl.toQString());
|
||||
const QString hl("<a href=\"%1\"><img src=\":/own/icons/own/drophere16.png\"></a> %2 %3");
|
||||
ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, latestVersionStr, currentPlatform));
|
||||
ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
75
src/blackgui/components/distributioninfocomponent.h
Normal file
75
src/blackgui/components/distributioninfocomponent.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_DISTRIBUTIONINFOCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_DISTRIBUTIONINFOCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CDistributionInfoComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Update info (distributions etc.)
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDistributionInfoComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CDistributionInfoComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CDistributionInfoComponent();
|
||||
|
||||
//! Is there a new version available return version, else empty string
|
||||
QString getNewVersionAvailable() const { return m_newVersionAvailable; }
|
||||
|
||||
signals:
|
||||
//! Distribution info loaded
|
||||
void distributionInfoAvailable(bool success);
|
||||
|
||||
private slots:
|
||||
//! Load latest version
|
||||
void ps_loadSetup();
|
||||
|
||||
//! Loaded latest version
|
||||
void ps_loadedDistributionInfo(bool success);
|
||||
|
||||
//! Channel has been changed
|
||||
void ps_channelChanged();
|
||||
|
||||
//! Platform changed
|
||||
void ps_platformChanged();
|
||||
|
||||
//! Cache values have been changed
|
||||
void ps_changedDistributionCache();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDistributionInfoComponent> ui;
|
||||
bool m_distributionsLoaded = false; //!< distribution info loaded
|
||||
QString m_newVersionAvailable; //!< new version number if any
|
||||
BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Db::TDistributionInfo> m_distributionInfo { this, &CDistributionInfoComponent::ps_changedDistributionCache }; //!< version cache
|
||||
BlackMisc::CSetting<BlackMisc::Db::TDistributionSetting> m_distributionSettings { this }; //!< channel/platform selected
|
||||
|
||||
//! Save the current settings
|
||||
void saveSettings();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
108
src/blackgui/components/distributioninfocomponent.ui
Normal file
108
src/blackgui/components/distributioninfocomponent.ui
Normal file
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDistributionInfoComponent</class>
|
||||
<widget class="QFrame" name="CDistributionInfoComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>307</width>
|
||||
<height>90</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>90</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Distribution info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_DistributionInfo">
|
||||
<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 row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_CurrentVersion">
|
||||
<property name="text">
|
||||
<string>This version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="cb_Platforms"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_LatestVersion">
|
||||
<property name="text">
|
||||
<string>Latest:</string>
|
||||
</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="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="1" column="1">
|
||||
<widget class="QComboBox" name="cb_Channels"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_Platforms">
|
||||
<property name="text">
|
||||
<string>Platform:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="pb_CheckForUpdates">
|
||||
<property name="text">
|
||||
<string>check again</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_NewVersionInfo">
|
||||
<property name="text">
|
||||
<string>Nothing new</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lbl_NewVersionUrl">
|
||||
<property name="text">
|
||||
<string>URL goes here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -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