Option to disable the automatic search for updates.

This commit is contained in:
Roman Telezhynskyi 2021-11-18 14:55:15 +02:00
parent 679bb9af48
commit d61eda4a41
14 changed files with 147 additions and 16 deletions

View File

@ -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.

View File

@ -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());

View File

@ -155,6 +155,28 @@ This option will take an affect after restart.</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Update</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QCheckBox" name="checkBoxAutomaticallyCheckUpdates">
<property name="toolTip">
<string>Automatically check for updates each time the application starts</string>
</property>
<property name="text">
<string>Automatically check for updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -37,6 +37,7 @@
#include "../vmisc/vsysexits.h"
#include "../vmisc/diagnostic.h"
#include "../vmisc/qt_dispatch/qt_dispatch.h"
#include "../fervor/fvupdater.h"
#include <QMessageBox>
#include <QLoggingCategory>
@ -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();
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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;
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>544</width>
<height>648</height>
<height>636</height>
</rect>
</property>
<property name="windowTitle">
@ -25,7 +25,7 @@
<x>0</x>
<y>0</y>
<width>524</width>
<height>628</height>
<height>616</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -188,6 +188,28 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Update</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="checkBoxAutomaticallyCheckUpdates">
<property name="toolTip">
<string>Automatically check for updates each time the application starts</string>
</property>
<property name="text">
<string>Automatically check for updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -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 <QDir>
#include <QFileOpenEvent>
@ -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();
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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<QString>(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<QString>(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());

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>680</width>
<height>624</height>
<height>872</height>
</rect>
</property>
<property name="windowTitle">
@ -33,9 +33,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-27</y>
<width>624</width>
<height>765</height>
<height>838</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -293,6 +293,28 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Update</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="checkBoxAutomaticallyCheckUpdates">
<property name="toolTip">
<string>Automatically check for updates each time the application starts</string>
</property>
<property name="text">
<string>Automatically check for updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -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);

View File

@ -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)
{
drop();
}
return true;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool FvUpdater::CheckForUpdatesNotSilent()
auto FvUpdater::CheckForUpdatesNotSilent() -> bool
{
const bool success = CheckForUpdates(false);
if (m_dropOnFinnish && not success)

View File

@ -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
{

View File

@ -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);