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:
14
main.py
14
main.py
@@ -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,7 +357,8 @@ 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()
|
||||||
right_menu.addAction("Quit", QtWidgets.QApplication.quit)
|
if not no_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,9 +470,7 @@ 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)
|
||||||
|
|
||||||
QtWidgets.QApplication.quit()
|
QtWidgets.QApplication.quit()
|
||||||
@@ -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
|
||||||
@@ -500,4 +500,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user