Prevent Windows from floating if no decoration

* Windows users cannot move a window which has no native decorations. Toggling a dock widget's titlebar off also removes native decorations on a floating window. Until we implement a replacement titlebar by overriding paintEvents, simply force the floating window to go back to docked state after we toggled the titlebar off.
This commit is contained in:
glubsy 2020-07-15 22:04:19 +02:00
parent 3c816b2f11
commit 75621cc816
1 changed files with 6 additions and 0 deletions

View File

@ -10,11 +10,13 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDockWidget, QWidget
from .details_table import DetailsModel
from hscommon.plat import ISLINUX
class DetailsDialog(QDockWidget):
def __init__(self, parent, app, **kwargs):
super().__init__(parent, Qt.Tool, **kwargs)
self.parent = parent
self.app = app
self.model = app.model.details_panel
self.setAllowedAreas(Qt.AllDockWidgetAreas)
@ -44,6 +46,10 @@ class DetailsDialog(QDockWidget):
if not self.app.prefs.details_dialog_titlebar_enabled \
and not self.titleBarWidget():
self.setTitleBarWidget(QWidget())
# Windows (and MacOS?) users cannot move a floating window which
# has not native decoration so we force it to dock for now
if not ISLINUX:
self.setFloating(False)
elif self.titleBarWidget() is not None:
# resets to the default title bar
self.setTitleBarWidget(None)