mirror of
https://github.com/tnodir/fort
synced 2024-11-15 04:05:50 +00:00
UI: AboutPage: Simplify setupAutoUpdate()
This commit is contained in:
parent
d8d2f6dc65
commit
923b7558ee
@ -140,32 +140,33 @@ void AboutPage::setupNewVersionUpdate()
|
|||||||
|
|
||||||
void AboutPage::setupAutoUpdate()
|
void AboutPage::setupAutoUpdate()
|
||||||
{
|
{
|
||||||
const auto refreshAutoUpdate = [&] {
|
|
||||||
auto manager = autoUpdateManager();
|
|
||||||
|
|
||||||
const bool hasUpdate = manager->hasUpdate();
|
|
||||||
const bool isDownloaded = manager->isDownloaded();
|
|
||||||
const bool isDownloading = manager->isDownloading();
|
|
||||||
const bool isDownloadActive = (isDownloading || isDownloaded);
|
|
||||||
|
|
||||||
if (!isDownloading || isDownloaded) {
|
|
||||||
m_progressBar->setValue(
|
|
||||||
isDownloaded ? m_progressBar->maximum() : m_progressBar->minimum());
|
|
||||||
}
|
|
||||||
m_progressBar->setVisible(hasUpdate && isDownloadActive);
|
|
||||||
|
|
||||||
m_btDownload->setVisible(hasUpdate && !isDownloadActive);
|
|
||||||
m_btInstall->setVisible(hasUpdate && isDownloaded);
|
|
||||||
|
|
||||||
m_btInstall->setToolTip(isDownloaded ? manager->installerPath() : QString());
|
|
||||||
};
|
|
||||||
|
|
||||||
refreshAutoUpdate();
|
refreshAutoUpdate();
|
||||||
|
|
||||||
connect(autoUpdateManager(), &AutoUpdateManager::keepCurrentVersionChanged, this,
|
connect(autoUpdateManager(), &AutoUpdateManager::keepCurrentVersionChanged, this,
|
||||||
refreshAutoUpdate);
|
&AboutPage::refreshAutoUpdate);
|
||||||
connect(autoUpdateManager(), &AutoUpdateManager::flagsChanged, this, refreshAutoUpdate);
|
connect(autoUpdateManager(), &AutoUpdateManager::flagsChanged, this,
|
||||||
|
&AboutPage::refreshAutoUpdate);
|
||||||
|
|
||||||
connect(autoUpdateManager(), &AutoUpdateManager::bytesReceivedChanged, m_progressBar,
|
connect(autoUpdateManager(), &AutoUpdateManager::bytesReceivedChanged, m_progressBar,
|
||||||
&QProgressBar::setValue);
|
&QProgressBar::setValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutPage::refreshAutoUpdate()
|
||||||
|
{
|
||||||
|
auto manager = autoUpdateManager();
|
||||||
|
|
||||||
|
const bool hasUpdate = manager->hasUpdate();
|
||||||
|
const bool isDownloaded = manager->isDownloaded();
|
||||||
|
const bool isDownloading = manager->isDownloading();
|
||||||
|
const bool isDownloadActive = (isDownloading || isDownloaded);
|
||||||
|
|
||||||
|
if (!isDownloading || isDownloaded) {
|
||||||
|
m_progressBar->setValue(isDownloaded ? m_progressBar->maximum() : m_progressBar->minimum());
|
||||||
|
}
|
||||||
|
m_progressBar->setVisible(hasUpdate && isDownloadActive);
|
||||||
|
|
||||||
|
m_btDownload->setVisible(hasUpdate && !isDownloadActive);
|
||||||
|
m_btInstall->setVisible(hasUpdate && isDownloaded);
|
||||||
|
|
||||||
|
m_btInstall->setToolTip(isDownloaded ? manager->installerPath() : QString());
|
||||||
|
}
|
||||||
|
@ -24,6 +24,8 @@ private:
|
|||||||
void setupNewVersionUpdate();
|
void setupNewVersionUpdate();
|
||||||
void setupAutoUpdate();
|
void setupAutoUpdate();
|
||||||
|
|
||||||
|
void refreshAutoUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_keepCurrentVersion = false;
|
bool m_keepCurrentVersion = false;
|
||||||
bool m_isNewVersion = false;
|
bool m_isNewVersion = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user