Skip to content

Commit 55c04e8

Browse files
authored
Option to disable tray icon on Windows (flameshot-org#4634)
1 parent f500885 commit 55c04e8

3 files changed

Lines changed: 5 additions & 23 deletions

File tree

src/config/generalconf.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ GeneralConf::GeneralConf(QWidget* parent)
3434
initScrollArea();
3535

3636
initAutostart();
37-
#if !defined(Q_OS_WIN)
3837
initAutoCloseIdleDaemon();
39-
#endif
4038
initShowTrayIcon();
4139
initShowDesktopNotification();
4240
initShowAbortNotification();
@@ -112,11 +110,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
112110
m_squareMagnifier->setChecked(config.squareMagnifier());
113111
m_saveLastRegion->setChecked(config.saveLastRegion());
114112
m_reverseArrow->setChecked(config.reverseArrow());
115-
116-
#if !defined(Q_OS_WIN)
117113
m_autoCloseIdleDaemon->setChecked(config.autoCloseIdleDaemon());
118-
#endif
119-
120114
m_predefinedColorPaletteLarge->setChecked(
121115
config.predefinedColorPaletteLarge());
122116
m_showStartupLaunchMessage->setChecked(config.showStartupLaunchMessage());
@@ -127,9 +121,9 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
127121
if (allowEmptySavePath || !config.savePath().isEmpty()) {
128122
m_savePath->setText(config.savePath());
129123
}
130-
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
124+
131125
m_showTray->setChecked(!config.disabledTrayIcon());
132-
#endif
126+
133127
#if !defined(Q_OS_MACOS)
134128
m_captureActiveMonitor->setChecked(config.captureActiveMonitor());
135129
#endif
@@ -335,15 +329,13 @@ void GeneralConf::initShowAbortNotification()
335329

336330
void GeneralConf::initShowTrayIcon()
337331
{
338-
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
339332
m_showTray = new QCheckBox(tr("Show tray icon"), this);
340333
m_showTray->setToolTip(tr("Show icon in the system tray"));
341334
m_scrollAreaLayout->addWidget(m_showTray);
342335

343336
connect(m_showTray, &QCheckBox::clicked, this, [](bool checked) {
344337
ConfigHandler().setDisabledTrayIcon(!checked);
345338
});
346-
#endif
347339
}
348340

349341
void GeneralConf::initHistoryConfirmationToDelete()

src/core/flameshotdaemon.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
* quits.
5252
*
5353
* If the `autoCloseIdleDaemon` option is true, the daemon will close as soon as
54-
* it is not needed to host pinned screenshots and the clipboard. On Windows,
55-
* this option is disabled and the daemon always persists, because the system
56-
* tray is currently the only way to interact with flameshot there.
54+
* it is not needed to host pinned screenshots and the clipboard.
5755
*
5856
* Both the daemon and non-daemon flameshot processes use the same public API,
5957
* which is implemented as static methods. In the daemon process, this class is
@@ -85,9 +83,7 @@ FlameshotDaemon::FlameshotDaemon()
8583
m_hostingClipboard = false;
8684
quitIfIdle();
8785
});
88-
#ifdef Q_OS_WIN
89-
m_persist = true;
90-
#else
86+
9187
m_persist = !ConfigHandler().autoCloseIdleDaemon();
9288
connect(ConfigHandler::getInstance(),
9389
&ConfigHandler::fileChanged,
@@ -97,7 +93,6 @@ FlameshotDaemon::FlameshotDaemon()
9793
enableTrayIcon(!config.disabledTrayIcon());
9894
m_persist = !config.autoCloseIdleDaemon();
9995
});
100-
#endif
10196

10297
#if !defined(DISABLE_UPDATE_CHECKER)
10398
if (ConfigHandler().checkForUpdates()) {
@@ -371,13 +366,10 @@ void FlameshotDaemon::attachTextToClipboard(const QString& text,
371366

372367
void FlameshotDaemon::initTrayIcon()
373368
{
374-
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
375369
if (!ConfigHandler().disabledTrayIcon()) {
376370
enableTrayIcon(true);
377371
}
378-
#elif defined(Q_OS_WIN)
379-
enableTrayIcon(true);
380-
372+
#if defined(Q_OS_WIN)
381373
GlobalShortcutFilter* nativeFilter = new GlobalShortcutFilter(this);
382374
qApp->installNativeEventFilter(nativeFilter);
383375
#endif

src/utils/confighandler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
8686
OPTION("allowMultipleGuiInstances" ,Bool ( false )),
8787
OPTION("showMagnifier" ,Bool ( false )),
8888
OPTION("squareMagnifier" ,Bool ( false )),
89-
#if !defined(Q_OS_WIN)
9089
OPTION("autoCloseIdleDaemon" ,Bool ( false )),
91-
#endif
9290
OPTION("startupLaunch" ,Bool ( false )),
9391
OPTION("showStartupLaunchMessage" ,Bool ( true )),
9492
OPTION("showQuitPrompt" ,Bool ( false )),

0 commit comments

Comments
 (0)