From a196015b73151e5f8be4f1f1a21622dabb922bf6 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 28 Sep 2017 00:10:01 +0200 Subject: [PATCH] Ref T165, using CGuiApplication::distributionInfoAvailable is redundant, the cache changed signal is enough * distribution info avaialble signal no longer needs flag * some functions can be removed --- .../components/distributioninfocomponent.cpp | 50 +++++-------------- .../components/distributioninfocomponent.h | 14 ++---- src/swiftlauncher/swiftlauncher.cpp | 11 +--- src/swiftlauncher/swiftlauncher.h | 2 +- 4 files changed, 19 insertions(+), 58 deletions(-) diff --git a/src/blackgui/components/distributioninfocomponent.cpp b/src/blackgui/components/distributioninfocomponent.cpp index 90658a467..35f2cc976 100644 --- a/src/blackgui/components/distributioninfocomponent.cpp +++ b/src/blackgui/components/distributioninfocomponent.cpp @@ -37,19 +37,10 @@ namespace BlackGui // use version signal as trigger for completion const CDistributionList distributions = m_distributionsInfo.get(); - if (!distributions.isEmpty()) - { - // we have at least cached data: - // in case CGuiApplication::distributionInfoAvailable never comes/was already sent - // 1) we do not know if we missed the signal, the server is down etc - // 2) for better user experience we display straight away, it will overridden if the signal will br received - this->ps_loadedDistributionInfo(true); - } + if (!distributions.isEmpty()) { this->changedDistributionInfo(); } - Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui"); - connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo); - connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_requestLoadOfSetup); - connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_installXSwiftBusDialog); + connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::requestLoadOfSetup); + connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::installXSwiftBusDialog); } CDistributionInfoComponent::~CDistributionInfoComponent() @@ -65,7 +56,7 @@ namespace BlackGui return (vCurrentChannelPlatform > vCurrent); } - void CDistributionInfoComponent::ps_requestLoadOfSetup() + void CDistributionInfoComponent::requestLoadOfSetup() { if (sGui && !ui->le_LatestVersion->text().isEmpty()) { @@ -78,28 +69,16 @@ namespace BlackGui } } - void CDistributionInfoComponent::ps_loadedDistributionInfo(bool success) + void CDistributionInfoComponent::changedDistributionInfo() { - if (!success) - { - ui->pb_CheckForUpdates->setToolTip(""); - CLogMessage(this).warning("Loading setup or distribution information failed"); - return; - } - - this->ps_channelChanged(); + this->channelChanged(); ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl()); // emit via digest signal m_dsDistributionAvailable.inputSignal(); } - void CDistributionInfoComponent::ps_changedDistributionCache() - { - this->ps_loadedDistributionInfo(true); - } - - void CDistributionInfoComponent::ps_installXSwiftBusDialog() + void CDistributionInfoComponent::installXSwiftBusDialog() { if (!m_installXSwiftBusDialog) { @@ -121,12 +100,7 @@ namespace BlackGui } } - void CDistributionInfoComponent::triggerInfoAvailableSignal() - { - emit this->distributionInfoAvailable(true); - } - - void CDistributionInfoComponent::ps_channelChanged() + void CDistributionInfoComponent::channelChanged() { const CDistributionList distributions(m_distributionsInfo.get()); const QStringList channels = distributions.getChannels().toList(); @@ -161,12 +135,12 @@ namespace BlackGui 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); + this->platformChanged(); + connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::channelChanged); + connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::platformChanged); } - void CDistributionInfoComponent::ps_platformChanged() + void CDistributionInfoComponent::platformChanged() { this->saveSettings(); diff --git a/src/blackgui/components/distributioninfocomponent.h b/src/blackgui/components/distributioninfocomponent.h index b078683fb..d2623cfa9 100644 --- a/src/blackgui/components/distributioninfocomponent.h +++ b/src/blackgui/components/distributioninfocomponent.h @@ -51,7 +51,7 @@ namespace BlackGui signals: //! Distribution info loaded - void distributionInfoAvailable(bool success); + void distributionInfoAvailable(); //! New platfrom or channel void selectionChanged(); @@ -61,15 +61,15 @@ namespace BlackGui QScopedPointer m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus QString m_newVersionAvailable; //!< new version number if any BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution - BlackMisc::CDataReadOnly m_distributionsInfo { this, &CDistributionInfoComponent::changedDistributionCache }; //!< version cache + BlackMisc::CDataReadOnly m_distributionsInfo { this, &CDistributionInfoComponent::changedDistributionInfo }; //!< version cache BlackMisc::CSetting m_distributionSetting { this }; //!< channel/platform selected - BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::triggerInfoAvailableSignal, 10000, 2 }; + BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::distributionInfoAvailable, 10000, 2 }; //! Load latest version void requestLoadOfSetup(); //! Loaded latest version - void loadedDistributionInfo(bool success); + void changedDistributionInfo(); //! Channel has been changed void channelChanged(); @@ -77,18 +77,12 @@ namespace BlackGui //! Platform changed void platformChanged(); - //! Cache values have been changed - void changedDistributionCache(); - //! Install XSwiftBus dialog void installXSwiftBusDialog(); //! Save the current settings void saveSettings(); - //! Trigger the CDistributionInfoComponent::distributionInfoAvailable signal - void triggerInfoAvailableSignal(); - //! Selected platform from UI or guessed platform QString getSelectedOrGuessedPlatform() const; }; diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index b66559bd4..0d2144e3a 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -145,16 +145,9 @@ void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply) } } -void CSwiftLauncher::ps_distributionInfoAvailable(bool success) +void CSwiftLauncher::ps_distributionInfoAvailable() { - if (success) - { - this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection()); - } - else - { - this->setHeaderInfo(""); - } + this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection()); this->loadLatestNews(); this->loadAbout(); } diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index ec14554e8..d434ef8ed 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -153,7 +153,7 @@ private slots: void ps_displayLatestNews(QNetworkReply *reply); //! Distribution info is available - void ps_distributionInfoAvailable(bool success); + void ps_distributionInfoAvailable(); //! Start button pressed void ps_startButtonPressed();