add new NO_UPDATE_CHECK build switch
This commit is contained in:
parent
4f2f991bc4
commit
e6536a172b
4 changed files with 41 additions and 28 deletions
|
@ -20,6 +20,7 @@
|
||||||
#
|
#
|
||||||
# Variables:
|
# Variables:
|
||||||
# BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
|
# BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
|
||||||
|
# NO_UPDATE_CHECK - Disable automatic checking for new application updates.
|
||||||
# USE_WEBENGINE - if specified, then QtWebEngine module for internal web browser is used.
|
# USE_WEBENGINE - if specified, then QtWebEngine module for internal web browser is used.
|
||||||
# Otherwise simple text component is used and some features will be disabled.
|
# Otherwise simple text component is used and some features will be disabled.
|
||||||
# Default value is "false". If QtWebEngine is installed during compilation, then
|
# Default value is "false". If QtWebEngine is installed during compilation, then
|
||||||
|
@ -106,6 +107,7 @@ option(USE_WEBENGINE "Use QtWebEngine for embedded web browser" ON)
|
||||||
option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)" OFF)
|
option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)" OFF)
|
||||||
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)" OFF)
|
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)" OFF)
|
||||||
option(REVISION_FROM_GIT "Get revision using `git rev-parse`" ON)
|
option(REVISION_FROM_GIT "Get revision using `git rev-parse`" ON)
|
||||||
|
option(NO_UPDATE_CHECK "Disable automatic checking for new application updates" OFF)
|
||||||
|
|
||||||
# Import Qt libraries.
|
# Import Qt libraries.
|
||||||
set(QT6_MIN_VERSION 6.3.0)
|
set(QT6_MIN_VERSION 6.3.0)
|
||||||
|
@ -203,6 +205,10 @@ add_compile_definitions(
|
||||||
_UNICODE
|
_UNICODE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NO_UPDATE_CHECK)
|
||||||
|
add_compile_definitions(NO_UPDATE_CHECK)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Configure and copy some needed files.
|
# Configure and copy some needed files.
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
configure_file(
|
configure_file(
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="4.2.2" date="2022-04-29"/>
|
<release version="4.2.2" date="2022-05-02"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
|
|
@ -11,6 +11,10 @@ SettingsGeneral::SettingsGeneral(Settings* settings, QWidget* parent)
|
||||||
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(QSL(APP_NAME)));
|
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(QSL(APP_NAME)));
|
||||||
m_ui->m_checkForUpdatesOnStart->setText(m_ui->m_checkForUpdatesOnStart->text().arg(QSL(APP_NAME)));
|
m_ui->m_checkForUpdatesOnStart->setText(m_ui->m_checkForUpdatesOnStart->text().arg(QSL(APP_NAME)));
|
||||||
|
|
||||||
|
#if defined(NO_UPDATE_CHECK)
|
||||||
|
m_ui->m_checkForUpdatesOnStart->setVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(m_ui->m_checkAutostart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);
|
connect(m_ui->m_checkAutostart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);
|
||||||
connect(m_ui->m_checkForUpdatesOnStart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);
|
connect(m_ui->m_checkForUpdatesOnStart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +25,8 @@ SettingsGeneral::~SettingsGeneral() {
|
||||||
|
|
||||||
void SettingsGeneral::loadSettings() {
|
void SettingsGeneral::loadSettings() {
|
||||||
onBeginLoadSettings();
|
onBeginLoadSettings();
|
||||||
m_ui->m_checkForUpdatesOnStart->setChecked(settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool());
|
m_ui->m_checkForUpdatesOnStart
|
||||||
|
->setChecked(settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool());
|
||||||
|
|
||||||
// Load auto-start status.
|
// Load auto-start status.
|
||||||
const SystemFactory::AutoStartStatus autostart_status = qApp->system()->autoStartStatus();
|
const SystemFactory::AutoStartStatus autostart_status = qApp->system()->autoStartStatus();
|
||||||
|
|
|
@ -48,10 +48,9 @@ SystemFactory::AutoStartStatus SystemFactory::autoStartStatus() const {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QSettings registry_key(QSL("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
|
QSettings registry_key(QSL("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
|
||||||
QSettings::Format::NativeFormat);
|
QSettings::Format::NativeFormat);
|
||||||
const bool autostart_enabled = registry_key.value(QSL(APP_LOW_NAME),
|
const bool autostart_enabled =
|
||||||
QString()).toString().replace(QL1C('\\'),
|
registry_key.value(QSL(APP_LOW_NAME), QString()).toString().replace(QL1C('\\'), QL1C('/')) ==
|
||||||
QL1C('/')) ==
|
Application::applicationFilePath();
|
||||||
Application::applicationFilePath();
|
|
||||||
|
|
||||||
if (autostart_enabled) {
|
if (autostart_enabled) {
|
||||||
return AutoStartStatus::Enabled;
|
return AutoStartStatus::Enabled;
|
||||||
|
@ -122,12 +121,12 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QSettings registry_key(QSL("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"), QSettings::NativeFormat);
|
QSettings registry_key(QSL("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
|
||||||
|
QSettings::NativeFormat);
|
||||||
|
|
||||||
switch (new_status) {
|
switch (new_status) {
|
||||||
case AutoStartStatus::Enabled:
|
case AutoStartStatus::Enabled:
|
||||||
registry_key.setValue(QSL(APP_LOW_NAME),
|
registry_key.setValue(QSL(APP_LOW_NAME), Application::applicationFilePath().replace(QL1C('/'), QL1C('\\')));
|
||||||
Application::applicationFilePath().replace(QL1C('/'), QL1C('\\')));
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case AutoStartStatus::Disabled:
|
case AutoStartStatus::Disabled:
|
||||||
|
@ -155,7 +154,8 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString source_autostart_desktop_file = QString(APP_DESKTOP_ENTRY_PATH) + QDir::separator() + APP_DESKTOP_SOURCE_ENTRY_FILE;
|
const QString source_autostart_desktop_file =
|
||||||
|
QString(APP_DESKTOP_ENTRY_PATH) + QDir::separator() + APP_DESKTOP_SOURCE_ENTRY_FILE;
|
||||||
|
|
||||||
return QFile::copy(source_autostart_desktop_file, destination_file);
|
return QFile::copy(source_autostart_desktop_file, destination_file);
|
||||||
}
|
}
|
||||||
|
@ -204,26 +204,29 @@ void SystemFactory::checkForUpdates() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFactory::checkForUpdatesOnStartup() {
|
void SystemFactory::checkForUpdatesOnStartup() {
|
||||||
|
#if !defined(NO_UPDATE_CHECK)
|
||||||
if (qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()) {
|
if (qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()) {
|
||||||
QObject::connect(qApp->system(), &SystemFactory::updatesChecked,
|
QObject::connect(qApp->system(),
|
||||||
this, [&](const QPair<QList<UpdateInfo>, QNetworkReply::NetworkError>& updates) {
|
&SystemFactory::updatesChecked,
|
||||||
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, this, nullptr);
|
this,
|
||||||
|
[&](const QPair<QList<UpdateInfo>, QNetworkReply::NetworkError>& updates) {
|
||||||
|
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, this, nullptr);
|
||||||
|
|
||||||
if (!updates.first.isEmpty() &&
|
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NetworkError::NoError &&
|
||||||
updates.second == QNetworkReply::NetworkError::NoError &&
|
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) {
|
||||||
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) {
|
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable,
|
||||||
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, {
|
{QObject::tr("New version available"),
|
||||||
QObject::tr("New version available"),
|
QObject::tr("Click the bubble for more information."),
|
||||||
QObject::tr("Click the bubble for more information."),
|
QSystemTrayIcon::Information},
|
||||||
QSystemTrayIcon::Information }, {}, {
|
{},
|
||||||
tr("See new version info"),
|
{tr("See new version info"), [] {
|
||||||
[] {
|
FormUpdate(qApp->mainForm()).exec();
|
||||||
FormUpdate(qApp->mainForm()).exec();
|
}});
|
||||||
} });
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
qApp->system()->checkForUpdates();
|
qApp->system()->checkForUpdates();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemFactory::isVersionNewer(const QString& new_version, const QString& base_version) {
|
bool SystemFactory::isVersionNewer(const QString& new_version, const QString& base_version) {
|
||||||
|
@ -239,8 +242,7 @@ bool SystemFactory::isVersionEqualOrNewer(const QString& new_version, const QStr
|
||||||
|
|
||||||
bool SystemFactory::openFolderFile(const QString& file_path) {
|
bool SystemFactory::openFolderFile(const QString& file_path) {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
return QProcess::startDetached(QSL("explorer.exe"),
|
return QProcess::startDetached(QSL("explorer.exe"), {"/select,", QDir::toNativeSeparators(file_path)});
|
||||||
{ "/select,", QDir::toNativeSeparators(file_path) });
|
|
||||||
#else
|
#else
|
||||||
const QString folder = QDir::toNativeSeparators(QFileInfo(file_path).absoluteDir().absolutePath());
|
const QString folder = QDir::toNativeSeparators(QFileInfo(file_path).absoluteDir().absolutePath());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue