Add no_quit parameter to MainWindow initialization

Added 'no_quit' parameter to MainWindow and modified context menu behavior to conditionally show the 'Quit' action.
This commit is contained in:
N0\A
2025-10-23 20:22:56 +02:00
committed by GitHub
parent 8703abf507
commit 68ad2c53e2

View File

@@ -319,7 +319,7 @@ class WebSearchResults(QtWidgets.QDialog):
class MainWindow(QtWidgets.QMainWindow): class MainWindow(QtWidgets.QMainWindow):
def __init__(self, restart=False): def __init__(self, restart=False, no_quit=False):
super().__init__() super().__init__()
flags = ( flags = (
@@ -357,6 +357,7 @@ class MainWindow(QtWidgets.QMainWindow):
right_menu.addAction("Restart", self.restart_application) right_menu.addAction("Restart", self.restart_application)
right_menu.addAction("Hide/Show", self.toggle_visible) right_menu.addAction("Hide/Show", self.toggle_visible)
right_menu.addSeparator() right_menu.addSeparator()
if not no_quit:
right_menu.addAction("Quit", QtWidgets.QApplication.quit) right_menu.addAction("Quit", QtWidgets.QApplication.quit)
self.tray.setContextMenu(right_menu) self.tray.setContextMenu(right_menu)
self.tray.show() self.tray.show()
@@ -469,8 +470,6 @@ class MainWindow(QtWidgets.QMainWindow):
presence.end() presence.end()
args = [sys.executable] + sys.argv args = [sys.executable] + sys.argv
if "--restart" not in args:
args.append("--restart")
subprocess.Popen(args) subprocess.Popen(args)
@@ -482,7 +481,8 @@ def main():
app.setApplicationName("CLARA") app.setApplicationName("CLARA")
restart_enabled = "--restart" in sys.argv restart_enabled = "--restart" in sys.argv
pet = MainWindow(restart=restart_enabled) no_quit = "--no-quit" in sys.argv
pet = MainWindow(restart=restart_enabled, no_quit=no_quit)
presence.start() presence.start()
# bottom right corner # bottom right corner