- fixed the "headless" feature; running headless still start the GUI just it does not show it
- when running headless the sys tray icon will always be shown so the user can close the app correctly - in the systray icon context menu I've added a menu entry to toggle the GUI
This commit is contained in:
@@ -5149,6 +5149,7 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
|
||||
|
||||
menu = QtWidgets.QMenu(parent)
|
||||
|
||||
# Run Script
|
||||
menu_runscript = QtGui.QAction(QtGui.QIcon(self.app.resource_location + '/script14.png'),
|
||||
'%s' % _('Run Script ...'), self)
|
||||
menu_runscript.setToolTip(
|
||||
@@ -5158,6 +5159,14 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
|
||||
)
|
||||
menu.addAction(menu_runscript)
|
||||
|
||||
# Toggle GUI
|
||||
menu_toggle_gui = QtGui.QAction(QtGui.QIcon(self.app.resource_location + '/grid_lines32.png'),
|
||||
'%s' % _('Toggle GUI ...'), self)
|
||||
menu_toggle_gui.setToolTip(
|
||||
_("Will show/hide the GUI.")
|
||||
)
|
||||
menu.addAction(menu_toggle_gui)
|
||||
|
||||
menu.addSeparator()
|
||||
|
||||
if headless is None:
|
||||
@@ -5195,6 +5204,8 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
|
||||
exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
|
||||
self.setContextMenu(menu)
|
||||
|
||||
menu_toggle_gui.triggered.connect(self.app.ui.on_toggle_gui)
|
||||
|
||||
menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
|
||||
silent=True if self.app.cmd_line_headless == 1 else False))
|
||||
|
||||
|
||||
@@ -2017,6 +2017,20 @@ class MainGUI(QtWidgets.QMainWindow):
|
||||
self.app.version, ('BETA' if self.app.beta else ''), platform.architecture()[0], self.app.engine, name)
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def on_toggle_gui(self):
|
||||
if self.isHidden():
|
||||
mgui_settings = QSettings("Open Source", "FlatCAM")
|
||||
if mgui_settings.contains("maximized_gui"):
|
||||
maximized_ui = mgui_settings.value('maximized_gui', type=bool)
|
||||
if maximized_ui is True:
|
||||
self.showMaximized()
|
||||
else:
|
||||
self.show()
|
||||
else:
|
||||
self.show()
|
||||
else:
|
||||
self.hide()
|
||||
|
||||
def save_geometry(self, x, y, width, height, notebook_width):
|
||||
"""
|
||||
Will save the application geometry and positions in the defaults dicitionary to be restored at the next
|
||||
|
||||
Reference in New Issue
Block a user