mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-04 09:21:03 +03:00
[#1346] Option to Disable Systray
This commit is contained in:
parent
ed964b3e55
commit
eae0417797
@ -446,13 +446,20 @@ class AppWindow:
|
|||||||
|
|
||||||
self.prefsdialog = None
|
self.prefsdialog = None
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32' and not bool(config.get_int('no_systray')):
|
||||||
from simplesystray import SysTrayIcon
|
from simplesystray import SysTrayIcon
|
||||||
|
|
||||||
def open_window(systray: 'SysTrayIcon', *args) -> None:
|
def open_window(systray: 'SysTrayIcon', *args) -> None:
|
||||||
self.w.deiconify()
|
self.w.deiconify()
|
||||||
|
|
||||||
menu_options = (("Open", None, open_window),)
|
logfile_loc = pathlib.Path(config.app_dir_path / 'logs')
|
||||||
|
menu_options = (
|
||||||
|
("Open", None, open_window),
|
||||||
|
("Report a Bug", None, self.help_report_a_bug),
|
||||||
|
("About EDMC", None, lambda: not self.HelpAbout.showing and self.HelpAbout(self.w)),
|
||||||
|
("Open Log Folder", None, lambda: prefs.open_folder(logfile_loc)),
|
||||||
|
("Open System Profiler", None, lambda: prefs.help_open_system_profiler(self)),
|
||||||
|
)
|
||||||
# Method associated with on_quit is called whenever the systray is closing
|
# Method associated with on_quit is called whenever the systray is closing
|
||||||
self.systray = SysTrayIcon("EDMarketConnector.ico", applongname, menu_options, on_quit=self.exit_tray)
|
self.systray = SysTrayIcon("EDMarketConnector.ico", applongname, menu_options, on_quit=self.exit_tray)
|
||||||
self.systray.start()
|
self.systray.start()
|
||||||
@ -616,7 +623,7 @@ class AppWindow:
|
|||||||
self.help_menu.add_command(command=lambda: not self.HelpAbout.showing and self.HelpAbout(self.w))
|
self.help_menu.add_command(command=lambda: not self.HelpAbout.showing and self.HelpAbout(self.w))
|
||||||
logfile_loc = pathlib.Path(config.app_dir_path / 'logs')
|
logfile_loc = pathlib.Path(config.app_dir_path / 'logs')
|
||||||
self.help_menu.add_command(command=lambda: prefs.open_folder(logfile_loc)) # Open Log Folder
|
self.help_menu.add_command(command=lambda: prefs.open_folder(logfile_loc)) # Open Log Folder
|
||||||
self.help_menu.add_command(command=lambda: prefs.help_open_system_profiler(self)) # Open Log Folde
|
self.help_menu.add_command(command=lambda: prefs.help_open_system_profiler(self)) # Open System Profiler
|
||||||
|
|
||||||
self.menubar.add_cascade(menu=self.help_menu)
|
self.menubar.add_cascade(menu=self.help_menu)
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
@ -1857,10 +1864,14 @@ class AppWindow:
|
|||||||
def onexit(self, event=None, restart: bool = False) -> None:
|
def onexit(self, event=None, restart: bool = False) -> None:
|
||||||
"""Application shutdown procedure."""
|
"""Application shutdown procedure."""
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
shutdown_thread = threading.Thread(
|
try:
|
||||||
target=self.systray.shutdown,
|
shutdown_thread = threading.Thread(
|
||||||
daemon=True,
|
target=self.systray.shutdown,
|
||||||
)
|
daemon=True,
|
||||||
|
)
|
||||||
|
except AttributeError: # No SysTray
|
||||||
|
shutdown_thread = threading.Thread(daemon=True)
|
||||||
|
|
||||||
shutdown_thread.start()
|
shutdown_thread.start()
|
||||||
|
|
||||||
config.set_shutdown() # Signal we're in shutdown now.
|
config.set_shutdown() # Signal we're in shutdown now.
|
||||||
@ -1938,7 +1949,9 @@ class AppWindow:
|
|||||||
def default_iconify(self, event=None) -> None:
|
def default_iconify(self, event=None) -> None:
|
||||||
"""Handle the Windows default theme 'minimise' button."""
|
"""Handle the Windows default theme 'minimise' button."""
|
||||||
# If we're meant to "minimize to system tray" then hide the window so no taskbar icon is seen
|
# If we're meant to "minimize to system tray" then hide the window so no taskbar icon is seen
|
||||||
if sys.platform == 'win32' and config.get_bool('minimize_system_tray'):
|
if (sys.platform == 'win32'
|
||||||
|
and config.get_bool('minimize_system_tray')
|
||||||
|
and not bool(config.get_int('no_systray'))):
|
||||||
# This gets called for more than the root widget, so only react to that
|
# This gets called for more than the root widget, so only react to that
|
||||||
if str(event.widget) == '.':
|
if str(event.widget) == '.':
|
||||||
self.w.withdraw()
|
self.w.withdraw()
|
||||||
|
@ -78,6 +78,9 @@
|
|||||||
/* EDMarketConnector.py: Label for 'Station' line in main UI; prefs.py: Configuration - Label for selection of 'Station' provider website; prefs.py: Appearance - Example 'Normal' text; stats.py: Status dialog subtitle; In files: EDMarketConnector.py:918; prefs.py:632; prefs.py:770; stats.py:408; */
|
/* EDMarketConnector.py: Label for 'Station' line in main UI; prefs.py: Configuration - Label for selection of 'Station' provider website; prefs.py: Appearance - Example 'Normal' text; stats.py: Status dialog subtitle; In files: EDMarketConnector.py:918; prefs.py:632; prefs.py:770; stats.py:408; */
|
||||||
"Station" = "Station";
|
"Station" = "Station";
|
||||||
|
|
||||||
|
/* prefs.py: Appearance option for Windows "Disable Systray"; */
|
||||||
|
"Disable Systray" = "Disable Systray";
|
||||||
|
|
||||||
/* EDMarketConnector.py: 'File' menu title on OSX; EDMarketConnector.py: 'File' menu title; EDMarketConnector.py: 'File' menu; In files: EDMarketConnector.py:921; EDMarketConnector.py:939; EDMarketConnector.py:942; EDMarketConnector.py:2264; */
|
/* EDMarketConnector.py: 'File' menu title on OSX; EDMarketConnector.py: 'File' menu title; EDMarketConnector.py: 'File' menu; In files: EDMarketConnector.py:921; EDMarketConnector.py:939; EDMarketConnector.py:942; EDMarketConnector.py:2264; */
|
||||||
"File" = "File";
|
"File" = "File";
|
||||||
|
|
||||||
|
15
prefs.py
15
prefs.py
@ -704,6 +704,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
self.lang = tk.StringVar(value=self.languages.get(config.get_str('language'), tr.tl('Default')))
|
self.lang = tk.StringVar(value=self.languages.get(config.get_str('language'), tr.tl('Default')))
|
||||||
self.always_ontop = tk.BooleanVar(value=bool(config.get_int('always_ontop')))
|
self.always_ontop = tk.BooleanVar(value=bool(config.get_int('always_ontop')))
|
||||||
self.minimize_system_tray = tk.BooleanVar(value=config.get_bool('minimize_system_tray'))
|
self.minimize_system_tray = tk.BooleanVar(value=config.get_bool('minimize_system_tray'))
|
||||||
|
self.disable_system_tray = tk.BooleanVar(value=config.get_bool('no_systray'))
|
||||||
self.theme = tk.IntVar(value=config.get_int('theme'))
|
self.theme = tk.IntVar(value=config.get_int('theme'))
|
||||||
self.theme_colors = [config.get_str('dark_text'), config.get_str('dark_highlight')]
|
self.theme_colors = [config.get_str('dark_text'), config.get_str('dark_highlight')]
|
||||||
self.theme_prompts = [
|
self.theme_prompts = [
|
||||||
@ -881,7 +882,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
columnspan=3, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get()
|
columnspan=3, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get()
|
||||||
) # Appearance setting
|
) # Appearance setting
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32' and not bool(config.get_int('no_systray')):
|
||||||
nb.Checkbutton(
|
nb.Checkbutton(
|
||||||
appearance_frame,
|
appearance_frame,
|
||||||
# LANG: Appearance option for Windows "minimize to system tray"
|
# LANG: Appearance option for Windows "minimize to system tray"
|
||||||
@ -890,6 +891,15 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
command=self.themevarchanged
|
command=self.themevarchanged
|
||||||
).grid(columnspan=3, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get()) # Appearance setting
|
).grid(columnspan=3, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get()) # Appearance setting
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
nb.Checkbutton(
|
||||||
|
appearance_frame,
|
||||||
|
# LANG: Appearance option for Windows "Disable Systray"
|
||||||
|
text=tr.tl('Disable Systray'),
|
||||||
|
variable=self.disable_system_tray,
|
||||||
|
command=self.themevarchanged,
|
||||||
|
).grid(columnspan=3, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get()) # Appearance setting
|
||||||
|
|
||||||
nb.Label(appearance_frame).grid(sticky=tk.W) # big spacer
|
nb.Label(appearance_frame).grid(sticky=tk.W) # big spacer
|
||||||
|
|
||||||
# LANG: Label for Settings > Appearance tab
|
# LANG: Label for Settings > Appearance tab
|
||||||
@ -1280,6 +1290,9 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
config.set('ui_transparency', self.transparency.get())
|
config.set('ui_transparency', self.transparency.get())
|
||||||
config.set('always_ontop', self.always_ontop.get())
|
config.set('always_ontop', self.always_ontop.get())
|
||||||
config.set('minimize_system_tray', self.minimize_system_tray.get())
|
config.set('minimize_system_tray', self.minimize_system_tray.get())
|
||||||
|
if self.disable_system_tray.get() != config.get('no_systray'):
|
||||||
|
self.req_restart = True
|
||||||
|
config.set('no_systray', self.disable_system_tray.get())
|
||||||
config.set('theme', self.theme.get())
|
config.set('theme', self.theme.get())
|
||||||
config.set('dark_text', self.theme_colors[0])
|
config.set('dark_text', self.theme_colors[0])
|
||||||
config.set('dark_highlight', self.theme_colors[1])
|
config.set('dark_highlight', self.theme_colors[1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user