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

Enable standard icons #2480

Merged
merged 2 commits into from
Jun 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 25 additions & 6 deletions spyderlib/utils/icon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from spyderlib.external import qtawesome as qta
from spyderlib.baseconfig import get_image_path
from spyderlib.config import CONF
from spyderlib.qt.QtGui import QIcon
from spyderlib.qt.QtGui import QIcon, QWidget, QStyle


_resource = {
Expand Down Expand Up @@ -140,7 +140,6 @@
'package_new': [('fa.folder-o', 'spyder.python-logo'), {'options': [{'offset': (0.0, -0.125)}, {'offset': (0.0, 0.125)}]}],
'vcs_commit': [('fa.check',), {'color': 'green'}],
'vcs_browse': [('fa.search',), {'color': 'green'}],
'ArrowUp': [('fa.arrow-circle-up',), {}],
'kill': [('fa.warning',), {}],
'reload': [('fa.repeat',), {}],
'auto_reload': [('fa.repeat', 'fa.clock-o'), {'options': [{'scale_factor': 0.75, 'offset': (-0.1, -0.1)}, {'scale_factor': 0.5, 'offset': (0.25, 0.25)}]}],
Expand All @@ -149,6 +148,8 @@
'environ': [('fa.th-list',), {}],
'options_less': [('fa.minus-square',), {}],
'options_more': [('fa.plus-square',), {}],
'ArrowDown': [('fa.arrow-circle-down',), {}],
'ArrowUp': [('fa.arrow-circle-up',), {}],
'ArrowBack': [('fa.arrow-circle-left',), {}],
'ArrowForward': [('fa.arrow-circle-right',), {}],
'DialogApplyButton': [('fa.check',), {}],
Expand Down Expand Up @@ -183,18 +184,36 @@
}


def get_std_icon(name, size=None):
"""Get standard platform icon
Call 'show_std_icons()' for details"""
if not name.startswith('SP_'):
name = 'SP_' + name
icon = QWidget().style().standardIcon(getattr(QStyle, name))
if size is None:
return icon
else:
return QIcon(icon.pixmap(size, size))


def get_icon(name, default=None, resample=False):
"""Return image inside a QIcon object
default: default image name or icon
resample: if True, manually resample icon pixmaps for usual sizes
(16, 24, 32, 48, 96, 128, 256). This is recommended for QMainWindow icons
created from SVG images on non-Windows platforms due to a Qt bug (see
Issue 1314)."""
if default is None:
icon = QIcon(get_image_path(name))

icon_path = get_image_path(name, default=None)
if icon_path is not None:
icon = QIcon(icon_path)
elif isinstance(default, QIcon):
icon_path = get_image_path(name, default=None)
icon = default if icon_path is None else QIcon(icon_path)
icon = default
elif default is None:
try:
icon = get_std_icon(name[:-4])
except AttributeError:
icon = QIcon(get_image_path(name, default))
else:
icon = QIcon(get_image_path(name, default))
if resample:
Expand Down
14 changes: 1 addition & 13 deletions spyderlib/utils/qthelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
QLibraryInfo, QEvent, Slot)
from spyderlib.qt.compat import to_qvariant, from_qvariant
import spyderlib.utils.icon_manager as ima
from spyderlib.utils.icon_manager import get_icon
from spyderlib.utils.icon_manager import get_icon, get_std_icon

import os
import re
Expand Down Expand Up @@ -380,18 +380,6 @@ def close_all(self):
dlg.reject()


def get_std_icon(name, size=None):
"""Get standard platform icon
Call 'show_std_icons()' for details"""
if not name.startswith('SP_'):
name = 'SP_'+name
icon = QWidget().style().standardIcon( getattr(QStyle, name) )
if size is None:
return icon
else:
return QIcon( icon.pixmap(size, size) )


def get_filetype_icon(fname):
"""Return file type icon"""
ext = osp.splitext(fname)[1]
Expand Down
7 changes: 3 additions & 4 deletions spyderlib/widgets/findreplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
# Local imports
from spyderlib.baseconfig import _
from spyderlib.guiconfig import create_shortcut, new_shortcut
from spyderlib.utils.qthelpers import (get_icon, get_std_icon,
create_toolbutton)
from spyderlib.utils.qthelpers import get_icon, create_toolbutton
from spyderlib.widgets.comboboxes import PatternComboBox
from spyderlib.py3compat import to_text_string

Expand Down Expand Up @@ -67,10 +66,10 @@ def __init__(self, parent, enable_replace=False):

self.previous_button = create_toolbutton(self,
triggered=self.find_previous,
icon=ima.icon('up'))
icon=ima.icon('ArrowUp'))
self.next_button = create_toolbutton(self,
triggered=self.find_next,
icon=ima.icon('down'))
icon=ima.icon('ArrowDown'))
self.next_button.clicked.connect(self.update_search_combo)
self.previous_button.clicked.connect(self.update_search_combo)

Expand Down