Skip to content

Commit

Permalink
Merge pull request #21233 from ccordoba12/improve-preferences-ui
Browse files Browse the repository at this point in the history
PR: Improve style of the Preferences dialog (UI)
  • Loading branch information
ccordoba12 authored Nov 4, 2023
2 parents b0b1a01 + 34f5bdc commit 7ee864a
Show file tree
Hide file tree
Showing 31 changed files with 1,850 additions and 1,311 deletions.
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
)


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

0 comments on commit 7ee864a

Please sign in to comment.