mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-26 11:50:47 +00:00
Add option to disable feature for checking for a new update
(cherry picked from commit d26dd55dba066aa4884b00b55173597f49309f0d)
This commit is contained in:
@@ -38,6 +38,7 @@ GeneralConf::GeneralConf(QWidget* parent)
|
|||||||
initShowSidePanelButton();
|
initShowSidePanelButton();
|
||||||
initShowDesktopNotification();
|
initShowDesktopNotification();
|
||||||
initShowTrayIcon();
|
initShowTrayIcon();
|
||||||
|
initCheckForUpdates();
|
||||||
initAutostart();
|
initAutostart();
|
||||||
initUseJpgForClipboard();
|
initUseJpgForClipboard();
|
||||||
initSaveAfterCopy();
|
initSaveAfterCopy();
|
||||||
@@ -93,6 +94,12 @@ void GeneralConf::showTrayIconChanged(bool checked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralConf::checkForUpdatesChanged(bool checked)
|
||||||
|
{
|
||||||
|
ConfigHandler().setCheckForUpdates(checked);
|
||||||
|
Controller::getInstance()->setCheckForUpdatesEnabled(checked);
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralConf::autostartChanged(bool checked)
|
void GeneralConf::autostartChanged(bool checked)
|
||||||
{
|
{
|
||||||
ConfigHandler().setStartupLaunch(checked);
|
ConfigHandler().setStartupLaunch(checked);
|
||||||
@@ -247,6 +254,19 @@ void GeneralConf::initConfigButtons()
|
|||||||
&GeneralConf::resetConfiguration);
|
&GeneralConf::resetConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralConf::initCheckForUpdates()
|
||||||
|
{
|
||||||
|
m_checkForUpdates = new QCheckBox(tr("Automatic check for updates"), this);
|
||||||
|
m_checkForUpdates->setChecked(ConfigHandler().checkForUpdates());
|
||||||
|
m_checkForUpdates->setToolTip(tr("Automatic check for updates"));
|
||||||
|
m_layout->addWidget(m_checkForUpdates);
|
||||||
|
|
||||||
|
connect(m_checkForUpdates,
|
||||||
|
&QCheckBox::clicked,
|
||||||
|
this,
|
||||||
|
&GeneralConf::checkForUpdatesChanged);
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralConf::initAutostart()
|
void GeneralConf::initAutostart()
|
||||||
{
|
{
|
||||||
m_autostart = new QCheckBox(tr("Launch at startup"), this);
|
m_autostart = new QCheckBox(tr("Launch at startup"), this);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ private slots:
|
|||||||
void showSidePanelButtonChanged(bool checked);
|
void showSidePanelButtonChanged(bool checked);
|
||||||
void showDesktopNotificationChanged(bool checked);
|
void showDesktopNotificationChanged(bool checked);
|
||||||
void showTrayIconChanged(bool checked);
|
void showTrayIconChanged(bool checked);
|
||||||
|
void checkForUpdatesChanged(bool checked);
|
||||||
void autostartChanged(bool checked);
|
void autostartChanged(bool checked);
|
||||||
void saveAfterCopyChanged(bool checked);
|
void saveAfterCopyChanged(bool checked);
|
||||||
void changeSavePath();
|
void changeSavePath();
|
||||||
@@ -56,6 +57,7 @@ private:
|
|||||||
void initShowDesktopNotification();
|
void initShowDesktopNotification();
|
||||||
void initShowTrayIcon();
|
void initShowTrayIcon();
|
||||||
void initConfigButtons();
|
void initConfigButtons();
|
||||||
|
void initCheckForUpdates();
|
||||||
void initAutostart();
|
void initAutostart();
|
||||||
void initSaveAfterCopy();
|
void initSaveAfterCopy();
|
||||||
void initUseJpgForClipboard();
|
void initUseJpgForClipboard();
|
||||||
@@ -66,6 +68,7 @@ private:
|
|||||||
QCheckBox* m_showTray;
|
QCheckBox* m_showTray;
|
||||||
QCheckBox* m_helpMessage;
|
QCheckBox* m_helpMessage;
|
||||||
QCheckBox* m_sidePanelButton;
|
QCheckBox* m_sidePanelButton;
|
||||||
|
QCheckBox* m_checkForUpdates;
|
||||||
QCheckBox* m_autostart;
|
QCheckBox* m_autostart;
|
||||||
QPushButton* m_importButton;
|
QPushButton* m_importButton;
|
||||||
QPushButton* m_exportButton;
|
QPushButton* m_exportButton;
|
||||||
|
|||||||
@@ -135,6 +135,15 @@ void Controller::enableExports()
|
|||||||
this, &Controller::captureFailed, this, &Controller::handleCaptureFailed);
|
this, &Controller::captureFailed, this, &Controller::handleCaptureFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::setCheckForUpdatesEnabled(const bool enabled)
|
||||||
|
{
|
||||||
|
m_appUpdates->setVisible(enabled);
|
||||||
|
m_appUpdates->setEnabled(enabled);
|
||||||
|
if (enabled) {
|
||||||
|
getLatestAvailableVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::getLatestAvailableVersion()
|
void Controller::getLatestAvailableVersion()
|
||||||
{
|
{
|
||||||
// This features is required for MacOS and Windows user and for Linux users
|
// This features is required for MacOS and Windows user and for Linux users
|
||||||
@@ -149,12 +158,17 @@ void Controller::getLatestAvailableVersion()
|
|||||||
|
|
||||||
// check for updates each 24 hours
|
// check for updates each 24 hours
|
||||||
doLater(1000 * 60 * 60 * 24, this, [this]() {
|
doLater(1000 * 60 * 60 * 24, this, [this]() {
|
||||||
this->getLatestAvailableVersion();
|
if (ConfigHandler().checkForUpdates()) {
|
||||||
|
this->getLatestAvailableVersion();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::handleReplyCheckUpdates(QNetworkReply* reply)
|
void Controller::handleReplyCheckUpdates(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
|
if (!ConfigHandler().checkForUpdates()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
|
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
|
||||||
QJsonObject json = response.object();
|
QJsonObject json = response.object();
|
||||||
@@ -402,6 +416,7 @@ void Controller::enableTrayIcon()
|
|||||||
m_trayIconMenu->addAction(infoAction);
|
m_trayIconMenu->addAction(infoAction);
|
||||||
m_trayIconMenu->addSeparator();
|
m_trayIconMenu->addSeparator();
|
||||||
m_trayIconMenu->addAction(quitAction);
|
m_trayIconMenu->addAction(quitAction);
|
||||||
|
setCheckForUpdatesEnabled(ConfigHandler().checkForUpdates());
|
||||||
|
|
||||||
m_trayIcon = new QSystemTrayIcon();
|
m_trayIcon = new QSystemTrayIcon();
|
||||||
m_trayIcon->setToolTip(QStringLiteral("Flameshot"));
|
m_trayIcon->setToolTip(QStringLiteral("Flameshot"));
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ public:
|
|||||||
void enableExports();
|
void enableExports();
|
||||||
void updateRecentScreenshots();
|
void updateRecentScreenshots();
|
||||||
|
|
||||||
|
void setCheckForUpdatesEnabled(const bool enabled);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void captureTaken(uint id, QPixmap p, QRect selection);
|
void captureTaken(uint id, QPixmap p, QRect selection);
|
||||||
void captureFailed(uint id);
|
void captureFailed(uint id);
|
||||||
|
|||||||
@@ -309,6 +309,20 @@ void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen)
|
|||||||
m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen);
|
m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfigHandler::checkForUpdates()
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
if (m_settings.contains(QStringLiteral("checkForUpdates"))) {
|
||||||
|
res = m_settings.value(QStringLiteral("checkForUpdates")).toBool();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigHandler::setCheckForUpdates(const bool checkForUpdates)
|
||||||
|
{
|
||||||
|
m_settings.setValue(QStringLiteral("checkForUpdates"), checkForUpdates);
|
||||||
|
}
|
||||||
|
|
||||||
bool ConfigHandler::startupLaunchValue()
|
bool ConfigHandler::startupLaunchValue()
|
||||||
{
|
{
|
||||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ public:
|
|||||||
bool keepOpenAppLauncherValue();
|
bool keepOpenAppLauncherValue();
|
||||||
void setKeepOpenAppLauncher(const bool);
|
void setKeepOpenAppLauncher(const bool);
|
||||||
|
|
||||||
|
bool checkForUpdates();
|
||||||
|
void setCheckForUpdates(const bool);
|
||||||
|
|
||||||
bool verifyLaunchFile();
|
bool verifyLaunchFile();
|
||||||
bool startupLaunchValue();
|
bool startupLaunchValue();
|
||||||
void setStartupLaunch(const bool);
|
void setStartupLaunch(const bool);
|
||||||
|
|||||||
@@ -808,6 +808,10 @@ void CaptureWidget::initPanel()
|
|||||||
void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
||||||
const QString& appLatestUrl)
|
const QString& appLatestUrl)
|
||||||
{
|
{
|
||||||
|
if (!ConfigHandler().checkForUpdates()) {
|
||||||
|
// option check for updates disabled
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (nullptr == m_updateNotificationWidget) {
|
if (nullptr == m_updateNotificationWidget) {
|
||||||
m_updateNotificationWidget =
|
m_updateNotificationWidget =
|
||||||
new UpdateNotificationWidget(this, appLatestVersion, appLatestUrl);
|
new UpdateNotificationWidget(this, appLatestVersion, appLatestUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user