Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Improve style of the Preferences dialog (UI) #21233

Merged
merged 36 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a8ed626
Preferences: Add a max width to all pages
ccordoba12 Jul 28, 2023
b4ab294
Preferences: Fix layout of Appearance page after last changes
ccordoba12 Jul 29, 2023
db007c2
Preferences: Replace splitter for a grid layout in config dialog
ccordoba12 Jul 31, 2023
e38f331
Fix setting and restoring Preferences dialog size
ccordoba12 Jul 31, 2023
088b3b9
Stylesheet: Change QGroupBox style in the application
ccordoba12 Aug 2, 2023
92b6717
Preferences: Add a modern style for its dialog
ccordoba12 Aug 2, 2023
b3cc034
Preferences: Remove unneeded margins in "Completions and linting" tabs
ccordoba12 Aug 2, 2023
c7f6101
Preferences: Set for its tabs the same style used for dockwidget tabbars
ccordoba12 Aug 3, 2023
d6e7a3f
Preferences: Show wait cursor when opening its dialog
ccordoba12 Aug 3, 2023
9c05e3a
Preferences: Small style fixes in several pages
ccordoba12 Aug 3, 2023
4c33c52
Preferences: Show tooltips for plugin names whose text is elided
ccordoba12 Aug 3, 2023
25af2a6
Editor: Improve config page
ccordoba12 Aug 3, 2023
78f5477
IPython console: Improve its config page
ccordoba12 Aug 4, 2023
001db9f
Preferences: Increase tabs font size and padding per review
ccordoba12 Aug 4, 2023
3c63e25
Preferences: Add header sections to its plugin and minor style fixes
ccordoba12 Aug 8, 2023
9f2033b
Preferences: Move `api` module to `widgets/config_widgets.py`
ccordoba12 Sep 10, 2023
bb51667
Preferences: Organize page entries in different sections
ccordoba12 Sep 11, 2023
c7894fc
Preferences: Improve how we add tooltips to contents_widget elided items
ccordoba12 Sep 12, 2023
f7062b0
Preferences: Move Qt method to the right section
ccordoba12 Sep 12, 2023
678d6bb
Widgets: Fix bug in ElementsTable when hovering
ccordoba12 Sep 17, 2023
9fd5d0a
Widgets: Fix right margin of ElementsTable last column on Mac
ccordoba12 Sep 17, 2023
f501efd
Widgets: Remove setting ElementsTable layout on QEvent.LayoutRequest
ccordoba12 Sep 17, 2023
fd694e8
Preferences: Standardize how tabs are created in config pages
ccordoba12 Sep 18, 2023
175953d
Set scroll buttons and prevent eliding text on dock and preference tabs
ccordoba12 Sep 18, 2023
acefd0d
Merge branch 'master' into improve-preferences-ui
ccordoba12 Oct 21, 2023
5d4c23d
Testing: Fix tests related to Preferences
ccordoba12 Oct 21, 2023
9935686
Preferences: Set min height for config pages
ccordoba12 Oct 21, 2023
189806e
Add superqt as a new dependency
ccordoba12 Oct 22, 2023
4fb839f
Preferences: Debounce operations when its dialog is resized
ccordoba12 Oct 22, 2023
85310f8
Preferences: Adjust separators width when its dialog is resized
ccordoba12 Oct 22, 2023
7c7c396
Widgets: Debounce operations when resizing ElementsTable
ccordoba12 Oct 23, 2023
66700f0
Preferences: Make several adjustments per operating system
ccordoba12 Oct 23, 2023
69fa4ba
Stylesheet: Create a new class for tab bars used in Preferences
ccordoba12 Oct 25, 2023
f739662
Preferences: Show "Main interpreter" entry above "Keyboard shortcuts"
ccordoba12 Oct 25, 2023
c59a2e5
Preferences: Move MOST_IMPORTANT_PAGES constant to its init module
ccordoba12 Nov 4, 2023
34f5bdc
Merge branch 'master' into improve-preferences-ui
ccordoba12 Nov 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
- setuptools >=49.6.0
- sphinx >=0.6.6
- spyder-kernels >=3.0.0b2,<3.0.0b3
- superqt >=0.6.1,<1.0.0
- textdistance >=4.2.0
- three-merge >=0.1.1
- watchdog >=0.10.3
Expand Down
1 change: 1 addition & 0 deletions requirements/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies:
- setuptools >=49.6.0
- sphinx >=0.6.6
- spyder-kernels >=3.0.0b2,<3.0.0b3
- superqt >=0.6.1,<1.0.0
- textdistance >=4.2.0
- three-merge >=0.1.1
- watchdog >=0.10.3
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def run(self):
'setuptools>=49.6.0',
'sphinx>=0.6.6',
'spyder-kernels>=3.0.0b2,<3.0.0b3',
'superqt>=0.6.1,<1.0.0',
'textdistance>=4.2.0',
'three-merge>=0.1.1',
'watchdog>=0.10.3'
Expand Down
10 changes: 9 additions & 1 deletion spyder/api/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from spyder.config.manager import CONF
from spyder.config.types import ConfigurationKey
from spyder.api.utils import PrefixedTuple
from spyder.plugins.preferences.api import SpyderConfigPage, BaseConfigTab
from spyder.plugins.preferences.widgets.config_widgets import (
SpyderConfigPage,
BaseConfigTab
)
Comment on lines +19 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we preserve the import call that was before and instead do this new import from spyder.plugins.preferences.api? Although those definitions are widgets, it is also true that they are part of the preferences plugin API, no?

