Application wide updates for dark mode support including dark canvas option and better colors

This commit is contained in:
Ali Khalil
2022-04-17 22:41:02 +03:00
parent adad500f15
commit 5cc869c1fd
93 changed files with 690 additions and 567 deletions

View File

@@ -26,9 +26,9 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
if theme_settings.contains("theme"):
theme = theme_settings.value('theme', type=str)
else:
theme = 'white'
theme = 'light'
if theme == 'white':
if theme == 'light':
self.resource_loc = 'assets/resources'
else:
self.resource_loc = 'assets/resources'
@@ -37,7 +37,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# Grid Settings Frame
# #############################################################################################################
# GRID Settings
self.grid_label = FCLabel('<span style="color:magenta;"><b>%s</b></span>' % _('Grid Settings'))
self.grid_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('magenta'), _('Grid Settings')))
self.layout.addWidget(self.grid_label)
grids_frame = FCFrame()
@@ -90,7 +90,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# Workspace Frame
# #############################################################################################################
# Workspace
self.workspace_label = FCLabel('<span style="color:brown;"><b>%s</b></span>' % _('Workspace Settings'))
self.workspace_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('brown'), _('Workspace Settings')))
self.layout.addWidget(self.workspace_label)
wk_frame = FCFrame()
@@ -191,7 +191,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# Font Frame
# #############################################################################################################
# Font Size
self.font_size_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Font Size'))
self.font_size_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('green'), _('Font Size')))
self.layout.addWidget(self.font_size_label)
fnt_frame = FCFrame()
@@ -283,7 +283,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# Axis Frame
# #############################################################################################################
# Axis Size
self.axis_label = FCLabel('<span style="color:brown;"><b>%s</b></span>' % _('Axis'))
self.axis_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('brown'), _('Axis')))
self.layout.addWidget(self.axis_label)
ax_frame = FCFrame()
@@ -305,7 +305,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# #############################################################################################################
# Mouse Frame
# #############################################################################################################
self.mouse_lbl = FCLabel('<span style="color:darkorange;"><b>%s</b></span>' % _('Mouse Settings'))
self.mouse_lbl = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('darkorange'), _('Mouse Settings')))
self.layout.addWidget(self.mouse_lbl)
m_frame = FCFrame()
@@ -408,7 +408,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
# #############################################################################################################
# Parameters Frame
# #############################################################################################################
self.par_label = FCLabel('<b><font color="blue">%s</font></b>' % _('Parameters'))
self.par_label = FCLabel('<b><font color="%s">%s</font></b>' % (self.app.theme_safe_color('blue'), _('Parameters')))
self.layout.addWidget(self.par_label)
par_frame = FCFrame()
@@ -496,9 +496,14 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
if theme_settings.contains("theme"):
theme = theme_settings.value('theme', type=str)
else:
theme = 'white'
theme = 'light'
if theme == 'white':
if theme_settings.contains("dark_canvas"):
dark_canvas = theme_settings.value('dark_canvas', type=bool)
else:
dark_canvas = True
if theme == 'light' and not dark_canvas:
self.app.cursor_color_3D = 'black'
else:
self.app.cursor_color_3D = 'gray'
@@ -509,4 +514,4 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
def on_axis_color_entry(self):
self.app.options['global_axis_color'] = self.axis_color_entry.get_value()
self.app.plotcanvas.apply_axis_color()
self.app.plotcanvas.apply_axis_color()

View File

