Skip to content

Commit

Permalink
DarkTheme: Rename of the theme setting and foreground color constant
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Oct 14, 2018
1 parent c9f26fd commit 21178bf
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 188 deletions.
6 changes: 3 additions & 3 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ def setup(self):
"""Setup main window"""
self.debug_print("*** Start of MainWindow setup ***")
self.debug_print(" ..theme configuration")
color_theme = CONF.get('color_schemes', 'color_theme')
ui_theme = CONF.get('color_schemes', 'ui_theme')
color_scheme = CONF.get('color_schemes', 'selected')
if color_theme == 'dark':
if ui_theme == 'dark':
self.setStyleSheet(qdarkstyle.load_stylesheet_from_environment())
elif color_theme == 'automatic':
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
self.setStyleSheet(
qdarkstyle.load_stylesheet_from_environment())
Expand Down
2 changes: 1 addition & 1 deletion spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
}),
('color_schemes',
{
'color_theme': 'automatic',
'ui_theme': 'automatic',
'names': ['emacs', 'idle', 'monokai', 'pydev', 'scintilla',
'spyder', 'spyder/dark', 'zenburn', 'solarized/light',
'solarized/dark'],
Expand Down
45 changes: 22 additions & 23 deletions spyder/preferences/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,14 +1171,13 @@ def setup_page(self):
'selected')
self.schemes_combobox = schemes_combobox_widget.combobox

color_themes = ['Automatic', 'Light', 'Dark']
color_theme_choices = list(zip(color_themes,
[color_theme.lower()
for color_theme in color_themes]))
color_theme_combo = self.create_combobox(_('User interface theme:'),
color_theme_choices,
'color_theme',
restart=True)
ui_themes = ['Automatic', 'Light', 'Dark']
ui_theme_choices = list(zip(ui_themes, [ui_theme.lower()
for ui_theme in ui_themes]))
ui_theme_combo = self.create_combobox(_('Interface theme:'),
ui_theme_choices,
'ui_theme',
restart=True)

# Layouts
manage_layout = QVBoxLayout()
Expand All @@ -1188,12 +1187,12 @@ def setup_page(self):
combo_layout.addWidget(schemes_combobox_widget.label)
combo_layout.addWidget(schemes_combobox_widget.combobox)

color_theme_combo_layout = QHBoxLayout()
color_theme_combo_layout.addWidget(color_theme_combo.label)
color_theme_combo_layout.addWidget(color_theme_combo.combobox)
ui_theme_combo_layout = QHBoxLayout()
ui_theme_combo_layout.addWidget(ui_theme_combo.label)
ui_theme_combo_layout.addWidget(ui_theme_combo.combobox)

buttons_layout = QVBoxLayout()
buttons_layout.addLayout(color_theme_combo_layout)
buttons_layout.addLayout(ui_theme_combo_layout)
buttons_layout.addLayout(combo_layout)
buttons_layout.addWidget(edit_button)
buttons_layout.addWidget(self.reset_button)
Expand Down Expand Up @@ -1237,16 +1236,16 @@ def setup_page(self):
def apply_settings(self, options):
self.set_option('selected', self.current_scheme)
color_scheme = self.get_option('selected')
color_theme = self.get_option('color_theme')
ui_theme = self.get_option('ui_theme')
style_sheet = self.main.styleSheet()
if color_theme == 'automatic':
if ui_theme == 'automatic':
if ((not is_dark_font_color(color_scheme) and not style_sheet)
or (is_dark_font_color(color_scheme) and style_sheet)):
self.changed_options.add('color_theme')
elif 'color_theme' in self.changed_options:
self.changed_options.remove('color_theme')
self.changed_options.add('ui_theme')
elif 'ui_theme' in self.changed_options:
self.changed_options.remove('ui_theme')

if 'color_theme' not in self.changed_options:
if 'ui_theme' not in self.changed_options:
self.main.editor.apply_plugin_settings(['color_scheme_name'])
if self.main.ipyconsole is not None:
self.main.ipyconsole.apply_plugin_settings(
Expand All @@ -1259,12 +1258,12 @@ def apply_settings(self, options):
self.update_combobox()
self.update_preview()
else:
if 'color_theme' in self.changed_options:
if (style_sheet and color_theme == 'dark' or
not style_sheet and color_theme == 'light'):
self.changed_options.remove('color_theme')
if 'ui_theme' in self.changed_options:
if (style_sheet and ui_theme == 'dark' or
not style_sheet and ui_theme == 'light'):
self.changed_options.remove('ui_theme')

if 'color_theme' not in self.changed_options:
if 'ui_theme' not in self.changed_options:
self.main.editor.apply_plugin_settings(['color_scheme_name'])
if self.main.ipyconsole is not None:
self.main.ipyconsole.apply_plugin_settings(
Expand Down
Loading

0 comments on commit 21178bf

Please sign in to comment.