Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cuegui] Limit user actions on alien jobs #1488

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion cuegui/cuegui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from builtins import range
import sys
import time
import yaml

from qtpy import QtCore
from qtpy import QtGui
Expand All @@ -46,6 +47,9 @@
class MainWindow(QtWidgets.QMainWindow):
"""The main window of the application. Multiple windows may exist."""

# Message to be displayed when a change requires an application restart
USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: move use USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: " to cuegui/cuegui/Constants.py


windows = []
windows_names = []
windows_titles = {}
Expand All @@ -68,6 +72,7 @@ def __init__(self, app_name, app_version, window_name, parent = None):
self.name = window_name
else:
self.name = self.windows_names[0]
self.__isEnabled = yaml.safe_load(self.app.settings.value("EnableJobInteraction", "False"))

# Provides a location for widgets to the right of the menu
menuLayout = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -195,6 +200,22 @@ def __createMenus(self):
self.windowMenu = self.menuBar().addMenu("&Window")
self.helpMenu = self.menuBar().addMenu("&Help")

if self.__isEnabled is False:
# Menu Bar: File -> Enable Job Interaction
enableJobInteraction = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'),
'&Enable Job Interaction', self)
enableJobInteraction.setStatusTip('Enable Job Interaction')
enableJobInteraction.triggered.connect(self.__enableJobInteraction)
self.fileMenu.addAction(enableJobInteraction)
# allow user to disable the job interaction
else:
# Menu Bar: File -> Disable Job Interaction
enableJobInteraction = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'),
'&Disable Job Interaction', self)
enableJobInteraction.setStatusTip('Disable Job Interaction')
enableJobInteraction.triggered.connect(self.__enableJobInteraction)
self.fileMenu.addAction(enableJobInteraction)

# Menu Bar: File -> Close Window
close = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'), '&Close Window', self)
close.setStatusTip('Close Window')
Expand Down Expand Up @@ -454,9 +475,26 @@ def __revertLayout(self):
result = QtWidgets.QMessageBox.question(
self,
"Restart required ",
"You must restart for this action to take effect, close window?: ",
MainWindow.USER_CONFIRM_RESTART,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: use cuegui.Constants.USER_CONFIRM_RESTART instead of MainWindow.USER_CONFIRM_RESTART.

Constants.py

USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: "

QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
self.settings.setValue("RevertLayout", True)
self.__windowCloseApplication()

def __enableJobInteraction(self):
""" Enable/Disable user job interaction """
result = QtWidgets.QMessageBox.question(
self,
"Job Interaction Settings ",
MainWindow.USER_CONFIRM_RESTART,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
# currently not enabled, user wants to enable
if self.__isEnabled is False:
self.settings.setValue("EnableJobInteraction", 1)
self.__windowCloseApplication()
else:
self.settings.setValue("EnableJobInteraction", 0)
self.__windowCloseApplication()
Loading
Loading