-
Notifications
You must be signed in to change notification settings - Fork 201
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
DiegoTavares
merged 6 commits into
AcademySoftwareFoundation:master
from
DiegoTavares:limit_user_interaction
Aug 22, 2024
+308
−108
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bb1e0c
Limit non job owners interaction
roulaoregan-spi 59c6a14
Remove unecessary constants from Constants.py
DiegoTavares 7b6f9aa
Avoid spamming errors when interacting with multiple jobs
DiegoTavares a61b939
Fix lint and unit-tests
DiegoTavares 403b4da
Merge branch 'master' into limit_user_interaction
DiegoTavares 60c53d9
Merge branch 'master' into limit_user_interaction
DiegoTavares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
from builtins import range | ||
import sys | ||
import time | ||
import yaml | ||
|
||
from qtpy import QtCore | ||
from qtpy import QtGui | ||
|
@@ -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?: " | ||
|
||
windows = [] | ||
windows_names = [] | ||
windows_titles = {} | ||
|
@@ -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() | ||
|
@@ -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') | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: use 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() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?: "
tocuegui/cuegui/Constants.py