Skip to content

Commit

Permalink
Merge from 2.3: Improve Mac Qt style and fix for issue #2028
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Jun 20, 2015
2 parents b70e081 + fa77637 commit 2813ed1
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 119 deletions.
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ spyderlib/images/vitables.png
[5] MIT License

spyderlib/images/winpython.svg
spyderlib/images/chevron-left.png
spyderlib/images/chevron-right.png


[6] BSD License
Expand Down
Binary file added spyderlib/images/chevron-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spyderlib/images/chevron-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions spyderlib/mac_stylesheet.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Qt Stylesheet for MacOS X
* Copyright (c) 2015- The Spyder Development Team
*/


/* ---------------- Dock widget and QSplitter separators --------------- */

QMainWindow::separator {
width: 3px;
height: 3px;
border: 1px solid lightgrey;
border-radius: 1px;
}

QMainWindow::separator:hover {
background: darkgrey;
}

QToolButton {
border: none;
}

QSplitter::handle:horizontal {
border: 1px solid darkgrey;
width: 2px;
}

QSplitter::handle:vertical {
border: 1px solid darkgrey;
height: 2px;
}

QSplitter::handle:pressed {
background: darkgrey;
}


/* ----------------- Tabs ------------------ */

QWidget#tab-container {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b1b1b1, stop: 0.07 #b3b3b3,
stop: 0.33 #b3b3b3, stop: 0.4 #b0b0b0,
stop: 0.47 #b3b3b3, stop: 1.0 #b2b2b2);
}

QTabWidget::pane#plugin-tab {
border-top: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b1b1b1, stop: 0.07 #b3b3b3,
stop: 0.33 #b3b3b3, stop: 0.4 #b0b0b0,
stop: 0.47 #b3b3b3, stop: 1.0 #b2b2b2);
border-bottom: 0px;
border-left: 0px;
border-right: 0px;
}

QTabWidget::tab-bar#plugin-tab {
left: 5px;
}

QTabBar::tab#plugin-tab {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b1b1b1, stop: 0.07 #b3b3b3,
stop: 0.33 #b3b3b3, stop: 0.4 #b0b0b0,
stop: 0.47 #b3b3b3, stop: 1.0 #b2b2b2);
border: 1px solid #787878;
border-top-color: transparent;
border-bottom-color: transparent;
margin-left: -1px;
margin-right: -1px;
min-width: 15ex;
padding: 3px;
}

QTabBar::tab:selected#plugin-tab {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dfdfdf, stop: 0.1 #dddddd,
stop: 0.12 #dfdfdf, stop: 0.22 #e0e0e0,
stop: 0.33 #dedede, stop: 0.47 #dedede,
stop: 0.49 #e0e0e0, stop: 0.59 #dddddd,
stop: 0.61 #dfdfdf, stop: 0.73 #dedede,
stop: 0.80 #e0e0e0, stop: 1.0 #dedede);
border: 1px solid #787878;
border-top: 0px;
border-top-color: transparent;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}

QTabBar::tab:first#plugin-tab {
margin-left: 0;
}

QTabBar::tab:last#plugin-tab {
margin-right: 0;
}

QTabBar::tab:only-one#plugin-tab {
margin: 0;
}

QTabBar::scroller#plugin-tab {
width: 22px;
}

QTabBar#plugin-tab QToolButton::left-arrow {
background: lightgrey;
border-right: 1px solid darkgrey;
image: url(spyderlib/images/chevron-left.png);
}

QTabBar#plugin-tab QToolButton::right-arrow {
background: lightgrey;
image: url(spyderlib/images/chevron-right.png);
}


/* ------------------ Dock widgets ------------------- */

QDockWidget::close-button, QDockWidget::float-button {
padding: 0px;
margin: 2px;
}
65 changes: 0 additions & 65 deletions spyderlib/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
from spyderlib.qt.QtCore import Qt, Signal, QObject, QEvent, QPoint
import spyderlib.utils.icon_manager as ima

# Stdlib imports
import sys

