diff --git a/src/blackgui/components/distributioninfocomponent.cpp b/src/blackgui/components/distributioninfocomponent.cpp
new file mode 100644
index 000000000..7bb38c416
--- /dev/null
+++ b/src/blackgui/components/distributioninfocomponent.cpp
@@ -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("
%2 %3");
+ ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, latestVersionStr, currentPlatform));
+ ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform));
+ }
+ }
+ }
+ } // ns
+} // ns
diff --git a/src/blackgui/components/distributioninfocomponent.h b/src/blackgui/components/distributioninfocomponent.h
new file mode 100644
index 000000000..7be2fab38
--- /dev/null
+++ b/src/blackgui/components/distributioninfocomponent.h
@@ -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
+
+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;
+ bool m_distributionsLoaded = false; //!< distribution info loaded
+ QString m_newVersionAvailable; //!< new version number if any
+ BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution
+ BlackMisc::CDataReadOnly m_distributionInfo { this, &CDistributionInfoComponent::ps_changedDistributionCache }; //!< version cache
+ BlackMisc::CSetting m_distributionSettings { this }; //!< channel/platform selected
+
+ //! Save the current settings
+ void saveSettings();
+ };
+ } // ns
+} // ns
+#endif // guard
diff --git a/src/blackgui/components/distributioninfocomponent.ui b/src/blackgui/components/distributioninfocomponent.ui
new file mode 100644
index 000000000..179458773
--- /dev/null
+++ b/src/blackgui/components/distributioninfocomponent.ui
@@ -0,0 +1,108 @@
+
+
+ CDistributionInfoComponent
+
+
+
+ 0
+ 0
+ 307
+ 90
+
+
+
+
+ 0
+ 90
+
+
+
+ Distribution info
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ This version:
+
+
+
+ -
+
+
+ -
+
+
+ Latest:
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ Channel:
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ -
+
+
+ Platform:
+
+
+
+ -
+
+
+ check again
+
+
+
+ -
+
+
+ Nothing new
+
+
+
+ -
+
+
+ URL goes here
+
+
+
+
+
+
+
+
diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp
index 875dd1a8e..b419314e8 100644
--- a/src/swiftlauncher/swiftlauncher.cpp
+++ b/src/swiftlauncher/swiftlauncher.cpp
@@ -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
#include
#include
+#include
#include
#include
#include
@@ -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("
");
- 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();
diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h
index 076c9bfb1..269a5e559 100644
--- a/src/swiftlauncher/swiftlauncher.h
+++ b/src/swiftlauncher/swiftlauncher.h
@@ -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;
QScopedPointer m_wizard;
- BlackMisc::CData m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache
- BlackMisc::CData m_setup { this }; //!< setup, i.e. last user selection
+ BlackMisc::CData 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();
diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui
index c385e8961..b5c5902a6 100644
--- a/src/swiftlauncher/swiftlauncher.ui
+++ b/src/swiftlauncher/swiftlauncher.ui
@@ -38,7 +38,7 @@
QFrame::Raised
- 1
+ 0
@@ -457,7 +457,7 @@
Software
-
+
4
@@ -470,109 +470,13 @@
4
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- You are running the latest version!
-
-
-
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- New version available
-
-
-
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- This version:
-
-
-
- -
-
-
- Latest version:
-
-
-
- -
-
-
- Channel:
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- check again
-
-
-
- -
-
-
- URL goes here
+
-
+
+
+
+ 0
+ 80
+
@@ -611,7 +515,7 @@
0
0
376
- 189
+ 199
@@ -933,6 +837,12 @@ p, li { white-space: pre-wrap; }
blackgui/components/infobarwebreadersstatussmallcomponent.h
1
+
+ BlackGui::Components::CDistributionInfoComponent
+ QFrame
+ blackgui/components/distributioninfocomponent.h
+ 1
+