Skip to content

Commit

Permalink
Remember window position and force-quit on holding SHIFT
Browse files Browse the repository at this point in the history
  • Loading branch information
mottosso committed May 31, 2017
1 parent f041811 commit 18a85c6
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions mindbender/tools/loader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ def __init__(self, parent=None):
module.root, module.project))

self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

body = QtWidgets.QWidget()
sidepanel = QtWidgets.QWidget()
sidepanel.setFixedWidth(200)
sidepanel.setFixedWidth(270)
footer = QtWidgets.QWidget()
footer.setFixedHeight(20)

Expand Down Expand Up @@ -455,8 +454,9 @@ def _versionschanged(self):

self.data["label"]["commentContainer"].show()
comment = self.data["label"]["comment"]
comment.setText(version_document["data"].get(
"comment", "No comment"))
comment.setText(
version_document["data"].get("comment") or "No comment"
)

self.data["label"]["sourceContainer"].show()
source = self.data["label"]["source"]
Expand Down Expand Up @@ -566,6 +566,14 @@ def closeEvent(self, event):
modifiers = QtWidgets.QApplication.queryKeyboardModifiers()
shift_pressed = QtCore.Qt.ShiftModifier & modifiers

if shift_pressed:
print("Force quitted..")
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

# Kill on holding SHIFT
modifiers = QtWidgets.QApplication.queryKeyboardModifiers()
shift_pressed = QtCore.Qt.ShiftModifier & modifiers

if shift_pressed:
print("Force quitted..")
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Expand All @@ -583,11 +591,16 @@ def show(root=None, debug=False, parent=None):
"""

try:
module.window.close()
del module.window
except (RuntimeError, AttributeError):
pass
# Remember window
if module.window is not None:
try:
return module.window.show()
except RuntimeError as e:
if not e.message.rstrip().endswith("already deleted."):
raise

# Garbage collected
module.window = None

if debug:
import traceback
Expand Down

0 comments on commit 18a85c6

Please sign in to comment.