Skip to content

Commit

Permalink
fix: modal windows now have the Qt.Dialog flag
Browse files Browse the repository at this point in the history
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: TagStudioDev#392, TagStudioDev#464
  • Loading branch information
ChloeZamorano committed Jan 18, 2025
1 parent a25ef8c commit 5854ccc
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/add_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, library: Library):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/delete_unlinked.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, driver: "QtDriver", tracker: MissingRegistry):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/drop_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, driver: "QtDriver"):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/file_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, library: "Library"):
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)
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/fix_dupes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
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)

Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/fix_unlinked.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/folders_to_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/modals/mirror_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, driver: "QtDriver", tracker: DupeRegistry):
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/widgets/paged_panel/paged_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, size: tuple[int, int], stack: list[PagedPanelState]):
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)
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/widgets/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
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")
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/widgets/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
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)
Expand Down

0 comments on commit 5854ccc

Please sign in to comment.