Skip to content

Commit

Permalink
调整搜索界面样式,调整深色主题下死亡数标签的颜色 (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Nov 19, 2024
1 parent 1fd739f commit d7b7b4d
Show file tree
Hide file tree
Showing 9 changed files with 485 additions and 261 deletions.
10 changes: 6 additions & 4 deletions app/common/style_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ def __getStyleSheetColor(color: QColor):

f1, f2 = 1.1, 0.9

type_conversion = lambda x: int(x)
r1, g1, b1 = map(type_conversion, [min(r * f1, 255), min(g * f1, 255), min(b * f1, 255)])
r2, g2, b2 = map(type_conversion, [min(r * f2, 255), min(g * f2, 255), min(b * f2, 255)])
a1, a2 = map(type_conversion, [min(a + 25, 255), min(a + 50, 255)])
def toInt(x): return int(x)
r1, g1, b1 = map(toInt, [min(
r * f1, 255), min(g * f1, 255), min(b * f1, 255)])
r2, g2, b2 = map(toInt, [min(
r * f2, 255), min(g * f2, 255), min(b * f2, 255)])
a1, a2 = map(toInt, [min(a + 25, 255), min(a + 50, 255)])

c1 = QColor.fromRgb(r1, g1, b1, a1)
c2 = QColor.fromRgb(r2, g2, b2, a2)
Expand Down
24 changes: 22 additions & 2 deletions app/components/color_label.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QHBoxLayout, QPushButton, QLabel, QFrame

from PyQt5.QtWidgets import QLabel
from PyQt5.QtGui import QColor
from app.common.style_sheet import ColorChangeable
from app.common.qfluentwidgets import isDarkTheme


class ColorLabel(QLabel, ColorChangeable):
Expand All @@ -14,3 +15,22 @@ def __init__(self, text: str = None, type: str = None, parent=None):

def setColor(self, c1, c2, c3, c4):
self.setStyleSheet(f"ColorLabel {{color: {c1.name()}}}")


class DeathsLabel(ColorLabel):
def __init__(self, text: str = None, parent=None):
super().__init__(text=text, type='lose', parent=parent)

def setColor(self, c1: QColor, c2, c3, c4):
r, g, b, a = c1.getRgb()

if isDarkTheme():
r = int(min(255, (r+50)*1.4))
g = int(min(255, (g+50)*1.4))
b = int(min(255, (b+50)*1.4))
else:
r = int(min(255, r*0.9))
g = int(min(255, g*0.9))
b = int(min(255, b*0.9))

self.setStyleSheet(f"ColorLabel {{color: rgb({r}, {g}, {b});}}")
4 changes: 2 additions & 2 deletions app/components/game_infobar_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from app.common.signals import signalBus
from app.common.config import cfg
from app.components.champion_icon_widget import RoundIcon, RoundedLabel
from app.components.color_label import ColorLabel
from app.components.color_label import ColorLabel, DeathsLabel
from app.components.animation_frame import CardWidget, ColorAnimationFrame


Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, items, kills, deaths, assists, cs, gold, parent=None):

self.kills = QLabel(f"{kills}")
self.slash1 = QLabel("/")
self.deaths = ColorLabel(f"{deaths}", type='lose')
self.deaths = DeathsLabel(f"{deaths}")
self.slash2 = QLabel("/")
self.assists = QLabel(f"{assists}")

Expand Down
Binary file modified app/resource/i18n/Seraphine.zh_CN.qm
Binary file not shown.
Loading

0 comments on commit d7b7b4d

Please sign in to comment.