mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-01-30 06:40:50 +00:00
Merge branch 'Alpha-v9.4' into thumbnails
This commit is contained in:
@@ -61,7 +61,7 @@ def folders_to_tags(library: Library):
|
||||
library.add_tag_to_library(new_tag)
|
||||
branch["dirs"][folder] = dict(dirs={}, tag=new_tag)
|
||||
branch = branch["dirs"][folder]
|
||||
return branch["tag"]
|
||||
return branch.get("tag")
|
||||
|
||||
for tag in library.tags:
|
||||
reversed_tag = reverse_tag(library, tag, None)
|
||||
|
||||
@@ -12,6 +12,7 @@ from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
)
|
||||
|
||||
from src.core.constants import TAG_COLORS
|
||||
from src.core.library import Library
|
||||
from src.qt.widgets.panel import PanelWidget, PanelModal
|
||||
from src.qt.widgets.tag import TagWidget
|
||||
@@ -103,8 +104,28 @@ class TagDatabasePanel(PanelWidget):
|
||||
# Get tag ids to keep this behaviorally identical
|
||||
tags = [t.id for t in self.lib.tags]
|
||||
|
||||
if query:
|
||||
# sort tags by whether the tag's name is the text that's matching the search, alphabetically, and then by color
|
||||
sorted_tags = sorted(
|
||||
tags,
|
||||
key=lambda tag_id: (
|
||||
not self.lib.get_tag(tag_id).name.lower().startswith(query.lower()),
|
||||
self.lib.get_tag(tag_id).display_name(self.lib),
|
||||
TAG_COLORS.index(self.lib.get_tag(tag_id).color.lower()),
|
||||
),
|
||||
)
|
||||
else:
|
||||
# sort tags by color and then alphabetically
|
||||
sorted_tags = sorted(
|
||||
tags,
|
||||
key=lambda tag_id: (
|
||||
TAG_COLORS.index(self.lib.get_tag(tag_id).color.lower()),
|
||||
self.lib.get_tag(tag_id).display_name(self.lib),
|
||||
),
|
||||
)
|
||||
|
||||
first_id_set = False
|
||||
for tag_id in tags:
|
||||
for tag_id in sorted_tags:
|
||||
if not first_id_set:
|
||||
self.first_tag_id = tag_id
|
||||
first_id_set = True
|
||||
|
||||
@@ -17,6 +17,7 @@ from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
)
|
||||
|
||||
from src.core.constants import TAG_COLORS
|
||||
from src.core.library import Library
|
||||
from src.core.palette import ColorType, get_tag_color
|
||||
from src.qt.widgets.panel import PanelWidget
|
||||
@@ -84,6 +85,7 @@ class TagSearchPanel(PanelWidget):
|
||||
|
||||
self.root_layout.addWidget(self.search_field)
|
||||
self.root_layout.addWidget(self.scroll_area)
|
||||
self.update_tags("")
|
||||
|
||||
# def reset(self):
|
||||
# self.search_field.setText('')
|
||||
@@ -110,7 +112,27 @@ class TagSearchPanel(PanelWidget):
|
||||
found_tags = self.lib.search_tags(query, include_cluster=True)[: self.tag_limit]
|
||||
self.first_tag_id = found_tags[0] if found_tags else None
|
||||
|
||||
for tag_id in found_tags:
|
||||
if query:
|
||||
# sort tags by whether the tag's name is the text that's matching the search, alphabetically, and then by color
|
||||
sorted_tags = sorted(
|
||||
found_tags,
|
||||
key=lambda tag_id: (
|
||||
not self.lib.get_tag(tag_id).name.lower().startswith(query.lower()),
|
||||
self.lib.get_tag(tag_id).display_name(self.lib),
|
||||
TAG_COLORS.index(self.lib.get_tag(tag_id).color.lower()),
|
||||
),
|
||||
)
|
||||
else:
|
||||
# sort tags by color and then alphabetically
|
||||
sorted_tags = sorted(
|
||||
found_tags,
|
||||
key=lambda tag_id: (
|
||||
TAG_COLORS.index(self.lib.get_tag(tag_id).color.lower()),
|
||||
self.lib.get_tag(tag_id).display_name(self.lib),
|
||||
),
|
||||
)
|
||||
|
||||
for tag_id in sorted_tags:
|
||||
c = QWidget()
|
||||
l = QHBoxLayout(c)
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
@@ -883,10 +883,9 @@ class ThumbRenderer(QObject):
|
||||
else Image.Resampling.BILINEAR
|
||||
)
|
||||
image = image.resize((new_x, new_y), resample=resampling_method)
|
||||
mask: Image.Image = None
|
||||
if gradient:
|
||||
mask: Image.Image = self._get_mask(
|
||||
(adj_size, adj_size), pixel_ratio
|
||||
)
|
||||
mask = self._get_mask((adj_size, adj_size), pixel_ratio)
|
||||
edge: tuple[Image.Image, Image.Image] = self._get_edge(
|
||||
(adj_size, adj_size), pixel_ratio
|
||||
)
|
||||
@@ -896,7 +895,7 @@ class ThumbRenderer(QObject):
|
||||
)
|
||||
else:
|
||||
scalar = 4
|
||||
mask: Image.Image = self._get_mask(image.size, pixel_ratio)
|
||||
mask = self._get_mask(image.size, pixel_ratio)
|
||||
# rec: Image.Image = Image.new(
|
||||
# "RGB",
|
||||
# tuple([d * scalar for d in image.size]), # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user