Skip to content

Commit 861d8d9

Browse files
committed
1
1 parent 8c9828c commit 861d8d9

File tree

11 files changed

+126
-1
lines changed

11 files changed

+126
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Version 0.10.0
33
Released: 2026-XX-XX
44

55
Features:
6+
* Add status icon mode setting in Preferences (no icon, normal, blinking).
67
* [#711] Add macOS menu bar status item (NSStatusItem) with system tray icon.
78

89
Version 0.9.4

src/api/iptux-core/ProgramData.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "iptux-core/IptuxConfig.h"
99
#include "iptux-core/Models.h"
10+
#include "iptux-core/StatusIconMode.h"
1011

1112
namespace iptux {
1213

@@ -53,6 +54,8 @@ class ProgramData {
5354
bool IsUsingBlacklist() const;
5455
bool IsFilterFileShareRequest() const;
5556
bool isHideTaskbarWhenMainWindowIconified() const;
57+
int statusIconMode() const;
58+
void setStatusIconMode(int value);
5659
void set_port(uint16_t port, bool is_init = false);
5760
void setOpenChat(bool value) { open_chat = value; }
5861
void setHideStartup(bool value) { hide_startup = value; }
@@ -108,6 +111,7 @@ class ProgramData {
108111
uint8_t proof_shared : 1;
109112
uint8_t hide_taskbar_when_main_window_iconified_ : 1;
110113
uint8_t need_restart_ : 1;
114+
uint8_t status_icon_mode_ : 2;
111115

112116
private:
113117
void InitSublayer();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#pragma once
3+
4+
namespace iptux {
5+
6+
enum StatusIconMode {
7+
STATUS_ICON_MODE_NONE = 0,
8+
STATUS_ICON_MODE_NORMAL = 1,
9+
STATUS_ICON_MODE_BLINKING = 2,
10+
};
11+
12+
} // namespace iptux

src/config.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#mesondefine SYSTEM_DARWIN
2323
#mesondefine HAVE_APPINDICATOR
2424

25+
#if SYSTEM_DARWIN || HAVE_APPINDICATOR
26+
#define HAVE_STATUS_ICON 1
27+
#else
28+
#define HAVE_STATUS_ICON 0
29+
#endif
30+
2531
#if defined(__APPLE__) || defined(__CYGWIN__)
2632
#define O_LARGEFILE 0
2733
#endif

src/iptux-core/ProgramData.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void ProgramData::WriteProgData() {
6969
config->SetBool("proof_shared", proof_shared);
7070
config->SetBool("hide_taskbar_when_main_window_iconified",
7171
hide_taskbar_when_main_window_iconified_);
72+
config->SetInt("status_icon_mode", status_icon_mode_);
7273
config->SetString("access_shared_limit", passwd);
7374
config->SetInt("send_message_retry_in_us", send_message_retry_in_us);
7475
WriteNetSegment();
@@ -144,6 +145,7 @@ void ProgramData::ReadProgData() {
144145
proof_shared = config->GetBool("proof_shared");
145146
hide_taskbar_when_main_window_iconified_ =
146147
config->GetBool("hide_taskbar_when_main_window_iconified");
148+
status_icon_mode_ = config->GetInt("status_icon_mode", STATUS_ICON_MODE_NORMAL);
147149

148150
passwd = config->GetString("access_shared_limit");
149151
send_message_retry_in_us =
@@ -245,6 +247,14 @@ bool ProgramData::isHideTaskbarWhenMainWindowIconified() const {
245247
#endif
246248
}
247249

250+
int ProgramData::statusIconMode() const {
251+
return status_icon_mode_;
252+
}
253+
254+
void ProgramData::setStatusIconMode(int value) {
255+
status_icon_mode_ = value;
256+
}
257+
248258
ProgramData& ProgramData::SetUsingBlacklist(bool value) {
249259
open_blacklist = value;
250260
return *this;

src/iptux/AppIndicator.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class IptuxAppIndicatorPrivate {
2020
IptuxAppIndicator* owner;
2121
AppIndicator* indicator;
2222
GtkBuilder* menuBuilder;
23+
StatusIconMode mode = STATUS_ICON_MODE_NORMAL;
24+
int unreadCount = 0;
2325

2426
static void onScrollEvent(IptuxAppIndicatorPrivate* self) {
2527
self->owner->sigActivateMainWindow.emit();
@@ -57,11 +59,22 @@ IptuxAppIndicator::IptuxAppIndicator(GActionGroup* action_group) {
5759
}
5860

5961
void IptuxAppIndicator::SetUnreadCount(int i) {
62+
priv->unreadCount = i;
63+
if (priv->mode == STATUS_ICON_MODE_NONE) return;
6064
if (i > 0) {
6165
app_indicator_set_status(priv->indicator, APP_INDICATOR_STATUS_ATTENTION);
6266
} else {
6367
app_indicator_set_status(priv->indicator, APP_INDICATOR_STATUS_ACTIVE);
6468
}
6569
}
6670

71+
void IptuxAppIndicator::SetMode(StatusIconMode mode) {
72+
priv->mode = mode;
73+
if (mode == STATUS_ICON_MODE_NONE) {
74+
app_indicator_set_status(priv->indicator, APP_INDICATOR_STATUS_PASSIVE);
75+
} else {
76+
SetUnreadCount(priv->unreadCount);
77+
}
78+
}
79+
6780
} // namespace iptux

src/iptux/AppIndicator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66
#include <memory>
77

8+
#include "iptux-core/StatusIconMode.h"
9+
810
namespace iptux {
911
class IptuxAppIndicatorPrivate;
1012
class IptuxAppIndicator {
1113
public:
1214
IptuxAppIndicator(GActionGroup* action_group);
1315
void SetUnreadCount(int count);
16+
void SetMode(StatusIconMode mode);
1417

1518
sigc::signal<void> sigActivateMainWindow;
1619

src/iptux/AppIndicatorDummy.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ IptuxAppIndicator::IptuxAppIndicator(GActionGroup*) {
88
void IptuxAppIndicator::SetUnreadCount(int) {
99
// Dummy implementation
1010
}
11+
12+
void IptuxAppIndicator::SetMode(StatusIconMode) {
13+
// Dummy implementation
14+
}
1115
} // namespace iptux

src/iptux/AppIndicatorMac.mm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ - (void)statusItemClicked:(id)sender {
130130
IptuxStatusItemHelper* helper = nil;
131131
NSImage* normalIcon = nil;
132132
NSImage* attentionIcon = nil;
133+
StatusIconMode mode = STATUS_ICON_MODE_NORMAL;
134+
int unreadCount = 0;
133135
};
134136

135137
IptuxAppIndicator::IptuxAppIndicator(GActionGroup* action_group) {
@@ -185,7 +187,8 @@ - (void)statusItemClicked:(id)sender {
185187
}
186188

187189
void IptuxAppIndicator::SetUnreadCount(int count) {
188-
if (!priv->statusItem) return;
190+
priv->unreadCount = count;
191+
if (!priv->statusItem || priv->mode == STATUS_ICON_MODE_NONE) return;
189192

190193
if (count > 0 && priv->attentionIcon) {
191194
priv->statusItem.button.image = priv->attentionIcon;
@@ -194,4 +197,13 @@ - (void)statusItemClicked:(id)sender {
194197
}
195198
}
196199

200+
void IptuxAppIndicator::SetMode(StatusIconMode mode) {
201+
priv->mode = mode;
202+
if (!priv->statusItem) return;
203+
priv->statusItem.visible = (mode != STATUS_ICON_MODE_NONE);
204+
if (mode != STATUS_ICON_MODE_NONE) {
205+
SetUnreadCount(priv->unreadCount);
206+
}
207+
}
208+
197209
} // namespace iptux

src/iptux/Application.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void Application::onStartup(Application& self) {
128128
if (self.enable_app_indicator_) {
129129
self.app_indicator =
130130
make_shared<IptuxAppIndicator>(G_ACTION_GROUP(self.app));
131+
self.app_indicator->SetMode(StatusIconMode(self.data->statusIconMode()));
131132
self.app_indicator->sigActivateMainWindow.connect([&self]() {
132133
g_action_group_activate_action(G_ACTION_GROUP(self.app),
133134
"open_main_window", NULL);
@@ -392,6 +393,9 @@ void Application::onConfigChanged() {
392393
} else {
393394
add_accelerator(app, "win.send_message", "<Primary>Return");
394395
}
396+
if (app_indicator) {
397+
app_indicator->SetMode(StatusIconMode(data->statusIconMode()));
398+
}
395399
}
396400

397401
void Application::updateItemToTransTree(const TransFileModel& para) {

0 commit comments

Comments
 (0)