Skip to content

Commit 03b8f8d

Browse files
authored
Title editor: Convert opacity to QColor alpha level (#3331)
This lets us display and retain the opacity in use, both initially and between edits.
1 parent f1f32a1 commit 03b8f8d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/windows/title_editor.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ def btnFontColor_clicked(self):
354354
if col.isValid():
355355
self.set_font_color_elements(col.name(), col.alphaF())
356356
self.update_font_color_button()
357-
self.font_color_code = col
358357

359358
# Something changed, so update temp SVG
360359
self.writeToFile(self.xmldoc)
@@ -374,7 +373,6 @@ def btnBackgroundColor_clicked(self):
374373
if col.isValid():
375374
self.set_bg_style(col.name(), col.alphaF())
376375
self.update_background_color_button()
377-
self.bg_color_code = col
378376

379377
# Something changed, so update temp SVG
380378
self.writeToFile(self.xmldoc)
@@ -461,13 +459,13 @@ def update_font_color_button(self):
461459
else:
462460
text_color = QtGui.QColor(Qt.black)
463461

464-
# Convert the opacity into the alpha value
465-
alpha = int(opacity * 65535.0)
466-
467-
# Set the colors of the button
462+
# Set the color of the button, ignoring alpha
468463
self.btnFontColor.setStyleSheet(
469464
"background-color: %s; opacity: %s; color: %s;"
470-
% (color.name(), alpha, text_color.name()))
465+
% (color.name(), 1, text_color.name()))
466+
467+
# Store the opacity as the color's alpha level
468+
color.setAlphaF(opacity)
471469
self.font_color_code = color
472470

473471
def update_background_color_button(self):
@@ -519,13 +517,13 @@ def update_background_color_button(self):
519517
else:
520518
text_color = QtGui.QColor(Qt.black)
521519

522-
# Convert the opacity into the alpha value
523-
alpha = int(opacity * 65535.0)
524-
525-
# Set the colors of the button
520+
# Set the colors of the button, ignoring opacity
526521
self.btnBackgroundColor.setStyleSheet(
527522
"background-color: %s; opacity: %s; color: %s;"
528-
% (color.name(), alpha, text_color.name()))
523+
% (color.name(), 1, text_color.name()))
524+
525+
# Store the opacity as the color's alpha level
526+
color.setAlphaF(opacity)
529527
self.bg_color_code = color
530528

531529
def set_font_style(self):

0 commit comments

Comments
 (0)