mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
add cmake option DISABLE_UPDATE_CHECKER (#2793)
* add cmake option DISABLE_UPDATE_CHECKER * add cmake option DISABLE_UPDATE_CHECKER to compile out updatechecker * format code use `clang-format -i $(git ls-files "*.cpp" "*.h")` * fallback wrong code format * replace `add_definitions` with `add_compile_definitions`
This commit is contained in:
@@ -68,6 +68,10 @@ option(GENERATE_TS "Regenerate translation source files" OFF)
|
||||
option(USE_EXTERNAL_SINGLEAPPLICATION "Use external QtSingleApplication library" OFF)
|
||||
option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" ON)
|
||||
option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF)
|
||||
option(DISABLE_UPDATE_CHECKER "Disable check for updates" OFF)
|
||||
if (DISABLE_UPDATE_CHECKER)
|
||||
add_compile_definitions(DISABLE_UPDATE_CHECKER)
|
||||
endif ()
|
||||
|
||||
include(cmake/StandardProjectSettings.cmake)
|
||||
|
||||
|
||||
@@ -38,7 +38,9 @@ GeneralConf::GeneralConf(QWidget* parent)
|
||||
#endif
|
||||
initShowTrayIcon();
|
||||
initShowDesktopNotification();
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
initCheckForUpdates();
|
||||
#endif
|
||||
initShowStartupLaunchMessage();
|
||||
initAllowMultipleGuiInstances();
|
||||
initSaveLastRegion();
|
||||
@@ -82,7 +84,9 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
|
||||
m_uploadWithoutConfirmation->setChecked(config.uploadWithoutConfirmation());
|
||||
m_historyConfirmationToDelete->setChecked(
|
||||
config.historyConfirmationToDelete());
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
m_checkForUpdates->setChecked(config.checkForUpdates());
|
||||
#endif
|
||||
m_allowMultipleGuiInstances->setChecked(config.allowMultipleGuiInstances());
|
||||
m_showMagnifier->setChecked(config.showMagnifier());
|
||||
m_squareMagnifier->setChecked(config.squareMagnifier());
|
||||
@@ -132,10 +136,12 @@ void GeneralConf::showDesktopNotificationChanged(bool checked)
|
||||
ConfigHandler().setShowDesktopNotification(checked);
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void GeneralConf::checkForUpdatesChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setCheckForUpdates(checked);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GeneralConf::allowMultipleGuiInstancesChanged(bool checked)
|
||||
{
|
||||
@@ -339,6 +345,7 @@ void GeneralConf::initConfigButtons()
|
||||
&GeneralConf::resetConfiguration);
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void GeneralConf::initCheckForUpdates()
|
||||
{
|
||||
m_checkForUpdates = new QCheckBox(tr("Automatic check for updates"), this);
|
||||
@@ -350,6 +357,7 @@ void GeneralConf::initCheckForUpdates()
|
||||
this,
|
||||
&GeneralConf::checkForUpdatesChanged);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GeneralConf::initAllowMultipleGuiInstances()
|
||||
{
|
||||
|
||||
@@ -37,7 +37,9 @@ private slots:
|
||||
void saveLastRegion(bool checked);
|
||||
void showSidePanelButtonChanged(bool checked);
|
||||
void showDesktopNotificationChanged(bool checked);
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void checkForUpdatesChanged(bool checked);
|
||||
#endif
|
||||
void allowMultipleGuiInstancesChanged(bool checked);
|
||||
void autoCloseIdleDaemonChanged(bool checked);
|
||||
void autostartChanged(bool checked);
|
||||
@@ -63,7 +65,9 @@ private:
|
||||
void initAntialiasingPinZoom();
|
||||
void initAutoCloseIdleDaemon();
|
||||
void initAutostart();
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void initCheckForUpdates();
|
||||
#endif
|
||||
void initConfigButtons();
|
||||
void initCopyAndCloseAfterUpload();
|
||||
void initCopyOnDoubleClick();
|
||||
@@ -97,7 +101,9 @@ private:
|
||||
QCheckBox* m_showTray;
|
||||
QCheckBox* m_helpMessage;
|
||||
QCheckBox* m_sidePanelButton;
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
QCheckBox* m_checkForUpdates;
|
||||
#endif
|
||||
QCheckBox* m_allowMultipleGuiInstances;
|
||||
QCheckBox* m_autoCloseIdleDaemon;
|
||||
QCheckBox* m_autostart;
|
||||
|
||||
@@ -12,15 +12,18 @@
|
||||
#include <QClipboard>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
#include <QDesktopServices>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "src/core/globalshortcutfilter.h"
|
||||
@@ -57,9 +60,11 @@ FlameshotDaemon::FlameshotDaemon()
|
||||
, m_hostingClipboard(false)
|
||||
, m_clipboardSignalBlocked(false)
|
||||
, m_trayIcon(nullptr)
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
, m_networkCheckUpdates(nullptr)
|
||||
, m_showCheckAppUpdateStatus(false)
|
||||
, m_appLatestVersion(QStringLiteral(APP_VERSION).replace("v", ""))
|
||||
#endif
|
||||
{
|
||||
connect(
|
||||
QApplication::clipboard(), &QClipboard::dataChanged, this, [this]() {
|
||||
@@ -87,9 +92,12 @@ FlameshotDaemon::FlameshotDaemon()
|
||||
m_persist = !config.autoCloseIdleDaemon();
|
||||
});
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
if (ConfigHandler().checkForUpdates()) {
|
||||
getLatestAvailableVersion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FlameshotDaemon::start()
|
||||
@@ -169,6 +177,7 @@ void FlameshotDaemon::sendTrayNotification(const QString& text,
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void FlameshotDaemon::showUpdateNotificationIfAvailable(CaptureWidget* widget)
|
||||
{
|
||||
if (!m_appLatestUrl.isEmpty() &&
|
||||
@@ -207,6 +216,7 @@ void FlameshotDaemon::checkForUpdates()
|
||||
QDesktopServices::openUrl(QUrl(m_appLatestUrl));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Return the daemon instance.
|
||||
@@ -344,6 +354,7 @@ void FlameshotDaemon::enableTrayIcon(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void FlameshotDaemon::handleReplyCheckUpdates(QNetworkReply* reply)
|
||||
{
|
||||
if (!ConfigHandler().checkForUpdates()) {
|
||||
@@ -382,6 +393,7 @@ void FlameshotDaemon::handleReplyCheckUpdates(QNetworkReply* reply)
|
||||
}
|
||||
m_showCheckAppUpdateStatus = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
QDBusMessage FlameshotDaemon::createMethodCall(QString method)
|
||||
{
|
||||
|
||||
@@ -9,10 +9,13 @@ class QRect;
|
||||
class QDBusMessage;
|
||||
class QDBusConnection;
|
||||
class TrayIcon;
|
||||
class CaptureWidget;
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class QVersionNumber;
|
||||
class CaptureWidget;
|
||||
#endif
|
||||
|
||||
class FlameshotDaemon : public QObject
|
||||
{
|
||||
@@ -30,14 +33,19 @@ public:
|
||||
const QString& title = QStringLiteral("Flameshot Info"),
|
||||
const int timeout = 5000);
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void showUpdateNotificationIfAvailable(CaptureWidget* widget);
|
||||
|
||||
public slots:
|
||||
void checkForUpdates();
|
||||
void getLatestAvailableVersion();
|
||||
|
||||
private slots:
|
||||
void handleReplyCheckUpdates(QNetworkReply* reply);
|
||||
|
||||
signals:
|
||||
void newVersionAvailable(QVersionNumber version);
|
||||
#endif
|
||||
|
||||
private:
|
||||
FlameshotDaemon();
|
||||
@@ -52,10 +60,6 @@ private:
|
||||
void initTrayIcon();
|
||||
void enableTrayIcon(bool enable);
|
||||
|
||||
private slots:
|
||||
void handleReplyCheckUpdates(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
static QDBusMessage createMethodCall(QString method);
|
||||
static void checkDBusConnection(const QDBusConnection& connection);
|
||||
static void call(const QDBusMessage& m);
|
||||
@@ -66,10 +70,12 @@ private:
|
||||
QList<QWidget*> m_widgets;
|
||||
TrayIcon* m_trayIcon;
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
QString m_appLatestUrl;
|
||||
QString m_appLatestVersion;
|
||||
bool m_showCheckAppUpdateStatus;
|
||||
QNetworkAccessManager* m_networkCheckUpdates;
|
||||
#endif
|
||||
|
||||
static FlameshotDaemon* m_instance;
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
|
||||
OPTION("showDesktopNotification" ,Bool ( true )),
|
||||
OPTION("disabledTrayIcon" ,Bool ( false )),
|
||||
OPTION("historyConfirmationToDelete" ,Bool ( true )),
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
OPTION("checkForUpdates" ,Bool ( true )),
|
||||
#endif
|
||||
OPTION("allowMultipleGuiInstances" ,Bool ( false )),
|
||||
OPTION("showMagnifier" ,Bool ( false )),
|
||||
OPTION("squareMagnifier" ,Bool ( false )),
|
||||
|
||||
@@ -86,7 +86,9 @@ public:
|
||||
CONFIG_GETTER_SETTER(drawThickness, setDrawThickness, int)
|
||||
CONFIG_GETTER_SETTER(drawFontSize, setDrawFontSize, int)
|
||||
CONFIG_GETTER_SETTER(keepOpenAppLauncher, setKeepOpenAppLauncher, bool)
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
CONFIG_GETTER_SETTER(checkForUpdates, setCheckForUpdates, bool)
|
||||
#endif
|
||||
CONFIG_GETTER_SETTER(allowMultipleGuiInstances,
|
||||
setAllowMultipleGuiInstances,
|
||||
bool)
|
||||
|
||||
@@ -20,7 +20,6 @@ target_sources(
|
||||
orientablepushbutton.h
|
||||
uploadhistory.h
|
||||
uploadlineitem.h
|
||||
updatenotificationwidget.h
|
||||
colorpickerwidget.h
|
||||
imguploaddialog.h
|
||||
capture/capturetoolobjects.h
|
||||
@@ -28,7 +27,8 @@ target_sources(
|
||||
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE capturelauncher.cpp
|
||||
PRIVATE
|
||||
capturelauncher.cpp
|
||||
draggablewidgetmaker.cpp
|
||||
imagelabel.cpp
|
||||
trayicon.cpp
|
||||
@@ -38,8 +38,16 @@ target_sources(
|
||||
orientablepushbutton.cpp
|
||||
uploadhistory.cpp
|
||||
uploadlineitem.cpp
|
||||
updatenotificationwidget.cpp
|
||||
colorpickerwidget.cpp
|
||||
imguploaddialog.cpp
|
||||
capture/capturetoolobjects.cpp
|
||||
)
|
||||
|
||||
if (NOT DISABLE_UPDATE_CHECKER)
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE
|
||||
updatenotificationwidget.h
|
||||
updatenotificationwidget.cpp
|
||||
)
|
||||
endif()
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "src/widgets/orientablepushbutton.h"
|
||||
#include "src/widgets/panel/sidepanelwidget.h"
|
||||
#include "src/widgets/panel/utilitypanel.h"
|
||||
#include "src/widgets/updatenotificationwidget.h"
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
@@ -42,6 +41,10 @@
|
||||
#include <QShortcut>
|
||||
#include <draggablewidgetmaker.h>
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
#include "src/widgets/updatenotificationwidget.h"
|
||||
#endif
|
||||
|
||||
#define MOUSE_DISTANCE_TO_START_MOVING 3
|
||||
|
||||
// CaptureWidget is the main component used to capture the screen. It contains
|
||||
@@ -64,7 +67,9 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
|
||||
, m_toolWidget(nullptr)
|
||||
, m_colorPicker(nullptr)
|
||||
, m_lastMouseWheel(0)
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
, m_updateNotificationWidget(nullptr)
|
||||
#endif
|
||||
, m_activeToolIsMoved(false)
|
||||
, m_panel(nullptr)
|
||||
, m_sidePanel(nullptr)
|
||||
@@ -1127,6 +1132,7 @@ void CaptureWidget::initPanel()
|
||||
m_panel->fillCaptureTools(m_captureToolObjects.captureToolObjects());
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
||||
const QString& appLatestUrl)
|
||||
{
|
||||
@@ -1159,6 +1165,7 @@ void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
||||
makeChild(m_updateNotificationWidget);
|
||||
m_updateNotificationWidget->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CaptureWidget::initSelection()
|
||||
{
|
||||
|
||||
@@ -35,7 +35,9 @@ class QNetworkReply;
|
||||
class ColorPicker;
|
||||
class NotifierBox;
|
||||
class HoverEventFilter;
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
class UpdateNotificationWidget;
|
||||
#endif
|
||||
class UtilityPanel;
|
||||
class SidePanelWidget;
|
||||
|
||||
@@ -50,9 +52,11 @@ public:
|
||||
~CaptureWidget();
|
||||
|
||||
QPixmap pixmap();
|
||||
void setCaptureToolObjects(const CaptureToolObjects& captureToolObjects);
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void showAppUpdateNotification(const QString& appLatestVersion,
|
||||
const QString& appLatestUrl);
|
||||
void setCaptureToolObjects(const CaptureToolObjects& captureToolObjects);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
bool commitCurrentTool();
|
||||
@@ -168,7 +172,9 @@ private:
|
||||
bool m_configError;
|
||||
bool m_configErrorResolved;
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
UpdateNotificationWidget* m_updateNotificationWidget;
|
||||
#endif
|
||||
quint64 m_lastMouseWheel;
|
||||
QPointer<CaptureToolButton> m_sizeIndButton;
|
||||
// Last pressed button
|
||||
|
||||
@@ -86,10 +86,12 @@ TrayIcon::~TrayIcon()
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
QAction* TrayIcon::appUpdates()
|
||||
{
|
||||
return m_appUpdates;
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrayIcon::initMenu()
|
||||
{
|
||||
@@ -127,6 +129,7 @@ void TrayIcon::initMenu()
|
||||
connect(
|
||||
infoAction, &QAction::triggered, Flameshot::instance(), &Flameshot::info);
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
m_appUpdates = new QAction(tr("Check for updates"), this);
|
||||
connect(m_appUpdates,
|
||||
&QAction::triggered,
|
||||
@@ -141,6 +144,7 @@ void TrayIcon::initMenu()
|
||||
tr("New version %1 is available").arg(version.toString());
|
||||
m_appUpdates->setText(newVersion);
|
||||
});
|
||||
#endif
|
||||
|
||||
QAction* quitAction = new QAction(tr("&Quit"), this);
|
||||
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||
@@ -159,12 +163,15 @@ void TrayIcon::initMenu()
|
||||
m_menu->addSeparator();
|
||||
m_menu->addAction(configAction);
|
||||
m_menu->addSeparator();
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
m_menu->addAction(m_appUpdates);
|
||||
#endif
|
||||
m_menu->addAction(infoAction);
|
||||
m_menu->addSeparator();
|
||||
m_menu->addAction(quitAction);
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void TrayIcon::enableCheckUpdatesAction(bool enable)
|
||||
{
|
||||
if (m_appUpdates != nullptr) {
|
||||
@@ -175,9 +182,12 @@ void TrayIcon::enableCheckUpdatesAction(bool enable)
|
||||
FlameshotDaemon::instance()->getLatestAvailableVersion();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrayIcon::startGuiCapture()
|
||||
{
|
||||
auto* widget = Flameshot::instance()->gui();
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
FlameshotDaemon::instance()->showUpdateNotificationIfAvailable(widget);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -11,15 +11,21 @@ public:
|
||||
TrayIcon(QObject* parent = nullptr);
|
||||
virtual ~TrayIcon();
|
||||
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
QAction* appUpdates();
|
||||
#endif
|
||||
|
||||
private:
|
||||
void initTrayIcon();
|
||||
void initMenu();
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
void enableCheckUpdatesAction(bool enable);
|
||||
#endif
|
||||
|
||||
void startGuiCapture();
|
||||
|
||||
QMenu* m_menu;
|
||||
#if !defined(DISABLE_UPDATE_CHECKER)
|
||||
QAction* m_appUpdates;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user