Copy link
Member Author

@ccordoba12 ccordoba12 Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although those definitions are widgets, it is also true that they are part of the preferences plugin API, no?

I'd say that not really. I mean, I think what we should put in spyder/plugins/myplugin/api.py are things that other plugins need to import to work in relationship to myplugin. That's why we have mainly enums for actions in the api module of most of our plugins (to place other actions in menus or toolbars before or after them, for instance).

In this particular case, other plugins don't need to import SpyderConfigPage and BaseConfigTab but SpyderPreferencesTab and PluginConfigPage, which are declared here.

However, your comment made me realize that the MOST_IMPORTANT_PAGES constant that I added to spyder.plugins.preferences.api shouldn't be there. That's because that constant is not needed by other plugins but by several modules in the Preferences plugin. So, I put it in api.py to avoid circular imports, but I think it's better placed in spyder.plugins.preferences.__init__, which is where I'll move it in my next commit.



OptionSet = Set[ConfigurationKey]
Expand Down Expand Up @@ -65,6 +68,11 @@ def __getattr__(self, attr):
else:
return super().__getattr__(attr)

def setLayout(self, layout):
"""Remove default margins by default."""
layout.setContentsMargins(0, 0, 0, 0)
super().setLayout(layout)


class PluginConfigPage(SpyderConfigPage):
"""
Expand Down
7 changes: 1 addition & 6 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def signal_handler(signum, frame=None):
self.thirdparty_plugins = []

# Preferences
self.prefs_dialog_size = None
self.prefs_dialog_instance = None

# Actions
Expand Down Expand Up @@ -1310,11 +1309,7 @@ def apply_panes_settings(self):
@Slot()
def show_preferences(self):
"""Edit Spyder preferences."""
self.preferences.open_dialog(self.prefs_dialog_size)

def set_prefs_size(self, size):
"""Save preferences dialog size."""
self.prefs_dialog_size = size
self.preferences.open_dialog()

# ---- Open files server
# -------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions spyder/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ def preferences_dialog_helper(qtbot, main_window, section):
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(
lambda: shell.spyder_kernel_ready and shell._prompt_html is not None,
timeout=SHELL_TIMEOUT)
timeout=SHELL_TIMEOUT
)

main_window.show_preferences()
preferences = main_window.preferences
container = preferences.get_container()

qtbot.waitUntil(lambda: container.dialog is not None,
timeout=5000)
qtbot.waitUntil(lambda: container.dialog is not None, timeout=5000)
dlg = container.dialog
index = dlg.get_index_by_name(section)
page = dlg.get_page(index)
Expand Down
15 changes: 12 additions & 3 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
'window/position': (10, 10),
'window/is_maximized': True,
'window/is_fullscreen': False,
'window/prefs_dialog_size': (1050, 530),
'use_custom_margin': True,
'custom_margin': 0,
'use_custom_cursor_blinking': False,
Expand Down Expand Up @@ -292,6 +291,13 @@
'follow_cursor': True,
'display_variables': False
}),
('preferences',
{
'enable': True,
'dialog_size': (
(1010, 725) if MAC else ((900, 670) if WIN else (950, 690))
),
}),
('project_explorer',
{
'name_filters': NAME_FILTERS,
Expand Down Expand Up @@ -567,7 +573,6 @@
'current_version',
'historylog_filename',
'window/position',
'window/prefs_dialog_size',
'window/size',
'window/state',
]
Expand Down Expand Up @@ -611,6 +616,10 @@
'scrollbar_position',
],
),
('preferences', [
'dialog_size',
],
),
('project_explorer', [
'current_project_path',
'expanded_state',
Expand Down Expand Up @@ -653,4 +662,4 @@
# or if you want to *rename* options, then you need to do a MAJOR update in
# version, e.g. from 3.0.0 to 4.0.0
# 3. You don't need to touch this value if you're just adding a new option
CONF_VERSION = '79.0.0'
CONF_VERSION = '80.0.0'
10 changes: 7 additions & 3 deletions spyder/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
SETUPTOOLS_REQVER = '>=49.6.0'
SPHINX_REQVER = '>=0.6.6'
SPYDER_KERNELS_REQVER = '>=3.0.0b2,<3.0.0b3'
SUPERQT_REQVER = '>=0.6.1,<1.0.0'
TEXTDISTANCE_REQVER = '>=4.2.0'
THREE_MERGE_REQVER = '>=0.1.1'
WATCHDOG_REQVER = '>=0.10.3'


# Optional dependencies
CYTHON_REQVER = '>=0.21'
MATPLOTLIB_REQVER = '>=3.0.0'
Expand Down Expand Up @@ -234,11 +234,11 @@
'required_version': QTPY_REQVER},
{'modname': "rtree",
'package_name': "rtree",
'features': _("Fast access to code snippets regions"),
'features': _("Fast access to code snippet regions"),
'required_version': RTREE_REQVER},
{'modname': "setuptools",
'package_name': "setuptools",
'features': _("Determine package version"),
'features': _("Determine package versions"),
'required_version': SETUPTOOLS_REQVER},
{'modname': "sphinx",
'package_name': "sphinx",
Expand All @@ -248,6 +248,10 @@
'package_name': "spyder-kernels",
'features': _("Jupyter kernels for the Spyder console"),
'required_version': SPYDER_KERNELS_REQVER},
{'modname': "superqt",
'package_name': "superqt",
'features': _("Special widgets and utilities for PyQt applications"),
'required_version': SUPERQT_REQVER},
{'modname': 'textdistance',
'package_name': "textdistance",
'features': _('Compute distances between strings'),
Expand Down
13 changes: 6 additions & 7 deletions spyder/plugins/appearance/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from spyder.plugins.appearance.widgets import SchemeEditor
from spyder.utils import syntaxhighlighters
from spyder.utils.palette import QStylePalette
from spyder.utils.stylesheet import AppStyle
from spyder.widgets.simplecodeeditor import SimpleCodeEditor


Expand Down Expand Up @@ -77,6 +78,7 @@ def setup_page(self):
self.reset_button = QPushButton(_("Reset to defaults"))

self.preview_editor = SimpleCodeEditor(self)
self.preview_editor.setMinimumWidth(210)
self.stacked_widget = QStackedWidget(self)
self.scheme_editor_dialog = SchemeEditor(parent=self,
stack=self.stacked_widget)
Expand Down Expand Up @@ -132,12 +134,10 @@ def setup_page(self):
fonts_grid_layout = QGridLayout()
fonts_grid_layout.addWidget(self.plain_text_font.fontlabel, 0, 0)
fonts_grid_layout.addWidget(self.plain_text_font.fontbox, 0, 1)
fonts_grid_layout.addWidget(self.plain_text_font.sizelabel, 0, 2)
fonts_grid_layout.addWidget(self.plain_text_font.sizebox, 0, 3)
fonts_grid_layout.addWidget(self.plain_text_font.sizebox, 0, 2)
fonts_grid_layout.addWidget(self.app_font.fontlabel, 2, 0)
fonts_grid_layout.addWidget(self.app_font.fontbox, 2, 1)
fonts_grid_layout.addWidget(self.app_font.sizelabel, 2, 2)
fonts_grid_layout.addWidget(self.app_font.sizebox, 2, 3)
fonts_grid_layout.addWidget(self.app_font.sizebox, 2, 2)
fonts_grid_layout.setRowStretch(fonts_grid_layout.rowCount(), 1)

fonts_layout = QVBoxLayout()
Expand All @@ -161,8 +161,7 @@ def setup_page(self):

# Combined layout
combined_layout = QGridLayout()
combined_layout.setRowStretch(0, 1)
combined_layout.setColumnStretch(1, 100)
combined_layout.setHorizontalSpacing(AppStyle.MarginSize * 5)
combined_layout.addLayout(options_layout, 0, 0)
combined_layout.addWidget(preview_group, 0, 1)

Expand Down Expand Up @@ -349,7 +348,7 @@ def update_preview(self, index=None, scheme_name=None):

def update_app_font_group(self, state):
"""Update app font group enabled state."""
subwidgets = ['fontlabel', 'sizelabel', 'fontbox', 'sizebox']
subwidgets = ['fontlabel', 'fontbox', 'sizebox']

if state:
for widget in subwidgets:
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/appearance/tests/test_confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Local imports
from spyder.config.manager import CONF
from spyder.plugins.appearance.plugin import Appearance
from spyder.plugins.preferences.api import SpyderConfigPage
from spyder.plugins.preferences.widgets.config_widgets import SpyderConfigPage
from spyder.plugins.preferences.tests.conftest import (
config_dialog, MainWindowMock)

Expand Down
26 changes: 12 additions & 14 deletions spyder/plugins/application/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from qtpy.compat import from_qvariant
from qtpy.QtCore import Qt
from qtpy.QtWidgets import (QApplication, QButtonGroup, QGridLayout, QGroupBox,
QHBoxLayout, QLabel, QMessageBox, QTabWidget,
QVBoxLayout, QWidget)
QHBoxLayout, QLabel, QMessageBox, QVBoxLayout,
QWidget)

from spyder.config.base import (_, DISABLED_LANGUAGES, LANGUAGE_CODES,
is_conda_based_app, save_lang_conf)
Expand Down Expand Up @@ -236,21 +236,19 @@ def set_open_file(state):

screen_resolution_layout.addLayout(screen_resolution_inner_layout)
screen_resolution_group.setLayout(screen_resolution_layout)

if sys.platform == "darwin" and not is_conda_based_app():
interface_tab = self.create_tab(screen_resolution_group,
interface_group, macOS_group)
self.create_tab(
_("Interface"),
[screen_resolution_group, interface_group, macOS_group]
)
else:
interface_tab = self.create_tab(screen_resolution_group,
interface_group)

self.tabs = QTabWidget()
self.tabs.addTab(interface_tab, _("Interface"))
self.tabs.addTab(self.create_tab(advanced_widget),
_("Advanced settings"))
self.create_tab(
_("Interface"),
[screen_resolution_group, interface_group]
)

vlayout = QVBoxLayout()
vlayout.addWidget(self.tabs)
self.setLayout(vlayout)
self.create_tab(_("Advanced settings"), advanced_widget)

def apply_settings(self, options):
if 'high_dpi_custom_scale_factors' in options:
Expand Down
1 change: 1 addition & 0 deletions spyder/plugins/completion/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def disable_completion_after_characters(state):
disable_completion_after_characters)

layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self.completions_group)
layout.addWidget(self.providers_group)
layout.addStretch(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def __init__(self, parent):

# Combined layout
servers_layout = QVBoxLayout()
servers_layout.addSpacing(-10)
servers_layout.addWidget(servers_label)
servers_layout.addSpacing(9)
servers_layout.addWidget(table_group)
servers_layout.addSpacing(10)
servers_layout.addSpacing(9)
servers_layout.addLayout(buttons_layout)

self.setLayout(servers_layout)
Expand Down
7 changes: 4 additions & 3 deletions spyder/plugins/completion/providers/snippets/conftabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

# Third party imports
from qtpy.compat import getsavefilename, getopenfilename
from qtpy.QtCore import Qt, Slot
from qtpy.QtCore import Qt
from qtpy.QtWidgets import (QComboBox, QGroupBox, QGridLayout, QLabel,
QMessageBox, QPushButton, QTabWidget, QVBoxLayout,
QWidget, QFileDialog)
QMessageBox, QPushButton, QVBoxLayout, QFileDialog)

# Local imports
from spyder.config.base import _
Expand Down Expand Up @@ -57,6 +56,7 @@ def __init__(self, parent):
self.change_language_snippets)

snippet_lang_group = QGroupBox(_('Language'))
snippet_lang_group.setStyleSheet('margin-bottom: 3px')
snippet_lang_layout = QVBoxLayout()
snippet_lang_layout.addWidget(self.snippets_language_cb)
snippet_lang_group.setLayout(snippet_lang_layout)
Expand Down Expand Up @@ -103,6 +103,7 @@ def __init__(self, parent):
# Snippets layout
snippets_layout = QVBoxLayout()
snippets_layout.addWidget(snippets_info_label)
snippets_layout.addSpacing(9)
snippets_layout.addWidget(snippet_lang_group)
snippets_layout.addWidget(snippet_table_group)
snippets_layout.addLayout(sn_buttons_layout)
Expand Down
3 changes: 0 additions & 3 deletions spyder/plugins/completion/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def get_plugin(self, plugin_name, error=True):
if plugin_name in PLUGIN_REGISTRY:
return PLUGIN_REGISTRY.get_plugin(plugin_name)

def set_prefs_size(self, size):
pass


@pytest.fixture(scope="module")
def qtbot_module(qapp, request):
Expand Down
Loading