Commit cd79aa29 authored by dmMaze's avatar dmMaze
Browse files

fix apply gradient & update CN translation

parent 6abcb4d2
Loading
Loading
Loading
Loading
+691 B (18.2 KiB)

File changed.

No diff preview for this file type.

+194 −93

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -84,13 +84,13 @@ class TextGradientGroup(QGroupBox):
        self.on_param_changed = on_param_changed

        self.start_picker = SmallColorPickerLabel(self, param_name='gradient_start_color')
        start_picker_label = SmallParamLabel(self.tr('Start Color'))
        start_picker_label = SmallParamLabel(self.tr('Start Color'), alignment=Qt.AlignmentFlag.AlignCenter)
        start_picker_layout = QHBoxLayout()
        start_picker_layout.addWidget(start_picker_label)
        start_picker_layout.addWidget(self.start_picker)

        self.end_picker = SmallColorPickerLabel(self, param_name='gradient_end_color')
        end_picker_label = SmallParamLabel(self.tr('End Color'))
        end_picker_label = SmallParamLabel(self.tr('End Color'), alignment=Qt.AlignmentFlag.AlignCenter)
        end_picker_layout = QHBoxLayout()
        end_picker_layout.addWidget(end_picker_label)
        end_picker_layout.addWidget(self.end_picker)
+29 −20
Original line number Diff line number Diff line
@@ -636,6 +636,10 @@ class TextBlkItem(QGraphicsTextItem):

        self.document().setDefaultFont(font)
        format.setFont(font)
        if ffmat.gradient_enabled:
            gradient = self.get_text_gradient(ffmat)
            format.setForeground(gradient)
        else:
            format.setForeground(QColor(*ffmat.foreground_color()))
        if not ffmat.bold:
            format.setFontWeight(fweight)
@@ -816,10 +820,20 @@ class TextBlkItem(QGraphicsTextItem):
        self.fontformat.gradient_enabled = value
        cursor, after_kwargs = self._before_set_ffmt(set_selected, restore_cursor)
        cfmt = QTextCharFormat()

        if value:
            gradient = self.get_text_gradient()
            cfmt.setForeground(gradient)
        else:
            cfmt.setForeground(QColor(*self.fontformat.frgb))

        self.set_cursor_cfmt(cursor, cfmt, True)
        self._after_set_ffmt(cursor, repaint_background, restore_cursor, **after_kwargs)

    def get_text_gradient(self, fontformat: FontFormat = None):
        gradient = QLinearGradient()
            angle = self.fontformat.gradient_angle
        if fontformat is None:
            fontformat = self.fontformat
        angle = fontformat.gradient_angle
        rad = math.radians(angle)
        dx = math.cos(rad)
        dy = math.sin(rad)
@@ -827,21 +841,16 @@ class TextBlkItem(QGraphicsTextItem):
        # Set gradient points with size adjustment
        rect = self.boundingRect()
        center = rect.center()
            radius = max(rect.width(), rect.height()) * self.fontformat.gradient_size
        radius = max(rect.width(), rect.height()) * fontformat.gradient_size
        gradient.setStart(center.x() - dx * radius, center.y() - dy * radius)
        gradient.setFinalStop(center.x() + dx * radius, center.y() + dy * radius)
        
        # Set gradient colors
            start_color = QColor(*self.fontformat.gradient_start_color)
            end_color = QColor(*self.fontformat.gradient_end_color)
        start_color = QColor(*fontformat.gradient_start_color)
        end_color = QColor(*fontformat.gradient_end_color)
        gradient.setColorAt(0, start_color)
        gradient.setColorAt(1, end_color)
            cfmt.setForeground(gradient)
        else:
            cfmt.setForeground(QColor(*self.fontformat.frgb))

        self.set_cursor_cfmt(cursor, cfmt, True)
        self._after_set_ffmt(cursor, repaint_background, restore_cursor, **after_kwargs)
        return gradient

    def setLineSpacing(self, value: float, repaint_background: bool = True, set_selected: bool = False, restore_cursor: bool = False):
        self.is_formatting = True
+1 −1

File changed.

Contains only whitespace changes.