mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-05 05:17:59 +03:00
Add "Hide Dock Icon" option
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Vendored
+8
@@ -1295,6 +1295,14 @@ TRANSLATION = {
|
||||
"ZH": "使用单色托盘图标",
|
||||
"isReviewed": "True"
|
||||
},
|
||||
"Hide Dock Icon": {
|
||||
"source": [
|
||||
"Furious.TrayActions.Settings"
|
||||
],
|
||||
"RU": "Скрыть значок Dock",
|
||||
"ZH": "隐藏程序坞图标",
|
||||
"isReviewed": "True"
|
||||
},
|
||||
"Customize JSON Configuration...": {
|
||||
"source": [
|
||||
"Furious.Widget.UserServersQTableWidget"
|
||||
|
||||
@@ -28,6 +28,10 @@ __all__ = ['SettingsAction']
|
||||
registerAppSettings('VPNMode', isBinary=True)
|
||||
registerAppSettings('DarkMode', isBinary=True)
|
||||
registerAppSettings('UseMonochromeTrayIcon', isBinary=True)
|
||||
|
||||
if PLATFORM == 'Darwin':
|
||||
registerAppSettings('HideDockIcon', isBinary=True)
|
||||
|
||||
registerAppSettings('StartupOnBoot', isBinary=True, default=BinarySettings.ON_)
|
||||
registerAppSettings('PowerSaveMode', isBinary=True, default=BinarySettings.ON_)
|
||||
registerAppSettings(
|
||||
@@ -100,6 +104,15 @@ class SettingsChildAction(AppQAction):
|
||||
APP().systemTray.setConnectedIcon()
|
||||
else:
|
||||
APP().systemTray.setDisconnectedIcon()
|
||||
elif self.textCompare('Hide Dock Icon'):
|
||||
if checked:
|
||||
APP().installDockIconVisibilityFeature()
|
||||
|
||||
AppSettings.turnON_('HideDockIcon')
|
||||
else:
|
||||
APP().installDockIconVisibilityFeature(remove=True)
|
||||
|
||||
AppSettings.turnOFF('HideDockIcon')
|
||||
elif self.textCompare('Startup On Boot'):
|
||||
if checked:
|
||||
StartupOnBoot.on_()
|
||||
@@ -135,7 +148,7 @@ class SettingsChildAction(AppQAction):
|
||||
class SettingsAction(AppQAction):
|
||||
def __init__(self, **kwargs):
|
||||
if PLATFORM == 'Windows' or PLATFORM == 'Darwin':
|
||||
extraActions = [
|
||||
tunActions = [
|
||||
TUNModeAction(
|
||||
checkable=True,
|
||||
checked=AppSettings.isStateON_('VPNMode'),
|
||||
@@ -149,13 +162,24 @@ class SettingsAction(AppQAction):
|
||||
AppQSeperator(),
|
||||
]
|
||||
else:
|
||||
extraActions = [None]
|
||||
tunActions = [None]
|
||||
|
||||
if PLATFORM == 'Darwin':
|
||||
hideDockIconAction = [
|
||||
SettingsChildAction(
|
||||
_('Hide Dock Icon'),
|
||||
checkable=True,
|
||||
checked=AppSettings.isStateON_('HideDockIcon'),
|
||||
)
|
||||
]
|
||||
else:
|
||||
hideDockIconAction = [None]
|
||||
|
||||
super().__init__(
|
||||
_('Settings'),
|
||||
icon=bootstrapIcon('gear-wide-connected.svg'),
|
||||
menu=AppQMenu(
|
||||
*extraActions,
|
||||
*tunActions,
|
||||
SettingsChildAction(
|
||||
_('Dark Mode'),
|
||||
checkable=True,
|
||||
@@ -166,6 +190,7 @@ class SettingsAction(AppQAction):
|
||||
checkable=True,
|
||||
checked=AppSettings.isStateON_('UseMonochromeTrayIcon'),
|
||||
),
|
||||
*hideDockIconAction,
|
||||
AppQSeperator(),
|
||||
SettingsChildAction(
|
||||
_('Startup On Boot'),
|
||||
|
||||
@@ -278,7 +278,8 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
|
||||
logger.info('final cleanup done')
|
||||
|
||||
def _setDockIconVisible(self, visible: bool):
|
||||
@staticmethod
|
||||
def setDockIconVisible(visible: bool):
|
||||
if PLATFORM != 'Darwin':
|
||||
return
|
||||
|
||||
@@ -292,14 +293,25 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
# and hide only when window is closed (not minimized)
|
||||
if PLATFORM == 'Darwin' and obj is getattr(self, 'mainWindow', None):
|
||||
if event.type() == QtCore.QEvent.Type.Show:
|
||||
self._setDockIconVisible(True)
|
||||
self.setDockIconVisible(True)
|
||||
elif event.type() == QtCore.QEvent.Type.Hide:
|
||||
# Hide Dock icon when window is closed (not minimized)
|
||||
if not self.mainWindow.isMinimized():
|
||||
self._setDockIconVisible(False)
|
||||
self.setDockIconVisible(False)
|
||||
|
||||
return super().eventFilter(obj, event)
|
||||
|
||||
def installDockIconVisibilityFeature(self, remove=False):
|
||||
if remove:
|
||||
self.mainWindow.removeEventFilter(self)
|
||||
self.setDockIconVisible(True)
|
||||
else:
|
||||
# Install event filter for main window to track show/hide
|
||||
self.mainWindow.installEventFilter(self)
|
||||
|
||||
if not self.mainWindow.isVisible() and not self.mainWindow.isMinimized():
|
||||
self.setDockIconVisible(False)
|
||||
|
||||
def exit(self, exitcode=0):
|
||||
self.setExitingFlag(True)
|
||||
|
||||
@@ -409,11 +421,9 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
self.mainWindow = AppMainWindow()
|
||||
self.systemTray = SystemTrayIcon()
|
||||
|
||||
if PLATFORM == 'Darwin':
|
||||
# Install event filter for main window to track show/hide
|
||||
self.mainWindow.installEventFilter(self)
|
||||
if PLATFORM == 'Darwin' and AppSettings.isStateON_('HideDockIcon'):
|
||||
# Hide Dock icon initially, keeping only the tray icon visible
|
||||
self._setDockIconVisible(False)
|
||||
self.installDockIconVisibilityFeature()
|
||||
|
||||
if AppSettings.isStateON_('DarkMode'):
|
||||
self.switchToDarkMode()
|
||||
|
||||
Reference in New Issue
Block a user