Add a util function to restack the windows
This commit is contained in:
+23
-1
@@ -21,6 +21,7 @@ General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import logging
|
||||
@@ -31,7 +32,7 @@ from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5.QtCore import Qt, QTimer, QThreadPool, pyqtSlot
|
||||
from PyQt5.QtGui import QCursor, QIcon, QKeySequence
|
||||
from PyQt5.QtGui import QCursor, QIcon, QKeySequence, QWindow
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QDialog, QFileDialog, QMainWindow, QMessageBox, QShortcut, QSplitter,
|
||||
QStackedWidget, QVBoxLayout, QWidget
|
||||
@@ -349,6 +350,27 @@ class GuiMain(QMainWindow):
|
||||
|
||||
return True
|
||||
|
||||
def restackGUI(self):
|
||||
"""Reorder the visibility of windows."""
|
||||
subOne: list[QWindow] = []
|
||||
subTwo: list[QWindow] = []
|
||||
for window in qApp.allWindows():
|
||||
name = window.objectName()
|
||||
if name == "GuiManuscriptWindow":
|
||||
subOne.append(window)
|
||||
elif name == "GuiBuildSettingsWindow":
|
||||
subTwo.append(window)
|
||||
elif name == "GuiManuscriptBuildWindow":
|
||||
subTwo.append(window)
|
||||
self.raise_()
|
||||
for window in subOne:
|
||||
if window.isExposed():
|
||||
window.raise_()
|
||||
for window in subTwo:
|
||||
if window.isExposed():
|
||||
window.raise_()
|
||||
return
|
||||
|
||||
def initMain(self):
|
||||
"""Initialise elements that depend on user settings.
|
||||
"""
|
||||
|
||||
@@ -250,7 +250,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
"""
|
||||
self._saveSettings()
|
||||
event.accept()
|
||||
self.guiParent.raise_() # Issue #1494
|
||||
self.mainGui.restackGUI()
|
||||
self.deleteLater()
|
||||
return
|
||||
|
||||
@@ -278,8 +278,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
)
|
||||
if savePath:
|
||||
self.buildPath.setText(savePath)
|
||||
self.guiParent.raise_() # Issue #1494
|
||||
self.raise_() # Issue #1494
|
||||
self.mainGui.restackGUI()
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
|
||||
@@ -225,7 +225,7 @@ class GuiBuildSettings(QDialog):
|
||||
self._askToSaveBuild()
|
||||
self._saveSettings()
|
||||
event.accept()
|
||||
self.guiParent.raise_() # Issue #1494
|
||||
self.mainGui.restackGUI()
|
||||
self.deleteLater()
|
||||
return
|
||||
|
||||
@@ -1163,8 +1163,7 @@ class _FormatTab(QWidget):
|
||||
if theStatus:
|
||||
self.textFont.setText(theFont.family())
|
||||
self.textSize.setValue(theFont.pointSize())
|
||||
self.buildMain.guiParent.raise_() # Issue #1494
|
||||
self.buildMain.raise_() # Issue #1494
|
||||
self.mainGui.restackGUI()
|
||||
return
|
||||
|
||||
@pyqtSlot(int)
|
||||
|
||||
Reference in New Issue
Block a user