From 62947da4f1ccfb60db5e2216390e8106b22e280a Mon Sep 17 00:00:00 2001 From: conradolandia Date: Thu, 29 Feb 2024 18:29:42 -0500 Subject: [PATCH 1/4] Add DarkPalette and LightPalette as arguments to Dark adn Light palette classes. Replace all instances of QStylePallette with SpyderPalette --- spyder/api/widgets/comboboxes.py | 10 +- spyder/api/widgets/menus.py | 14 +-- spyder/api/widgets/status.py | 6 +- spyder/app/mainwindow.py | 4 +- spyder/app/utils.py | 4 +- spyder/plugins/appearance/confpage.py | 4 +- .../languageserver/conftabs/introspection.py | 4 +- .../languageserver/widgets/serversconfig.py | 4 +- spyder/plugins/console/widgets/console.py | 8 +- .../debugger/widgets/breakpoint_table_view.py | 6 +- .../plugins/debugger/widgets/main_widget.py | 6 +- spyder/plugins/editor/panels/codefolding.py | 4 +- .../editor/widgets/codeeditor/codeeditor.py | 4 +- .../editor/widgets/editorstack/editorstack.py | 4 +- spyder/plugins/editor/widgets/splitter.py | 4 +- .../findinfiles/widgets/main_widget.py | 6 +- .../findinfiles/widgets/results_browser.py | 4 +- .../findinfiles/widgets/tests/test_widgets.py | 6 +- spyder/plugins/help/widgets.py | 4 +- .../plugins/ipythonconsole/widgets/client.py | 6 +- .../plugins/ipythonconsole/widgets/control.py | 4 +- .../ipythonconsole/widgets/main_widget.py | 10 +- .../plugins/ipythonconsole/widgets/shell.py | 4 +- spyder/plugins/mainmenu/plugin.py | 8 +- spyder/plugins/plots/widgets/figurebrowser.py | 8 +- spyder/plugins/plots/widgets/main_widget.py | 4 +- .../preferences/widgets/configdialog.py | 3 + .../plugins/profiler/widgets/main_widget.py | 4 +- spyder/plugins/pylint/main_widget.py | 6 +- spyder/plugins/shortcuts/widgets/table.py | 6 +- spyder/plugins/tours/widgets.py | 18 ++-- .../widgets/dataframeeditor.py | 6 +- spyder/utils/icon_manager.py | 14 +-- spyder/utils/palette.py | 6 +- spyder/utils/qthelpers.py | 4 +- spyder/utils/stylesheet.py | 92 +++++++++---------- spyder/widgets/arraybuilder.py | 6 +- spyder/widgets/browser.py | 8 +- spyder/widgets/dependencies.py | 6 +- spyder/widgets/dock.py | 24 ++--- spyder/widgets/elementstable.py | 14 +-- spyder/widgets/helperwidgets.py | 14 +-- spyder/widgets/mixins.py | 2 +- spyder/widgets/tabs.py | 12 +-- 44 files changed, 199 insertions(+), 196 deletions(-) diff --git a/spyder/api/widgets/comboboxes.py b/spyder/api/widgets/comboboxes.py index 0cc87361dc1..29e7ea2fbc7 100644 --- a/spyder/api/widgets/comboboxes.py +++ b/spyder/api/widgets/comboboxes.py @@ -29,7 +29,7 @@ ) # Local imports -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle, WIN @@ -56,7 +56,7 @@ class _SpyderComboBoxDelegate(QStyledItemDelegate): def paint(self, painter, option, index): data = index.data(Qt.AccessibleDescriptionRole) if data and data == "separator": - painter.setPen(QColor(QStylePalette.COLOR_BACKGROUND_6)) + painter.setPen(QColor(SpyderPalette.COLOR_BACKGROUND_6)) painter.drawLine( option.rect.left() + AppStyle.MarginSize, option.rect.center().y(), @@ -149,7 +149,7 @@ def _generate_stylesheet(self): # Make color of hovered combobox items match the one used in other # Spyder widgets css["QComboBox QAbstractItemView::item:selected:active"].setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_3, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_3, ) return css @@ -231,8 +231,8 @@ def hidePopup(self): # Make borders rounded when popup is not visible. This doesn't work # reliably on Mac. self._css.QComboBox.setValues( - borderBottomLeftRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderBottomRightRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderBottomLeftRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderBottomRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, ) self.setStyleSheet(self._css.toString()) diff --git a/spyder/api/widgets/menus.py b/spyder/api/widgets/menus.py index efb2317a25e..ff0dbb86c50 100644 --- a/spyder/api/widgets/menus.py +++ b/spyder/api/widgets/menus.py @@ -20,7 +20,7 @@ # Local imports from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle, MAC, WIN @@ -386,12 +386,12 @@ def _generate_stylesheet(cls): paddingTop=f'{2 * AppStyle.MarginSize}px', paddingBottom=f'{2 * AppStyle.MarginSize}px', # This uses the same color as the separator - border=f"1px solid {QStylePalette.COLOR_BACKGROUND_6}" + border=f"1px solid {SpyderPalette.COLOR_BACKGROUND_6}" ) # Set the right background color This is the only way to do it! css['QWidget:disabled QMenu'].setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_3, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_3, ) # Add padding around separators to prevent that hovering on items hides @@ -421,19 +421,19 @@ def _generate_stylesheet(cls): # Set hover and pressed state of items for state in ['selected', 'pressed']: if state == 'selected': - bg_color = QStylePalette.COLOR_BACKGROUND_4 + bg_color = SpyderPalette.COLOR_BACKGROUND_4 else: - bg_color = QStylePalette.COLOR_BACKGROUND_5 + bg_color = SpyderPalette.COLOR_BACKGROUND_5 css[f"QMenu::item:{state}"].setValues( backgroundColor=bg_color, - borderRadius=QStylePalette.SIZE_BORDER_RADIUS + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS ) # Set disabled state of items for state in ['disabled', 'selected:disabled']: css[f"QMenu::item:{state}"].setValues( - color=QStylePalette.COLOR_DISABLED, + color=SpyderPalette.COLOR_DISABLED, backgroundColor="transparent" ) diff --git a/spyder/api/widgets/status.py b/spyder/api/widgets/status.py index 233032d8383..e32202ac17f 100644 --- a/spyder/api/widgets/status.py +++ b/spyder/api/widgets/status.py @@ -16,7 +16,7 @@ # Local imports from spyder.api.exceptions import SpyderAPIError from spyder.api.widgets.mixins import SpyderWidgetMixin -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import create_waitspinner @@ -187,8 +187,8 @@ def _stylesheet(self): stylesheet = ("QToolTip {{background-color: {background_color};" "color: {color};" "border: none}}").format( - background_color=QStylePalette.COLOR_ACCENT_2, - color=QStylePalette.COLOR_TEXT_1 + background_color=SpyderPalette.COLOR_ACCENT_2, + color=SpyderPalette.COLOR_TEXT_1 ) return stylesheet diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py index 1c7f5f14894..bc1f0bfec18 100644 --- a/spyder/app/mainwindow.py +++ b/spyder/app/mainwindow.py @@ -84,7 +84,7 @@ from spyder.utils import encoding, programs from spyder.utils.icon_manager import ima from spyder.utils.misc import select_port, getcwd_or_home -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import file_uri, qapplication, start_file from spyder.utils.stylesheet import APP_STYLESHEET @@ -301,7 +301,7 @@ def signal_handler(signum, frame=None): "restart your computer:

