Match additional UI to color scheme

This commit is contained in:
Travis Abendshien
2024-06-15 22:52:48 -07:00
parent d2b5e31792
commit 05a486048c
5 changed files with 33 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ class SettingItems(str, enum.Enum):
class Theme(str, enum.Enum):
COLOR_BG_DARK = "#65000000"
COLOR_BG_LIGHT = "#33000000"
COLOR_BG_LIGHT = "#22000000"
COLOR_DARK_LABEL = "#DD000000"
COLOR_HOVER = "#65AAAAAA"
COLOR_PRESSED = "#65EEEEEE"

View File

@@ -10,7 +10,7 @@ from src.qt.helpers.gradient import linear_gradient
# TODO: Consolidate the built-in QT theme values with the values
# here, in enums.py, and in palette.py.
_THEME_DARK_FG: str = "#FFFFFF55"
_THEME_DARK_FG: str = "#FFFFFF77"
_THEME_LIGHT_FG: str = "#000000DD"
_THEME_DARK_BG: str = "#000000DD"
_THEME_LIGHT_BG: str = "#FFFFFF55"

View File

@@ -14,6 +14,7 @@ from PySide6.QtCore import Qt, QEvent
from PySide6.QtGui import QPixmap, QEnterEvent
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton
from src.qt.helpers.qbutton_wrapper import QPushButtonWrapper
from src.qt.helpers.color_overlay import theme_fg_overlay
class FieldContainer(QWidget):
@@ -47,6 +48,10 @@ class FieldContainer(QWidget):
button_size = 24
# self.setStyleSheet('border-style:solid;border-color:#1e1a33;border-radius:8px;border-width:2px;')
self.clipboard_icon_128 = theme_fg_overlay(FieldContainer.clipboard_icon_128)
self.edit_icon_128 = theme_fg_overlay(FieldContainer.edit_icon_128)
self.trash_icon_128 = theme_fg_overlay(FieldContainer.trash_icon_128)
self.root_layout = QVBoxLayout(self)
self.root_layout.setObjectName("baseLayout")
self.root_layout.setContentsMargins(0, 0, 0, 0)

View File

@@ -9,6 +9,7 @@ import typing
from PySide6.QtCore import Signal, Qt
from PySide6.QtWidgets import QPushButton
from PySide6.QtGui import QGuiApplication
from src.core.constants import TAG_FAVORITE, TAG_ARCHIVED
from src.core.library import Library, Tag
@@ -49,6 +50,22 @@ class TagBoxWidget(FieldWidget):
self.base_layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.base_layout)
bg_color: str = (
"#1E1E1E"
if QGuiApplication.styleHints().colorScheme() is Qt.ColorScheme.Dark
else "#EEEEEE"
)
fg_color: str = (
"#FFFFFF"
if QGuiApplication.styleHints().colorScheme() is Qt.ColorScheme.Dark
else "#444444"
)
ol_color: str = (
"#333333"
if QGuiApplication.styleHints().colorScheme() is Qt.ColorScheme.Dark
else "#F5F5F5"
)
self.add_button = QPushButton()
self.add_button.setCursor(Qt.CursorShape.PointingHandCursor)
self.add_button.setMinimumSize(23, 23)
@@ -56,10 +73,10 @@ class TagBoxWidget(FieldWidget):
self.add_button.setText("+")
self.add_button.setStyleSheet(
f"QPushButton{{"
f"background: #1e1e1e;"
f"color: #FFFFFF;"
f"background: {bg_color};"
f"color: {fg_color};"
f"font-weight: bold;"
f"border-color: #333333;"
f"border-color: {ol_color};"
f"border-radius: 6px;"
f"border-style:solid;"
f"border-width:{math.ceil(1*self.devicePixelRatio())}px;"

View File

@@ -76,10 +76,6 @@ class ThumbRenderer(QObject):
)
thumb_loading_512.load()
# TODO: Allow this to be dynamically updated at runtime
if QGuiApplication.styleHints().colorScheme() is not Qt.ColorScheme.Dark:
thumb_loading_512 = theme_fg_overlay(thumb_loading_512)
thumb_broken_512: Image.Image = Image.open(
Path(__file__).parents[3] / "resources/qt/images/thumb_broken_512.png"
)
@@ -112,6 +108,8 @@ class ThumbRenderer(QObject):
update_on_ratio_change=False,
):
"""Internal renderer. Renders an entry/element thumbnail for the GUI."""
loading_thumb: Image.Image = ThumbRenderer.thumb_loading_512
image: Image.Image = None
pixmap: QPixmap = None
final: Image.Image = None
@@ -124,9 +122,12 @@ class ThumbRenderer(QObject):
math.floor(12 * ThumbRenderer.font_pixel_ratio),
)
if QGuiApplication.styleHints().colorScheme() is Qt.ColorScheme.Light:
loading_thumb = theme_fg_overlay(loading_thumb)
adj_size = math.ceil(max(base_size[0], base_size[1]) * pixel_ratio)
if is_loading:
final = ThumbRenderer.thumb_loading_512.resize(
final = loading_thumb.resize(
(adj_size, adj_size), resample=Image.Resampling.BILINEAR
)
qim = ImageQt.ImageQt(final)
@@ -453,7 +454,6 @@ class ThumbRenderer(QObject):
image: Image.Image = None
try:
logging.info(f"{size}, {pixel_ratio}")
BARS: int = min(math.floor((size // pixel_ratio) / 5), 64)
audio: AudioSegment = AudioSegment.from_file(filepath, ext[1:])
data = numpy.fromstring(audio._data, numpy.int16) # type: ignore
@@ -488,7 +488,6 @@ class ThumbRenderer(QObject):
image = Image.new("RGB", (size_scaled, size_scaled), color="#000000")
draw = ImageDraw.Draw(image)
logging.info(f"data_ind {len(data_indices)}, max_array {len(max_array)}")
current_x = BAR_MARGIN
for item in max_array:
item_height = item / line_ratio