From d61eda4a41ee05b6607ccbe2daa2e798ea73437f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 18 Nov 2021 14:55:15 +0200 Subject: [PATCH] Option to disable the automatic search for updates. --- ChangeLog.txt | 1 + .../puzzlepreferencesconfigurationpage.cpp | 8 ++++++ .../puzzlepreferencesconfigurationpage.ui | 22 +++++++++++++++ src/app/puzzle/vpapplication.cpp | 10 +++++++ .../tapepreferencesconfigurationpage.cpp | 9 ++++++ .../tapepreferencesconfigurationpage.ui | 26 +++++++++++++++-- src/app/tape/main.cpp | 2 +- src/app/tape/mapplication.cpp | 10 +++++++ .../preferencesconfigurationpage.cpp | 10 +++++++ .../preferencesconfigurationpage.ui | 28 +++++++++++++++++-- src/app/valentina/main.cpp | 4 +-- src/libs/fervor/fvupdater.cpp | 14 ++++------ src/libs/vmisc/vcommonsettings.cpp | 16 +++++++++++ src/libs/vmisc/vcommonsettings.h | 3 ++ 14 files changed, 147 insertions(+), 16 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index bbab9f1ed..113cf9db7 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -21,6 +21,7 @@ - Fix double call of a main path context menu. - Improve storing visibility group items. Don't store duplicate information. - Remove tool from all visibility groups it in. +- Option to disable the automatic search for updates. # Valentina 0.7.49 July 1, 2021 - Fix crash. diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index 094f64011..bb5371900 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -61,6 +61,9 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget * ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); + //----------------------- Update + ui->checkBoxAutomaticallyCheckUpdates->setChecked(settings->IsAutomaticallyCheckUpdates()); + // Tab Scrolling ui->spinBoxDuration->setMinimum(VCommonSettings::scrollingDurationMin); ui->spinBoxDuration->setMaximum(VCommonSettings::scrollingDurationMax); @@ -140,6 +143,11 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked()); } + if (settings->IsAutomaticallyCheckUpdates() != ui->checkBoxAutomaticallyCheckUpdates->isChecked()) + { + settings->SetAutomaticallyCheckUpdates(ui->checkBoxAutomaticallyCheckUpdates->isChecked()); + } + // Tab Scrolling settings->SetScrollingDuration(ui->spinBoxDuration->value()); settings->SetScrollingUpdateInterval(ui->spinBoxUpdateInterval->value()); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.ui b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.ui index fd00092d3..cac143343 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.ui +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.ui @@ -155,6 +155,28 @@ This option will take an affect after restart. + + + + Update + + + + + + Automatically check for updates each time the application starts + + + Automatically check for updates + + + true + + + + + + diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index d95807f2c..cd90f96fb 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -37,6 +37,7 @@ #include "../vmisc/vsysexits.h" #include "../vmisc/diagnostic.h" #include "../vmisc/qt_dispatch/qt_dispatch.h" +#include "../fervor/fvupdater.h" #include #include @@ -565,6 +566,15 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd) void VPApplication::ProcessCMD() { ParseCommandLine(SocketConnection::Client, arguments()); + + if (IsAppInGUIMode() && Settings()->IsAutomaticallyCheckUpdates()) + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + + // Check for updates automatically + FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index 31e47d3fd..d779294ed 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -87,6 +87,10 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare //----------------------- Toolbar ui->toolBarStyleCheck->setChecked(MApplication::VApp()->TapeSettings()->GetToolBarStyle()); + + //----------------------- Update + ui->checkBoxAutomaticallyCheckUpdates->setChecked( + MApplication::VApp()->TapeSettings()->IsAutomaticallyCheckUpdates()); } //--------------------------------------------------------------------------------------------------------------------- @@ -133,6 +137,11 @@ QStringList TapePreferencesConfigurationPage::Apply() MApplication::VApp()->RetranslateGroups(); } + if (settings->IsAutomaticallyCheckUpdates() != ui->checkBoxAutomaticallyCheckUpdates->isChecked()) + { + settings->SetAutomaticallyCheckUpdates(ui->checkBoxAutomaticallyCheckUpdates->isChecked()); + } + return preferences; } diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui index 659ca5168..8747455c0 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui @@ -7,7 +7,7 @@ 0 0 544 - 648 + 636 @@ -25,7 +25,7 @@ 0 0 524 - 628 + 616 @@ -188,6 +188,28 @@ + + + + Update + + + + + + Automatically check for updates each time the application starts + + + Automatically check for updates + + + true + + + + + + diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index b836d341d..f60bee8af 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) #endif //Q_OS_MAC MApplication app(argc, argv); - app.InitOptions(); + app.InitOptions(); QTimer::singleShot(0, &app, &MApplication::ProcessCMD); diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index a365383e9..5fdf9e0d4 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -39,6 +39,7 @@ #include "../vmisc/qt_dispatch/qt_dispatch.h" #include "../qmuparser/qmuparsererror.h" #include "../vpatterndb/variables/vmeasurement.h" +#include "../fervor/fvupdater.h" #include #include @@ -871,6 +872,15 @@ TMainWindow *MApplication::NewMainWindow() void MApplication::ProcessCMD() { ParseCommandLine(SocketConnection::Client, arguments()); + + if (IsAppInGUIMode() && Settings()->IsAutomaticallyCheckUpdates()) + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + + // Check for updates automatically + FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index cbd1c2d47..3998bddc5 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -136,6 +136,9 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) // Native dialogs ui->checkBoxDontUseNativeDialog->setChecked(settings->IsDontUseNativeDialog()); + //----------------------- Update + ui->checkBoxAutomaticallyCheckUpdates->setChecked(settings->IsAutomaticallyCheckUpdates()); + // Tab Scrolling ui->spinBoxDuration->setMinimum(VCommonSettings::scrollingDurationMin); ui->spinBoxDuration->setMaximum(VCommonSettings::scrollingDurationMax); @@ -212,6 +215,7 @@ QStringList PreferencesConfigurationPage::Apply() VAbstractApplication::VApp()->LoadTranslation(locale); } + if (m_unitChanged) { const auto unit = qvariant_cast(ui->unitCombo->currentData()); @@ -219,6 +223,7 @@ QStringList PreferencesConfigurationPage::Apply() m_unitChanged = false; preferences.append(tr("default unit")); } + if (m_labelLangChanged) { const auto locale = qvariant_cast(ui->labelCombo->currentData()); @@ -226,6 +231,11 @@ QStringList PreferencesConfigurationPage::Apply() m_labelLangChanged = false; } + if (settings->IsAutomaticallyCheckUpdates() != ui->checkBoxAutomaticallyCheckUpdates->isChecked()) + { + settings->SetAutomaticallyCheckUpdates(ui->checkBoxAutomaticallyCheckUpdates->isChecked()); + } + // Tab Scrolling settings->SetScrollingDuration(ui->spinBoxDuration->value()); settings->SetScrollingUpdateInterval(ui->spinBoxUpdateInterval->value()); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui index 17f6b00c3..6eff5d3d6 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui @@ -7,7 +7,7 @@ 0 0 680 - 624 + 872 @@ -33,9 +33,9 @@ 0 - 0 + -27 624 - 765 + 838 @@ -293,6 +293,28 @@ + + + + Update + + + + + + Automatically check for updates each time the application starts + + + Automatically check for updates + + + true + + + + + + diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index be6d5d33f..323d220b7 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) VApplication app(argc, argv); app.InitOptions(); - if (VApplication::IsGUIMode()) + if (VApplication::IsGUIMode() && VAbstractApplication::VApp()->Settings()->IsAutomaticallyCheckUpdates()) { // Set feed URL before doing anything else FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) MainWindow w; #if !defined(Q_OS_MAC) - app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); + VApplication::setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); #endif // !defined(Q_OS_MAC) app.setMainWindow(&w); diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index f4efe04f4..1771db164 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -284,7 +284,7 @@ bool FvUpdater::CheckForUpdates(bool silentAsMuchAsItCouldGet) } //--------------------------------------------------------------------------------------------------------------------- -bool FvUpdater::CheckForUpdatesSilent() +auto FvUpdater::CheckForUpdatesSilent() -> bool { if (VAbstractApplication::VApp()->Settings()->GetDateOfLastRemind().daysTo(QDate::currentDate()) >= 1) { @@ -295,18 +295,16 @@ bool FvUpdater::CheckForUpdatesSilent() } return success; } - else + + if (m_dropOnFinnish) { - if (m_dropOnFinnish) - { - drop(); - } - return true; + drop(); } + return true; } //--------------------------------------------------------------------------------------------------------------------- -bool FvUpdater::CheckForUpdatesNotSilent() +auto FvUpdater::CheckForUpdatesNotSilent() -> bool { const bool success = CheckForUpdates(false); if (m_dropOnFinnish && not success) diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index a293912c0..f7298a756 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -121,6 +121,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QL Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, (QLatin1String("finalMeasurementsDialogSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) @@ -821,6 +822,21 @@ void VCommonSettings::SetFinalMeasurementsDialogSize(const QSize &sz) setValue(*settingFinalMeasurementsDialogSize, sz); } +//--------------------------------------------------------------------------------------------------------------------- +bool VCommonSettings::IsAutomaticallyCheckUpdates() const +{ + QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); + return settings.value(*settingAutomaticallyCheckUpdates, true).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::SetAutomaticallyCheckUpdates(bool value) +{ + QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); + settings.setValue(*settingAutomaticallyCheckUpdates, value); + settings.sync(); +} + //--------------------------------------------------------------------------------------------------------------------- unsigned VCommonSettings::GetLatestSkippedVersion() const { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 902599ea5..d9853e589 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -157,6 +157,9 @@ public: QSize GetFinalMeasurementsDialogSize() const; void SetFinalMeasurementsDialogSize(const QSize& sz); + bool IsAutomaticallyCheckUpdates() const; + void SetAutomaticallyCheckUpdates(bool value); + unsigned GetLatestSkippedVersion() const; void SetLatestSkippedVersion(unsigned value);