connect(updater, &OCUpdater::downloadStateChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection);
connect(_ui->restartButton, &QAbstractButton::clicked, updater, &OCUpdater::slotStartInstaller, Qt::UniqueConnection);
connect(_ui->restartButton, &QAbstractButton::clicked, qApp, &QApplication::quit, Qt::UniqueConnection);
+ connect(_ui->updateButton, &QAbstractButton::clicked, this, &GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection);
+ connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleAutoUpdateCheck);
QString status = updater->statusString();
Theme::replaceLinkColorStringBackgroundAware(status);
_ui->updateStateLabel->setText(status);
_ui->restartButton->setVisible(updater->downloadState() == OCUpdater::DownloadComplete);
+
+ _ui->updateButton->setEnabled(updater->downloadState() != OCUpdater::CheckingServer &&
+ updater->downloadState() != OCUpdater::Downloading &&
+ updater->downloadState() != OCUpdater::DownloadComplete);
+
+ _ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
} else {
// can't have those infos from sparkle currently
_ui->updatesGroupBox->setVisible(false);
}
}
+void GeneralSettings::slotUpdateCheckNow()
+{
+ OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance());
+ if (ConfigFile().skipUpdateCheck()) {
+ updater = nullptr; // don't show update info if updates are disabled
+ }
+
+ if (updater) {
+ _ui->updateButton->setEnabled(false);
+
+ updater->checkForUpdate();
+ }
+}
+
+void GeneralSettings::slotToggleAutoUpdateCheck()
+{
+ ConfigFile cfgFile;
+ bool isChecked = _ui->autoCheckForUpdatesCheckBox->isChecked();
+ cfgFile.setAutoUpdateCheck(isChecked, QString());
+}
+
void GeneralSettings::saveMiscSettings()
{
if (_currentlyLoading)
void slotToggleLaunchOnStartup(bool);
void slotToggleOptionalServerNotifications(bool);
void slotShowInExplorerNavigationPane(bool);
- void slotUpdateInfo();
void slotIgnoreFilesEditor();
void loadMiscSettings();
void slotShowLegalNotice();
+ void slotUpdateInfo();
+ void slotUpdateCheckNow();
+ void slotToggleAutoUpdateCheck();
private:
void customizeStyle();
<property name="title">
<string>Updates</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="updateStateLabel">
- <property name="text">
- <string/>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="openExternalLinks">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="restartButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&Restart && Update</string>
- </property>
- </widget>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QCheckBox" name="autoCheckForUpdatesCheckBox">
+ <property name="text">
+ <string>&Automatically check for Updates</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="updateButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&Check for Update now</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="updateStateLabel">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="restartButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&Restart && Update</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
</layout>
</widget>
<tabstop>newFolderLimitCheckBox</tabstop>
<tabstop>newFolderLimitSpinBox</tabstop>
<tabstop>crashreporterCheckBox</tabstop>
+ <tabstop>autoCheckForUpdatesCheckBox</tabstop>
+ <tabstop>updateButton</tabstop>
<tabstop>restartButton</tabstop>
</tabstops>
<resources/>
qCInfo(lcUpdater) << "Setting new update check interval " << checkInterval;
}
- // consider the skipUpdateCheck flag in the config.
- if (cfg.skipUpdateCheck()) {
+ // consider the skipUpdateCheck and !autoUpdateCheck flags in the config.
+ if (cfg.skipUpdateCheck() || !cfg.autoUpdateCheck()) {
qCInfo(lcUpdater) << "Skipping update check because of config file";
return;
}
static const char optionalServerNotificationsC[] = "optionalServerNotifications";
static const char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane";
static const char skipUpdateCheckC[] = "skipUpdateCheck";
+static const char autoUpdateCheckC[] = "autoUpdateCheck";
static const char updateCheckIntervalC[] = "updateCheckInterval";
static const char updateSegmentC[] = "updateSegment";
static const char geometryC[] = "geometry";
settings.sync();
}
+bool ConfigFile::autoUpdateCheck(const QString &connection) const
+{
+ QString con(connection);
+ if (connection.isEmpty())
+ con = defaultConnection();
+
+ QVariant fallback = getValue(QLatin1String(autoUpdateCheckC), con, true);
+ fallback = getValue(QLatin1String(autoUpdateCheckC), QString(), fallback);
+
+ QVariant value = getPolicySetting(QLatin1String(autoUpdateCheckC), fallback);
+ return value.toBool();
+}
+
+void ConfigFile::setAutoUpdateCheck(bool autoCheck, const QString &connection)
+{
+ QString con(connection);
+ if (connection.isEmpty())
+ con = defaultConnection();
+
+ QSettings settings(configFile(), QSettings::IniFormat);
+ settings.beginGroup(con);
+
+ settings.setValue(QLatin1String(autoUpdateCheckC), QVariant(autoCheck));
+ settings.sync();
+}
+
int ConfigFile::updateSegment() const
{
QSettings settings(configFile(), QSettings::IniFormat);
// how often the check about new versions runs
std::chrono::milliseconds updateCheckInterval(const QString &connection = QString()) const;
+ // skipUpdateCheck completely disables the updater and hides its UI
bool skipUpdateCheck(const QString &connection = QString()) const;
void setSkipUpdateCheck(bool, const QString &);
+ // autoUpdateCheck allows the user to make the choice in the UI
+ bool autoUpdateCheck(const QString &connection = QString()) const;
+ void setAutoUpdateCheck(bool, const QString &);
+
/** Query-parameter 'updatesegment' for the update check, value between 0 and 99.
Used to throttle down desktop release rollout in order to keep the update servers alive at peak times.
See: https://github.com/nextcloud/client_updater_server/pull/36 */