Skip to content

Commit

Permalink
Fix #846 close Fullscreen when exiting main editor (#854)
Browse files Browse the repository at this point in the history
* Fix #846 close Fullscreen when exiting main screen

* Removing debug code and initializing _fullscreen

* Removing the print
  • Loading branch information
belug23 committed Apr 9, 2021
1 parent 0a615bd commit 40e6bf0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 4 additions & 0 deletions manuskript/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,10 @@ def closeEvent(self, event):
# Remembering the current items (stores outlineItem's ID)
settings.openIndexes = self.mainEditor.tabSplitter.openIndexes()

# Call close on the main window to clean children widgets
if self.mainEditor:
self.mainEditor.close()

# Save data from models
if settings.saveOnQuit:
self.saveDatas()
Expand Down
18 changes: 9 additions & 9 deletions manuskript/ui/editors/fullScreenEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# --!-- coding: utf8 --!--
import os

from PyQt5.QtCore import Qt, QSize, QPoint, QRect, QEvent, QTime, QTimer
from PyQt5.QtCore import Qt, QSize, QPoint, QRect, QEvent, QTime, QTimer, pyqtSignal
from PyQt5.QtGui import QFontMetrics, QColor, QBrush, QPalette, QPainter, QPixmap, QCursor
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFrame, QWidget, QPushButton, qApp, QStyle, QComboBox, QLabel, QScrollBar, \
Expand All @@ -23,6 +23,8 @@
LOGGER = logging.getLogger(__name__)

class fullScreenEditor(QWidget):
exited = pyqtSignal()

def __init__(self, index, parent=None, screenNumber=None):
QWidget.__init__(self, parent)
self.setAttribute(Qt.WA_DeleteOnClose, True)
Expand Down Expand Up @@ -178,13 +180,13 @@ def __init__(self, index, parent=None, screenNumber=None):
# self.showMaximized()
# self.show()

def __del__(self):
LOGGER.debug("Leaving fullScreenEditor via Destructor event.")
self.showNormal()
self.close()

def leaveFullscreen(self):
self.__exit__("Leaving fullScreenEditor via leaveFullScreen.")

def __exit__(self, message):
LOGGER.debug(message)
self.showNormal()
self.exited.emit()
self.close()

def setLocked(self, val):
Expand Down Expand Up @@ -288,9 +290,7 @@ def resizeEvent(self, event):
def keyPressEvent(self, event):
if event.key() in [Qt.Key_Escape, Qt.Key_F11] and \
not self._locked:
LOGGER.debug("Leaving fullScreenEditor via keyPressEvent.")
self.showNormal()
self.close()
self.__exit__("Leaving fullScreenEditor via keyPressEvent.")
elif (event.modifiers() & Qt.AltModifier) and \
event.key() in [Qt.Key_PageUp, Qt.Key_PageDown, Qt.Key_Left, Qt.Key_Right]:
if event.key() in [Qt.Key_PageUp, Qt.Key_Left]:
Expand Down
10 changes: 10 additions & 0 deletions manuskript/ui/editors/mainEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
self._updating = False
self._fullScreen = None

self.mw = mainWindow()

Expand Down Expand Up @@ -154,6 +155,10 @@ def closeAllTabs(self):
for ts in reversed(self.allTabSplitters()):
ts.closeSplit()

def close(self):
if self._fullScreen is not None:
self._fullScreen.leaveFullscreen()

def allTabs(self, tabWidget=None):
"""Returns all the tabs from the given tabWidget. If tabWidget is None, from the current tabWidget."""
if tabWidget == None:
Expand Down Expand Up @@ -386,6 +391,11 @@ def showFullScreen(self):
self._fullScreen = fullScreenEditor(
self.currentEditor().currentIndex,
screenNumber=currentScreenNumber)
# Clean the variable when closing fullscreen prevent errors
self._fullScreen.exited.connect(self.clearFullScreen)

def clearFullScreen(self):
self._fullScreen = None

###############################################################################
# DICT AND STUFF LIKE THAT
Expand Down

0 comments on commit 40e6bf0

Please sign in to comment.