forked from trav/lintunes
v0.69.0: dark mode, with its own grays and a tint per mode
This commit is contained in:
+19
-16
@@ -15,7 +15,7 @@ from lintunes.player import REPEAT_MODES
|
||||
from lintunes import theme
|
||||
|
||||
|
||||
ICON_GRAY = QColor("#4A4A4A")
|
||||
ICON_GRAY = QColor("#4A4A4A") # light mode's; theme.icon_gray() follows the mode
|
||||
|
||||
# Breathing room between the menu bar and the row of boxes.
|
||||
TOP_MARGIN = 9
|
||||
@@ -54,7 +54,12 @@ def _box_style(bg: QColor) -> str:
|
||||
for kind in ("QToolButton", "QPushButton"):
|
||||
face += (f"QFrame#transportBox > {kind}:disabled {{ background:"
|
||||
f" {bg.lighter(104).name()}; border-color: {bg.darker(112).name()}; }}")
|
||||
return face + TILE_STYLE
|
||||
text = theme.text_color().name()
|
||||
return face + TILE_STYLE + f"""
|
||||
QFrame#transportBox QPushButton, QFrame#transportBox QPushButton:disabled {{
|
||||
color: {text};
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
# Where tiles meet: square corners, and one shared line (the later tile
|
||||
@@ -66,11 +71,7 @@ TILE_STYLE = "".join(
|
||||
("first", "border-top-right-radius: 0; border-bottom-right-radius: 0;"),
|
||||
("middle", "border-radius: 0; border-left: none;"),
|
||||
("last", "border-top-left-radius: 0; border-bottom-left-radius: 0;"
|
||||
" border-left: none;"))) + """
|
||||
QFrame#transportBox QPushButton, QFrame#transportBox QPushButton:disabled {
|
||||
color: black;
|
||||
}
|
||||
"""
|
||||
" border-left: none;")))
|
||||
|
||||
|
||||
def _nowplaying_style(bg: QColor) -> str:
|
||||
@@ -142,9 +143,10 @@ class FlashButton(QToolButton):
|
||||
|
||||
def _apply_icon(self, active: bool = False):
|
||||
show_active = active or (self.isCheckable() and self.isChecked())
|
||||
color = self.palette().highlight().color() if show_active else ICON_GRAY
|
||||
rest = theme.icon_gray()
|
||||
color = self.palette().highlight().color() if show_active else rest
|
||||
if not self.isEnabled():
|
||||
color = QColor(ICON_GRAY).lighter(160)
|
||||
color = rest.lighter(160) if not theme.is_dark() else rest.darker(180)
|
||||
self.setIcon(transport_icon(self._kind, color))
|
||||
|
||||
|
||||
@@ -439,7 +441,7 @@ class TransportBar(QWidget):
|
||||
# Rounded button boxes carry a user-tunable grayscale fill, decoupled
|
||||
# from the stripe color they used to share via palette(alternate-base).
|
||||
self._boxes = []
|
||||
box_bg = theme.gray(theme.gray_value(prefs, "color_button"))
|
||||
box_bg = theme.surface(prefs, "color_button")
|
||||
|
||||
self._prev_btn = FlashButton("previous")
|
||||
self._play_btn = FlashButton("play")
|
||||
@@ -581,7 +583,7 @@ class TransportBar(QWidget):
|
||||
self.dj_button.setObjectName("djButton")
|
||||
self.dj_button.setCheckable(True)
|
||||
self.dj_button.setToolTip("DJ mode")
|
||||
self.dj_button.setIcon(turntable_icon(QColor(ICON_GRAY), 22))
|
||||
self.dj_button.setIcon(turntable_icon(theme.icon_gray(), 22))
|
||||
self.dj_button.setIconSize(QSize(30, 22))
|
||||
self.dj_button.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.dj_button.setFixedWidth(52)
|
||||
@@ -635,10 +637,10 @@ class TransportBar(QWidget):
|
||||
def _apply_dj_button_style(self):
|
||||
"""The bpm button under the DJ box wears the shared face (radius 8);
|
||||
the DJ button is styled by its box like shuffle and repeat."""
|
||||
bg = theme.gray(theme.gray_value(self._prefs, "color_button"))
|
||||
bg = theme.surface(self._prefs, "color_button")
|
||||
self._bpm_button.setStyleSheet(theme.button_face_qss(
|
||||
"QPushButton#bpmHeader", bg, radius=8,
|
||||
extra="padding: 0; color: black;"))
|
||||
extra=f"padding: 0; color: {theme.text_color().name()};"))
|
||||
|
||||
def _on_dj_button(self, on: bool):
|
||||
self._on_dj_button_icon(on)
|
||||
@@ -671,7 +673,7 @@ class TransportBar(QWidget):
|
||||
self._on_track_changed(self._current_track)
|
||||
|
||||
def _on_dj_button_icon(self, on: bool):
|
||||
color = self.palette().highlight().color() if on else QColor(ICON_GRAY)
|
||||
color = self.palette().highlight().color() if on else theme.icon_gray()
|
||||
self.dj_button.setIcon(turntable_icon(color, 22))
|
||||
|
||||
def volume_level(self) -> float:
|
||||
@@ -787,16 +789,17 @@ class TransportBar(QWidget):
|
||||
for button in (self._prev_btn, self._play_btn, self._next_btn,
|
||||
self._shuffle_btn, self._repeat_btn):
|
||||
button.refresh_icons()
|
||||
box_bg = theme.gray(theme.gray_value(self._prefs, "color_button"))
|
||||
box_bg = theme.surface(self._prefs, "color_button")
|
||||
for box in self._boxes:
|
||||
box.setStyleSheet(_box_style(box_bg))
|
||||
self._apply_now_playing_bg()
|
||||
self._apply_now_playing_font()
|
||||
self._apply_dj_button_style()
|
||||
self._on_dj_button_icon(self.dj_button.isChecked())
|
||||
self._visualizer.update() # dim-mode bar color may have changed
|
||||
|
||||
def _apply_now_playing_bg(self):
|
||||
bg = theme.gray(theme.gray_value(self._prefs, "color_now_playing_bg"))
|
||||
bg = theme.surface(self._prefs, "color_now_playing_bg")
|
||||
self._now_playing.setStyleSheet(_nowplaying_style(bg))
|
||||
|
||||
def _on_volume_changed(self, value: int):
|
||||
|
||||
Reference in New Issue
Block a user