Skip to content

Commit

Permalink
have colorpicker respect application theme
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 20, 2024
1 parent 28a783d commit 1f8924a
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,27 @@ def get_icon(self, name):


def open_theme_dialog(self):
color = QColorDialog().getColor()
colorpicker = QColorDialog(self)
colorpicker.setStyleSheet(config.get('theme'))
colorpicker.setWindowTitle("OnTheSpot - Notice")

if color.isValid():
r, g, b = color.red(), color.green(), color.blue()
luminance = (0.299 * r + 0.587 * g + 0.114 * b)
if colorpicker.exec() == QColorDialog.DialogCode.Accepted:
color = colorpicker.selectedColor()

if luminance < 128:
# Dark color, set light font
stylesheet = f'background-color: {color.name()}; color: white;'
else:
# Light color, set dark font
stylesheet = f'background-color: {color.name()}; color: black;'
config.set_('theme', stylesheet)
config.update()
self.centralwidget.setStyleSheet(stylesheet)
self.__splash_dialog.update_theme(stylesheet)
if color.isValid():
r, g, b = color.red(), color.green(), color.blue()
luminance = (0.299 * r + 0.587 * g + 0.114 * b)

if luminance < 128:
# Dark color, set light font
stylesheet = f'background-color: {color.name()}; color: white;'
else:
# Light color, set dark font
stylesheet = f'background-color: {color.name()}; color: black;'
config.set_('theme', stylesheet)
config.update()
self.centralwidget.setStyleSheet(stylesheet)
self.__splash_dialog.update_theme(stylesheet)


def bind_button_inputs(self):
Expand Down

0 comments on commit 1f8924a

Please sign in to comment.