mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
better
This commit is contained in:
parent
d4d48d6f97
commit
4ee96ce991
@ -1,4 +1,4 @@
|
|||||||
from PyQt5.QtCore import Qt, QPoint
|
from PyQt5.QtCore import Qt, QPoint, QPointF
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QTextCharFormat,
|
QTextCharFormat,
|
||||||
QTextBlockFormat,
|
QTextBlockFormat,
|
||||||
@ -78,16 +78,22 @@ class PlainLabel(QLabel):
|
|||||||
|
|
||||||
|
|
||||||
class ShadowLabel(PlainLabel):
|
class ShadowLabel(PlainLabel):
|
||||||
def setColorWidth(self, colorshadow, colortext, width, deepth):
|
def setShadow(self, colorshadow, colortext, width, deepth, trace=False):
|
||||||
shadow2 = QGraphicsDropShadowEffect_multi(deepth)
|
shadow2 = QGraphicsDropShadowEffect_multi(deepth)
|
||||||
shadow2.setBlurRadius(width)
|
if trace:
|
||||||
shadow2.setOffset(0)
|
|
||||||
|
shadow2.setBlurRadius(width)
|
||||||
|
shadow2.setOffset(QPointF(width, width))
|
||||||
|
else:
|
||||||
|
shadow2.setBlurRadius(width)
|
||||||
|
shadow2.setOffset(0)
|
||||||
|
self.setStyleSheet("color:{}; background-color:(0,0,0,0)".format(colortext))
|
||||||
shadow2.setColor(QColor(colorshadow))
|
shadow2.setColor(QColor(colorshadow))
|
||||||
self.setGraphicsEffect(shadow2)
|
self.setGraphicsEffect(shadow2)
|
||||||
self.setStyleSheet("color:{}; background-color:(0,0,0,0)".format(colortext))
|
|
||||||
|
|
||||||
|
|
||||||
class BorderedLabel(QLabel):
|
class BorderedLabel(ShadowLabel):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.m_outLineColor = QColor()
|
self.m_outLineColor = QColor()
|
||||||
@ -153,15 +159,6 @@ class BorderedLabel(QLabel):
|
|||||||
elif self._type == 1:
|
elif self._type == 1:
|
||||||
painter.fillPath(path, QBrush(self.m_contentColor))
|
painter.fillPath(path, QBrush(self.m_contentColor))
|
||||||
painter.strokePath(path, pen)
|
painter.strokePath(path, pen)
|
||||||
elif self._type == 2:
|
|
||||||
w = self.m_fontOutLineWidth
|
|
||||||
while w > 0:
|
|
||||||
painter.fillPath(
|
|
||||||
path.translated(w, w),
|
|
||||||
self.m_contentColor,
|
|
||||||
)
|
|
||||||
w -= 0.2
|
|
||||||
painter.fillPath(path, self.m_outLineColor)
|
|
||||||
|
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.drawPixmap(0, 0, self._pix)
|
painter.drawPixmap(0, 0, self._pix)
|
||||||
@ -702,15 +699,15 @@ class Textbrowser:
|
|||||||
label = BorderedLabel(p)
|
label = BorderedLabel(p)
|
||||||
label.setColorWidth(c1, c2, globalconfig["miaobianwidth"], 1)
|
label.setColorWidth(c1, c2, globalconfig["miaobianwidth"], 1)
|
||||||
elif globalconfig["zitiyangshi2"] == 4:
|
elif globalconfig["zitiyangshi2"] == 4:
|
||||||
|
|
||||||
label = BorderedLabel(p)
|
label = BorderedLabel(p)
|
||||||
label.setColorWidth(c1, c2, globalconfig["traceoffset"], 2)
|
label.setColorWidth(c2, c1, globalconfig["miaobianwidth2"])
|
||||||
|
label.setShadow(c2, None, globalconfig["traceoffset"], 1, True)
|
||||||
elif globalconfig["zitiyangshi2"] == 0:
|
elif globalconfig["zitiyangshi2"] == 0:
|
||||||
label = PlainLabel(p)
|
label = PlainLabel(p)
|
||||||
label.setStyleSheet("color:{}; background-color:(0,0,0,0)".format(c1))
|
label.setStyleSheet("color:{}; background-color:(0,0,0,0)".format(c1))
|
||||||
elif globalconfig["zitiyangshi2"] == 5:
|
elif globalconfig["zitiyangshi2"] == 5:
|
||||||
label = ShadowLabel(p)
|
label = ShadowLabel(p)
|
||||||
label.setColorWidth(
|
label.setShadow(
|
||||||
c1, c2, globalconfig["fontsize"], globalconfig["shadowforce"]
|
c1, c2, globalconfig["fontsize"], globalconfig["shadowforce"]
|
||||||
)
|
)
|
||||||
return label
|
return label
|
||||||
|
Loading…
x
Reference in New Issue
Block a user