Skip to content

Commit a293034

Browse files
authored
Add option to disable abort notification (flameshot-org#3610)
1 parent de11a36 commit a293034

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

flameshot.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
;; Show desktop notifications (bool)
4343
;showDesktopNotification=true
4444
;
45+
;; Show abort notifications (bool)
46+
;showAbortNotification=true
47+
;
4548
;; Filename pattern using C++ strftime formatting
4649
;filenamePattern=%F_%H-%M
4750
;

src/config/generalconf.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ GeneralConf::GeneralConf(QWidget* parent)
3838
#endif
3939
initShowTrayIcon();
4040
initShowDesktopNotification();
41+
initShowAbortNotification();
4142
#if !defined(DISABLE_UPDATE_CHECKER)
4243
initCheckForUpdates();
4344
#endif
@@ -77,6 +78,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
7778
m_helpMessage->setChecked(config.showHelp());
7879
m_sidePanelButton->setChecked(config.showSidePanelButton());
7980
m_sysNotifications->setChecked(config.showDesktopNotification());
81+
m_abortNotifications->setChecked(config.showAbortNotification());
8082
m_autostart->setChecked(config.startupLaunch());
8183
m_copyURLAfterUpload->setChecked(config.copyURLAfterUpload());
8284
m_saveAfterCopy->setChecked(config.saveAfterCopy());
@@ -140,6 +142,11 @@ void GeneralConf::showDesktopNotificationChanged(bool checked)
140142
ConfigHandler().setShowDesktopNotification(checked);
141143
}
142144

145+
void GeneralConf::showAbortNotificationChanged(bool checked)
146+
{
147+
ConfigHandler().setShowAbortNotification(checked);
148+
}
149+
143150
#if !defined(DISABLE_UPDATE_CHECKER)
144151
void GeneralConf::checkForUpdatesChanged(bool checked)
145152
{
@@ -292,6 +299,18 @@ void GeneralConf::initShowDesktopNotification()
292299
&GeneralConf::showDesktopNotificationChanged);
293300
}
294301

302+
void GeneralConf::initShowAbortNotification()
303+
{
304+
m_abortNotifications = new QCheckBox(tr("Show abort notifications"), this);
305+
m_abortNotifications->setToolTip(tr("Enable abort notifications"));
306+
m_scrollAreaLayout->addWidget(m_abortNotifications);
307+
308+
connect(m_abortNotifications,
309+
&QCheckBox::clicked,
310+
this,
311+
&GeneralConf::showAbortNotificationChanged);
312+
}
313+
295314
void GeneralConf::initShowTrayIcon()
296315
{
297316
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)

src/config/generalconf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private slots:
3737
void saveLastRegion(bool checked);
3838
void showSidePanelButtonChanged(bool checked);
3939
void showDesktopNotificationChanged(bool checked);
40+
void showAbortNotificationChanged(bool checked);
4041
#if !defined(DISABLE_UPDATE_CHECKER)
4142
void checkForUpdatesChanged(bool checked);
4243
#endif
@@ -78,6 +79,7 @@ private slots:
7879
void initSaveAfterCopy();
7980
void initScrollArea();
8081
void initShowDesktopNotification();
82+
void initShowAbortNotification();
8183
void initShowHelp();
8284
void initShowMagnifier();
8385
void initShowQuitPrompt();
@@ -101,6 +103,7 @@ private slots:
101103
QVBoxLayout* m_scrollAreaLayout;
102104
QScrollArea* m_scrollArea;
103105
QCheckBox* m_sysNotifications;
106+
QCheckBox* m_abortNotifications;
104107
QCheckBox* m_showTray;
105108
QCheckBox* m_helpMessage;
106109
QCheckBox* m_sidePanelButton;

src/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ int requestCaptureAndWait(const CaptureRequest& req)
6363
#endif
6464
});
6565
QObject::connect(flameshot, &Flameshot::captureFailed, []() {
66-
AbstractLogger::info() << "Screenshot aborted.";
66+
AbstractLogger::Target logTarget = static_cast<AbstractLogger::Target>(
67+
ConfigHandler().showAbortNotification()
68+
? AbstractLogger::Target::Default
69+
: AbstractLogger::Target::Default &
70+
~AbstractLogger::Target::Notification);
71+
AbstractLogger::info(logTarget) << "Screenshot aborted.";
6772
qApp->exit(1);
6873
});
6974
return qApp->exec();

src/utils/confighandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
7777
OPTION("showHelp" ,Bool ( true )),
7878
OPTION("showSidePanelButton" ,Bool ( true )),
7979
OPTION("showDesktopNotification" ,Bool ( true )),
80+
OPTION("showAbortNotification" ,Bool ( true )),
8081
OPTION("disabledTrayIcon" ,Bool ( false )),
8182
OPTION("disabledGrimWarning" ,Bool ( false )),
8283
OPTION("historyConfirmationToDelete" ,Bool ( true )),

src/utils/confighandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class ConfigHandler : public QObject
8686
CONFIG_GETTER_SETTER(showDesktopNotification,
8787
setShowDesktopNotification,
8888
bool)
89+
CONFIG_GETTER_SETTER(showAbortNotification, setShowAbortNotification, bool)
8990
CONFIG_GETTER_SETTER(filenamePattern, setFilenamePattern, QString)
9091
CONFIG_GETTER_SETTER(disabledTrayIcon, setDisabledTrayIcon, bool)
9192
CONFIG_GETTER_SETTER(disabledGrimWarning, disabledGrimWarning, bool)

0 commit comments

Comments
 (0)