Fix #846 close Fullscreen when exiting main editor (#854)

* Fix #846 close Fullscreen when exiting main screen

* Removing debug code and initializing _fullscreen

* Removing the print
This commit is contained in:
Alexandre 2021-04-09 10:03:31 -04:00 committed by GitHub
parent 0a615bdef2
commit 40e6bf0793
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 9 deletions

View file

@ -794,6 +794,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 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()

View file

@ -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, \
@ -23,6 +23,8 @@ import logging
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)
@ -178,13 +180,13 @@ class fullScreenEditor(QWidget):
# 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):
@ -288,9 +290,7 @@ class fullScreenEditor(QWidget):
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]:

View file

@ -67,6 +67,7 @@ class mainEditor(QWidget, Ui_mainEditor):
QWidget.__init__(self, parent)
self.setupUi(self)
self._updating = False
self._fullScreen = None
self.mw = mainWindow()
@ -154,6 +155,10 @@ class mainEditor(QWidget, Ui_mainEditor):
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:
@ -386,6 +391,11 @@ class mainEditor(QWidget, Ui_mainEditor):
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