mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 15:49:09 +00:00
ui: show fields in preview panel
known issues: - fields to not visually update after being edited until the entries are reloaded from the thumbnail grid (yes, the thumbnail grid) - add field button currently non-functional - surprise segfaults
This commit is contained in:
@@ -524,6 +524,7 @@ class ItemThumb(FlowWidget):
|
||||
if toggle_value:
|
||||
self.lib.add_tags_to_entry(entry_id, tag_id)
|
||||
else:
|
||||
# TODO: Implement
|
||||
self.lib.remove_tag_from_entry(entry_id, tag_id)
|
||||
|
||||
if self.driver.preview_panel.is_open:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,46 +23,50 @@ class RecentLibraries(QWidget):
|
||||
def __init__(self, library: Library, driver: "QtDriver"):
|
||||
super().__init__()
|
||||
|
||||
# # keep list of rendered libraries to avoid needless re-rendering
|
||||
# self.render_libs: set = set()
|
||||
# self.library = library
|
||||
# self.driver = driver
|
||||
# layout = QVBoxLayout()
|
||||
|
||||
# # keep list of rendered libraries to avoid needless re-rendering
|
||||
# self.render_libs: set = set()
|
||||
# self.library = library
|
||||
# self.driver = driver
|
||||
# layout = QVBoxLayout()
|
||||
# settings = driver.settings
|
||||
# settings.beginGroup(SettingItems.LIBS_LIST)
|
||||
# lib_items: dict[str, tuple[str, str]] = {}
|
||||
# for item_tstamp in settings.allKeys():
|
||||
# val = str(settings.value(item_tstamp, type=str))
|
||||
# cut_val = val
|
||||
# if len(val) > 45:
|
||||
# cut_val = f"{val[0:10]} ... {val[-10:]}"
|
||||
# lib_items[item_tstamp] = (val, cut_val)
|
||||
|
||||
# settings = driver.settings
|
||||
# settings.beginGroup(SettingItems.LIBS_LIST)
|
||||
# lib_items: dict[str, tuple[str, str]] = {}
|
||||
# for item_tstamp in settings.allKeys():
|
||||
# val = str(settings.value(item_tstamp, type=str))
|
||||
# cut_val = val
|
||||
# if len(val) > 45:
|
||||
# cut_val = f"{val[0:10]} ... {val[-10:]}"
|
||||
# lib_items[item_tstamp] = (val, cut_val)
|
||||
# settings.endGroup()
|
||||
|
||||
# settings.endGroup()
|
||||
# new_keys = set(lib_items.keys())
|
||||
# if new_keys == self.render_libs:
|
||||
# # no need to re-render
|
||||
# return
|
||||
|
||||
# new_keys = set(lib_items.keys())
|
||||
# if new_keys == self.render_libs:
|
||||
# # no need to re-render
|
||||
# return
|
||||
# # sort lib_items by the key
|
||||
# libs_sorted = sorted(lib_items.items(), key=lambda item: item[0], reverse=True)
|
||||
|
||||
# # sort lib_items by the key
|
||||
# libs_sorted = sorted(lib_items.items(), key=lambda item: item[0], reverse=True)
|
||||
# self.render_libs = new_keys
|
||||
# self.setLayout(layout)
|
||||
|
||||
# self.render_libs = new_keys
|
||||
# self.setLayout(layout)
|
||||
# self._fill_libs_widget(libs_sorted, layout)
|
||||
|
||||
# self._fill_libs_widget(libs_sorted, layout)
|
||||
# def _fill_libs_widget(
|
||||
# self,
|
||||
# libraries: list[tuple[str, tuple[str, str]]],
|
||||
# layout: QVBoxLayout,
|
||||
# ):
|
||||
# def clear_layout(layout_item: QVBoxLayout):
|
||||
# for i in reversed(range(layout_item.count())):
|
||||
# child = layout_item.itemAt(i)
|
||||
# if child.widget() is not None:
|
||||
# child.widget().deleteLater()
|
||||
# elif child.layout() is not None:
|
||||
# clear_layout(child.layout()) # type: ignore
|
||||
|
||||
# def _fill_libs_widget(self, libraries: list[tuple[str, tuple[str, str]]], layout: QVBoxLayout):
|
||||
# def clear_layout(layout_item: QVBoxLayout):
|
||||
# for i in reversed(range(layout_item.count())):
|
||||
# child = layout_item.itemAt(i)
|
||||
# if child.widget() is not None:
|
||||
# child.widget().deleteLater()
|
||||
# elif child.layout() is not None:
|
||||
# clear_layout(child.layout()) # type: ignore
|
||||
|
||||
# # remove any potential previous items
|
||||
# clear_layout(layout)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Licensed under the GPL-3.0 License.
|
||||
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
|
||||
|
||||
import traceback
|
||||
import typing
|
||||
from pathlib import Path
|
||||
|
||||
@@ -64,8 +65,9 @@ class PreviewPanel(QWidget):
|
||||
splitter.addWidget(self.thumb)
|
||||
splitter.addWidget(self.thumb.media_player)
|
||||
splitter.addWidget(self.file_attrs)
|
||||
splitter.addWidget(self.fields)
|
||||
# splitter.addWidget(self.libs_flow_container)
|
||||
splitter.setStretchFactor(1, 2)
|
||||
splitter.setStretchFactor(3, 2)
|
||||
|
||||
root_layout = QHBoxLayout(self)
|
||||
root_layout.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -91,7 +93,8 @@ class PreviewPanel(QWidget):
|
||||
# self.file_attrs.update_blank()
|
||||
self.file_attrs.update_stats()
|
||||
self.file_attrs.update_date_label()
|
||||
pass
|
||||
|
||||
# One Item Selected
|
||||
elif len(self.driver.selected) == 1:
|
||||
entry: Entry = items[0]
|
||||
filepath: Path = self.lib.library_dir / entry.path
|
||||
@@ -99,19 +102,21 @@ class PreviewPanel(QWidget):
|
||||
|
||||
stats: dict = self.thumb.update_preview(filepath, ext)
|
||||
logger.info("stats", stats=stats, ext=ext)
|
||||
self.file_attrs.update_stats(filepath, ext, stats)
|
||||
self.file_attrs.update_date_label(filepath)
|
||||
# TODO: Render regular single selection
|
||||
# TODO: Return known attributes from thumb, and give those to field_attrs
|
||||
# self.file_attrs.update_filename()
|
||||
pass
|
||||
try:
|
||||
self.file_attrs.update_stats(filepath, ext, stats)
|
||||
self.file_attrs.update_date_label(filepath)
|
||||
self.fields.update_from_entry(entry)
|
||||
except Exception as e:
|
||||
logger.error("[Preview Panel] Error updating selection", error=e)
|
||||
traceback.print_exc()
|
||||
|
||||
# Multiple Selected Items
|
||||
elif len(self.driver.selected) > 1:
|
||||
# Render mixed selection
|
||||
self.file_attrs.update_multi_selection(len(self.driver.selected))
|
||||
self.file_attrs.update_date_label()
|
||||
# self.fields.update_from_entries(items)
|
||||
# self.file_attrs.update_selection_count()
|
||||
pass
|
||||
|
||||
# self.thumb.update_widgets()
|
||||
# # self.file_attrs.update_widgets()
|
||||
|
||||
Reference in New Issue
Block a user