fix: modal windows now have the Qt.Dialog flag

Set the Qt.Dialog flag for modal windows, such as "Add Field" so that
they will be seen as dialogs in the backend. This change is unlikely to
be at all noticeable in systems like Windows, but for users running
tiling window managers like bspwm or Sway, this will prevent these modal
windows from being tiled alongside the main window, instead they will be
floating on top, which is the expected behaviour seen on floating window
managers, like the ones used by Windows and macOS.

Added self.setWindowFlag(Qt.Dialog, on=True) # type: ignore to the
following files:
- tagstudio/src/qt/modals/add_field.py
- tagstudio/src/qt/modals/delete_unlinked.py
- tagstudio/src/qt/modals/drop_import.py
- tagstudio/src/qt/modals/file_extension.py
- tagstudio/src/qt/modals/fix_dupes.py
- tagstudio/src/qt/modals/fix_unlinked.py
- tagstudio/src/qt/modals/folders_to_tags.py
- tagstudio/src/qt/modals/mirror_entities.py
- tagstudio/src/qt/widgets/paged_panel/paged_panel.py
- tagstudio/src/qt/widgets/panel.py
- tagstudio/src/qt/widgets/progress.py

Note that without adding # type: ignore, MyPy *will* give out an error,
presumably because PySide6 is missing type hints for several things, and
this may *or* may not be a justifiable use of # type: ignore, which
throws the MyPy type checking for that line out the window.

Ref: #392, #464
This commit is contained in:
Chloe
2025-01-17 18:55:28 -07:00
parent a25ef8cd9c
commit 5854ccccab
11 changed files with 11 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ class AddFieldModal(QWidget):
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.title_widget = QLabel()
self.title_widget.setObjectName("fieldTitle")

View File

@@ -36,6 +36,7 @@ class DeleteUnlinkedEntriesModal(QWidget):
self.setMinimumSize(500, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.desc_widget = QLabel()
self.desc_widget.setObjectName("descriptionLabel")

View File

@@ -47,6 +47,7 @@ class DropImportModal(QWidget):
self.setMinimumSize(500, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.desc_widget = QLabel()
self.desc_widget.setObjectName("descriptionLabel")

View File

@@ -41,6 +41,7 @@ class FileExtensionModal(PanelWidget):
self.setMinimumSize(240, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
# Create Table Widget --------------------------------------------------
self.table = QTableWidget(len(self.lib.prefs(LibraryPrefs.EXTENSION_LIST)), 1)

View File

@@ -36,6 +36,7 @@ class FixDupeFilesModal(QWidget):
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.tracker = DupeRegistry(library=self.lib)

View File

@@ -35,6 +35,7 @@ class FixUnlinkedEntriesModal(QWidget):
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.unlinked_desc_widget = QLabel()
self.unlinked_desc_widget.setObjectName("unlinkedDescriptionLabel")

View File

@@ -168,6 +168,7 @@ class FoldersToTagsModal(QWidget):
self.setMinimumSize(640, 640)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.title_widget = QLabel()
self.title_widget.setObjectName("title")

View File

@@ -37,6 +37,7 @@ class MirrorEntriesModal(QWidget):
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.tracker = tracker
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.desc_widget = QLabel()
self.desc_widget.setObjectName("descriptionLabel")

View File

@@ -31,6 +31,7 @@ class PagedPanel(QWidget):
self.root_layout.setObjectName("baseLayout")
self.root_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.root_layout.setContentsMargins(0, 0, 0, 0)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.content_container = QWidget()
self.content_layout = QVBoxLayout(self.content_container)

View File

@@ -32,6 +32,7 @@ class PanelModal(QWidget):
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 0, 6, 6)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
self.title_widget = QLabel()
self.title_widget.setObjectName("fieldTitle")

View File

@@ -35,6 +35,7 @@ class ProgressWidget(QWidget):
self.setWindowFlags(self.pb.windowFlags() & ~Qt.WindowType.WindowCloseButtonHint)
self.setWindowTitle(window_title)
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setWindowFlag(Qt.Dialog, on=True) # type: ignore
def update_label(self, text: str):
self.pb.setLabelText(text)