Merge pull request #851 from belug23/fix_fullscreen_display_monitor

Fix #456 - Force the distraction free window on the display of the main window
This commit is contained in:
Tobias Frisch 2021-04-08 14:11:15 +02:00 committed by GitHub
commit 48fa9e4427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -6,7 +6,7 @@ from PyQt5.QtCore import Qt, QSize, QPoint, QRect, QEvent, QTime, QTimer
from PyQt5.QtGui import QFontMetrics, QColor, QBrush, QPalette, QPainter, QPixmap, QCursor from PyQt5.QtGui import QFontMetrics, QColor, QBrush, QPalette, QPainter, QPixmap, QCursor
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFrame, QWidget, QPushButton, qApp, QStyle, QComboBox, QLabel, QScrollBar, \ from PyQt5.QtWidgets import QFrame, QWidget, QPushButton, qApp, QStyle, QComboBox, QLabel, QScrollBar, \
QStyleOptionSlider, QHBoxLayout, QVBoxLayout, QMenu, QAction QStyleOptionSlider, QHBoxLayout, QVBoxLayout, QMenu, QAction, QDesktopWidget
# Spell checker support # Spell checker support
from manuskript import settings from manuskript import settings
@ -21,7 +21,7 @@ from manuskript.functions import Spellchecker
class fullScreenEditor(QWidget): class fullScreenEditor(QWidget):
def __init__(self, index, parent=None): def __init__(self, index, parent=None, screenNumber=None):
QWidget.__init__(self, parent) QWidget.__init__(self, parent)
self.setAttribute(Qt.WA_DeleteOnClose, True) self.setAttribute(Qt.WA_DeleteOnClose, True)
self._background = None self._background = None
@ -162,6 +162,12 @@ class fullScreenEditor(QWidget):
self.topPanel.setAutoHideVariable('autohide-top') self.topPanel.setAutoHideVariable('autohide-top')
self.leftPanel.setAutoHideVariable('autohide-left') self.leftPanel.setAutoHideVariable('autohide-left')
# Set the screen to the same screen as the main window
if screenNumber is not None:
screenres = QDesktopWidget().screenGeometry(screenNumber);
self.move(QPoint(screenres.x(), screenres.y()));
self.resize(screenres.width(), screenres.height());
# Connection # Connection
self._index.model().dataChanged.connect(self.dataChanged) self._index.model().dataChanged.connect(self.dataChanged)

View file

@ -5,7 +5,7 @@ import locale
from PyQt5.QtCore import QModelIndex, QRect, QPoint from PyQt5.QtCore import QModelIndex, QRect, QPoint
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QIcon from PyQt5.QtGui import QPixmap, QPainter, QIcon
from PyQt5.QtWidgets import QWidget, qApp from PyQt5.QtWidgets import QWidget, qApp, QDesktopWidget
from manuskript import settings from manuskript import settings
from manuskript.enums import Outline from manuskript.enums import Outline
@ -379,7 +379,10 @@ class mainEditor(QWidget, Ui_mainEditor):
def showFullScreen(self): def showFullScreen(self):
if self.currentEditor(): if self.currentEditor():
self._fullScreen = fullScreenEditor(self.currentEditor().currentIndex) currentScreenNumber = QDesktopWidget().screenNumber(widget=self)
self._fullScreen = fullScreenEditor(
self.currentEditor().currentIndex,
screenNumber=currentScreenNumber)
############################################################################### ###############################################################################
# DICT AND STUFF LIKE THAT # DICT AND STUFF LIKE THAT