# Local imports
from spyderlib.utils.qthelpers import toggle_actions, get_icon, create_action
from spyderlib.baseconfig import _
Expand Down Expand Up @@ -195,72 +192,10 @@ def show_nontab_menu(self, event):

class SpyderDockWidget(QDockWidget):
"""Subclass to override needed methods"""
DARWIN_STYLE = """
QDockWidget::close-button, QDockWidget::float-button {
padding: 0px;
margin: 2px;
}
QTabWidget::pane {
border: 3px solid rgb(235, 235, 235);
border-bottom: 0;
}
QTabWidget::tab-bar {
left: 5px;
}
QTabBar::tab {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b1b1b1, stop: 0.07 #b3b3b3,
stop: 0.33 #b3b3b3, stop: 0.4 #b0b0b0,
stop: 0.47 #b3b3b3, stop: 1.0 #b2b2b2);
border: 1px solid #787878;
border-top-color: transparent;
border-bottom-color: transparent;
margin-left: -1px;
margin-right: -1px;
min-width: 8ex;
padding: 3px;
}
QTabBar::tab:selected {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #dfdfdf, stop: 0.1 #dddddd,
stop: 0.12 #dfdfdf, stop: 0.22 #e0e0e0,
stop: 0.33 #dedede, stop: 0.47 #dedede,
stop: 0.49 #e0e0e0, stop: 0.59 #dddddd,
stop: 0.61 #dfdfdf, stop: 0.73 #dedede,
stop: 0.80 #e0e0e0, stop: 1.0 #dedede);
border: 1px solid #787878;
border-top-color: transparent;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
QTabBar::tab:first {
margin-left: 0;
}
QTabBar::tab:last {
margin-right: 0;
}
QTabBar::tab:only-one {
margin: 0;
}
QToolButton {
border: none;
}
"""

plugin_closed = Signal()

def __init__(self, title, parent):
super(SpyderDockWidget, self).__init__(title, parent)
if sys.platform == 'darwin':
self.setStyleSheet(self.DARWIN_STYLE)

# Needed for the installation of the event filter
self.title = title
Expand Down
2 changes: 0 additions & 2 deletions spyderlib/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,6 @@ def close_file(self):
"""Close current file"""
editorstack = self.get_current_editorstack()
editorstack.close_file()
if editorstack.get_stack_count() == 0:
self.new()

@Slot()
def close_all_files(self):
Expand Down
12 changes: 10 additions & 2 deletions spyderlib/plugins/externalconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from spyderlib.qt.QtGui import (QVBoxLayout, QMessageBox, QInputDialog,
QLineEdit, QPushButton, QGroupBox, QLabel,
QTabWidget, QFontComboBox, QHBoxLayout,
QButtonGroup)
QButtonGroup, QWidget)
from spyderlib.qt.QtCore import Signal, Slot, Qt
from spyderlib.qt.compat import getopenfilename
import spyderlib.utils.icon_manager as ima
Expand Down Expand Up @@ -518,7 +518,15 @@ def __init__(self, parent, light_mode):

self.tabwidget.set_close_function(self.close_console)

layout.addWidget(self.tabwidget)
if sys.platform == 'darwin':
tab_container = QWidget()
tab_container.setObjectName('tab-container')
tab_layout = QHBoxLayout(tab_container)
tab_layout.setContentsMargins(0, 0, 0, 0)
tab_layout.addWidget(self.tabwidget)
layout.addWidget(tab_container)
else:
layout.addWidget(self.tabwidget)

# Find/replace widget
self.find_widget = FindReplace(self)
Expand Down
15 changes: 13 additions & 2 deletions spyderlib/plugins/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

from spyderlib.qt import PYQT5
from spyderlib.qt.QtGui import (QVBoxLayout, QFontDialog, QInputDialog,
QToolButton, QMenu, QFontComboBox, QGroupBox)
QToolButton, QMenu, QFontComboBox, QGroupBox,
QHBoxLayout, QWidget)
from spyderlib.qt.QtCore import Signal, Slot
import spyderlib.utils.icon_manager as ima

import os.path as osp
import sys

