6 #include <QDesktopServices>
9 #include "ui_updateinfocomponent.h"
20 using namespace swift::config;
21 using namespace swift::core::application;
23 using namespace swift::misc::db;
24 using namespace swift::misc::network;
31 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Need sGui");
43 if (!m_updateInfo.
get().isEmpty()) { this->changedUpdateInfo(); }
51 const CPlatform p = this->getSelectedOrDefaultPlatform();
52 const CDistribution d = this->getSelectedOrDefaultDistribution();
61 Q_ASSERT_X(settings.
size() == 2, Q_FUNC_INFO,
"wrong setting");
63 if (channel.
isEmpty()) {
return false; }
70 if (vCurrentChannelPlatform.
isNull()) {
return false; }
71 return (vCurrentChannelPlatform > vCurrent);
78 if (!myself) {
return; }
79 ui->pb_DownloadInstaller->click();
83 void CUpdateInfoComponent::requestLoadOfSetup()
89 void CUpdateInfoComponent::changedUpdateInfo()
91 ui->lbl_CurrentVersionDisplay->setText(CBuildConfig::getVersionString());
95 Q_ASSERT_X(settings.
size() == 2, Q_FUNC_INFO,
"Settings");
97 const CPlatformSet platforms = updateInfo.getArtifactsPilotClient().getPlatforms();
98 CDistributionList distributions = updateInfo.getArtifactsPilotClient().getDistributions();
102 ui->cb_Platforms->disconnect();
103 ui->cb_Platforms->clear();
104 for (
const CPlatform &platform : platforms)
106 ui->cb_Platforms->insertItem(i++,
CIcon(platform.toIcon()).
toPixmap(), platform.getPlatformName());
108 if (platforms.contains(settings.
last())) { ui->cb_Platforms->setCurrentText(settings.
last()); }
109 else if (platforms.contains(CPlatform::currentPlatform().getPlatformName()))
111 ui->cb_Platforms->setCurrentText(CPlatform::currentPlatform().getPlatformName());
115 ui->cb_Channels->disconnect();
116 ui->cb_Channels->clear();
119 ui->cb_Channels->insertItem(i++,
CIcon(distribution.getRestrictionIcon()).
toPixmap(),
120 distribution.getChannel());
122 if (distributions.containsChannel(settings.
front())) { ui->cb_Channels->setCurrentText(settings.
front()); }
124 this->uiSelectionChanged();
134 void CUpdateInfoComponent::downloadXSwiftBusDialog()
136 const QString currentXsb = ui->cb_ArtifactsXsb->currentText();
137 const QString currentSwift = ui->cb_ArtifactsPilotClient->currentText();
141 const QString msg = QStringLiteral(
"xswiftbus '%1' does NOT match swift version, download anyway?")
142 .
arg(currentXsb, currentSwift);
148 if (!m_installXSwiftBusDialog)
150 m_installXSwiftBusDialog.reset(
new CInstallXSwiftBusDialog(
this));
151 m_installXSwiftBusDialog->setModal(
true);
154 m_installXSwiftBusDialog->setDefaultDownloadName(currentXsb);
155 m_installXSwiftBusDialog->show();
158 void CUpdateInfoComponent::downloadInstallerDialog()
161 const QString currentVersion = ui->cb_ArtifactsPilotClient->currentText();
162 const QString platform = ui->cb_Platforms->currentText();
163 if (!CPlatform::isCurrentPlatform(platform))
167 QStringLiteral(
"The platform '%1' does not match your current platform '%2'.\n"
168 "Do you want to continue?")
169 .arg(platform, CPlatform::currentPlatform().getPlatformName()),
176 update.getArtifactsPilotClient().findByMatchingPlatform(platform).findFirstByVersionOrDefault(
179 if (!m_downloadDialog)
181 m_downloadDialog.reset(
new CDownloadDialog(
this));
182 m_downloadDialog->setModal(
true);
189 m_downloadDialog->setMode(CDownloadComponent::SwiftInstaller);
190 m_downloadDialog->setDownloadFile(artifact.
asRemoteFile());
191 m_downloadDialog->showAndStartDownloading();
195 void CUpdateInfoComponent::saveSettings()
204 void CUpdateInfoComponent::channelChanged() { this->uiSelectionChanged(); }
206 void CUpdateInfoComponent::platformChanged() { this->uiSelectionChanged(); }
208 void CUpdateInfoComponent::uiSelectionChanged()
210 const CDistribution selectedDistribution(this->getSelectedOrDefaultDistribution());
211 const CPlatform selectedPlatform(this->getSelectedOrDefaultPlatform());
216 selectedDistribution, selectedPlatform,
true);
219 selectedDistribution, selectedPlatform,
true);
223 ui->cb_ArtifactsPilotClient->clear();
224 ui->cb_ArtifactsPilotClient->insertItems(0, sortedPilotClientVersions);
225 ui->pb_DownloadInstaller->setEnabled(!artifactsPilotClient.
isEmpty());
228 ui->cb_ArtifactsXsb->clear();
229 ui->cb_ArtifactsXsb->insertItems(0, sortedXsbVersions);
230 ui->pb_DownloadXSwiftBus->setEnabled(!artifactsXsb.
isEmpty());
233 this->saveSettings();
237 ui->lbl_StatusInfo->setText(newer ?
"New version available" :
"Nothing new");
238 ui->lbl_StatusInfo->setStyleSheet(newer ?
"background-color: green; color: white;" :
239 "background-color: red; color: white;");
246 const CPlatform &CUpdateInfoComponent::getSelectedOrDefaultPlatform()
const
249 QString p = ui->cb_Platforms->currentText();
251 if (p.
isEmpty()) { p = CPlatform::currentPlatform().getPlatformName(); }
252 return CPlatform::stringToPlatformObject(p);
255 CDistribution CUpdateInfoComponent::getSelectedOrDefaultDistribution()
const
258 QString c = ui->cb_Channels->currentText();
261 return c.
isEmpty() ? updateInfo.getDistributions().getMostStableOrDefault() :
262 updateInfo.getDistributions().findFirstByChannelOrDefault(c);
void updateInfoAvailable(bool success)
Update info available (cache, web load)
bool isShuttingDown() const
Is application shutting down?
void reloadUpdateInfo()
Reload update info.
Update info (distributions, artifacts etc.)
void selectionChanged()
New platfrom or channel.
bool isNewPilotClientVersionAvailable() const
Is there a new version available?
swift::misc::db::CArtifact getLatestAvailablePilotClientArtifactForSelection() const
Is there a new version available return version, else empty string.
void triggerDownload()
Trigger download.
void newerPilotClientAvailable(const swift::misc::db::CArtifact &latestPilotClient)
A newer pilot client is available.
virtual ~CUpdateInfoComponent()
Dtor.
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
T get() const
Get a copy of the current value.
void inputSignal()
Received input signal, or manually trigger.
Value object for icons. An icon is stored in the global icon repository and identified by its index....
QPixmap toPixmap() const
Corresponding pixmap.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
Artifacts ("our software" products)
network::CRemoteFile asRemoteFile() const
Turn into remote file.
CArtifactList findByDistribution(const CDistribution &distribution, bool findMoreStableDistribution=false) const
Find by distribution.
CArtifactList findByDistributionAndPlatform(const CDistribution &distribution, const CPlatform &platform, bool findMoreStableDistributions=false) const
Find by distribution and platform.
QVersionNumber getLatestQVersion() const
Latest version.
CArtifact getLatestArtifactOrDefault() const
Latest (newest) artifact.
CArtifactList findWithUnrestrictedDistributions() const
Find artifacts with public (unrestricted) distributions.
QStringList getSortedVersions() const
All unique versions.
Distributions for channel.
const QString & getChannel() const
Version channel (Alpha, Beta, Stable ..)
Multiple distributions for different channels:
CDistribution findFirstByChannelOrDefault(const QString &channel) const
Find by channel.
void sortByStability(Qt::SortOrder order=Qt::AscendingOrder)
Stability.
Update info, i.e. artifacts and distributions.
const CDistributionList & getDistributions() const
Distributions (all)
const CArtifactList & getArtifactsPilotClient() const
Artifacts (pilot client)
bool isLoadedFromDb() const
Loaded from DB.
const CUrl & getUrl() const
Get URL.
bool isHavingHtmlSuffix() const
Likely a HTM file?
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
void currentTextChanged(const QString &text)
bool openUrl(const QUrl &url)
QList< T >::reference front()
qsizetype size() const const
QMessageBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool isEmpty() const const
bool isNull() const const