@@ -28,7 +28,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
# #############################################################################################################
# Grid0 Frame
# #############################################################################################################
self.unitslabel = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Units'))
self.unitslabel = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('red'), _('Units')))
self.unitslabel.setToolTip(_("The default value for the application units.\n"
"Whatever is selected here is set every time\n"
"the application is started."))
@@ -76,7 +76,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
grid0.addWidget(self.precision_inch_label, 4, 0)
grid0.addWidget(self.precision_inch_entry, 4, 1)
self.par_label = FCLabel('<span style="color:blue;"><b>%s</b></span>' % _("Parameters"))
self.par_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('blue'), _("Parameters")))
self.layout.addWidget(self.par_label)
# #############################################################################################################
@@ -166,7 +166,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
# #############################################################################################################
# Grid0 Frame
# #############################################################################################################
self.app_level_label = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Application Level'))
self.app_level_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('red'), _('Application Level')))
self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
"BASIC level -> reduced functionality, best for beginner's.\n"
"ADVANCED level -> full functionality.\n\n"
@@ -189,7 +189,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
# Grid3 Frame
# #############################################################################################################
# Languages for FlatCAM
self.languagelabel = FCLabel('<span style="color:DarkCyan;"><b>%s</b></span>' % _('Languages'))
self.languagelabel = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('DarkCyan'), _('Languages')))
self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
self.layout.addWidget(self.languagelabel)
@@ -213,7 +213,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
# ----------- APPLICATION STARTUP SETTINGS ------------------
# -----------------------------------------------------------
self.startup_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Startup Settings'))
self.startup_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('green'), _('Startup Settings')))
self.layout.addWidget(self.startup_label)
# #############################################################################################################
@@ -284,7 +284,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
# Save Settings
self.save_label = FCLabel('<span style="color:purple;"><b>%s</b></span>' % _("Save Settings"))
self.save_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('purple'), _("Save Settings")))
self.layout.addWidget(self.save_label)
# #############################################################################################################
@@ -346,7 +346,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
# self.as_ois = OptionalInputSection(self.autosave_cb, [self.autosave_label, self.autosave_entry], True)
self.pdf_param_label = FCLabel('<span style="color:orange;"><b>%s</b></span>' % _("Text to PDF parameters"))
self.pdf_param_label = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('orange'), _("Text to PDF parameters")))
self.pdf_param_label.setToolTip(
_("Used when saving text in Code Editor or in FlatCAM Document objects.")
)

View File

@@ -292,9 +292,14 @@ class GeneralAppSettingsGroupUI(OptionsGroupUI2):
if theme_settings.contains("theme"):
theme = theme_settings.value('theme', type=str)
else:
theme = 'white'
theme = 'light'
if theme == 'white':
if theme_settings.contains("dark_canvas"):
dark_canvas = theme_settings.value('dark_canvas', type=bool)
else:
dark_canvas = True
if theme == 'light' and not dark_canvas:
self.app.cursor_color_3D = 'black'
else:
self.app.cursor_color_3D = 'gray'

View File

@@ -22,7 +22,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.decimals = app.decimals
self.options = app.options
self.param_lbl = FCLabel('<span style="color:blue;"><b>%s</b></span>' % _("Parameters"))
self.param_lbl = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('blue'), _("Parameters")))
self.layout.addWidget(self.param_lbl)
# #############################################################################################################
@@ -35,7 +35,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
par_frame.setLayout(grid0)
# Theme selection
self.appearance_label = FCLabel('%s:' % _('Theme'))
self.appearance_label = FCLabel('<b>%s</b>' % _('Theme'))
self.appearance_label.setToolTip(
_("Select a theme for the application.\n"
"It will theme the plot area.")
@@ -52,8 +52,16 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
"Dark: Dark mode")
)
grid0.addWidget(self.appearance_label, 0, 0)
grid0.addWidget(self.appearance_radio, 0, 1)
# Dark Canvas
self.dark_canvas_cb = FCCheckBox('%s' % _('Always use dark canvas'))
self.dark_canvas_cb.setToolTip(
_("Check this box to always use Dark canvas\n"
"even if Light theme is selected.")
)
grid0.addWidget(self.appearance_label, 0, 0, 1, 2)
grid0.addWidget(self.appearance_radio, 1, 0, 1, 3)
grid0.addWidget(self.dark_canvas_cb, 2, 0, 1, 3)
# self.theme_button = FCButton(_("Apply Theme"))
# self.theme_button.setToolTip(
@@ -143,7 +151,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
# #############################################################################################################
# Grid1 Frame
# #############################################################################################################
self.color_lbl = FCLabel('<span style="color:teal;"><b>%s</b></span>' % _("Colors"))
self.color_lbl = FCLabel('<span style="color:%s;"><b>%s</b></span>' % (self.app.theme_safe_color('teal'), _("Colors")))
self.layout.addWidget(self.color_lbl)
color_frame = FCFrame()
@@ -296,6 +304,11 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
grid1.addWidget(self.proj_color_dis_l_label, 32, 0)
grid1.addWidget(self.proj_color_dis_light_entry, 32, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid1.addWidget(separator_line, 33, 0, 1, 2)
# Dark Theme
self.proj_settings_d_label = FCLabel('<b>%s</b> - %s' % (_('Project Items Color'), _("Dark")))
grid1.addWidget(self.proj_settings_d_label, 34, 0, 1, 2)