# Local imports
from spyderlib.utils import encoding
Expand Down Expand Up @@ -99,7 +101,16 @@ def __init__(self, parent):
self.tabwidget = Tabs(self, self.menu_actions)
self.tabwidget.currentChanged.connect(self.refresh_plugin)
self.tabwidget.move_data.connect(self.move_tab)
layout.addWidget(self.tabwidget)

if sys.platform == 'darwin':
tab_container = QWidget()
tab_container.setObjectName('tab-container')
tab_layout = QHBoxLayout(tab_container)
tab_layout.setContentsMargins(0, 0, 0, 0)
tab_layout.addWidget(self.tabwidget)
layout.addWidget(tab_container)
else:
layout.addWidget(self.tabwidget)

# Menu as corner widget
options_button = create_toolbutton(self, text=_('Options'),
Expand Down
12 changes: 10 additions & 2 deletions spyderlib/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
QMessageBox, QGroupBox, QDialogButtonBox,
QDialog, QTabWidget, QFontComboBox,
QCheckBox, QApplication, QLabel,QLineEdit,
QPushButton, QKeySequence)
QPushButton, QKeySequence, QWidget)
from spyderlib.qt.compat import getopenfilename
from spyderlib.qt.QtCore import Signal, Slot, Qt
import spyderlib.utils.icon_manager as ima
Expand Down Expand Up @@ -613,7 +613,15 @@ def __init__(self, parent):

self.tabwidget.set_close_function(self.close_client)

layout.addWidget(self.tabwidget)
if sys.platform == 'darwin':
tab_container = QWidget()
tab_container.setObjectName('tab-container')
tab_layout = QHBoxLayout(tab_container)
tab_layout.setContentsMargins(0, 0, 0, 0)
tab_layout.addWidget(self.tabwidget)
layout.addWidget(tab_container)
else:
layout.addWidget(self.tabwidget)

# Find/replace widget
self.find_widget = FindReplace(self)
Expand Down
50 changes: 8 additions & 42 deletions spyderlib/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,46 +223,6 @@ def get_focus_widget_properties():
return widget, textedit_properties


#==============================================================================
# Qt Stylesheet for MainWindow
#==============================================================================
#TODO: Improve the stylesheet below for separator handles to be visible
# (in Qt, these handles are by default not visible on Windows!)
STYLESHEET="""
QSplitter::handle {
margin-left: 4px;
margin-right: 4px;
}
QSplitter::handle:horizontal {
width: 1px;
border-width: 0px;
background-color: lightgray;
}
QSplitter::handle:vertical {
border-top: 2px ridge lightgray;
border-bottom: 2px;
}
QMainWindow::separator:vertical {
margin-left: 1px;
margin-top: 25px;
margin-bottom: 25px;
border-left: 2px groove lightgray;
border-right: 1px;
}
QMainWindow::separator:horizontal {
margin-top: 1px;
margin-left: 5px;
margin-right: 5px;
border-top: 2px groove lightgray;
border-bottom: 2px;
}
"""


#==============================================================================
# Main Window
#==============================================================================
Expand Down Expand Up @@ -312,8 +272,6 @@ def __init__(self, options=None):

self.debug_print("Start of MainWindow constructor")

# self.setStyleSheet(STYLESHEET)

# Shortcut management data
self.shortcut_data = []

Expand Down Expand Up @@ -1227,6 +1185,14 @@ def add_xydoc(text, pathlist):
if isinstance(child, QMenu):
child.aboutToShow.connect(self.update_edit_menu)

# Use a custom stylesheet for Mac (for now). Set it here to
# avoid a Qt painting bug if it's set before the Editor is
# created. The bug only occurs on Mac.
if sys.platform == 'darwin':
spy_path = get_module_source_path('spyderlib')
mac_style = open(osp.join(spy_path, 'mac_stylesheet.qss')).read()
self.setStyleSheet(mac_style)

self.debug_print("*** End of MainWindow setup ***")
self.is_starting_up = False

Expand Down
Loading

0 comments on commit 2813ed1

Please sign in to comment.