From 5854ccccabc10dbb284ac647543106704258ad18 Mon Sep 17 00:00:00 2001 From: Chloe Date: Fri, 17 Jan 2025 18:55:28 -0700 Subject: [PATCH] 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 --- tagstudio/src/qt/modals/add_field.py | 1 + tagstudio/src/qt/modals/delete_unlinked.py | 1 + tagstudio/src/qt/modals/drop_import.py | 1 + tagstudio/src/qt/modals/file_extension.py | 1 + tagstudio/src/qt/modals/fix_dupes.py | 1 + tagstudio/src/qt/modals/fix_unlinked.py | 1 + tagstudio/src/qt/modals/folders_to_tags.py | 1 + tagstudio/src/qt/modals/mirror_entities.py | 1 + tagstudio/src/qt/widgets/paged_panel/paged_panel.py | 1 + tagstudio/src/qt/widgets/panel.py | 1 + tagstudio/src/qt/widgets/progress.py | 1 + 11 files changed, 11 insertions(+) diff --git a/tagstudio/src/qt/modals/add_field.py b/tagstudio/src/qt/modals/add_field.py index bea2255b..cdde180e 100644 --- a/tagstudio/src/qt/modals/add_field.py +++ b/tagstudio/src/qt/modals/add_field.py @@ -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") diff --git a/tagstudio/src/qt/modals/delete_unlinked.py b/tagstudio/src/qt/modals/delete_unlinked.py index 871c2d8a..a6dee89b 100644 --- a/tagstudio/src/qt/modals/delete_unlinked.py +++ b/tagstudio/src/qt/modals/delete_unlinked.py @@ -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") diff --git a/tagstudio/src/qt/modals/drop_import.py b/tagstudio/src/qt/modals/drop_import.py index 9b13b3d1..20a88b63 100644 --- a/tagstudio/src/qt/modals/drop_import.py +++ b/tagstudio/src/qt/modals/drop_import.py @@ -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") diff --git a/tagstudio/src/qt/modals/file_extension.py b/tagstudio/src/qt/modals/file_extension.py index 49b5b147..1f4e58e1 100644 --- a/tagstudio/src/qt/modals/file_extension.py +++ b/tagstudio/src/qt/modals/file_extension.py @@ -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) diff --git a/tagstudio/src/qt/modals/fix_dupes.py b/tagstudio/src/qt/modals/fix_dupes.py index 76261039..cadd9dbd 100644 --- a/tagstudio/src/qt/modals/fix_dupes.py +++ b/tagstudio/src/qt/modals/fix_dupes.py @@ -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) diff --git a/tagstudio/src/qt/modals/fix_unlinked.py b/tagstudio/src/qt/modals/fix_unlinked.py index eafe3297..4456e98d 100644 --- a/tagstudio/src/qt/modals/fix_unlinked.py +++ b/tagstudio/src/qt/modals/fix_unlinked.py @@ -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") diff --git a/tagstudio/src/qt/modals/folders_to_tags.py b/tagstudio/src/qt/modals/folders_to_tags.py index a0b9b355..0dce8e4e 100644 --- a/tagstudio/src/qt/modals/folders_to_tags.py +++ b/tagstudio/src/qt/modals/folders_to_tags.py @@ -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") diff --git a/tagstudio/src/qt/modals/mirror_entities.py b/tagstudio/src/qt/modals/mirror_entities.py index 4cb37a1c..7cbb3024 100644 --- a/tagstudio/src/qt/modals/mirror_entities.py +++ b/tagstudio/src/qt/modals/mirror_entities.py @@ -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") diff --git a/tagstudio/src/qt/widgets/paged_panel/paged_panel.py b/tagstudio/src/qt/widgets/paged_panel/paged_panel.py index de84d078..dbaac9fb 100644 --- a/tagstudio/src/qt/widgets/paged_panel/paged_panel.py +++ b/tagstudio/src/qt/widgets/paged_panel/paged_panel.py @@ -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) diff --git a/tagstudio/src/qt/widgets/panel.py b/tagstudio/src/qt/widgets/panel.py index 5803d4e6..59cb900f 100755 --- a/tagstudio/src/qt/widgets/panel.py +++ b/tagstudio/src/qt/widgets/panel.py @@ -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") diff --git a/tagstudio/src/qt/widgets/progress.py b/tagstudio/src/qt/widgets/progress.py index d9bc09a5..331ab802 100644 --- a/tagstudio/src/qt/widgets/progress.py +++ b/tagstudio/src/qt/widgets/progress.py @@ -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)