refactor!: organize project layout (#1483)

* refactor!: organize project layout

* refactor: organize tests

* fix: change main.py with __main__.py in tagstudio.spec

* refactor: rename renderer.py to file_renderer.py
This commit is contained in:
Travis Abendshien
2026-08-18 13:56:35 -07:00
committed by GitHub
parent f89f0a6c7f
commit c32f500f3c
139 changed files with 545 additions and 514 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"name": "TagStudio",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/src/tagstudio/main.py",
"program": "${workspaceRoot}/src/tagstudio/__main__.py",
"console": "integratedTerminal",
"justMyCode": true,
"args": ["-o", "~/Documents/Example"]
+2 -2
View File
@@ -16,11 +16,11 @@ File entry data is stored within the `ts_library.sqlite` file inside each librar
## Appearance
File entries appear as thumbnails inside the grid display. The preview panel shows a more detailed preview of the file, along with extra file stats and all attached TagStudio tags and fields.
File entries appear as thumbnails inside the grid display. The inspector shows a more detailed preview of the file, along with extra file stats and all attached TagStudio tags and fields.
## Unlinked Entries
If the file that an entry is referencing has been moved, renamed, or deleted on disk, then TagStudio will display its unlinked status with a red chain-link icon instead of its thumbnail image. Certain uncached stats such as the file size and image dimensions will also be unavailable to see in the preview panel.
If the file that an entry is referencing has been moved, renamed, or deleted on disk, then TagStudio will display its unlinked status with a red chain-link icon instead of its thumbnail image. Certain uncached stats such as the file size and image dimensions will also be unavailable to see in the inspector.
To fix file entries that have become unlinked, select the "Fix Unlinked Entries" option from the Tools menu. From there, refresh the unlinked entry count and choose whether to search and relink you files, and/or delete the file entries from your library. This will NOT delete or modify any files on disk.
+1 -1
View File
@@ -12,7 +12,7 @@ Fields are extra pieces of information you can add to [file entries](./entries.m
Unlike tags, fields are based on [templates](#templates) that contain pre-filled information such as the field type and title, and that information is _copied_ to fields when adding them to entries. Editing field information on entries **does not** modify the template it was created from.
To add a field to an entry, click the "Add Field" button in the preview panel. From there you can search and/or select a [field template](#field-templates) to choose from, or create a new one from the search bar. Alternatively you can create new field templates from **Edit -> Manage Field Templates**.
To add a field to an entry, click the "Add Field" button at the bottom of the inspector. From there you can search and/or select a [field template](#field-templates) to choose from, or create a new one from the search bar. Alternatively you can create new field templates from **Edit -> Manage Field Templates**.
<figure markdown="span">
![Fields Example](assets/fields_example.png)
+2 -2
View File
@@ -203,8 +203,8 @@ Discrete library objects representing [attributes](<https://en.wikipedia.org/wik
- [ ] User-Defined Icons :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.x]**
- [ ] Tint Icons with Text Color :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.x]**
- [x] [Category Property](tags.md#is-category) **[[v9.5.0](changelog.md#950-march-3rd-2025)]**
- [x] Property available for tags that allow the tag and any inheriting from it to be displayed separately in the preview panel under a title
- [ ] Fine-tuned exclusion from categories :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.x]**
- [x] Property available for tags that allow the tag and any inheriting from it to be displayed separately in the inspector under a title
- [x] Fine-tuned exclusion from categories :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.x]**
- [x] Hidden Property **[[v9.5.7](changelog.md#957-may-5th-2026)]**
- [x] Built-in "Archived" tag has this property by default **[[v9.5.7](changelog.md#957-may-5th-2026)]**
- [x] Checkbox near search bar to show hidden tags in search **[[v9.5.7](changelog.md#957-may-5th-2026)]**
+2 -2
View File
@@ -50,7 +50,7 @@ TagStudio provides an [EditorConfig](https://editorconfig.org/#example-file) fil
### :material-tag: TagStudio Systems
- Translation keys can be accessed via bracket notation (e.g. `Translations["translation_key"]`) or with the `Translations.format()` method when a value needs to be passed to a placeholder in the translation.
- Avoid passing around the `QtDriver` class where possible. Instead, pass only the necessary components such as the `Library` and `GlobalSettings` instances.
- Avoid passing around the `QtDriver` class where possible. Instead, pass only the necessary components such as the `Library` and `AppSettings` instances.
- Use HTML-like tags inside strings over explicit stylesheets where possible. The `Style` class provides several handy methods for formatting text with these.
- Use the `format` method in the stylesheets class to format text headers.
@@ -138,7 +138,7 @@ qt/
│ # Frontend classes that aren't related to widgets, like managers
├── resource_manager.py
├── cache_manager.py
├── ts_qt.py # Qt Driver
├── qt_driver.py
└── ...
```
+1 -1
View File
@@ -100,7 +100,7 @@ Properties are special attributes of tags that change their behavior in some way
#### Is Category
The "Is Category" property of tags determines if a tag should be treated as a category itself when being organized inside the preview panel. If this tag or any tags inheriting from this tag (i.e. tags that have this tag as a "[Parent Tag](#parent-tags)"), then these tags will appear under a separated group that's named after this tag. Tags inheriting from multiple "category tags" will still show up under any applicable category.
The "Is Category" property of tags determines if a tag should be treated as a category itself when being organized inside the inspector. If this tag or any tags inheriting from this tag (i.e. tags that have this tag as a "[Parent Tag](#parent-tags)"), then these tags will appear under a separated group that's named after this tag. Tags inheriting from multiple "category tags" will still show up under any applicable category.
This means that duplicates of tags can appear on entries if the tag inherits from multiple parent categories, however this is by design and reflects the nature of multiple inheritance. Any tags not inheriting from a category tag will simply show under a default "Tag" section.
+1 -1
View File
@@ -24,7 +24,7 @@ TagStudio automatically scans for new or updated files when opening a library by
## :material-tag-text: Tagging
With one or more file entries selected, you can **search for** or **create a new tag** by clicking the "Add Tag" button at the bottom of the preview panel or by pressing <kbd>Ctrl</kbd>+<kbd>T</kbd>.
With one or more file entries selected, you can **search for** or **create a new tag** by clicking the "Add Tag" button at the bottom of the inspector or by pressing <kbd>Ctrl</kbd>+<kbd>T</kbd>.
This will open the the **"Tag Bar"**, a combination search/creation bar that is designed to allow you to quickly create and apply tags that don't exist yet, find and apply existing tags from your library, and verify if certain tags already exist and/or are applied to your selection.
+3 -3
View File
@@ -43,7 +43,7 @@ dependencies = [
]
[project.gui-scripts]
tagstudio = "tagstudio.main:main"
tagstudio = "tagstudio.__main__:main"
[dependency-groups]
all = [
@@ -97,7 +97,7 @@ filterwarnings = [
ignore = [
".venv/**",
"src/tagstudio/core/library/json/",
"src/tagstudio/renderers/vendored/pydub/",
"src/tagstudio/previews/vendored/pydub/",
]
include = ["src/tagstudio", "tests"]
# Reference for the settings here: https://github.com/microsoft/pyright/blob/main/docs/configuration.md
@@ -126,7 +126,7 @@ ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107"]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["D", "E402"]
"src/tagstudio/renderers/vendored/**" = ["B", "E", "N", "UP", "SIM115"]
"src/tagstudio/previews/vendored/**" = ["B", "E", "N", "UP", "SIM115"]
[tool.ruff.lint.pydocstyle]
convention = "google"
+1 -1
View File
@@ -41,7 +41,7 @@ datafiles = [
]
a = Analysis(
[Path(project_root, "main.py")],
[Path(project_root, "__main__.py")],
pathex=[],
binaries=[],
datas=datafiles,
+66 -3
View File
@@ -1,9 +1,72 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-License-Identifier: MIT
from tagstudio.main import main
"""TagStudio launcher."""
import argparse
import sys
import traceback
import structlog
from tagstudio.core.constants import BUILD_TYPE, VERSION
from tagstudio.i18n.translations import Translations
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"-o",
"--open",
dest="open",
type=str,
help="Path to a TagStudio Library folder to open on start.",
)
parser.add_argument(
"-s",
"--settings-file",
dest="settings_file",
type=str,
help="Path to a TagStudio .toml global settings file to use.",
)
parser.add_argument(
"-c",
"--cache-file",
dest="cache_file",
type=str,
help="Path to a TagStudio .ini or .plist cache file to use.",
)
parser.add_argument(
"--debug",
dest="debug",
action="store_true",
help="Reveals additional internal data useful for debugging.",
)
parser.add_argument(
"-v",
"--version",
action="version",
help="Displays TagStudio version information.",
version=f"TagStudio v{VERSION} {Translations[BUILD_TYPE] if BUILD_TYPE else ''}",
)
args = parser.parse_args()
driver = QtDriver(args)
ui_name = "Qt"
# Run the chosen frontend driver.
try:
driver.start()
except Exception:
traceback.print_exc()
logger.info(f"\nTagStudio Frontend ({ui_name}) Crashed! Press Enter to Continue...")
input()
if __name__ == "__main__":
main()
sys.exit(main())
+4 -4
View File
@@ -10,16 +10,16 @@ from PySide6.QtCore import QSettings
from tagstudio.core.constants import TS_FOLDER_NAME
from tagstudio.core.enums import AppCacheItems
from tagstudio.core.library.alchemy.library import LibraryStatus
from tagstudio.qt.global_settings import GlobalSettings
from tagstudio.qt.app_settings import AppSettings
logger = structlog.get_logger(__name__)
# TODO: Turn into a BaseDriver class instead of a "Mixin".
class DriverMixin:
cached_values: QSettings
# TODO: GlobalSettings has become closely tied to Qt.
# Should there be a base Settings class?
settings: GlobalSettings
# TODO: AppSettings is Qt-specific and should not be in a base driver class.
settings: AppSettings
def evaluate_path(self, open_path: str | None) -> LibraryStatus:
"""Check if the path of library is valid."""
@@ -25,7 +25,7 @@ from tagstudio.core.library.alchemy.joins import TagParent
from tagstudio.core.library.alchemy.models import Entry, Tag, TagColorGroup, Version
from tagstudio.core.library.ignore import migrate_ext_list
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
logger = structlog.get_logger(__name__)
@@ -1,12 +1,12 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-License-Identifier: MIT
"""A collection of platform-dependant strings."""
import platform
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
def open_file_str() -> str:
@@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-License-Identifier: MIT
from collections import defaultdict
@@ -10,7 +10,7 @@ from typing import Any
import structlog
import ujson
from tagstudio.qt.mnemonics import remove_mnemonic_marker
from tagstudio.qt.helpers.mnemonics import remove_mnemonic_marker
logger = structlog.get_logger(__name__)
-80
View File
@@ -1,80 +0,0 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
"""TagStudio launcher."""
import argparse
import traceback
import structlog
from tagstudio.core.constants import BUILD_TYPE, VERSION
from tagstudio.qt.translations import Translations
from tagstudio.qt.ts_qt import QtDriver
logger = structlog.get_logger(__name__)
def main():
# appid = "cyanvoxel.tagstudio.9"
# ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)
# Parse arguments.
parser = argparse.ArgumentParser()
parser.add_argument(
"-o",
"--open",
dest="open",
type=str,
help="Path to a TagStudio Library folder to open on start.",
)
parser.add_argument(
"-s",
"--settings-file",
dest="settings_file",
type=str,
help="Path to a TagStudio .toml global settings file to use.",
)
parser.add_argument(
"-c",
"--cache-file",
dest="cache_file",
type=str,
help="Path to a TagStudio .ini or .plist cache file to use.",
)
# parser.add_argument('--browse', dest='browse', action='store_true',
# help='Jumps to entry browsing on startup.')
# parser.add_argument('--external_preview', dest='external_preview', action='store_true',
# help='Outputs current preview thumbnail to a live-updating file.')
parser.add_argument(
"--debug",
dest="debug",
action="store_true",
help="Reveals additional internal data useful for debugging.",
)
parser.add_argument(
"-v",
"--version",
action="version",
help="Displays TagStudio version information.",
version=f"TagStudio v{VERSION} {Translations[BUILD_TYPE] if BUILD_TYPE else ''}",
)
args = parser.parse_args()
driver = QtDriver(args)
ui_name = "Qt"
# Run the chosen frontend driver.
try:
driver.start()
except Exception:
traceback.print_exc()
logger.info(f"\nTagStudio Frontend ({ui_name}) Crashed! Press Enter to Continue...")
input()
if __name__ == "__main__":
main()
@@ -17,37 +17,41 @@ from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.ignore import Ignore
from tagstudio.core.media_types import MediaCategories, MediaType
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.cache_manager import CacheManager
from tagstudio.qt.global_settings import (
DEFAULT_CACHED_THUMB_RES,
MAX_CACHED_THUMB_RES,
MIN_CACHED_THUMB_RES,
GlobalSettings,
Theme,
)
from tagstudio.qt.helpers.gradients import four_corner_gradient
from tagstudio.qt.models.palette import UI_COLORS, ColorType, UiColor, get_ui_color
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.renderers.archive import (
from tagstudio.previews.gradients import four_corner_gradient
from tagstudio.previews.renderers.archive import (
apple_embedded_thumb,
archive_thumb,
krita_thumb,
open_doc_thumb,
powerpoint_thumb,
)
from tagstudio.renderers.audio import audio_album_thumb, audio_waveform_thumb
from tagstudio.renderers.blender import blender_thumb
from tagstudio.renderers.clip_studio import clip_studio_thumb
from tagstudio.renderers.ebook import epub_thumb
from tagstudio.renderers.font import font_full_preview, font_small_thumb
from tagstudio.renderers.medibang_paint import medibang_paint_thumb
from tagstudio.renderers.paint_dot_net import paint_dot_net_thumb
from tagstudio.renderers.pdf import pdf_thumb
from tagstudio.renderers.raster_image import exr_image_thumb, raster_image_thumb, raw_image_thumb
from tagstudio.renderers.source_engine import vtf_thumb
from tagstudio.renderers.text import text_thumb
from tagstudio.renderers.vector_image import vector_image_thumb
from tagstudio.renderers.video import video_thumb
from tagstudio.previews.renderers.audio import audio_album_thumb, audio_waveform_thumb
from tagstudio.previews.renderers.blender import blender_thumb
from tagstudio.previews.renderers.clip_studio import clip_studio_thumb
from tagstudio.previews.renderers.ebook import epub_thumb
from tagstudio.previews.renderers.font import font_full_preview, font_small_thumb
from tagstudio.previews.renderers.medibang_paint import medibang_paint_thumb
from tagstudio.previews.renderers.paint_dot_net import paint_dot_net_thumb
from tagstudio.previews.renderers.pdf import pdf_thumb
from tagstudio.previews.renderers.raster_image import (
exr_image_thumb,
raster_image_thumb,
raw_image_thumb,
)
from tagstudio.previews.renderers.source_engine import vtf_thumb
from tagstudio.previews.renderers.text import text_thumb
from tagstudio.previews.renderers.vector_image import vector_image_thumb
from tagstudio.previews.renderers.video import video_thumb
from tagstudio.qt.app_settings import (
DEFAULT_CACHED_THUMB_RES,
MAX_CACHED_THUMB_RES,
MIN_CACHED_THUMB_RES,
AppSettings,
Theme,
)
from tagstudio.qt.cache_manager import CacheManager
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.views.styles.palette import UI_COLORS, ColorType, UiColor, get_ui_color
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
@@ -62,7 +66,7 @@ class FileRenderer:
rm: ResourceManager = ResourceManager()
cached_img_ext: str = ".webp"
def __init__(self, library: Library, settings: GlobalSettings) -> None:
def __init__(self, library: Library, settings: AppSettings) -> None:
super().__init__()
self.lib = library
self.settings = settings
@@ -16,7 +16,7 @@ from PIL import Image
from tagstudio.core.media_types import MediaCategories
from tagstudio.core.utils.types import unwrap
from tagstudio.renderers.raster_image import image_from_bytes
from tagstudio.previews.renderers.raster_image import image_from_bytes
logger = structlog.get_logger(__name__)
@@ -13,7 +13,7 @@ from mutagen import flac, id3, mp4
from mutagen._util import MutagenError
from PIL import Image, ImageDraw
from tagstudio.renderers.vendored.pydub.audio_segment import (
from tagstudio.previews.vendored.pydub.audio_segment import (
_AudioSegment as AudioSegment, # pyright: ignore[reportPrivateUsage]
)
@@ -9,7 +9,7 @@ from PIL import Image
from PySide6.QtCore import Qt
from PySide6.QtGui import QGuiApplication
from tagstudio.renderers.vendored.blender_thumbnailer import blend_thumb
from tagstudio.previews.vendored.blender_thumbnailer import blend_thumb
logger = structlog.get_logger(__name__)
@@ -12,8 +12,8 @@ from PIL import Image
from tagstudio.core.media_types import MediaCategories
from tagstudio.core.utils.types import unwrap
from tagstudio.renderers.archive import Archive, first_image_in_archive, open_archive
from tagstudio.renderers.raster_image import image_from_bytes
from tagstudio.previews.renderers.archive import Archive, first_image_in_archive, open_archive
from tagstudio.previews.renderers.raster_image import image_from_bytes
logger = structlog.get_logger(__name__)
@@ -11,8 +11,8 @@ import structlog
from PIL import Image, ImageDraw, ImageFont
from tagstudio.core.constants import FONT_SAMPLE_SIZES, FONT_SAMPLE_TEXT
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.qt.helpers.text_wrapper import wrap_full_text
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
logger = structlog.get_logger(__name__)
@@ -14,7 +14,7 @@ from PySide6.QtCore import QBuffer, QFile, QFileDevice, QIODeviceBase, QSizeF
from PySide6.QtGui import QImage
from PySide6.QtPdf import QPdfDocument, QPdfDocumentRenderOptions
from tagstudio.qt.helpers.image_effects import replace_transparent_pixels
from tagstudio.qt.views.styles.image_effects import replace_transparent_pixels
logger = structlog.get_logger(__name__)
@@ -11,7 +11,7 @@ from cv2.typing import MatLike
from PIL import Image, UnidentifiedImageError
from PIL.Image import DecompressionBombError
from tagstudio.qt.helpers.file_tester import is_readable_video
from tagstudio.previews.video_tester import is_readable_video
logger = structlog.get_logger(__name__)
@@ -43,7 +43,7 @@ from pydub.utils import (
)
from tagstudio.core.utils.silent_subprocess import silent_popen
from tagstudio.renderers.vendored.pydub.utils import _mediainfo_json
from tagstudio.previews.vendored.pydub.utils import _mediainfo_json
basestring = str
xrange = range
@@ -8,11 +8,7 @@ import json
import re
import subprocess
from pydub.utils import (
_fd_or_path_or_tempfile,
fsdecode,
get_extra_info,
)
from pydub.utils import _fd_or_path_or_tempfile, fsdecode, get_extra_info
from tagstudio.core.utils.ffmpeg_status import FfprobeStatus
from tagstudio.core.utils.silent_subprocess import silent_popen
@@ -1,12 +1,12 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-License-Identifier: MIT
from pathlib import Path
import ffmpeg
from tagstudio.renderers.vendored.probe import probe
from tagstudio.previews.vendored.probe import probe
def is_readable_video(filepath: Path | str):
@@ -59,7 +59,7 @@ class TomlEnumEncoder(toml.TomlEncoder):
# NOTE: pydantic also has a BaseSettings class (from pydantic-settings) that allows any settings
# properties to be overwritten with environment variables. As TagStudio is not currently using
# environment variables, this was not based on that, but that may be useful in the future.
class GlobalSettings(BaseModel):
class AppSettings(BaseModel):
language: str = Field(default="en")
open_last_loaded_on_startup: bool = Field(default=True)
generate_thumbs: bool = Field(default=True)
@@ -88,17 +88,17 @@ class GlobalSettings(BaseModel):
loaded_from: Path = Field(default=DEFAULT_GLOBAL_SETTINGS_PATH, exclude=True)
@staticmethod
def read_settings(path: Path = DEFAULT_GLOBAL_SETTINGS_PATH) -> "GlobalSettings":
def read_settings(path: Path = DEFAULT_GLOBAL_SETTINGS_PATH) -> "AppSettings":
if path.exists():
with open(path) as file:
filecontents = file.read()
if len(filecontents.strip()) != 0:
logger.info("[Settings] Reading Global Settings File", path=path)
settings_data = toml.loads(filecontents)
settings = GlobalSettings(**settings_data, loaded_from=path)
settings = AppSettings(**settings_data, loaded_from=path)
return settings
return GlobalSettings(loaded_from=path)
return AppSettings(loaded_from=path)
def save(self, path: Path | None = None) -> None:
if path is None:
+1 -1
View File
@@ -12,7 +12,7 @@ import structlog
from PIL import Image
from tagstudio.core.constants import THUMB_CACHE_NAME, TS_FOLDER_NAME
from tagstudio.qt.global_settings import DEFAULT_CACHED_THUMB_QUALITY, DEFAULT_THUMB_CACHE_SIZE
from tagstudio.qt.app_settings import DEFAULT_CACHED_THUMB_QUALITY, DEFAULT_THUMB_CACHE_SIZE
logger = structlog.get_logger(__name__)
@@ -6,13 +6,9 @@ from typing import override
import structlog
from PySide6 import QtCore, QtGui
from PySide6.QtCore import QPoint, Signal
from PySide6.QtWidgets import (
QLineEdit,
QMenu,
QWidget,
)
from PySide6.QtWidgets import QLineEdit, QMenu, QWidget
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.stylesheets import (
autofill_scroll_top_focus_style,
autofill_scroll_top_style,
)
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-only
from typing import override
from typing import Any, override
import structlog
from PySide6.QtGui import QMouseEvent
@@ -18,7 +18,7 @@ class ClickableSlider(QSlider):
based on click events.
"""
def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any): # pyright: ignore[reportExplicitAny]
super().__init__(*args, **kwargs)
@override
@@ -9,13 +9,14 @@ from tagstudio.core.library.alchemy.fields import (
DatetimeFieldTemplate,
TextFieldTemplate,
)
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.views.edit_field_template_modal_view import EditFieldTemplateModalView
from tagstudio.qt.views.stylesheets.stylesheets import line_edit_style
from tagstudio.qt.views.styles.stylesheets import line_edit_style
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class EditFieldTemplateModal(EditFieldTemplateModalView):
field_type_map: dict[str, str] = {
"TextFieldTemplate": Translations["field_type.text"],
@@ -11,6 +11,7 @@ from tagstudio.qt.views.edit_text_view import EditTextView
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class EditText(EditTextView):
def __init__(self, name: str, text: str | None, is_multiline: bool = False):
super().__init__()
@@ -11,20 +11,20 @@ from PySide6.QtWidgets import QWidget
from tagstudio.core.library.alchemy.fields import BaseFieldTemplate
from tagstudio.core.library.alchemy.library import Library
from tagstudio.i18n.translations import Translations
from tagstudio.qt.app_settings import AppSettings
from tagstudio.qt.controllers.edit_field_template_modal import EditFieldTemplateModal
from tagstudio.qt.controllers.field_template_widget_controller import FieldTemplateWidget
from tagstudio.qt.controllers.field_template_widget import FieldTemplateWidget
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.suggest_box import SuggestBox
from tagstudio.qt.controllers.underlined_widget import UnderlinedWidget
from tagstudio.qt.global_settings import GlobalSettings
from tagstudio.qt.translations import Translations
logger = structlog.get_logger(__name__)
class FieldSuggestBox(SuggestBox[BaseFieldTemplate]):
def __init__(self, library: Library, settings: GlobalSettings, placeholder_text: str = ""):
def __init__(self, library: Library, settings: AppSettings, placeholder_text: str = ""):
super().__init__(library, settings, placeholder_text)
# Context Menu Actions
@@ -11,12 +11,12 @@ from PySide6.QtWidgets import QMessageBox, QWidget
from tagstudio.core.library.alchemy.fields import BaseFieldTemplate
from tagstudio.core.library.alchemy.library import Library
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.edit_field_template_modal import EditFieldTemplateModal
from tagstudio.qt.controllers.field_template_widget_controller import FieldTemplateWidget
from tagstudio.qt.controllers.field_template_widget import FieldTemplateWidget
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.search_panel_controller import SearchPanel
from tagstudio.qt.translations import Translations
from tagstudio.qt.controllers.search_panel import SearchPanel
from tagstudio.qt.views.search_panel_view import SearchPanelView
logger = structlog.get_logger(__name__)
@@ -7,10 +7,11 @@ from PySide6.QtCore import QEvent, Qt
from PySide6.QtGui import QAction, QEnterEvent
from tagstudio.core.library.alchemy.fields import BaseFieldTemplate
from tagstudio.qt.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.i18n.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.qt.views.field_template_widget_view import FieldTemplateWidgetView
# TODO: Use newer MVC style guidelines
class FieldTemplateWidget(FieldTemplateWidgetView):
def __init__(self) -> None:
super().__init__()
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
from pathlib import Path
from typing import override
import structlog
from PySide6.QtCore import Qt
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QLabel, QWidget
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.utils.file_opener import FileOpenerHelper
logger = structlog.get_logger(__name__)
class FileOpenerLabel(QLabel):
def __init__(self, parent: QWidget | None = None) -> None:
"""Initialize the FileOpenerLabel.
Args:
parent (QWidget, optional): The parent widget. Defaults to None.
"""
self.filepath: Path | None = None
super().__init__(parent)
def set_file_path(self, filepath: Path) -> None:
"""Set the filepath to open.
Args:
filepath (Path): The path to the file to open.
"""
self.filepath = filepath
@override
def mousePressEvent(self, ev: QMouseEvent) -> None:
"""Handle mouse press events.
On a left click, open the file in the default file explorer.
On a right click, show a context menu.
Args:
ev (QMouseEvent): The mouse press event.
"""
if ev.button() == Qt.MouseButton.LeftButton:
opener = FileOpenerHelper(unwrap(self.filepath))
opener.open_explorer()
elif ev.button() == Qt.MouseButton.RightButton:
# Show context menu
pass
else:
super().mousePressEvent(ev)
@@ -9,19 +9,20 @@ from PySide6 import QtGui
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.registries.ignored_registry import IgnoredRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
from tagstudio.qt.mixed.remove_ignored_modal import RemoveIgnoredModal
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.fix_ignored_modal_view import FixIgnoredEntriesModalView
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class FixIgnoredEntriesModal(FixIgnoredEntriesModalView):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__(library, driver)
@@ -19,6 +19,7 @@ from tagstudio.qt.views.ignore_modal_view import IgnoreModalView
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class IgnoreModal(IgnoreModalView):
on_edit = Signal(Tag)
@@ -25,16 +25,16 @@ from tagstudio.core.library.alchemy.fields import (
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.utils.ffmpeg_status import FfmpegStatus, FfprobeStatus
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.controllers.edit_text_controller import EditText
from tagstudio.i18n.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.qt.controllers.edit_text import EditText
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.mixed.datetime_picker import DatetimePicker
from tagstudio.qt.mixed.field_containers import FieldContainers
from tagstudio.qt.mixed.file_attributes import FileAttributeData
from tagstudio.qt.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.qt.views.preview_panel_view import PreviewPanelView
from tagstudio.qt.views.inspector_view import InspectorView
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
@@ -44,7 +44,7 @@ class _ItemMode(IntEnum):
FIELD = 2
class PreviewPanel(QWidget):
class Inspector(QWidget):
def __init__(self, driver: "QtDriver") -> None:
super().__init__()
self._driver = driver
@@ -68,7 +68,7 @@ class PreviewPanel(QWidget):
self,
)
self.setLayout(PreviewPanelView(driver=driver, pixel_ratio=self.devicePixelRatio()))
self.setLayout(InspectorView(driver=driver, pixel_ratio=self.devicePixelRatio()))
self._set_item_mode(None)
self._connect_callbacks()
@@ -276,7 +276,7 @@ class PreviewPanel(QWidget):
logger.error("[Preview Panel] Error updating selection", error=e)
def stop_media_playback(self) -> None:
"""Stop any media playback in the preview panel."""
"""Stop any media playback in the inspector."""
self.layout().preview_thumb.media_player.stop()
@property
@@ -284,5 +284,5 @@ class PreviewPanel(QWidget):
return self.layout().containers
@override
def layout(self) -> PreviewPanelView:
def layout(self) -> InspectorView:
return super().layout() # pyright: ignore[reportReturnType]
@@ -19,18 +19,19 @@ from tagstudio.core.library.alchemy.constants import (
)
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.utils import file_opener
from tagstudio.qt.views.library_info_window_view import LibraryInfoWindowView
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class LibraryInfoWindow(LibraryInfoWindowView):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__(library, driver)
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# TODO: Split view and logic, split classes into individual files
import typing
from collections.abc import Callable
@@ -37,20 +38,20 @@ from PySide6.QtWidgets import (
from tagstudio.core.enums import ShowFilepathOption
from tagstudio.core.library.alchemy.enums import SortingModeEnum
from tagstudio.qt.controllers.preview_panel_controller import PreviewPanel
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.i18n.platform_strings import trash_term
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.inspector import Inspector
from tagstudio.qt.helpers.mnemonics import assign_mnemonics
from tagstudio.qt.mixed.landing import LandingWidget
from tagstudio.qt.mixed.pagination import Pagination
from tagstudio.qt.mnemonics import assign_mnemonics
from tagstudio.qt.platform_strings import trash_term
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.thumb_grid_layout import ThumbGridLayout
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import checkbox_style
from tagstudio.qt.views.layouts.thumb_grid_layout import ThumbGridLayout
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
from tagstudio.qt.views.styles.stylesheets import checkbox_style
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
@@ -491,7 +492,7 @@ class MainWindow(QMainWindow):
self.pagination: Pagination
# initialized in setup_preview_panel
self.preview_panel: PreviewPanel
self.preview_panel: Inspector
# endregion
if not self.objectName():
@@ -700,7 +701,7 @@ class MainWindow(QMainWindow):
self.content_splitter.addWidget(self.entry_list_container)
def setup_preview_panel(self, driver: "QtDriver"):
self.preview_panel = PreviewPanel(driver)
self.preview_panel = Inspector(driver)
self.content_splitter.addWidget(self.preview_panel)
def setup_status_bar(self):
@@ -8,15 +8,14 @@ from PySide6.QtCore import QObject, Signal
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.registries.dupe_files_registry import DupeFilesRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
class MergeDuplicateEntries(QObject):
class MergeDuplicateEntriesProgress(QObject):
done = Signal()
def __init__(self, library: "Library", driver: "QtDriver"):
@@ -19,18 +19,19 @@ from rawpy import (
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.media_types import MediaCategories
from tagstudio.qt.helpers.file_tester import is_readable_video
from tagstudio.previews.video_tester import is_readable_video
from tagstudio.qt.mixed.file_attributes import FileAttributeData
from tagstudio.qt.utils.file_opener import open_file
from tagstudio.qt.views.preview_thumb_view import PreviewThumbView
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
Image.MAX_IMAGE_PIXELS = None
# TODO: Use newer MVC style guidelines
class PreviewThumb(PreviewThumbView):
def __init__(self, library: Library, driver: "QtDriver"):
super().__init__(library, driver)
@@ -11,6 +11,7 @@ from tagstudio.qt.utils.custom_runnable import CustomRunnable
from tagstudio.qt.utils.function_iterator import FunctionIterator
# TODO: Split to use MVC guidelines.
class ProgressWidget(QWidget):
"""Prebuilt thread-safe progress bar widget."""
@@ -5,11 +5,11 @@
from PySide6.QtCore import QObject, Signal
from tagstudio.core.library.alchemy.registries.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
class RelinkUnlinkedEntries(QObject):
class RelinkUnlinkedEntriesProgress(QObject):
done = Signal()
def __init__(self, tracker: UnlinkedRegistry):
@@ -11,15 +11,15 @@ from PySide6.QtGui import QShowEvent
from PySide6.QtWidgets import QWidget
from tagstudio.core.library.alchemy.library import Library
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.search_panel_view import SearchPanelView
logger = structlog.get_logger(__name__)
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
def _item_id(item: object) -> int:
@@ -11,13 +11,14 @@ from PySide6.QtGui import QColor, QFont, QPainter, QPen, QPixmap
from PySide6.QtWidgets import QSplashScreen, QWidget
from tagstudio.core.constants import BUILD_TYPE, COPYRIGHT, COPYRIGHT_COMPACT, VERSION
from tagstudio.qt.global_settings import Splash
from tagstudio.i18n.translations import Translations
from tagstudio.qt.app_settings import Splash
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
logger = structlog.get_logger(__name__)
# TODO: Split view and logic.
class SplashScreen:
"""The custom splash screen widget for TagStudio."""
+5 -7
View File
@@ -11,14 +11,14 @@ from PySide6.QtGui import QAction, QPixmap, QShowEvent, Qt
from PySide6.QtWidgets import QGraphicsOpacityEffect, QWidget
from tagstudio.core.library.alchemy.library import Library
from tagstudio.i18n.translations import Translations
from tagstudio.qt.app_settings import AppSettings
from tagstudio.qt.controllers.autofill_line_edit import QtCore, QtGui
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.underlined_widget import UnderlinedWidget
from tagstudio.qt.global_settings import GlobalSettings
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
from tagstudio.qt.views.styles.stylesheets import (
autofill_line_edit_style,
autofill_line_edit_top_style,
)
@@ -49,9 +49,7 @@ class SuggestBox[T](QWidget):
item_chosen = Signal(object)
done = Signal(str) # Query
def __init__(
self, library: Library, settings: GlobalSettings, placeholder_text: str = ""
) -> None:
def __init__(self, library: Library, settings: AppSettings, placeholder_text: str = "") -> None:
super().__init__()
self._lib = library
self._settings = settings
@@ -17,11 +17,12 @@ from tagstudio.qt.mixed.build_tag import BuildTagPanel
from tagstudio.qt.views.tag_box_view import TagBoxWidgetView
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Use newer MVC style guidelines
class TagBoxWidget(TagBoxWidgetView):
on_update = Signal()
@@ -12,11 +12,11 @@ from PySide6.QtWidgets import QMessageBox, QWidget
from tagstudio.core.constants import RESERVED_TAG_END, RESERVED_TAG_START
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.search_panel_controller import SearchPanel
from tagstudio.qt.controllers.search_panel import SearchPanel
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.search_panel_view import SearchPanelView
logger = structlog.get_logger(__name__)
@@ -12,14 +12,14 @@ from PySide6.QtWidgets import QGraphicsOpacityEffect, QWidget
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.i18n.translations import Translations
from tagstudio.qt.app_settings import AppSettings
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.suggest_box import SuggestBox
from tagstudio.qt.controllers.underlined_widget import UnderlinedWidget
from tagstudio.qt.global_settings import GlobalSettings
from tagstudio.qt.mixed.build_tag import BuildTagPanel
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.translations import Translations
logger = structlog.get_logger(__name__)
@@ -27,9 +27,7 @@ logger = structlog.get_logger(__name__)
class TagSuggestBox(SuggestBox[Tag]):
search_for_tag = Signal(int)
def __init__(
self, library: Library, settings: GlobalSettings, placeholder_text: str = ""
) -> None:
def __init__(self, library: Library, settings: AppSettings, placeholder_text: str = "") -> None:
super().__init__(library, settings, placeholder_text)
# Context Menu Actions
@@ -10,6 +10,8 @@ from tagstudio.qt.views.underlined_widget_view import UnderlinedWidgetView
class UnderlinedWidget(QWidget):
"""A container for a widget and an underline indicator."""
def __init__(self, widget: QWidget) -> None:
super().__init__()
self.setLayout(UnderlinedWidgetView(widget))
@@ -14,15 +14,16 @@ from PySide6.QtWidgets import QMessageBox
from tagstudio.core.constants import GITHUB_RELEASE_URL, VERSION
from tagstudio.core.ts_core import TagStudioCore
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.models.palette import ColorType, UiColor, get_ui_color
from tagstudio.i18n.translations import Translations
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.styles.palette import ColorType, UiColor, get_ui_color
logger = structlog.get_logger(__name__)
# TODO: Split view into UpdateAvailableMessageBoxView
class UpdateAvailableMessageBox(QMessageBox):
"""A warning dialog for if the TagStudio is not running under the latest release version."""
"""A message box notifying the user if there is a new version of TagStudio available."""
def __init__(self):
super().__init__()
@@ -35,7 +35,7 @@ def get_wanted_mnemonics(text: str) -> list[str]:
return matches
def sanitise_mnemonics(actions: list[QAction]) -> None:
def sanitize_mnemonics(actions: list[QAction]) -> None:
previous = []
for action in actions:
text = action.text()
@@ -127,8 +127,8 @@ def assign_mnemonics(menu: QMenu):
# Collect actions
actions = [a for a in menu.actions() if not a.isSeparator()]
# sanitise mnemonics to prevent deadlocks
sanitise_mnemonics(actions)
# sanitize mnemonics to prevent deadlocks
sanitize_mnemonics(actions)
# Sequence map: mnemonic key -> QAction
sequence_to_action: dict[str, QAction] = {}
+4 -3
View File
@@ -32,14 +32,15 @@ from tagstudio.core.utils.ffmpeg_status import FfmpegStatus, FfprobeStatus
from tagstudio.core.utils.ripgrep_status import RipgrepStatus
from tagstudio.core.utils.str_formatting import is_version_outdated
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.clickable_label import ClickableLabel
from tagstudio.qt.models.palette import ColorType, UiColor, get_ui_color
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.utils.file_opener import open_file
from tagstudio.qt.views.stylesheets.stylesheets import form_content_style, header
from tagstudio.qt.views.styles.palette import ColorType, UiColor, get_ui_color
from tagstudio.qt.views.styles.stylesheets import form_content_style, header
# TODO: Split to use MVC guidelines.
class AboutModal(QWidget):
"""Modal window showing information about the TagStudio application."""
+4 -3
View File
@@ -24,11 +24,11 @@ from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library, slugify
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.mixed.tag_color_preview import TagColorPreview
from tagstudio.qt.models.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.palette import ColorType, get_tag_color
from tagstudio.qt.views.styles.stylesheets import (
checkbox_style,
line_edit_style,
list_button_style,
@@ -37,6 +37,7 @@ from tagstudio.qt.views.stylesheets.stylesheets import (
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class BuildColorPanel(ModalContent):
on_edit = Signal(TagColorGroup)
+3 -2
View File
@@ -13,13 +13,14 @@ from PySide6.QtWidgets import QLabel, QLineEdit, QVBoxLayout, QWidget
from tagstudio.core.constants import RESERVED_NAMESPACE_PREFIX
from tagstudio.core.library.alchemy.library import Library, ReservedNamespaceError, slugify
from tagstudio.core.library.alchemy.models import Namespace
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import line_edit_style
from tagstudio.qt.views.styles.stylesheets import line_edit_style
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class BuildNamespacePanel(ModalContent):
on_edit = Signal(Namespace)
+4 -3
View File
@@ -29,15 +29,15 @@ from PySide6.QtWidgets import (
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag, TagAlias, TagColorGroup
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.controllers.tag_search_panel_controller import TagSearchPanel
from tagstudio.qt.controllers.tag_search_panel import TagSearchPanel
from tagstudio.qt.mixed.tag_color_preview import TagColorPreview
from tagstudio.qt.mixed.tag_color_selection import TagColorSelection
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.search_panel_view import SearchPanelView
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.stylesheets import (
checkbox_style,
colored_checkbox_style,
colored_radio_button_style,
@@ -77,6 +77,7 @@ class CustomTableItem(QLineEdit):
super().keyPressEvent(arg__1)
# TODO: Split to use MVC guidelines.
class BuildTagPanel(ModalContent):
on_edit = Signal(Tag)
+3 -2
View File
@@ -12,13 +12,13 @@ from PySide6.QtWidgets import QMessageBox, QPushButton
from tagstudio.core.constants import RESERVED_NAMESPACE_PREFIX
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.mixed.build_color import BuildColorPanel
from tagstudio.qt.mixed.field_widget import FieldWidget
from tagstudio.qt.mixed.tag_color_label import TagColorLabel
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.layouts.flow_layout import FlowLayout
from tagstudio.qt.views.stylesheets.stylesheets import add_button_style
from tagstudio.qt.views.styles.stylesheets import add_button_style
if typing.TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
@@ -26,6 +26,7 @@ if typing.TYPE_CHECKING:
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class ColorBoxWidget(FieldWidget):
updated = Signal()
+3 -2
View File
@@ -10,10 +10,10 @@ from PySide6.QtCore import QDateTime
from PySide6.QtWidgets import QDateTimeEdit, QLineEdit, QVBoxLayout
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.views.stylesheets.stylesheets import title_line_edit_style
from tagstudio.qt.views.styles.stylesheets import title_line_edit_style
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
@@ -39,6 +39,7 @@ def qdtf2dtf(dtf: str) -> str:
return out
# TODO: Split to use MVC guidelines.
class DatetimePicker(ModalContent):
def __init__(self, driver: "QtDriver", name: str, datetime: dt | str):
super().__init__()
+5 -11
View File
@@ -11,21 +11,14 @@ import structlog
from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt, QUrl
from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import (
QHBoxLayout,
QLabel,
QListView,
QPushButton,
QVBoxLayout,
QWidget,
)
from PySide6.QtWidgets import QHBoxLayout, QLabel, QListView, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
@@ -37,6 +30,7 @@ class DuplicateChoice(enum.StrEnum):
CANCEL = "Cancelled"
# TODO: Split to use MVC guidelines.
class DropImportModal(QWidget):
DUPE_NAME_LIMT: int = 5
+6 -5
View File
@@ -29,21 +29,22 @@ from tagstudio.core.library.alchemy.fields import (
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry, Tag
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.controllers.edit_text_controller import EditText
from tagstudio.i18n.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.qt.controllers.edit_text import EditText
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.tag_box_controller import TagBoxWidget
from tagstudio.qt.controllers.tag_box import TagBoxWidget
from tagstudio.qt.mixed.datetime_picker import DatetimePicker
from tagstudio.qt.mixed.field_widget import FieldContainer
from tagstudio.qt.mixed.text_field import TextContainerWidget
from tagstudio.qt.translations import FIELD_TYPE_KEYS, Translations
from tagstudio.qt.views.stylesheets.stylesheets import inset_container_style
from tagstudio.qt.views.styles.stylesheets import inset_container_style
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class FieldContainers(QWidget):
"""Widget for the tag and field containers displayed inside the Preview Panel."""
+3 -2
View File
@@ -12,13 +12,14 @@ from PySide6.QtCore import QEvent, QSize, Qt
from PySide6.QtGui import QEnterEvent, QPixmap, QResizeEvent
from PySide6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.views.stylesheets.stylesheets import container_style, header
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
from tagstudio.qt.views.styles.stylesheets import container_style, header
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class FieldContainer(QWidget):
rm: ResourceManager = ResourceManager()
copy_icon = auto_theme_overlay(rm.copy, inverse=True)
+7 -7
View File
@@ -21,13 +21,14 @@ from tagstudio.core.library.ignore import Ignore
from tagstudio.core.media_types import MediaCategories
from tagstudio.core.utils.str_formatting import format_duration
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.models.palette import ColorType, UiColor, get_ui_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.utils.file_opener import FileOpenerHelper, FileOpenerLabel
from tagstudio.qt.views.stylesheets.stylesheets import properties_style
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.file_opener_label import FileOpenerLabel
from tagstudio.qt.utils.file_opener import FileOpenerHelper
from tagstudio.qt.views.styles.palette import ColorType, UiColor, get_ui_color
from tagstudio.qt.views.styles.stylesheets import properties_style
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
@@ -39,9 +40,8 @@ class FileAttributeData:
duration: int | None = None
# TODO: Split to use MVC guidelines.
class FileAttributes(QWidget):
"""The Preview Panel Widget."""
def __init__(self, library: Library, driver: "QtDriver"):
super().__init__()
root_layout = QVBoxLayout(self)
+4 -4
View File
@@ -17,16 +17,16 @@ from PySide6.QtWidgets import (
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.registries.dupe_files_registry import DupeFilesRegistry
from tagstudio.i18n.translations import Translations
from tagstudio.qt.mixed.mirror_entries_modal import MirrorEntriesModal
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Break up into MVC classes, similar to fix_ignored_modal
# TODO: Split to use MVC guidelines.
class FixDupeFilesModal(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()
+9 -9
View File
@@ -10,19 +10,19 @@ from PySide6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWi
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.registries.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.mixed.merge_dupe_entries import MergeDuplicateEntries
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.mixed.relink_entries_modal import RelinkUnlinkedEntries
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.merge_dupe_entries_progress import MergeDuplicateEntriesProgress
from tagstudio.qt.controllers.progress_bar import ProgressWidget
from tagstudio.qt.controllers.relink_entries_progress import RelinkUnlinkedEntriesProgress
from tagstudio.qt.mixed.remove_unlinked_modal import RemoveUnlinkedEntriesModal
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Break up into MVC classes, similar to fix_ignored_modal
# TODO: Split to use MVC guidelines.
class FixUnlinkedEntriesModal(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()
@@ -55,8 +55,8 @@ class FixUnlinkedEntriesModal(QWidget):
self.refresh_unlinked_button = QPushButton(Translations["entries.generic.refresh_alt"])
self.refresh_unlinked_button.clicked.connect(self.refresh_unlinked)
self.merge_class = MergeDuplicateEntries(self.lib, self.driver)
self.relink_class = RelinkUnlinkedEntries(self.tracker)
self.merge_class = MergeDuplicateEntriesProgress(self.lib, self.driver)
self.relink_class = RelinkUnlinkedEntriesProgress(self.tracker)
self.search_button = QPushButton(Translations["entries.unlinked.search_and_relink"])
self.relink_class.done.connect(
+4 -4
View File
@@ -26,13 +26,13 @@ from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.models.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.views.layouts.flow_layout import FlowLayout
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.palette import ColorType, get_tag_color
from tagstudio.qt.views.styles.stylesheets import header
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
+4 -3
View File
@@ -17,15 +17,15 @@ from tagstudio.core.library.alchemy.enums import ItemType
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.media_types import MediaCategories, MediaType
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.platform_strings import open_file_str, trash_term
from tagstudio.qt.translations import Translations
from tagstudio.i18n.platform_strings import open_file_str, trash_term
from tagstudio.i18n.translations import Translations
from tagstudio.qt.utils.file_opener import FileOpenerHelper
from tagstudio.qt.views.layouts.flow_layout import FlowWidget
from tagstudio.qt.views.thumb_button import ThumbButton
if TYPE_CHECKING:
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
@@ -60,6 +60,7 @@ def badge_update_lock(func):
return wrapper
# TODO: Split to use MVC guidelines.
class ItemThumb(FlowWidget):
"""The thumbnail widget for a library item (Entry, Entry Group, etc.)."""
+4 -3
View File
@@ -11,18 +11,19 @@ from PySide6.QtCore import QEasingCurve, QPoint, QPropertyAnimation, Qt
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.clickable_label import ClickableLabel
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class LandingWidget(QWidget):
rm: ResourceManager = ResourceManager()
mono_logo: Image.Image = rm.ts_logo_text_mono
+5 -4
View File
@@ -36,16 +36,17 @@ from PySide6.QtWidgets import (
QWidget,
)
from tagstudio.qt.helpers.color_overlay import light_overlay
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.clickable_slider import ClickableSlider
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.clickable_slider import ClickableSlider
from tagstudio.qt.views.styles.color_overlay import light_overlay
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class MediaPlayer(QGraphicsView):
"""A basic media player widget.
+7 -5
View File
@@ -23,6 +23,7 @@ from PySide6.QtWidgets import (
)
from sqlalchemy import select
from sqlalchemy.orm import Session
from typing_extensions import deprecated
from tagstudio.core.constants import (
IGNORE_NAME,
@@ -42,17 +43,18 @@ from tagstudio.core.library.ignore import PATH_GLOB_FLAGS, Ignore, ignore_to_glo
from tagstudio.core.library.json.library import Library as JsonLibrary
from tagstudio.core.library.json.library import Tag as JsonTag
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.controllers.paged_panel_controller import PagedPanel
from tagstudio.qt.controllers.paged_panel_state import PagedPanelState
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.mixed.paged_body_wrapper import PagedBodyWrapper
from tagstudio.qt.mixed.paged_panel import PagedPanel
from tagstudio.qt.mixed.paged_panel_state import PagedPanelState
from tagstudio.qt.utils.custom_runnable import CustomRunnable
from tagstudio.qt.utils.function_iterator import FunctionIterator
from tagstudio.qt.views.paged_body_wrapper import PagedBodyWrapper
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
logger = structlog.get_logger(__name__)
@deprecated("This modal will be removed when legacy JSON library support is dropped.")
class JsonMigrationModal(QObject):
"""A modal for data migration from v9.4 JSON to v9.5+ SQLite."""
@@ -10,14 +10,15 @@ from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import QHBoxLayout, QLabel, QListView, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.registries.dupe_files_registry import DupeFilesRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Split to use MVC guidelines.
class MirrorEntriesModal(QWidget):
done = Signal()
@@ -7,8 +7,6 @@ from PySide6.QtWidgets import QVBoxLayout, QWidget
class PagedBodyWrapper(QWidget):
"""A state object for paged panels."""
def __init__(self):
super().__init__()
layout: QVBoxLayout = QVBoxLayout(self)
@@ -9,12 +9,13 @@ from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QHBoxLayout, QLabel, QVBoxLayout, QWidget
from tagstudio.qt.controllers.paged_panel_state import PagedPanelState
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.mixed.paged_panel_state import PagedPanelState
from tagstudio.qt.views.styles.stylesheets import header
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines, or remove the Paged[...] classes.
class PagedPanel(QWidget):
"""A paginated modal panel."""
@@ -4,7 +4,7 @@
from PySide6.QtWidgets import QPushButton
from tagstudio.qt.views.paged_body_wrapper import PagedBodyWrapper
from tagstudio.qt.mixed.paged_body_wrapper import PagedBodyWrapper
class PagedPanelState:
+2 -3
View File
@@ -2,8 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-only
"""A pagination widget created for TagStudio."""
from typing import cast, override
from warnings import catch_warnings
@@ -12,10 +10,11 @@ from PySide6.QtCore import QSize, Signal
from PySide6.QtGui import QIntValidator, QPixmap
from PySide6.QtWidgets import QHBoxLayout, QLabel, QLineEdit, QPushButton, QSizePolicy, QWidget
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.views.styles.color_overlay import auto_theme_overlay
# TODO: Split to use MVC guidelines.
class Pagination(QWidget):
"""Widget containing controls for navigating between pages of items."""
+5 -12
View File
@@ -7,25 +7,18 @@ from typing import TYPE_CHECKING, override
from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt, QThreadPool, Signal
from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import (
QHBoxLayout,
QLabel,
QListView,
QPushButton,
QVBoxLayout,
QWidget,
)
from PySide6.QtWidgets import QHBoxLayout, QLabel, QListView, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.registries.ignored_registry import IgnoredRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
from tagstudio.qt.utils.custom_runnable import CustomRunnable
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Split to use MVC guidelines.
class RemoveIgnoredModal(QWidget):
done = Signal()
@@ -7,25 +7,18 @@ from typing import TYPE_CHECKING, override
from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt, QThreadPool, Signal
from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import (
QHBoxLayout,
QLabel,
QListView,
QPushButton,
QVBoxLayout,
QWidget,
)
from PySide6.QtWidgets import QHBoxLayout, QLabel, QListView, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.registries.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.translations import Translations
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.progress_bar import ProgressWidget
from tagstudio.qt.utils.custom_runnable import CustomRunnable
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Split to use MVC guidelines.
class RemoveUnlinkedEntriesModal(QWidget):
done = Signal()
+6 -5
View File
@@ -20,9 +20,8 @@ from PySide6.QtWidgets import (
)
from tagstudio.core.enums import ShowFilepathOption, TagClickActionOption
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.global_settings import (
from tagstudio.i18n.translations import DEFAULT_TRANSLATION, LANGUAGES, Translations
from tagstudio.qt.app_settings import (
DEFAULT_CACHED_THUMB_RES,
DEFAULT_THUMB_CACHE_SIZE,
MAX_CACHED_THUMB_RES,
@@ -31,14 +30,16 @@ from tagstudio.qt.global_settings import (
Splash,
Theme,
)
from tagstudio.qt.translations import DEFAULT_TRANSLATION, LANGUAGES, Translations
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.modal_content import ModalContent
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class SettingsPanel(ModalContent):
driver: "QtDriver"
+3 -3
View File
@@ -10,9 +10,9 @@ from PySide6.QtGui import QAction, QColor, QEnterEvent
from PySide6.QtWidgets import QHBoxLayout, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.i18n.translations import Translations
from tagstudio.qt.helpers.escape_text import escape_text
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.stylesheets import (
get_tag_border_color,
get_tag_highlight_color,
get_tag_text_color,
@@ -22,11 +22,11 @@ from tagstudio.qt.views.stylesheets.stylesheets import (
logger = structlog.get_logger(__name__)
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
# TODO: Split to use MVC guidelines.
class TagColorLabel(QWidget):
"""A widget for displaying a tag color's name.
+4 -4
View File
@@ -23,20 +23,20 @@ from PySide6.QtWidgets import (
from tagstudio.core.constants import RESERVED_NAMESPACE_PREFIX
from tagstudio.core.enums import Theme
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.mixed.build_namespace import BuildNamespacePanel
from tagstudio.qt.mixed.color_box import ColorBoxWidget
from tagstudio.qt.mixed.field_widget import FieldContainer
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.stylesheets import header
logger = structlog.get_logger(__name__)
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# TODO: Split to use MVC guidelines.
class TagColorManager(QWidget):
create_namespace_modal: Modal | None = None
+4 -3
View File
@@ -11,9 +11,9 @@ from PySide6.QtWidgets import QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.qt.models.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.i18n.translations import Translations
from tagstudio.qt.views.styles.palette import ColorType, get_tag_color
from tagstudio.qt.views.styles.stylesheets import (
get_tag_border_color,
get_tag_highlight_color,
get_tag_text_color,
@@ -26,6 +26,7 @@ if typing.TYPE_CHECKING:
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class TagColorPreview(QWidget):
on_click = Signal()
@@ -20,11 +20,11 @@ from PySide6.QtWidgets import (
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.models.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.layouts.flow_layout import FlowLayout
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.palette import ColorType, get_tag_color
from tagstudio.qt.views.styles.stylesheets import (
color_swatch_style,
get_tag_border_color,
get_tag_highlight_color,
@@ -35,6 +35,7 @@ from tagstudio.qt.views.stylesheets.stylesheets import (
logger = structlog.get_logger(__name__)
# TODO: Split to use MVC guidelines.
class TagColorSelection(ModalContent):
def __init__(self, library: Library):
super().__init__()
+4 -3
View File
@@ -12,10 +12,10 @@ from PySide6.QtWidgets import QHBoxLayout, QLineEdit, QPushButton, QSizePolicy,
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.i18n.translations import Translations
from tagstudio.qt.helpers.escape_text import escape_text
from tagstudio.qt.models.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import (
from tagstudio.qt.views.styles.palette import ColorType, get_tag_color
from tagstudio.qt.views.styles.stylesheets import (
get_tag_border_color,
get_tag_highlight_color,
get_tag_primary_color,
@@ -31,6 +31,7 @@ if TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
# TODO: Split to use MVC guidelines.
class TagAliasWidget(QWidget):
on_remove = Signal()
+1
View File
@@ -10,6 +10,7 @@ from PySide6.QtWidgets import QHBoxLayout, QLabel
from tagstudio.qt.mixed.field_widget import FieldWidget
# TODO: Split to use MVC guidelines.
class TextContainerWidget(FieldWidget):
def __init__(self, title: str, text: str) -> None:
super().__init__(title)
@@ -56,15 +56,20 @@ from tagstudio.core.utils.module_status import ModuleStatus
from tagstudio.core.utils.ripgrep_status import RipgrepStatus
from tagstudio.core.utils.str_formatting import is_version_outdated
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.platform_strings import trash_term
from tagstudio.i18n.translations import Translations
from tagstudio.qt.app_settings import DEFAULT_GLOBAL_SETTINGS_PATH, AppSettings, Theme
from tagstudio.qt.cache_manager import CacheManager
from tagstudio.qt.controllers.field_template_search_panel_controller import FieldTemplateSearchPanel
from tagstudio.qt.controllers.fix_ignored_modal_controller import FixIgnoredEntriesModal
from tagstudio.qt.controllers.ignore_modal_controller import IgnoreModal
from tagstudio.qt.controllers.library_info_window_controller import LibraryInfoWindow
from tagstudio.qt.controllers.field_template_search_panel import FieldTemplateSearchPanel
from tagstudio.qt.controllers.fix_ignored_modal import FixIgnoredEntriesModal
from tagstudio.qt.controllers.ignore_modal import IgnoreModal
from tagstudio.qt.controllers.library_info_window import LibraryInfoWindow
from tagstudio.qt.controllers.main_window import MainWindow
from tagstudio.qt.controllers.modal import Modal
from tagstudio.qt.controllers.tag_search_panel_controller import TagSearchPanel
from tagstudio.qt.controllers.progress_bar import ProgressWidget
from tagstudio.qt.controllers.splash import SplashScreen
from tagstudio.qt.controllers.tag_search_panel import TagSearchPanel
from tagstudio.qt.controllers.update_available_message_box import UpdateAvailableMessageBox
from tagstudio.qt.global_settings import DEFAULT_GLOBAL_SETTINGS_PATH, GlobalSettings, Theme
from tagstudio.qt.mixed.about_modal import AboutModal
from tagstudio.qt.mixed.build_tag import BuildTagPanel
from tagstudio.qt.mixed.drop_import_modal import DropImportModal
@@ -73,20 +78,15 @@ from tagstudio.qt.mixed.fix_unlinked import FixUnlinkedEntriesModal
from tagstudio.qt.mixed.folders_to_tags import FoldersToTagsModal
from tagstudio.qt.mixed.item_thumb import BadgeType
from tagstudio.qt.mixed.migration_modal import JsonMigrationModal
from tagstudio.qt.mixed.progress_bar import ProgressWidget
from tagstudio.qt.mixed.settings_panel import SettingsPanel
from tagstudio.qt.mixed.tag_color_manager import TagColorManager
from tagstudio.qt.models.palette import ColorType, Palette, UiColor, get_ui_color
from tagstudio.qt.platform_strings import trash_term
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.utils.custom_runnable import CustomRunnable
from tagstudio.qt.utils.file_deleter import delete_file
from tagstudio.qt.utils.function_iterator import FunctionIterator
from tagstudio.qt.views.main_window import MainWindow
from tagstudio.qt.views.search_panel_view import SearchPanelView
from tagstudio.qt.views.splash import SplashScreen
from tagstudio.qt.views.stylesheets.stylesheets import header
from tagstudio.qt.views.styles.palette import ColorType, Palette, UiColor, get_ui_color
from tagstudio.qt.views.styles.stylesheets import header
BADGE_TAGS = {
BadgeType.FAVORITE: TAG_FAVORITE,
@@ -164,6 +164,8 @@ class QtDriver(DriverMixin, QObject):
SIGTERM = Signal()
# TODO: If these signals are removed from the base QtDriver, we can probably get rid of the
# QObject multiple inheritance and make DriverMixin a proper BaseDriver class.
favorite_updated = Signal(bool)
archived_updated = Signal(bool)
@@ -215,7 +217,7 @@ class QtDriver(DriverMixin, QObject):
self.global_settings_path = Path(self.args.settings_file)
else:
logger.info("[Settings] Global Settings File Path not specified, using default")
self.settings = GlobalSettings.read_settings(self.global_settings_path)
self.settings = AppSettings.read_settings(self.global_settings_path)
if not self.global_settings_path.exists():
logger.warning(
"[Settings] Global Settings File does not exist creating",
+3 -3
View File
@@ -8,9 +8,9 @@ from PySide6.QtCore import QObject, QSize, Signal
from PySide6.QtGui import QGuiApplication, QPixmap, Qt
from tagstudio.core.library.alchemy.library import Library
from tagstudio.previews.file_renderer import FileRenderer
from tagstudio.qt.app_settings import AppSettings, Theme
from tagstudio.qt.cache_manager import CacheManager
from tagstudio.qt.global_settings import GlobalSettings, Theme
from tagstudio.qt.previews.renderer import FileRenderer
class QtFileRenderer(QObject):
@@ -19,7 +19,7 @@ class QtFileRenderer(QObject):
updated = Signal(float, QPixmap, QSize, Path)
updated_ratio = Signal(float)
def __init__(self, library: Library, settings: GlobalSettings) -> None:
def __init__(self, library: Library, settings: AppSettings) -> None:
super().__init__()
self.renderer = FileRenderer(library, settings)
self.theme = (
-44
View File
@@ -7,15 +7,10 @@ import subprocess
import sys
import traceback
from pathlib import Path
from typing import override
import structlog
from PySide6.QtCore import Qt
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QLabel, QWidget
from tagstudio.core.utils.silent_subprocess import silent_popen # pyright: ignore
from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger(__name__)
@@ -131,42 +126,3 @@ class FileOpenerHelper:
"""Open the file in the default file explorer."""
if Path(self.filepath).is_file():
open_file(self.filepath, file_manager=True)
class FileOpenerLabel(QLabel):
def __init__(self, parent: QWidget | None = None) -> None:
"""Initialize the FileOpenerLabel.
Args:
parent (QWidget, optional): The parent widget. Defaults to None.
"""
self.filepath: Path | None = None
super().__init__(parent)
def set_file_path(self, filepath: Path) -> None:
"""Set the filepath to open.
Args:
filepath (Path): The path to the file to open.
"""
self.filepath = filepath
@override
def mousePressEvent(self, ev: QMouseEvent) -> None:
"""Handle mouse press events.
On a left click, open the file in the default file explorer.
On a right click, show a context menu.
Args:
ev (QMouseEvent): The mouse press event.
"""
if ev.button() == Qt.MouseButton.LeftButton:
opener = FileOpenerHelper(unwrap(self.filepath))
opener.open_explorer()
elif ev.button() == Qt.MouseButton.RightButton:
# Show context menu
pass
else:
super().mousePressEvent(ev)
@@ -14,10 +14,10 @@ from PySide6.QtWidgets import (
QWidget,
)
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.clickable_label import ClickableLabel
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import checkbox_style
from tagstudio.qt.views.styles.stylesheets import checkbox_style
logger = structlog.get_logger(__name__)
+2 -2
View File
@@ -13,10 +13,10 @@ from PySide6.QtWidgets import (
QWidget,
)
from tagstudio.i18n.translations import Translations
from tagstudio.qt.controllers.clickable_label import ClickableLabel
from tagstudio.qt.controllers.modal_content import ModalContent
from tagstudio.qt.translations import Translations
from tagstudio.qt.views.stylesheets.stylesheets import checkbox_style, title_line_edit_style
from tagstudio.qt.views.styles.stylesheets import checkbox_style, title_line_edit_style
class EditTextView(ModalContent):

Some files were not shown because too many files have changed in this diff Show More