netsh winsock reset " "
").format( - color=QStylePalette.COLOR_BACKGROUND_4) + color=SpyderPalette.COLOR_BACKGROUND_4) ) else: self.open_files_server = socket.socket(socket.AF_INET, diff --git a/spyder/app/utils.py b/spyder/app/utils.py index b6ef29216c5..b13d651dec7 100644 --- a/spyder/app/utils.py +++ b/spyder/app/utils.py @@ -32,7 +32,7 @@ from spyder.utils.external.dafsa.dafsa import DAFSA from spyder.utils.image_path_manager import get_image_path from spyder.utils.installers import running_installer_test -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import file_uri, qapplication # For spyder-ide/spyder#7447. @@ -264,7 +264,7 @@ def set_links_color(app): This was taken from QDarkstyle, which is MIT licensed. """ - color = QStylePalette.COLOR_ACCENT_4 + color = SpyderPalette.COLOR_ACCENT_4 qcolor = QColor(color) app_palette = app.palette() diff --git a/spyder/plugins/appearance/confpage.py b/spyder/plugins/appearance/confpage.py index 5566c654283..25bbcf1227e 100644 --- a/spyder/plugins/appearance/confpage.py +++ b/spyder/plugins/appearance/confpage.py @@ -19,7 +19,7 @@ from spyder.config.manager import CONF from spyder.plugins.appearance.widgets import SchemeEditor from spyder.utils import syntaxhighlighters -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle from spyder.widgets.simplecodeeditor import SimpleCodeEditor @@ -490,7 +490,7 @@ def is_dark_interface(self): We need to do this because when applying settings we can't detect correctly the current theme. """ - return dark_color(QStylePalette.COLOR_BACKGROUND_1) + return dark_color(SpyderPalette.COLOR_BACKGROUND_1) def color_scheme_and_ui_theme_mismatch(self, color_scheme, ui_theme): """ diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/introspection.py b/spyder/plugins/completion/providers/languageserver/conftabs/introspection.py index e43afb84c0d..a949c6ef0eb 100644 --- a/spyder/plugins/completion/providers/languageserver/conftabs/introspection.py +++ b/spyder/plugins/completion/providers/languageserver/conftabs/introspection.py @@ -17,7 +17,7 @@ # Local imports from spyder.api.preferences import SpyderPreferencesTab from spyder.config.base import _ -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette class IntrospectionConfigTab(SpyderPreferencesTab): @@ -65,7 +65,7 @@ def __init__(self, parent): 'preload_modules' ) modules_textedit.textbox.setStyleSheet( - f"border: 1px solid {QStylePalette.COLOR_BACKGROUND_2};" + f"border: 1px solid {SpyderPalette.COLOR_BACKGROUND_2};" ) advanced_layout = QVBoxLayout() diff --git a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py index c771695beca..39684408c12 100644 --- a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py +++ b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py @@ -27,7 +27,7 @@ from spyder.config.base import _ from spyder.plugins.completion.api import SUPPORTED_LANGUAGES from spyder.utils.misc import check_connection_port -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.programs import find_program from spyder.widgets.helperwidgets import ItemDelegate from spyder.widgets.simplecodeeditor import SimpleCodeEditor @@ -500,7 +500,7 @@ def __init__(self, parent): self.widths = [] # Needed to compensate for the HTMLDelegate color selection unawareness - self.text_color = QStylePalette.COLOR_TEXT_1 + self.text_color = SpyderPalette.COLOR_TEXT_1 def sortByName(self): """Qt Override.""" diff --git a/spyder/plugins/console/widgets/console.py b/spyder/plugins/console/widgets/console.py index ce9301c1b89..cf5a25bb566 100644 --- a/spyder/plugins/console/widgets/console.py +++ b/spyder/plugins/console/widgets/console.py @@ -15,13 +15,13 @@ from spyder.plugins.editor.widgets.base import TextEditBaseWidget from spyder.plugins.console.utils.ansihandler import ANSIEscapeCodeHandler -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette -MAIN_BG_COLOR = QStylePalette.COLOR_BACKGROUND_1 -MAIN_DEFAULT_FG_COLOR = QStylePalette.COLOR_TEXT_1 +MAIN_BG_COLOR = SpyderPalette.COLOR_BACKGROUND_1 +MAIN_DEFAULT_FG_COLOR = SpyderPalette.COLOR_TEXT_1 MAIN_ERROR_FG_COLOR = SpyderPalette.COLOR_ERROR_1 -MAIN_TB_FG_COLOR = QStylePalette.COLOR_ACCENT_3 +MAIN_TB_FG_COLOR = SpyderPalette.COLOR_ACCENT_3 MAIN_PROMPT_FG_COLOR = SpyderPalette.COLOR_SUCCESS_1 def insert_text_to(cursor, text, fmt): diff --git a/spyder/plugins/debugger/widgets/breakpoint_table_view.py b/spyder/plugins/debugger/widgets/breakpoint_table_view.py index 3f20367b3af..d5a3bbfa24a 100644 --- a/spyder/plugins/debugger/widgets/breakpoint_table_view.py +++ b/spyder/plugins/debugger/widgets/breakpoint_table_view.py @@ -27,7 +27,7 @@ from spyder.api.widgets.main_widget import PluginMainWidgetMenus from spyder.api.widgets.mixins import SpyderWidgetMixin from spyder.utils.sourcecode import disambiguate_fname -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette # --- Constants @@ -205,8 +205,8 @@ def __init__(self, parent, data): css.setValues( borderTopLeftRadius='0px', borderBottomLeftRadius='0px', - borderTopRightRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderBottomRightRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderTopRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderBottomRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, ) self.setStyleSheet(css.toString()) diff --git a/spyder/plugins/debugger/widgets/main_widget.py b/spyder/plugins/debugger/widgets/main_widget.py index 252ba80cf7e..3ca0b3aa92a 100644 --- a/spyder/plugins/debugger/widgets/main_widget.py +++ b/spyder/plugins/debugger/widgets/main_widget.py @@ -26,7 +26,7 @@ FramesBrowser, FramesBrowserState) from spyder.plugins.debugger.widgets.breakpoint_table_view import ( BreakpointTableView, BreakpointTableViewActions) -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette # ============================================================================= @@ -187,7 +187,7 @@ def __init__(self, name=None, plugin=None, parent=None): # This is necessary so that the border radius is maintained when # showing/hiding the breakpoints table self.splitter.setStyleSheet( - f"border-radius: {QStylePalette.SIZE_BORDER_RADIUS}" + f"border-radius: {SpyderPalette.SIZE_BORDER_RADIUS}" ) # Layout @@ -765,7 +765,7 @@ def _update_stylesheet(self, is_table_shown=False): if is_table_shown: border_radius = '0px' else: - border_radius = QStylePalette.SIZE_BORDER_RADIUS + border_radius = SpyderPalette.SIZE_BORDER_RADIUS css = qstylizer.style.StyleSheet() css.setValues( diff --git a/spyder/plugins/editor/panels/codefolding.py b/spyder/plugins/editor/panels/codefolding.py index f51e31c6c75..e8924115d9e 100644 --- a/spyder/plugins/editor/panels/codefolding.py +++ b/spyder/plugins/editor/panels/codefolding.py @@ -35,7 +35,7 @@ from spyder.plugins.editor.utils.editor import (TextHelper, DelayJobRunner, drift_color) from spyder.utils.icon_manager import ima -from spyder.widgets.mixins import EOL_SYMBOLS +from spyder.utils.palette import SpyderPalette class FoldingPanel(Panel): @@ -485,8 +485,8 @@ def _add_fold_decoration(self, block, end_line): deco.block = block deco.select_line() deco.set_background(self._get_scope_highlight_color()) + deco.set_foreground(QColor(SpyderPalette.COLOR_TEXT_4)) deco.set_full_width(flag=True, clear=True) - self._block_decos[start_line] = deco self.editor.decorations.add(deco, key='folded') diff --git a/spyder/plugins/editor/widgets/codeeditor/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor/codeeditor.py index d0ca6d78972..828383da3d9 100644 --- a/spyder/plugins/editor/widgets/codeeditor/codeeditor.py +++ b/spyder/plugins/editor/widgets/codeeditor/codeeditor.py @@ -2126,6 +2126,7 @@ def show_code_analysis_results(self, line_number, block_data): self.show_tooltip( title=_("Code analysis"), text='\n'.join(msglist), + title_color=SpyderPalette.COLOR_ACCENT_4, at_line=line_number, with_html_format=True ) @@ -2271,6 +2272,7 @@ def show_todo(self, line_number, data): self.show_tooltip( title=_("To do"), text=data.todo, + title_color=SpyderPalette.COLOR_ACCENT_4, at_line=line_number, ) @@ -3050,7 +3052,7 @@ def create_new_cell(self): cursor.movePosition(QTextCursor.StartOfBlock) cursor.insertText(firstline) cursor.endEditBlock() - + # ---- Kill ring handlers # Taken from Jupyter's QtConsole # Copyright (c) 2001-2015, IPython Development Team diff --git a/spyder/plugins/editor/widgets/editorstack/editorstack.py b/spyder/plugins/editor/widgets/editorstack/editorstack.py index e0fa5a3778c..cd37a5f76ae 100644 --- a/spyder/plugins/editor/widgets/editorstack/editorstack.py +++ b/spyder/plugins/editor/widgets/editorstack/editorstack.py @@ -49,7 +49,7 @@ from spyder.utils import encoding, sourcecode, syntaxhighlighters from spyder.utils.icon_manager import ima from spyder.utils.misc import getcwd_or_home -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import (add_actions, create_action, create_toolbutton, MENU_SEPARATOR, mimedata2url, set_menu_icons, @@ -648,7 +648,7 @@ def create_top_widgets(self): css.QToolBar.setValues( margin='0px', padding='4px', - borderBottom=f'1px solid {QStylePalette.COLOR_BACKGROUND_4}' + borderBottom=f'1px solid {SpyderPalette.COLOR_BACKGROUND_4}' ) self.top_toolbar.setStyleSheet(css.toString()) diff --git a/spyder/plugins/editor/widgets/splitter.py b/spyder/plugins/editor/widgets/splitter.py index ef6052a6e9c..94f2abf2f7e 100644 --- a/spyder/plugins/editor/widgets/splitter.py +++ b/spyder/plugins/editor/widgets/splitter.py @@ -23,7 +23,7 @@ from spyder.config.base import running_under_pytest from spyder.plugins.editor.widgets.editorstack.editorstack import EditorStack from spyder.py3compat import qbytearray_to_str -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette logger = logging.getLogger(__name__) @@ -274,6 +274,6 @@ def set_layout_settings(self, settings, dont_goto=None): def _stylesheet(self): css = qstylizer.style.StyleSheet() css.QSplitter.setValues( - background=QStylePalette.COLOR_BACKGROUND_1 + background=SpyderPalette.COLOR_BACKGROUND_1 ) return css.toString() diff --git a/spyder/plugins/findinfiles/widgets/main_widget.py b/spyder/plugins/findinfiles/widgets/main_widget.py index c64ebf9fd25..6df16ee8f7c 100644 --- a/spyder/plugins/findinfiles/widgets/main_widget.py +++ b/spyder/plugins/findinfiles/widgets/main_widget.py @@ -26,7 +26,7 @@ MAX_PATH_HISTORY, SearchInComboBox) from spyder.plugins.findinfiles.widgets.search_thread import SearchThread from spyder.utils.misc import regexp_error_msg -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette, SpyderPalette from spyder.utils.stylesheet import AppStyle from spyder.widgets.comboboxes import PatternComboBox from spyder.widgets.helperwidgets import PaneEmptyWidget @@ -34,7 +34,7 @@ # ---- Constants # ----------------------------------------------------------------------------- -MAIN_TEXT_COLOR = QStylePalette.COLOR_TEXT_1 +MAIN_TEXT_COLOR = SpyderPalette.COLOR_TEXT_1 MAX_COMBOBOX_WIDTH = AppStyle.FindMinWidth + 80 # In pixels MIN_COMBOBOX_WIDTH = AppStyle.FindMinWidth - 80 # In pixels @@ -168,7 +168,7 @@ def __init__(self, name=None, plugin=None, parent=None): _("Search the content of text files in any directory using the " "search box.") ) - + self.search_text_edit = PatternComboBox( self, items=search_text, diff --git a/spyder/plugins/findinfiles/widgets/results_browser.py b/spyder/plugins/findinfiles/widgets/results_browser.py index bb48dacc509..5d39d630d1d 100644 --- a/spyder/plugins/findinfiles/widgets/results_browser.py +++ b/spyder/plugins/findinfiles/widgets/results_browser.py @@ -22,7 +22,7 @@ from spyder.plugins.findinfiles.widgets.search_thread import ( ELLIPSIS, MAX_RESULT_LENGTH) from spyder.utils import icon_manager as ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle from spyder.widgets.onecolumntree import OneColumnTree @@ -127,7 +127,7 @@ class ItemDelegate(QStyledItemDelegate): def __init__(self, parent): super().__init__(parent) self._margin = None - self._background_color = QColor(QStylePalette.COLOR_BACKGROUND_3) + self._background_color = QColor(SpyderPalette.COLOR_BACKGROUND_3) self.width = 0 def paint(self, painter, option, index): diff --git a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py index 06eac50cbec..070ce010f83 100644 --- a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py +++ b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py @@ -28,7 +28,7 @@ SearchInComboBoxItems ) from spyder.plugins.findinfiles.widgets.search_thread import SearchThread -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette, SpyderPalette from spyder.utils.stylesheet import APP_STYLESHEET @@ -249,7 +249,7 @@ def test_truncate_result_with_different_input(findinfiles, qtbot, line_input): line_input_expected = line_input expected_result = ( - f'' + f'' f'{line_input_expected[:slice_start]}' f'' f'{line_input_expected[slice_start:slice_end]}' @@ -257,7 +257,7 @@ def test_truncate_result_with_different_input(findinfiles, qtbot, line_input): ) # when - thread = SearchThread(None, '', text_color=QStylePalette.COLOR_TEXT_1) + thread = SearchThread(None, '', text_color=SpyderPalette.COLOR_TEXT_1) truncated_line = thread.truncate_result(line_input, slice_start, slice_end) # then diff --git a/spyder/plugins/help/widgets.py b/spyder/plugins/help/widgets.py index abc7f9bc315..7a465d1f2f8 100644 --- a/spyder/plugins/help/widgets.py +++ b/spyder/plugins/help/widgets.py @@ -35,7 +35,7 @@ from spyder.py3compat import to_text_string from spyder.utils import programs from spyder.utils.image_path_manager import get_image_path -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import start_file from spyder.widgets.browser import FrameWebView from spyder.widgets.comboboxes import EditableComboBox @@ -45,7 +45,7 @@ # --- Constants # ---------------------------------------------------------------------------- -MAIN_BG_COLOR = QStylePalette.COLOR_BACKGROUND_1 +MAIN_BG_COLOR = SpyderPalette.COLOR_BACKGROUND_1 class HelpWidgetActions: diff --git a/spyder/plugins/ipythonconsole/widgets/client.py b/spyder/plugins/ipythonconsole/widgets/client.py index 0755234c950..40e6f95a28f 100644 --- a/spyder/plugins/ipythonconsole/widgets/client.py +++ b/spyder/plugins/ipythonconsole/widgets/client.py @@ -36,7 +36,7 @@ from spyder.utils.image_path_manager import get_image_path from spyder.utils.installers import InstallerIPythonKernelError from spyder.utils.environ import RemoteEnvDialog -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import DialogManager from spyder.plugins.ipythonconsole import SpyderKernelError from spyder.plugins.ipythonconsole.utils.kernel_handler import ( @@ -709,9 +709,9 @@ def show_time(self, end=False): else: fmt = "%H:%M:%S" if end: - color = QStylePalette.COLOR_TEXT_3 + color = SpyderPalette.COLOR_TEXT_3 else: - color = QStylePalette.COLOR_ACCENT_4 + color = SpyderPalette.COLOR_ACCENT_4 text = "%s" \ "" % (color, time.strftime(fmt, time.gmtime(elapsed_time))) diff --git a/spyder/plugins/ipythonconsole/widgets/control.py b/spyder/plugins/ipythonconsole/widgets/control.py index f7abdcfaadd..b51d8c74e1f 100644 --- a/spyder/plugins/ipythonconsole/widgets/control.py +++ b/spyder/plugins/ipythonconsole/widgets/control.py @@ -12,7 +12,7 @@ from qtpy.QtWidgets import QTextEdit # Local imports -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import restore_keyevent from spyder.widgets.calltip import CallTipWidget from spyder.widgets.mixins import (BaseEditMixin, GetHelpMixin, @@ -64,7 +64,7 @@ def insert_horizontal_ruler(self): ruler = QTextFrameFormat() ruler.setHeight(1) ruler.setWidth(10000) - ruler.setBackground(QColor(QStylePalette.COLOR_TEXT_1)) + ruler.setBackground(QColor(SpyderPalette.COLOR_TEXT_1)) cursor = self.textCursor() cursor.movePosition(cursor.End) cursor.insertFrame(ruler) diff --git a/spyder/plugins/ipythonconsole/widgets/main_widget.py b/spyder/plugins/ipythonconsole/widgets/main_widget.py index ce5eeadb3f5..4dadec7d641 100644 --- a/spyder/plugins/ipythonconsole/widgets/main_widget.py +++ b/spyder/plugins/ipythonconsole/widgets/main_widget.py @@ -51,7 +51,7 @@ from spyder.utils import encoding, programs, sourcecode from spyder.utils.envs import get_list_envs from spyder.utils.misc import get_error_match, remove_backslashes -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle from spyder.utils.workers import WorkerManager from spyder.widgets.browser import FrameWebView @@ -67,7 +67,7 @@ # ============================================================================= # ---- Constants # ============================================================================= -MAIN_BG_COLOR = QStylePalette.COLOR_BACKGROUND_1 +MAIN_BG_COLOR = SpyderPalette.COLOR_BACKGROUND_1 # --- Widgets @@ -295,12 +295,12 @@ def __init__(self, name=None, plugin=None, parent=None): self.pager_label = QLabel(_("Press Q to exit pager"), self) pager_label_css = qstylizer.style.StyleSheet() pager_label_css.setValues(**{ - 'background-color': f'{QStylePalette.COLOR_ACCENT_2}', - 'color': f'{QStylePalette.COLOR_TEXT_1}', + 'background-color': f'{SpyderPalette.COLOR_ACCENT_2}', + 'color': f'{SpyderPalette.COLOR_TEXT_1}', 'margin': '2px 1px 1px 1px', 'padding': '5px', 'qproperty-alignment': 'AlignCenter', - 'border-radius': f'{QStylePalette.SIZE_BORDER_RADIUS}' + 'border-radius': f'{SpyderPalette.SIZE_BORDER_RADIUS}' }) self.pager_label.setStyleSheet(pager_label_css.toString()) self.pager_label.hide() diff --git a/spyder/plugins/ipythonconsole/widgets/shell.py b/spyder/plugins/ipythonconsole/widgets/shell.py index 772ac499dd2..e42ed2eae9a 100644 --- a/spyder/plugins/ipythonconsole/widgets/shell.py +++ b/spyder/plugins/ipythonconsole/widgets/shell.py @@ -38,7 +38,7 @@ ControlWidget, DebuggingWidget, FigureBrowserWidget, HelpWidget, NamepaceBrowserWidget, PageControlWidget) from spyder.utils import syntaxhighlighters as sh -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette, SpyderPalette from spyder.utils.clipboard_helper import CLIPBOARD_HELPER from spyder.widgets.helperwidgets import MessageCheckBox @@ -1039,7 +1039,7 @@ def append_html_message(self, html, before_prompt=False, # This makes the header text have good contrast against its background # for the light theme. if is_dark_interface(): - font_color = QStylePalette.COLOR_TEXT_1 + font_color = SpyderPalette.COLOR_TEXT_1 else: font_color = 'white' diff --git a/spyder/plugins/mainmenu/plugin.py b/spyder/plugins/mainmenu/plugin.py index 3b08f1643b9..7751b6c5edb 100644 --- a/spyder/plugins/mainmenu/plugin.py +++ b/spyder/plugins/mainmenu/plugin.py @@ -26,7 +26,7 @@ from spyder.api.widgets.menus import SpyderMenu from spyder.plugins.mainmenu.api import ApplicationMenu, ApplicationMenus from spyder.utils.qthelpers import SpyderAction -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle @@ -122,7 +122,7 @@ def _stylesheet(self): # Set the same color as the one used for the app toolbar css.QMenuBar.setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_4 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_4 ) # Give more padding and margin to items @@ -140,11 +140,11 @@ def _stylesheet(self): for state in ['selected', 'pressed']: # Don't use a different color for the QMenuBar pressed state # because a lighter color has too little contrast with the text. - bg_color = QStylePalette.COLOR_BACKGROUND_5 + bg_color = SpyderPalette.COLOR_BACKGROUND_5 css[f"QMenuBar::item:{state}"].setValues( backgroundColor=bg_color, - borderRadius=QStylePalette.SIZE_BORDER_RADIUS + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS ) return css.toString() diff --git a/spyder/plugins/plots/widgets/figurebrowser.py b/spyder/plugins/plots/widgets/figurebrowser.py index f9e03e90de2..5441be4980b 100644 --- a/spyder/plugins/plots/widgets/figurebrowser.py +++ b/spyder/plugins/plots/widgets/figurebrowser.py @@ -29,7 +29,7 @@ from spyder.api.translations import _ from spyder.api.widgets.mixins import SpyderWidgetMixin from spyder.utils.misc import getcwd_or_home -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.widgets.helperwidgets import PaneEmptyWidget @@ -189,7 +189,7 @@ def __init__(self, parent=None, background_color=None): splitter.setFrameStyle(QScrollArea().frameStyle()) splitter.setContentsMargins(0, 0, 0, 0) splitter.setStyleSheet( - f"border-radius: {QStylePalette.SIZE_BORDER_RADIUS}" + f"border-radius: {SpyderPalette.SIZE_BORDER_RADIUS}" ) self.stack_layout = QStackedLayout() @@ -246,7 +246,7 @@ def show_fig_outline_in_viewer(self, state): if state is True: self.figviewer.figcanvas.setStyleSheet( "FigureCanvas{border: 2px solid %s;}" % - QStylePalette.COLOR_BACKGROUND_4 + SpyderPalette.COLOR_BACKGROUND_4 ) else: self.figviewer.figcanvas.setStyleSheet( @@ -1060,7 +1060,7 @@ def highlight_canvas(self, highlight): # See spyder-ide/spyder#21598 for choice of styling. self.canvas.setStyleSheet( "FigureCanvas{border: 3px solid %s;}" % - QStylePalette.COLOR_ACCENT_3 + SpyderPalette.COLOR_ACCENT_3 ) else: self.canvas.setStyleSheet("FigureCanvas{}") diff --git a/spyder/plugins/plots/widgets/main_widget.py b/spyder/plugins/plots/widgets/main_widget.py index f3be080b3cf..b73d2a263ee 100644 --- a/spyder/plugins/plots/widgets/main_widget.py +++ b/spyder/plugins/plots/widgets/main_widget.py @@ -19,11 +19,11 @@ from spyder.api.shellconnect.main_widget import ShellConnectMainWidget from spyder.plugins.plots.widgets.figurebrowser import FigureBrowser from spyder.utils.misc import getcwd_or_home -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.widgets.helperwidgets import PaneEmptyWidget -MAIN_BG_COLOR = QStylePalette.COLOR_BACKGROUND_1 +MAIN_BG_COLOR = SpyderPalette.COLOR_BACKGROUND_1 # --- Constants diff --git a/spyder/plugins/preferences/widgets/configdialog.py b/spyder/plugins/preferences/widgets/configdialog.py index b93d2ff66a3..0294de25a3d 100644 --- a/spyder/plugins/preferences/widgets/configdialog.py +++ b/spyder/plugins/preferences/widgets/configdialog.py @@ -15,6 +15,9 @@ from spyder.utils.icon_manager import ima from spyder.utils.stylesheet import MAC, WIN from spyder.widgets.sidebardialog import SidebarDialog +from spyder.utils.palette import SpyderPalette +from spyder.utils.stylesheet import ( + AppStyle, MAC, PREFERENCES_TABBAR_STYLESHEET, WIN) class ConfigDialog(SidebarDialog): diff --git a/spyder/plugins/profiler/widgets/main_widget.py b/spyder/plugins/profiler/widgets/main_widget.py index 847e9327630..b106786ea48 100644 --- a/spyder/plugins/profiler/widgets/main_widget.py +++ b/spyder/plugins/profiler/widgets/main_widget.py @@ -39,7 +39,7 @@ from spyder.plugins.variableexplorer.widgets.texteditor import TextEditor from spyder.py3compat import to_text_string from spyder.utils.misc import get_python_executable, getcwd_or_home -from spyder.utils.palette import SpyderPalette, QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.programs import shell_split from spyder.utils.qthelpers import get_item_user_text, set_item_user_text from spyder.widgets.comboboxes import PythonModulesComboBox @@ -52,7 +52,7 @@ # --- Constants # ---------------------------------------------------------------------------- -MAIN_TEXT_COLOR = QStylePalette.COLOR_TEXT_1 +MAIN_TEXT_COLOR = SpyderPalette.COLOR_TEXT_1 class ProfilerWidgetActions: diff --git a/spyder/plugins/pylint/main_widget.py b/spyder/plugins/pylint/main_widget.py index ecbe514ac2f..63187296b6d 100644 --- a/spyder/plugins/pylint/main_widget.py +++ b/spyder/plugins/pylint/main_widget.py @@ -38,7 +38,7 @@ from spyder.utils.icon_manager import ima from spyder.utils.misc import getcwd_or_home, get_home_dir from spyder.utils.misc import get_python_executable -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette from spyder.widgets.comboboxes import (PythonModulesComboBox, is_module_or_package) from spyder.widgets.onecolumntree import OneColumnTree, OneColumnTreeActions @@ -57,8 +57,8 @@ # TODO: There should be some palette from the appearance plugin so this # is easier to use -MAIN_TEXT_COLOR = QStylePalette.COLOR_TEXT_1 -MAIN_PREVRATE_COLOR = QStylePalette.COLOR_TEXT_1 +MAIN_TEXT_COLOR = SpyderPalette.COLOR_TEXT_1 +MAIN_PREVRATE_COLOR = SpyderPalette.COLOR_TEXT_1 class PylintWidgetActions: diff --git a/spyder/plugins/shortcuts/widgets/table.py b/spyder/plugins/shortcuts/widgets/table.py index ca30a52a75b..0a10716191f 100644 --- a/spyder/plugins/shortcuts/widgets/table.py +++ b/spyder/plugins/shortcuts/widgets/table.py @@ -23,7 +23,7 @@ from spyder.api.translations import _ from spyder.config.manager import CONF from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import create_toolbutton from spyder.utils.stringmatching import get_search_regex, get_search_scores from spyder.widgets.helperwidgets import ( @@ -515,8 +515,8 @@ def __init__(self, parent): self.widths = [] # Needed to compensate for the HTMLDelegate color selection unawarness - self.text_color = QStylePalette.COLOR_TEXT_1 - self.text_color_highlight = QStylePalette.COLOR_TEXT_1 + self.text_color = SpyderPalette.COLOR_TEXT_1 + self.text_color_highlight = SpyderPalette.COLOR_TEXT_1 def current_index(self): """Get the currently selected index in the parent table view.""" diff --git a/spyder/plugins/tours/widgets.py b/spyder/plugins/tours/widgets.py index 43bd7821ca5..74343891c72 100644 --- a/spyder/plugins/tours/widgets.py +++ b/spyder/plugins/tours/widgets.py @@ -34,12 +34,12 @@ from spyder.py3compat import to_binary_string from spyder.utils.icon_manager import ima from spyder.utils.image_path_manager import get_image_path -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import add_actions, create_action from spyder.utils.stylesheet import DialogStyle -MAIN_TOP_COLOR = MAIN_BG_COLOR = QColor(QStylePalette.COLOR_BACKGROUND_1) +MAIN_TOP_COLOR = MAIN_BG_COLOR = QColor(SpyderPalette.COLOR_BACKGROUND_1) MAC = sys.platform == 'darwin' @@ -1094,13 +1094,13 @@ def __init__(self, parent, tour_function): # Buttons buttons_layout = QHBoxLayout() - start_tour_color = QStylePalette.COLOR_ACCENT_2 - start_tour_hover = QStylePalette.COLOR_ACCENT_3 - start_tour_pressed = QStylePalette.COLOR_ACCENT_4 - dismiss_tour_color = QStylePalette.COLOR_BACKGROUND_4 - dismiss_tour_hover = QStylePalette.COLOR_BACKGROUND_5 - dismiss_tour_pressed = QStylePalette.COLOR_BACKGROUND_6 - font_color = QStylePalette.COLOR_TEXT_1 + start_tour_color = SpyderPalette.COLOR_ACCENT_2 + start_tour_hover = SpyderPalette.COLOR_ACCENT_3 + start_tour_pressed = SpyderPalette.COLOR_ACCENT_4 + dismiss_tour_color = SpyderPalette.COLOR_BACKGROUND_4 + dismiss_tour_hover = SpyderPalette.COLOR_BACKGROUND_5 + dismiss_tour_pressed = SpyderPalette.COLOR_BACKGROUND_6 + font_color = SpyderPalette.COLOR_TEXT_1 self.launch_tour_button = QPushButton(_('Start tour')) self.launch_tour_button.setStyleSheet(( "QPushButton {{ " diff --git a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py index d8ccec58928..269805dccb1 100644 --- a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py +++ b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py @@ -59,7 +59,7 @@ from spyder.py3compat import (is_text_string, is_type_text_string, to_text_string) from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import keybinding, qapplication from spyder.utils.stylesheet import AppStyle, MAC @@ -143,7 +143,7 @@ class DataframeEditorToolbarSections: BACKGROUND_NUMBER_SATURATION = 0.7 BACKGROUND_NUMBER_VALUE = 1.0 BACKGROUND_NUMBER_ALPHA = 0.6 -BACKGROUND_NONNUMBER_COLOR = QStylePalette.COLOR_BACKGROUND_2 +BACKGROUND_NONNUMBER_COLOR = SpyderPalette.COLOR_BACKGROUND_2 BACKGROUND_STRING_ALPHA = 0.05 BACKGROUND_MISC_ALPHA = 0.3 @@ -1634,7 +1634,7 @@ class DataFrameLevelModel(QAbstractTableModel, SpyderFontsMixin): def __init__(self, model): super().__init__() self.model = model - self._background = QColor(QStylePalette.COLOR_BACKGROUND_2) + self._background = QColor(SpyderPalette.COLOR_BACKGROUND_2) def rowCount(self, index=None): """Get number of rows (number of levels for the header).""" diff --git a/spyder/utils/icon_manager.py b/spyder/utils/icon_manager.py index a0ed56e6faa..35e68177cb4 100644 --- a/spyder/utils/icon_manager.py +++ b/spyder/utils/icon_manager.py @@ -19,7 +19,7 @@ from spyder.config.manager import CONF from spyder.config.utils import EDIT_EXTENSIONS from spyder.utils.image_path_manager import get_image_path -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette import qtawesome as qta @@ -146,9 +146,9 @@ def __init__(self): 'enter_debug': [('mdi.location-enter',), {'color': SpyderPalette.ICON_2}], 'run': [('mdi.play',), {'color': SpyderPalette.ICON_3}], 'todo_list': [('mdi.check-bold',), {'color': self.MAIN_FG_COLOR}], - 'wng_list': [('mdi.alert',), {'options': [{'color': SpyderPalette.COLOR_WARN_2, 'color_disabled': QStylePalette.COLOR_TEXT_4}]}], - 'prev_wng': [('mdi.arrow-left',), {'options': [{'color': SpyderPalette.ICON_1, 'color_disabled': QStylePalette.COLOR_TEXT_4}]}], - 'next_wng': [('mdi.arrow-right',), {'options': [{'color': SpyderPalette.ICON_1, 'color_disabled': QStylePalette.COLOR_TEXT_4}]}], + 'wng_list': [('mdi.alert',), {'options': [{'color': SpyderPalette.COLOR_WARN_2, 'color_disabled': SpyderPalette.COLOR_TEXT_4}]}], + 'prev_wng': [('mdi.arrow-left',), {'options': [{'color': SpyderPalette.ICON_1, 'color_disabled': SpyderPalette.COLOR_TEXT_4}]}], + 'next_wng': [('mdi.arrow-right',), {'options': [{'color': SpyderPalette.ICON_1, 'color_disabled': SpyderPalette.COLOR_TEXT_4}]}], 'prev_cursor': [('mdi.hand-pointing-left',), {'color': self.MAIN_FG_COLOR}], 'next_cursor': [('mdi.hand-pointing-right',), {'color': self.MAIN_FG_COLOR}], 'comment': [('mdi.comment-text-outline',), {'color': self.MAIN_FG_COLOR}], @@ -168,7 +168,7 @@ def __init__(self): 'findf': [('mdi.file-find-outline',), {'color': self.MAIN_FG_COLOR}], 'history': [('mdi.history',), {'color': self.MAIN_FG_COLOR}], 'files': [('mdi.file-multiple',), {'color': self.MAIN_FG_COLOR}], - 'help_gray': [('mdi.help-circle-outline',), {'color': SpyderPalette.COLOR_OCCURRENCE_4}], + 'help_gray': [('mdi.help-circle-outline',), {'color': SpyderPalette.COLOR_OCCURRENCE_4}], 'help': [('mdi.help-circle',), {'color': self.MAIN_FG_COLOR}], 'online_help': [('mdi.help-rhombus-outline',), {'color': self.MAIN_FG_COLOR}], 'lock': [('mdi.lock',), {'color': self.MAIN_FG_COLOR}], @@ -423,7 +423,7 @@ def get_icon(self, name, resample=False): # -- Disabled state # Taken from https://stackoverflow.com/a/65618075/438386 - disabled_color = QColor(QStylePalette.COLOR_DISABLED) + disabled_color = QColor(SpyderPalette.COLOR_DISABLED) disabled_state = wrapping_icon.pixmap(512, 512) qp = QPainter(disabled_state) qp.setCompositionMode(QPainter.CompositionMode_SourceIn) @@ -449,7 +449,7 @@ def icon(self, name, scale_factor=None, resample=False): args, kwargs = self._qtaargs[name] if scale_factor is not None: kwargs['scale_factor'] = scale_factor - kwargs['color_disabled'] = QStylePalette.COLOR_DISABLED + kwargs['color_disabled'] = SpyderPalette.COLOR_DISABLED return qta.icon(*args, **kwargs) except KeyError: # Load custom icons diff --git a/spyder/utils/palette.py b/spyder/utils/palette.py index d63c63ce6c1..467440fb8fc 100644 --- a/spyder/utils/palette.py +++ b/spyder/utils/palette.py @@ -21,7 +21,7 @@ # ============================================================================= # ---- Spyder palettes # ============================================================================= -class SpyderPaletteDark: +class SpyderPaletteDark(DarkPalette): """Dark palette for Spyder.""" # Colors for information and feedback in dialogs @@ -78,7 +78,7 @@ class SpyderPaletteDark: SPYDER_LOGO_WEB = Logos.B40 SPYDER_LOGO_SNAKE = Logos.B50 -class SpyderPaletteLight: +class SpyderPaletteLight(LightPalette): """Light palette for Spyder.""" # Colors for information and feedback in dialogs @@ -140,7 +140,5 @@ class SpyderPaletteLight: # ============================================================================= if is_dark_interface(): SpyderPalette = SpyderPaletteDark - QStylePalette = DarkPalette else: SpyderPalette = SpyderPaletteLight - QStylePalette = LightPalette diff --git a/spyder/utils/qthelpers.py b/spyder/utils/qthelpers.py index 22b25dc8f0f..d631e13889d 100644 --- a/spyder/utils/qthelpers.py +++ b/spyder/utils/qthelpers.py @@ -39,7 +39,7 @@ from spyder.utils.icon_manager import ima from spyder.utils import programs from spyder.utils.image_path_manager import get_image_path -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.registries import ACTION_REGISTRY, TOOLBUTTON_REGISTRY from spyder.widgets.waitingspinner import QWaitingSpinner @@ -312,7 +312,7 @@ def create_waitspinner(size=32, n=11, parent=None): spinner.setLineLength(dot_size) spinner.setLineWidth(dot_size) spinner.setInnerRadius(inner_radius) - spinner.setColor(QStylePalette.COLOR_TEXT_1) + spinner.setColor(SpyderPalette.COLOR_TEXT_1) return spinner diff --git a/spyder/utils/stylesheet.py b/spyder/utils/stylesheet.py index d5acd79340d..7dfcd0c184a 100644 --- a/spyder/utils/stylesheet.py +++ b/spyder/utils/stylesheet.py @@ -22,7 +22,7 @@ from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin from spyder.api.utils import classproperty from spyder.config.gui import is_dark_interface -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette # ============================================================================= @@ -150,7 +150,7 @@ def set_stylesheet(self): This takes the stylesheet from QDarkstyle and applies our customizations to it. """ - stylesheet = qdarkstyle.load_stylesheet(palette=QStylePalette) + stylesheet = qdarkstyle.load_stylesheet(palette=SpyderPalette) self._stylesheet = parse_stylesheet(stylesheet) # Add our customizations @@ -224,9 +224,9 @@ def _customize_stylesheet(self): for state in ['hover', 'pressed', 'checked', 'checked:hover']: if state == 'hover': - color = QStylePalette.COLOR_BACKGROUND_2 + color = SpyderPalette.COLOR_BACKGROUND_2 else: - color = QStylePalette.COLOR_BACKGROUND_3 + color = SpyderPalette.COLOR_BACKGROUND_3 css[f'QToolButton:{state}'].setValues( backgroundColor=color ) @@ -298,7 +298,7 @@ def set_stylesheet(self): # Main background color css.QToolBar.setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_4 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_4 ) # Adjust QToolButton to follow the main toolbar style. @@ -314,9 +314,9 @@ def set_stylesheet(self): for state in ['hover', 'pressed', 'checked', 'checked:hover']: if state == 'hover': - color = QStylePalette.COLOR_BACKGROUND_5 + color = SpyderPalette.COLOR_BACKGROUND_5 else: - color = QStylePalette.COLOR_BACKGROUND_6 + color = SpyderPalette.COLOR_BACKGROUND_6 css[f'QToolBar QToolButton:{state}'].setValues( backgroundColor=color ) @@ -375,7 +375,7 @@ class BaseTabBarStyleSheet(SpyderStyleSheet): def set_stylesheet(self): css = self.get_stylesheet() - buttons_color = QStylePalette.COLOR_BACKGROUND_1 + buttons_color = SpyderPalette.COLOR_BACKGROUND_1 # Set style for scroll buttons css[f'QTabBar{self.OBJECT_NAME} QToolButton'].setValues( @@ -399,9 +399,9 @@ def set_stylesheet(self): # Hover and pressed state for scroll buttons for state in ['hover', 'pressed', 'checked', 'checked:hover']: if state == 'hover': - color = QStylePalette.COLOR_BACKGROUND_2 + color = SpyderPalette.COLOR_BACKGROUND_2 else: - color = QStylePalette.COLOR_BACKGROUND_3 + color = SpyderPalette.COLOR_BACKGROUND_3 css[f'QTabBar{self.OBJECT_NAME} QToolButton:{state}'].setValues( background=color ) @@ -519,9 +519,9 @@ def set_stylesheet(self): self.color_tabs_separator = Gray.B70 if is_dark_interface(): - self.color_selected_tab = QStylePalette.COLOR_ACCENT_2 + self.color_selected_tab = SpyderPalette.COLOR_ACCENT_2 else: - self.color_selected_tab = QStylePalette.COLOR_ACCENT_5 + self.color_selected_tab = SpyderPalette.COLOR_ACCENT_5 # Center tabs to differentiate them from the regular ones. # See spyder-ide/spyder#9763 for details. @@ -536,8 +536,8 @@ def set_stylesheet(self): # Style for selected tabs css['QTabBar::tab:selected'].setValues( color=( - QStylePalette.COLOR_TEXT_1 if is_dark_interface() else - QStylePalette.COLOR_BACKGROUND_1 + SpyderPalette.COLOR_TEXT_1 if is_dark_interface() else + SpyderPalette.COLOR_BACKGROUND_1 ), backgroundColor=self.color_selected_tab, ) @@ -583,14 +583,14 @@ def set_stylesheet(self): # -- Style for not selected tabs css['QTabBar::tab:!selected'].setValues( border='0px', - backgroundColor=QStylePalette.COLOR_BACKGROUND_4, - borderLeft=f'1px solid {QStylePalette.COLOR_BACKGROUND_4}', + backgroundColor=SpyderPalette.COLOR_BACKGROUND_4, + borderLeft=f'1px solid {SpyderPalette.COLOR_BACKGROUND_4}', borderRight=f'1px solid {self.color_tabs_separator}', ) css['QTabBar::tab:!selected:hover'].setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_5, - borderLeftColor=QStylePalette.COLOR_BACKGROUND_5 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5, + borderLeftColor=SpyderPalette.COLOR_BACKGROUND_5 ) # -- Style for the not selected tabs to the right and left of the @@ -598,42 +598,42 @@ def set_stylesheet(self): # Note: For some strange reason, Qt uses the `next-selected` state for # the left tab. css['QTabBar::tab:next-selected'].setValues( - borderRightColor=QStylePalette.COLOR_BACKGROUND_4, + borderRightColor=SpyderPalette.COLOR_BACKGROUND_4, ) css['QTabBar::tab:next-selected:hover'].setValues( borderRightColor=self.color_tabs_separator, - backgroundColor=QStylePalette.COLOR_BACKGROUND_5 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5 ) css['QTabBar::tab:previous-selected'].setValues( - borderLeftColor=QStylePalette.COLOR_BACKGROUND_4, + borderLeftColor=SpyderPalette.COLOR_BACKGROUND_4, ) css['QTabBar::tab:previous-selected:hover'].setValues( borderLeftColor=self.color_tabs_separator, - backgroundColor=f'{QStylePalette.COLOR_BACKGROUND_5}' + backgroundColor=f'{SpyderPalette.COLOR_BACKGROUND_5}' ) # -- First and last tabs have rounded borders css['QTabBar::tab:first'].setValues( - borderTopLeftRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderBottomLeftRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderTopLeftRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderBottomLeftRadius=SpyderPalette.SIZE_BORDER_RADIUS, ) css['QTabBar::tab:last'].setValues( - borderTopRightRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderBottomRightRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderTopRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderBottomRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, ) # -- Last tab doesn't need to show the separator css['QTabBar::tab:last:!selected'].setValues( - borderRightColor=QStylePalette.COLOR_BACKGROUND_4 + borderRightColor=SpyderPalette.COLOR_BACKGROUND_4 ) css['QTabBar::tab:last:!selected:hover'].setValues( - borderRightColor=QStylePalette.COLOR_BACKGROUND_5, - backgroundColor=QStylePalette.COLOR_BACKGROUND_5 + borderRightColor=SpyderPalette.COLOR_BACKGROUND_5, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5 ) # -- Set bottom margin for scroll buttons. @@ -751,58 +751,58 @@ def set_stylesheet(self): # -- Style for not selected tabs css['QTabBar::tab:!selected'].setValues( border='0px', - backgroundColor=QStylePalette.COLOR_BACKGROUND_4, - borderTop=f'1px solid {QStylePalette.COLOR_BACKGROUND_4}', + backgroundColor=SpyderPalette.COLOR_BACKGROUND_4, + borderTop=f'1px solid {SpyderPalette.COLOR_BACKGROUND_4}', borderBottom=f'1px solid {self.color_tabs_separator}', ) css['QTabBar::tab:!selected:hover'].setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_5, - borderTopColor=QStylePalette.COLOR_BACKGROUND_5, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5, + borderTopColor=SpyderPalette.COLOR_BACKGROUND_5, ) # -- Style for the not selected tabs above and below the selected one. css['QTabBar::tab:next-selected'].setValues( - borderBottomColor=QStylePalette.COLOR_BACKGROUND_4, + borderBottomColor=SpyderPalette.COLOR_BACKGROUND_4, ) css['QTabBar::tab:next-selected:hover'].setValues( borderBottomColor=self.color_tabs_separator, - backgroundColor=QStylePalette.COLOR_BACKGROUND_5 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5 ) css['QTabBar::tab:previous-selected'].setValues( - borderTopColor=QStylePalette.COLOR_BACKGROUND_4, + borderTopColor=SpyderPalette.COLOR_BACKGROUND_4, ) css['QTabBar::tab:previous-selected:hover'].setValues( borderTopColor=self.color_tabs_separator, - backgroundColor=f'{QStylePalette.COLOR_BACKGROUND_5}' + backgroundColor=f'{SpyderPalette.COLOR_BACKGROUND_5}' ) # -- First and last tabs have rounded borders. # Also, add margin to avoid them touch the top and bottom borders, # respectively. css['QTabBar::tab:first'].setValues( - borderTopLeftRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderTopRightRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderTopLeftRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderTopRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, marginTop=f'{2 * margin_size}px', ) css['QTabBar::tab:last'].setValues( - borderBottomLeftRadius=QStylePalette.SIZE_BORDER_RADIUS, - borderBottomRightRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderBottomLeftRadius=SpyderPalette.SIZE_BORDER_RADIUS, + borderBottomRightRadius=SpyderPalette.SIZE_BORDER_RADIUS, marginBottom=f'{2 * margin_size}px', ) # -- Last tab doesn't need to show the separator css['QTabBar::tab:last:!selected'].setValues( - borderBottomColor=QStylePalette.COLOR_BACKGROUND_4 + borderBottomColor=SpyderPalette.COLOR_BACKGROUND_4 ) css['QTabBar::tab:last:!selected:hover'].setValues( - borderBottomColor=QStylePalette.COLOR_BACKGROUND_5, - backgroundColor=QStylePalette.COLOR_BACKGROUND_5 + borderBottomColor=SpyderPalette.COLOR_BACKGROUND_5, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5 ) # -- Make style for scroll buttons match the horizontal one @@ -826,8 +826,8 @@ class DialogStyle(SpyderFontsMixin): IconScaleFactor = 0.5 ButtonsPadding = '6px' if MAC else '4px 10px' - BackgroundColor = QStylePalette.COLOR_BACKGROUND_2 - BorderColor = QStylePalette.COLOR_BACKGROUND_5 + BackgroundColor = SpyderPalette.COLOR_BACKGROUND_2 + BorderColor = SpyderPalette.COLOR_BACKGROUND_5 @classproperty def _fs(cls): diff --git a/spyder/widgets/arraybuilder.py b/spyder/widgets/arraybuilder.py index fae62011882..3aab151c413 100644 --- a/spyder/widgets/arraybuilder.py +++ b/spyder/widgets/arraybuilder.py @@ -24,7 +24,7 @@ # Local imports from spyder.config.base import _ from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.widgets.helperwidgets import HelperToolButton # Constants @@ -231,8 +231,8 @@ def __init__(self, parent=None, inline=True, offset=0, force_float=False, background-color: qlineargradient(x1: 1, y1: 1, x2: 1, y2: 1, stop: 0 {stop_0}, stop: 1 {stop_1}); }} - """).format(stop_0=QStylePalette.COLOR_BACKGROUND_4, - stop_1=QStylePalette.COLOR_BACKGROUND_2)) + """).format(stop_0=SpyderPalette.COLOR_BACKGROUND_4, + stop_1=SpyderPalette.COLOR_BACKGROUND_2)) self._button_help.setStyleSheet(style) diff --git a/spyder/widgets/browser.py b/spyder/widgets/browser.py index 32dc100d202..c3f674dbb3d 100644 --- a/spyder/widgets/browser.py +++ b/spyder/widgets/browser.py @@ -26,7 +26,7 @@ from spyder.config.base import DEV from spyder.py3compat import is_text_string, to_text_string from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import (action2button, create_plugin_layout, create_toolbutton) from spyder.widgets.comboboxes import UrlComboBox @@ -598,16 +598,16 @@ def web_widget(self): def _apply_stylesheet(self, focus=False): """Apply stylesheet according to the current focus.""" if focus: - border_color = QStylePalette.COLOR_ACCENT_3 + border_color = SpyderPalette.COLOR_ACCENT_3 else: - border_color = QStylePalette.COLOR_BACKGROUND_4 + border_color = SpyderPalette.COLOR_BACKGROUND_4 css = qstylizer.style.StyleSheet() css.QFrame.setValues( border=f'1px solid {border_color}', margin='0px', padding='0px', - borderRadius=QStylePalette.SIZE_BORDER_RADIUS + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS ) self.setStyleSheet(css.toString()) diff --git a/spyder/widgets/dependencies.py b/spyder/widgets/dependencies.py index 96fe1e5a518..df932052503 100644 --- a/spyder/widgets/dependencies.py +++ b/spyder/widgets/dependencies.py @@ -21,7 +21,7 @@ from spyder.config.gui import is_dark_interface from spyder.dependencies import OPTIONAL, PLUGIN from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle, MAC, WIN from spyder.widgets.helperwidgets import PaneEmptyWidget @@ -68,7 +68,7 @@ def update_dependencies(self, dependencies): # Fix foreground color in the light theme if not is_dark_interface(): item.setForeground( - 2, QColor(QStylePalette.COLOR_BACKGROUND_1) + 2, QColor(SpyderPalette.COLOR_BACKGROUND_1) ) else: item.setIcon(0, ima.icon('dependency_error')) @@ -77,7 +77,7 @@ def update_dependencies(self, dependencies): # Fix foreground color in the light theme if not is_dark_interface(): item.setForeground( - 2, QColor(QStylePalette.COLOR_BACKGROUND_1) + 2, QColor(SpyderPalette.COLOR_BACKGROUND_1) ) # Add to tree diff --git a/spyder/widgets/dock.py b/spyder/widgets/dock.py index aeb0508cd09..e75d368d762 100644 --- a/spyder/widgets/dock.py +++ b/spyder/widgets/dock.py @@ -16,7 +16,7 @@ from spyder.api.translations import _ from spyder.api.config.mixins import SpyderConfigurationAccessor from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import ( PanesToolbarStyleSheet, HORIZONTAL_DOCK_TABBAR_STYLESHEET, VERTICAL_DOCK_TABBAR_STYLESHEET) @@ -136,7 +136,7 @@ def __init__(self, parent, button_size): self.setAutoRaise(True) self.setIcon(ima.icon('lock_open')) self.setToolTip(_("Lock pane")) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_3, 0) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_3, 0) def _apply_stylesheet(self, bgcolor, bradius): css = qstylizer.style.StyleSheet() @@ -151,18 +151,18 @@ def _apply_stylesheet(self, bgcolor, bradius): def enterEvent(self, event): self.setCursor(Qt.ArrowCursor) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_5, 3) - self.parent._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_3) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_5, 3) + self.parent._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_3) self.setIcon(ima.icon('lock')) super().enterEvent(event) def mousePressEvent(self, event): - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_6, 3) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_6, 3) super().mousePressEvent(event) def leaveEvent(self, event): - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_3, 0) - self.parent._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_5) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_3, 0) + self.parent._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_5) self.setIcon(ima.icon('lock_open')) super().leaveEvent(event) @@ -201,28 +201,28 @@ def __init__(self, parent): hlayout.addWidget(right_spacer) hlayout.addWidget(close_button) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_3) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_3) def mouseReleaseEvent(self, event): self.setCursor(Qt.OpenHandCursor) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_5) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_5) QWidget.mouseReleaseEvent(self, event) def mousePressEvent(self, event): self.setCursor(Qt.ClosedHandCursor) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_6) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_6) QWidget.mousePressEvent(self, event) def enterEvent(self, event): # To signal that dock widgets can be dragged from here self.setCursor(Qt.OpenHandCursor) - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_5) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_5) super().enterEvent(event) def leaveEvent(self, event): """Remove customizations when leaving widget.""" self.unsetCursor() - self._apply_stylesheet(QStylePalette.COLOR_BACKGROUND_3) + self._apply_stylesheet(SpyderPalette.COLOR_BACKGROUND_3) super().leaveEvent(event) def _apply_stylesheet(self, bgcolor): diff --git a/spyder/widgets/elementstable.py b/spyder/widgets/elementstable.py index fa80115d67d..8a01dcda146 100644 --- a/spyder/widgets/elementstable.py +++ b/spyder/widgets/elementstable.py @@ -23,7 +23,7 @@ # Local imports from spyder.api.config.fonts import SpyderFontsMixin, SpyderFontType from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle from spyder.widgets.helperwidgets import HoverRowsTableView, HTMLDelegate @@ -87,12 +87,12 @@ def __init__( self.columns['widgets'] = 1 # Text styles - text_color = QStylePalette.COLOR_TEXT_1 + text_color = SpyderPalette.COLOR_TEXT_1 title_font_size = self.get_font( SpyderFontType.Interface, font_size_delta=1).pointSize() self.title_style = f'color:{text_color}; font-size:{title_font_size}pt' - self.additional_info_style = f'color:{QStylePalette.COLOR_TEXT_4}' + self.additional_info_style = f'color:{SpyderPalette.COLOR_TEXT_4}' self.description_style = f'color:{text_color}' # ---- Qt overrides @@ -280,7 +280,7 @@ def _on_hover_index_changed(self, index): # Set background for the new row widget new_row_widget = self.elements[row]["row_widget"] new_row_widget.setStyleSheet( - f"background-color: {QStylePalette.COLOR_BACKGROUND_3}" + f"background-color: {SpyderPalette.COLOR_BACKGROUND_3}" ) # Set new current row widget @@ -289,10 +289,10 @@ def _on_hover_index_changed(self, index): def _set_stylesheet(self, leave=False): """Set stylesheet when entering or leaving the widget.""" css = qstylizer.style.StyleSheet() - bgcolor = QStylePalette.COLOR_BACKGROUND_1 if leave else "transparent" + bgcolor = SpyderPalette.COLOR_BACKGROUND_1 if leave else "transparent" css["QTableView::item"].setValues( - borderBottom=f"1px solid {QStylePalette.COLOR_BACKGROUND_4}", + borderBottom=f"1px solid {SpyderPalette.COLOR_BACKGROUND_4}", paddingLeft="5px", backgroundColor=bgcolor ) @@ -375,7 +375,7 @@ def enterEvent(self, event): # Restore background color that's going to be painted on hovered row if self._current_row_widget is not None: self._current_row_widget.setStyleSheet( - f"background-color: {QStylePalette.COLOR_BACKGROUND_3}" + f"background-color: {SpyderPalette.COLOR_BACKGROUND_3}" ) self._set_stylesheet() diff --git a/spyder/widgets/helperwidgets.py b/spyder/widgets/helperwidgets.py index 59ba88f6903..a33b0f06955 100644 --- a/spyder/widgets/helperwidgets.py +++ b/spyder/widgets/helperwidgets.py @@ -33,7 +33,7 @@ from spyder.config.base import _ from spyder.utils.icon_manager import ima from spyder.utils.stringmatching import get_search_regex -from spyder.utils.palette import QStylePalette, SpyderPalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import AppStyle @@ -166,7 +166,7 @@ def paint(self, painter, option, index): # row (see HoverRowsTableView for an example). if index.row() == self._hovered_row: painter.fillRect( - options.rect, QColor(QStylePalette.COLOR_BACKGROUND_3) + options.rect, QColor(SpyderPalette.COLOR_BACKGROUND_3) ) # Note: We need to pass the options widget as an argument of @@ -339,7 +339,7 @@ def paintEvent(self, event): fm = QFontMetrics(self.font()) text = fm.elidedText(self.text(), self.ellipsis_place, text_rect.width()) - painter.setPen(QColor(QStylePalette.COLOR_TEXT_1)) + painter.setPen(QColor(SpyderPalette.COLOR_TEXT_1)) painter.drawText(text_rect, int(Qt.AlignLeft | Qt.AlignVCenter), text) return @@ -698,16 +698,16 @@ def focusOutEvent(self, event): # ------------------------------------------------------------------------- def _apply_stylesheet(self, focus): if focus: - border_color = QStylePalette.COLOR_ACCENT_3 + border_color = SpyderPalette.COLOR_ACCENT_3 else: - border_color = QStylePalette.COLOR_BACKGROUND_4 + border_color = SpyderPalette.COLOR_BACKGROUND_4 qss = qstylizer.style.StyleSheet() qss.QFrame.setValues( border=f'1px solid {border_color}', margin='0px', padding='0px', - borderRadius=QStylePalette.SIZE_BORDER_RADIUS + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS ) self.setStyleSheet(qss.toString()) @@ -756,7 +756,7 @@ def __init__(self, parent): # over the widget. css = qstylizer.style.StyleSheet() css["QTableView::item"].setValues( - backgroundColor=f"{QStylePalette.COLOR_BACKGROUND_1}" + backgroundColor=f"{SpyderPalette.COLOR_BACKGROUND_1}" ) self._stylesheet = css.toString() diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py index 7519733af94..b52761d6b7a 100644 --- a/spyder/widgets/mixins.py +++ b/spyder/widgets/mixins.py @@ -36,7 +36,7 @@ from spyder.utils import syntaxhighlighters as sh from spyder.utils.misc import get_error_match from spyder.utils.color_system import Green, Orange -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.widgets.arraybuilder import ArrayBuilderDialog diff --git a/spyder/widgets/tabs.py b/spyder/widgets/tabs.py index 225303f9cad..c138b3cd7f2 100644 --- a/spyder/widgets/tabs.py +++ b/spyder/widgets/tabs.py @@ -30,7 +30,7 @@ from spyder.py3compat import to_text_string from spyder.utils.icon_manager import ima from spyder.utils.misc import get_common_path -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.qthelpers import (add_actions, create_action, create_toolbutton) from spyder.utils.stylesheet import MAC, PANES_TABBAR_STYLESHEET, WIN @@ -169,16 +169,16 @@ def __init__(self, parent, index): self.setIconSize(QSize(size, size)) # Colors for different states - self._selected_tab_color = QStylePalette.COLOR_BACKGROUND_5 - self._not_selected_tab_color = QStylePalette.COLOR_BACKGROUND_4 + self._selected_tab_color = SpyderPalette.COLOR_BACKGROUND_5 + self._not_selected_tab_color = SpyderPalette.COLOR_BACKGROUND_4 - self._hover_selected_tab_color = QStylePalette.COLOR_BACKGROUND_6 - self._hover_not_selected_tab_color = QStylePalette.COLOR_BACKGROUND_5 + self._hover_selected_tab_color = SpyderPalette.COLOR_BACKGROUND_6 + self._hover_not_selected_tab_color = SpyderPalette.COLOR_BACKGROUND_5 self._clicked_selected_tab_color = ( Gray.B70 if is_dark_interface() else Gray.B80 ) - self._clicked_not_selected_tab_color = QStylePalette.COLOR_BACKGROUND_6 + self._clicked_not_selected_tab_color = SpyderPalette.COLOR_BACKGROUND_6 # To keep track of the tab's current color self._tab_color = self._selected_tab_color From a092bee342a03d8de236609b00045222aaa777ca Mon Sep 17 00:00:00 2001 From: conradolandia Date: Thu, 29 Feb 2024 20:16:05 -0500 Subject: [PATCH 2/4] Find and replace some remaining instances of QStylePalette --- spyder/widgets/calltip.py | 10 +++++----- spyder/widgets/mixins.py | 4 ++-- spyder/widgets/sidebardialog.py | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spyder/widgets/calltip.py b/spyder/widgets/calltip.py index 1525bfd40ba..a420d46f0fc 100644 --- a/spyder/widgets/calltip.py +++ b/spyder/widgets/calltip.py @@ -31,12 +31,12 @@ # Local imports from spyder.config.gui import is_dark_interface -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette BACKGROUND_COLOR = ( - QStylePalette.COLOR_BACKGROUND_4 if is_dark_interface() else - QStylePalette.COLOR_BACKGROUND_2 + SpyderPalette.COLOR_BACKGROUND_4 if is_dark_interface() else + SpyderPalette.COLOR_BACKGROUND_2 ) @@ -137,7 +137,7 @@ def _stylesheet(self): css["ToolTipWidget"].setValues( backgroundColor=BACKGROUND_COLOR, - border=f"1px solid {QStylePalette.COLOR_TEXT_4}" + border=f"1px solid {SpyderPalette.COLOR_TEXT_4}" ) return css.toString() @@ -682,7 +682,7 @@ def _stylesheet(self): css["CallTipWidget"].setValues( backgroundColor=BACKGROUND_COLOR, - border=f"1px solid {QStylePalette.COLOR_TEXT_4}" + border=f"1px solid {SpyderPalette.COLOR_TEXT_4}" ) return css.toString() diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py index b52761d6b7a..bd71663bdd2 100644 --- a/spyder/widgets/mixins.py +++ b/spyder/widgets/mixins.py @@ -62,8 +62,8 @@ ] # Tips style -TIP_TEXT_COLOR = QStylePalette.COLOR_TEXT_2 -TIP_PARAMETER_HIGHLIGHT_COLOR = QStylePalette.COLOR_TEXT_1 +TIP_TEXT_COLOR = SpyderPalette.COLOR_TEXT_2 +TIP_PARAMETER_HIGHLIGHT_COLOR = SpyderPalette.COLOR_TEXT_1 TIP_TITLE_COLOR = Green.B80 if is_dark_interface() else Green.B20 TIP_CHAR_HIGHLIGHT_COLOR = Orange.B90 if is_dark_interface() else Orange.B30 diff --git a/spyder/widgets/sidebardialog.py b/spyder/widgets/sidebardialog.py index 5996ef64c60..6ac23a9fcac 100644 --- a/spyder/widgets/sidebardialog.py +++ b/spyder/widgets/sidebardialog.py @@ -30,7 +30,7 @@ # Local imports from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin from spyder.utils.icon_manager import ima -from spyder.utils.palette import QStylePalette +from spyder.utils.palette import SpyderPalette from spyder.utils.stylesheet import ( AppStyle, MAC, @@ -439,18 +439,18 @@ def _generate_contents_stylesheet(self): # This also sets the background color of the vertical scrollbar # associated to this widget css.setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_2 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_2 ) # Main style css.QListView.setValues( padding=f'{self.ITEMS_MARGIN}px 0px', - border=f'1px solid {QStylePalette.COLOR_BACKGROUND_2}', + border=f'1px solid {SpyderPalette.COLOR_BACKGROUND_2}', ) # Remove border color on focus css['QListView:focus'].setValues( - border=f'1px solid {QStylePalette.COLOR_BACKGROUND_2}', + border=f'1px solid {SpyderPalette.COLOR_BACKGROUND_2}', ) # Add margin and padding for items @@ -462,13 +462,13 @@ def _generate_contents_stylesheet(self): # Set border radius and background color for hover, active and inactive # states of items css['QListView::item:hover'].setValues( - borderRadius=QStylePalette.SIZE_BORDER_RADIUS, + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS, ) for state in ['item:selected:active', 'item:selected:!active']: css[f'QListView::{state}'].setValues( - borderRadius=QStylePalette.SIZE_BORDER_RADIUS, - backgroundColor=QStylePalette.COLOR_BACKGROUND_4 + borderRadius=SpyderPalette.SIZE_BORDER_RADIUS, + backgroundColor=SpyderPalette.COLOR_BACKGROUND_4 ) return css @@ -479,7 +479,7 @@ def _contents_scrollbar_stylesheet(self): # Give border a darker color to stand out over the background css.setValues( - border=f"1px solid {QStylePalette.COLOR_BACKGROUND_5}" + border=f"1px solid {SpyderPalette.COLOR_BACKGROUND_5}" ) return css.toString() @@ -490,7 +490,7 @@ def _separators_stylesheet(self): # This makes separators stand out better over the background css.setValues( - backgroundColor=QStylePalette.COLOR_BACKGROUND_5 + backgroundColor=SpyderPalette.COLOR_BACKGROUND_5 ) return css.toString() From 1342b8ae778e7eae48bfb635476353cad5c5384b Mon Sep 17 00:00:00 2001 From: conradolandia Date: Fri, 1 Mar 2024 11:21:14 -0500 Subject: [PATCH 3/4] Fix errors introduced with the last squash merge --- spyder/plugins/editor/panels/codefolding.py | 3 +-- spyder/plugins/editor/widgets/codeeditor/codeeditor.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/spyder/plugins/editor/panels/codefolding.py b/spyder/plugins/editor/panels/codefolding.py index e8924115d9e..d0b3196f56b 100644 --- a/spyder/plugins/editor/panels/codefolding.py +++ b/spyder/plugins/editor/panels/codefolding.py @@ -35,7 +35,7 @@ from spyder.plugins.editor.utils.editor import (TextHelper, DelayJobRunner, drift_color) from spyder.utils.icon_manager import ima -from spyder.utils.palette import SpyderPalette +from spyder.utils.palette import EOL_SYMBOLS class FoldingPanel(Panel): @@ -485,7 +485,6 @@ def _add_fold_decoration(self, block, end_line): deco.block = block deco.select_line() deco.set_background(self._get_scope_highlight_color()) - deco.set_foreground(QColor(SpyderPalette.COLOR_TEXT_4)) deco.set_full_width(flag=True, clear=True) self._block_decos[start_line] = deco self.editor.decorations.add(deco, key='folded') diff --git a/spyder/plugins/editor/widgets/codeeditor/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor/codeeditor.py index 828383da3d9..15590374175 100644 --- a/spyder/plugins/editor/widgets/codeeditor/codeeditor.py +++ b/spyder/plugins/editor/widgets/codeeditor/codeeditor.py @@ -2126,7 +2126,6 @@ def show_code_analysis_results(self, line_number, block_data): self.show_tooltip( title=_("Code analysis"), text='\n'.join(msglist), - title_color=SpyderPalette.COLOR_ACCENT_4, at_line=line_number, with_html_format=True ) @@ -2272,7 +2271,6 @@ def show_todo(self, line_number, data): self.show_tooltip( title=_("To do"), text=data.todo, - title_color=SpyderPalette.COLOR_ACCENT_4, at_line=line_number, ) From ae23f34e15da1fbd494d64e0fb516a18efaa98df Mon Sep 17 00:00:00 2001 From: conradolandia Date: Fri, 1 Mar 2024 13:49:50 -0500 Subject: [PATCH 4/4] Fix wrong immport call introduced by the last commit --- spyder/plugins/editor/panels/codefolding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder/plugins/editor/panels/codefolding.py b/spyder/plugins/editor/panels/codefolding.py index d0b3196f56b..982f5ea549a 100644 --- a/spyder/plugins/editor/panels/codefolding.py +++ b/spyder/plugins/editor/panels/codefolding.py @@ -35,7 +35,7 @@ from spyder.plugins.editor.utils.editor import (TextHelper, DelayJobRunner, drift_color) from spyder.utils.icon_manager import ima -from spyder.utils.palette import EOL_SYMBOLS +from spyder.widgets.mixins import EOL_SYMBOLS class FoldingPanel(Panel):