Skip to content

Commit

Permalink
Merge pull request #15366 from jnsebgosselin/panes_cornerwidget_style…
Browse files Browse the repository at this point in the history
…_improvement

PR: Minor layout improvements to the cornet widget of the panes toolbar
  • Loading branch information
ccordoba12 committed Apr 22, 2021
2 parents 7e50267 + cde3982 commit b8e46d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
27 changes: 17 additions & 10 deletions spyder/api/widgets/auxiliary_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"""

# Third party imports
from qtpy.QtCore import Signal
from qtpy.QtWidgets import QHBoxLayout, QMainWindow, QWidget
from qtpy.QtCore import Signal, QSize
from qtpy.QtWidgets import QMainWindow, QSizePolicy, QToolBar, QWidget

# Local imports
from spyder.api.exceptions import SpyderAPIError
Expand Down Expand Up @@ -44,23 +44,27 @@ def closeEvent(self, event):
self.sig_closed.emit()


class MainCornerWidget(QWidget):
class MainCornerWidget(QToolBar):
"""
Corner widget to hold options menu, spinner and additional options.
"""

def __init__(self, parent, name):
super().__init__(parent)
self._icon_size = QSize(16, 16)
self.setIconSize(self._icon_size)

self._widgets = {}
self._actions = []
self.setObjectName(name)

self._layout = QHBoxLayout()
self.setLayout(self._layout)

# left, top, right, bottom
self._layout.setContentsMargins(0, 0, 0, 0)
self.setContentsMargins(0, 0, 0, 0)
# We add an strut widget here so that there is a spacing
# between the first item of the corner widget and the last
# item of the MainWidgetToolbar.
self._strut = QWidget()
self._strut.setFixedWidth(0)
self._strut.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.addWidget(self._strut)

def add_widget(self, widget_id, widget):
"""
Expand All @@ -74,7 +78,10 @@ def add_widget(self, widget_id, widget):

widget.ID = widget_id
self._widgets[widget_id] = widget
self._layout.insertWidget(0, widget)
if len(self._actions):
self._actions.append(self.insertWidget(self._actions[-1], widget))
else:
self._actions.append(self.addWidget(widget))

def get_widget(self, widget_id):
"""
Expand Down
4 changes: 3 additions & 1 deletion spyder/api/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from spyder.utils.qthelpers import create_waitspinner, set_menu_icons
from spyder.utils.registries import (
ACTION_REGISTRY, TOOLBAR_REGISTRY, MENU_REGISTRY)
from spyder.utils.stylesheet import APP_STYLESHEET, PANES_TABBAR_STYLESHEET
from spyder.utils.stylesheet import (
APP_STYLESHEET, PANES_TABBAR_STYLESHEET, PANES_TOOLBAR_STYLESHEET)
from spyder.widgets.dock import SpyderDockWidget
from spyder.widgets.tabs import Tabs

Expand Down Expand Up @@ -374,6 +375,7 @@ def _setup(self):
toolbar=self._corner_toolbar,
section="corner",
)
self._corner_widget.setStyleSheet(str(PANES_TOOLBAR_STYLESHEET))

# Update title
self.setWindowTitle(self.get_title())
Expand Down

0 comments on commit b8e46d6

Please sign in to comment.