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

🪲 Bug/saving #105

Merged
merged 3 commits into from
Dec 9, 2021
Merged
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
18 changes: 13 additions & 5 deletions opencodeblocks/graphics/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ def __init__(self):
)
loadStylesheets(
(
os.path.join(os.path.dirname(__file__), "..", "qss", "ocb_dark.qss"),
os.path.join(os.path.dirname(__file__),
"..", "qss", "ocb_dark.qss"),
self.stylesheet_filename,
)
)

self.mdiArea = QMdiArea()
self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.mdiArea.setHorizontalScrollBarPolicy(
Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.mdiArea.setVerticalScrollBarPolicy(
Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.mdiArea.setViewMode(QMdiArea.ViewMode.TabbedView)
self.mdiArea.setDocumentMode(True)
self.mdiArea.setTabsMovable(True)
Expand Down Expand Up @@ -306,7 +309,8 @@ def onFileNew(self):

def onFileOpen(self):
"""Open a file."""
filename, _ = QFileDialog.getOpenFileName(self, "Open ipygraph from file")
filename, _ = QFileDialog.getOpenFileName(
self, "Open ipygraph from file")
if filename == "":
return
if os.path.isfile(filename):
Expand All @@ -322,6 +326,7 @@ def onFileSave(self) -> bool:

"""
current_window = self.activeMdiChild()

if current_window is not None:
if current_window.savepath is None:
return self.onFileSaveAs()
Expand All @@ -337,7 +342,10 @@ def onFileSaveAs(self) -> bool:
"""
current_window = self.activeMdiChild()
if current_window is not None:
filename, _ = QFileDialog.getSaveFileName(self, "Save ipygraph to file")
dialog = QFileDialog()
dialog.setDefaultSuffix(".ipyg")
filename, _ = dialog.getSaveFileName(
self, "Save ipygraph to file", filter="IPython Graph (*.ipyg)")
if filename == "":
return False
current_window.savepath = filename
Expand Down