diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py b/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py index aa44d1c7a9d..32b74a65088 100644 --- a/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py +++ b/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py @@ -19,7 +19,7 @@ from spyder.plugins.completion.api import SUPPORTED_LANGUAGES from spyder.plugins.completion.providers.languageserver.widgets import ( LSPServerTable) -from spyder.utils.icon_manager import ima + LSP_URL = "https://microsoft.github.io/language-server-protocol" @@ -45,7 +45,7 @@ def __init__(self, parent): # Servers table table_group = QGroupBox(_('Available servers:')) - self.table = LSPServerTable(self, text_color=ima.MAIN_FG_COLOR) + self.table = LSPServerTable(self) self.table.setMaximumHeight(150) table_layout = QVBoxLayout() table_layout.addWidget(self.table) diff --git a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py index 2dc8e2d0043..1777b89799f 100644 --- a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py +++ b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py @@ -26,6 +26,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.programs import find_program from spyder.widgets.helperwidgets import ItemDelegate from spyder.widgets.simplecodeeditor import SimpleCodeEditor @@ -484,7 +485,7 @@ def get_options(self): class LSPServersModel(QAbstractTableModel): - def __init__(self, parent, text_color=None, text_color_highlight=None): + def __init__(self, parent): QAbstractTableModel.__init__(self) self._parent = parent @@ -498,17 +499,7 @@ def __init__(self, parent, text_color=None, text_color_highlight=None): self.widths = [] # Needed to compensate for the HTMLDelegate color selection unawareness - palette = parent.palette() - if text_color is None: - self.text_color = palette.text().color().name() - else: - self.text_color = text_color - - if text_color_highlight is None: - self.text_color_highlight = \ - palette.highlightedText().color().name() - else: - self.text_color_highlight = text_color_highlight + self.text_color = QStylePalette.COLOR_TEXT_1 def sortByName(self): """Qt Override.""" @@ -582,11 +573,11 @@ def reset(self): class LSPServerTable(QTableView): - def __init__(self, parent, text_color=None): + def __init__(self, parent): QTableView.__init__(self, parent) self._parent = parent self.delete_queue = [] - self.source_model = LSPServersModel(self, text_color=text_color) + self.source_model = LSPServersModel(self) self.setModel(self.source_model) self.setItemDelegateForColumn(CMD, ItemDelegate(self)) self.setSelectionBehavior(QAbstractItemView.SelectRows) diff --git a/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py b/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py index a51a7488c4b..7254d54bbcc 100644 --- a/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py +++ b/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py @@ -405,7 +405,7 @@ class SnippetsModel(QAbstractTableModel): TRIGGER = 0 DESCRIPTION = 1 - def __init__(self, parent, text_color=None, text_color_highlight=None): + def __init__(self, parent): QAbstractTableModel.__init__(self) self.parent = parent @@ -418,19 +418,6 @@ def __init__(self, parent, text_color=None, text_color_highlight=None): self.label = QLabel() self.widths = [] - # Needed to compensate for the HTMLDelegate color selection unawareness - palette = parent.palette() - if text_color is None: - self.text_color = palette.text().color().name() - else: - self.text_color = text_color - - if text_color_highlight is None: - self.text_color_highlight = \ - palette.highlightedText().color().name() - else: - self.text_color_highlight = text_color_highlight - def sortByName(self): self.snippets = sorted(self.snippets, key=lambda x: x.trigger_text) self.reset() @@ -493,9 +480,9 @@ def __init__(self, parent): self.awaiting_queue = {} self.parent = parent - def get_model(self, table, language, text_color=None): + def get_model(self, table, language): if language not in self.models: - language_model = SnippetsModel(table, text_color=text_color) + language_model = SnippetsModel(table) to_add = self.awaiting_queue.pop(language, []) self.load_snippets(language, language_model, to_add=to_add) self.models[language] = language_model @@ -660,13 +647,12 @@ def import_snippets(self, filename): class SnippetTable(QTableView): - def __init__(self, parent, proxy, language=None, text_color=None): + def __init__(self, parent, proxy, language=None): super(SnippetTable, self).__init__() self._parent = parent self.language = language self.proxy = proxy - self.source_model = proxy.get_model( - self, language.lower(), text_color=text_color) + self.source_model = proxy.get_model(self, language.lower()) self.setModel(self.source_model) self.setItemDelegateForColumn(CMD, ItemDelegate(self)) self.setSelectionBehavior(QAbstractItemView.SelectRows) diff --git a/spyder/plugins/shortcuts/confpage.py b/spyder/plugins/shortcuts/confpage.py index ab41f1b1f80..a2c5542a0bb 100644 --- a/spyder/plugins/shortcuts/confpage.py +++ b/spyder/plugins/shortcuts/confpage.py @@ -6,20 +6,15 @@ """Shortcut configuration page.""" -# Standard library imports -import re - # Third party imports -from qtpy import PYQT5 from qtpy.QtWidgets import (QHBoxLayout, QLabel, QMessageBox, QPushButton, QVBoxLayout) # Local imports from spyder.api.preferences import PluginConfigPage from spyder.api.translations import _ -from spyder.plugins.shortcuts.widgets.table import (ShortcutFinder, - ShortcutsTable) -from spyder.utils.icon_manager import ima +from spyder.plugins.shortcuts.widgets.table import ( + ShortcutFinder, ShortcutsTable) class ShortcutsConfigPage(PluginConfigPage): @@ -27,7 +22,7 @@ class ShortcutsConfigPage(PluginConfigPage): def setup_page(self): # Widgets - self.table = ShortcutsTable(self, text_color=ima.MAIN_FG_COLOR) + self.table = ShortcutsTable(self) self.finder = ShortcutFinder(self.table, self.table.set_regex) self.label_finder = QLabel(_('Search: ')) self.reset_btn = QPushButton(_("Reset to default values")) diff --git a/spyder/plugins/shortcuts/widgets/table.py b/spyder/plugins/shortcuts/widgets/table.py index 7371e6111e8..f3aa815e1d0 100644 --- a/spyder/plugins/shortcuts/widgets/table.py +++ b/spyder/plugins/shortcuts/widgets/table.py @@ -23,6 +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.qthelpers import create_toolbutton from spyder.utils.stringmatching import get_search_regex, get_search_scores from spyder.widgets.helperwidgets import ( @@ -500,7 +501,7 @@ def save(self): class ShortcutsModel(QAbstractTableModel): - def __init__(self, parent, text_color=None, text_color_highlight=None): + def __init__(self, parent): QAbstractTableModel.__init__(self) self._parent = parent @@ -514,17 +515,8 @@ def __init__(self, parent, text_color=None, text_color_highlight=None): self.widths = [] # Needed to compensate for the HTMLDelegate color selection unawarness - palette = parent.palette() - if text_color is None: - self.text_color = palette.text().color().name() - else: - self.text_color = text_color - - if text_color_highlight is None: - self.text_color_highlight = \ - palette.highlightedText().color().name() - else: - self.text_color_highlight = text_color_highlight + self.text_color = QStylePalette.COLOR_TEXT_1 + self.text_color_highlight = QStylePalette.COLOR_TEXT_1 def current_index(self): """Get the currently selected index in the parent table view.""" @@ -573,6 +565,7 @@ def data(self, index, role=Qt.DisplayRole): return to_qvariant(text) elif column == SEQUENCE: text = QKeySequence(key).toString(QKeySequence.NativeText) + text = '
{1}
'.format(color, text) return to_qvariant(text) elif column == SEARCH_SCORE: # Treating search scores as a table column simplifies the @@ -652,16 +645,12 @@ def reset(self): class ShortcutsTable(HoverRowsTableView): - def __init__(self, parent=None, text_color=None, - text_color_highlight=None): + def __init__(self, parent=None): HoverRowsTableView.__init__(self, parent) self._parent = parent self.finder = None self.shortcut_data = None - self.source_model = ShortcutsModel( - self, - text_color=text_color, - text_color_highlight=text_color_highlight) + self.source_model = ShortcutsModel(self) self.proxy_model = ShortcutsSortFilterProxy(self) self.last_regex = ''