Skip to content

Commit

Permalink
Application: Make adjustments to about dialog per operating system
Browse files Browse the repository at this point in the history
- Also, make some minor improvements to the text shown on it per
review.
- Rename MARGIN class constant to PADDING because it makes more
sense.
- Fix modules tests.
  • Loading branch information
ccordoba12 committed Dec 22, 2023
1 parent 07e6585 commit c5d2962
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/modules_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ for f in spyder/*/*/*/*.py; do
if [[ $f == spyder/plugins/findinfiles/widgets/main_widget.py ]]; then
continue
fi
if [[ $f == spyder/plugins/application/widgets/__init__.py ]]; then
continue
fi
python "$f"
if [ $? -ne 0 ]; then
exit 1
Expand Down
44 changes: 25 additions & 19 deletions spyder/plugins/application/widgets/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
from spyder.utils.stylesheet import (
AppStyle,
DialogStyle,
PREFERENCES_TABBAR_STYLESHEET
MAC,
PREFERENCES_TABBAR_STYLESHEET,
WIN
)


class AboutDialog(QDialog, SvgToScaledPixmap):

MARGIN = 15
PADDING = 5 if MAC else 15

def __init__(self, parent):
"""Create About Spyder dialog with general information."""
Expand Down Expand Up @@ -109,13 +111,11 @@ def __init__(self, parent):
font-weight: normal;
'>
<br>
<p>
Created by Pierre Raybaut; current maintainer is Carlos Cordoba.
Developed by the
<a href="{project_url}/graphs/contributors">international
Spyder community</a>. Many thanks to all the Spyder beta testers
and dedicated users.
</p>
<p>For help with Spyder errors and crashes, please read our
<a href="{trouble_url}">Troubleshooting Guide</a>, and for bug
reports and feature requests, visit our
Expand All @@ -140,12 +140,10 @@ def __init__(self, parent):
font-weight: normal;
'>
<br>
<p>
Copyright &copy; 2009-2020 Spyder Project Contributors and
<a href="{project_url}/blob/master/AUTHORS.txt">others</a>.
Distributed under the terms of the
<a href="{project_url}/blob/master/LICENSE.txt">MIT License</a>.
</p>
<p>
<p>Certain source files under other compatible permissive
licenses and/or originally by other authors.
Expand All @@ -161,7 +159,7 @@ def __init__(self, parent):
unsplash&utm_medium=referral&utm_content=creditCopyText">Bench
Accounting</a> on <a href="https://unsplash.com/?utm_source=
unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash
</a>
</a>.
</p>
<p>
See the
Expand All @@ -177,7 +175,12 @@ def __init__(self, parent):
label.setAlignment(Qt.AlignTop)
label.setOpenExternalLinks(True)
label.setTextInteractionFlags(Qt.TextBrowserInteraction)
label.setContentsMargins(self.MARGIN, 0, self.MARGIN, 0)
label.setContentsMargins(
(3 if MAC else 1) * self.PADDING,
0,
(3 if MAC else 1) * self.PADDING,
(3 if MAC else 1) * self.PADDING,
)

self.label_pic = QLabel(self)
self.label_pic.setPixmap(
Expand Down Expand Up @@ -224,6 +227,7 @@ def __init__(self, parent):
self.tabs.addTab(scroll_overview, _('Overview'))
self.tabs.addTab(scroll_community, _('Community'))
self.tabs.addTab(scroll_legal, _('Legal'))
self.tabs.setElideMode(Qt.ElideNone)
self.tabs.setStyleSheet(self._tabs_stylesheet)

# -- Buttons
Expand All @@ -247,23 +251,23 @@ def __init__(self, parent):
piclayout.addStretch()
piclayout.setContentsMargins(
# This makes the left and right margins around the image and info
# to be the same.
self.MARGIN - AppStyle.MarginSize,
# to be the same on Linux and Windows.
self.PADDING - (0 if MAC else 1) * AppStyle.MarginSize,
0,
self.MARGIN,
self.PADDING,
0
)

tabslayout = QHBoxLayout()
tabslayout.addWidget(self.tabs)
tabslayout.setSizeConstraint(tabslayout.SetFixedSize)
tabslayout.setContentsMargins(0, self.MARGIN, 0, 0)
tabslayout.setContentsMargins(0, self.PADDING, 0, 0)

btmhlayout = QHBoxLayout()
btmhlayout.addStretch(1)
btmhlayout.addWidget(info_btn)
btmhlayout.addWidget(ok_btn)
btmhlayout.setContentsMargins(0, 0, self.MARGIN, self.MARGIN)
btmhlayout.setContentsMargins(0, 0, self.PADDING, self.PADDING)
btmhlayout.addStretch()

vlayout = QVBoxLayout()
Expand All @@ -275,14 +279,16 @@ def __init__(self, parent):
mainlayout.addLayout(piclayout)
# This compensates the margin set for scroll areas to center them on
# the tabbar
mainlayout.addSpacing(-self.MARGIN)
mainlayout.addSpacing(-self.PADDING)
mainlayout.addLayout(vlayout)

# -- Signals
info_btn.clicked.connect(self.copy_to_clipboard)
ok_btn.accepted.connect(self.accept)

# -- Style
size = (600, 460) if MAC else ((580, 450) if WIN else (610, 470))
self.setFixedSize(*size)
self.setStyleSheet(self._main_stylesheet)

def copy_to_clipboard(self):
Expand Down Expand Up @@ -316,7 +322,7 @@ def _scrollarea_stylesheet(self):
# background.
border=f"1px solid {DialogStyle.BorderColor}",
# This is necessary to center the tabbar on the scroll area
marginLeft=f"{self.MARGIN}px"
marginLeft=f"{self.PADDING}px"
)

css.QScrollBar.setValues(
Expand Down Expand Up @@ -350,10 +356,10 @@ def _tabs_stylesheet(self):

css['QTabWidget::pane'].setValues(
# Set tab pane margins according to the dialog contents and layout
margin=(
f'{2 * AppStyle.MarginSize}px {self.MARGIN}px '
f'{2 * AppStyle.MarginSize}px 0px'
),
marginTop=f"{(3 if MAC else 2) * AppStyle.MarginSize}px",
marginRight=f"{self.PADDING}px",
marginBottom=f"{(0 if MAC else 2) * AppStyle.MarginSize}px",
marginLeft="0px",
# Padding is not necessary in this case because we set a border for
# the scroll areas.
padding="0px",
Expand Down

0 comments on commit c5d2962

Please sign in to comment.