Skip to content

Commit 66d67a3

Browse files
authored
ENH: Add icons (#41)
* add icons * include package data in setup * add icons readme from mne-python * fix flake * fix flake * fix merging artefact
1 parent 14a3e50 commit 66d67a3

18 files changed

+1086
-28
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include *.py
22
include *.txt
33
include *.yml
44
recursive-include mne_qt_browser *.py
5+
recursive-include mne_qt_browser/icons *

mne_qt_browser/_pg_figure.py

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from mne.utils import _to_rgb, logger, sizeof_fmt, warn, get_config
5252

5353
from . import _browser_instances
54+
from .icons import resources # noqa: F401
5455

5556
try:
5657
from pytestqt.exceptions import capture_exceptions
@@ -124,11 +125,6 @@ def _init_mne_qtapp(enable_icon=True, pg_app=False):
124125
return app
125126

126127

127-
def _get_std_icon(icon_name):
128-
return QApplication.instance().style().standardIcon(
129-
getattr(QStyle, icon_name))
130-
131-
132128
def _get_color(color_spec):
133129
"""Wraps mkColor to accept all possible matplotlib color-specifiers."""
134130
try:
@@ -2117,7 +2113,7 @@ def _init_ui(self):
21172113
self.stop_bx.editingFinished.connect(self._stop_changed)
21182114
layout.addWidget(self.stop_bx)
21192115

2120-
help_bt = QPushButton(_get_std_icon('SP_DialogHelpButton'), 'Help')
2116+
help_bt = QPushButton(QIcon(":/help.svg"), 'Help')
21212117
help_bt.clicked.connect(self._show_help)
21222118
layout.addWidget(help_bt)
21232119

@@ -2834,59 +2830,53 @@ def __init__(self, **kwargs):
28342830
toolbar = self.addToolBar('Tools')
28352831
toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
28362832

2837-
adecr_time = QAction(_get_std_icon('SP_ArrowDown'),
2838-
'Time', parent=self)
2833+
adecr_time = QAction(QIcon(":/less_time.svg"), '- Time', parent=self)
28392834
adecr_time.triggered.connect(partial(self.change_duration, -0.2))
28402835
toolbar.addAction(adecr_time)
28412836

2842-
aincr_time = QAction(_get_std_icon('SP_ArrowUp'),
2843-
'Time', parent=self)
2837+
aincr_time = QAction(QIcon(":/more_time.svg"), '+ Time', parent=self)
28442838
aincr_time.triggered.connect(partial(self.change_duration, 0.25))
28452839
toolbar.addAction(aincr_time)
28462840

2847-
adecr_nchan = QAction(_get_std_icon('SP_ArrowDown'),
2848-
'Channels', parent=self)
2841+
adecr_nchan = QAction(QIcon(":/less_channels.svg"), '- Channels',
2842+
parent=self)
28492843
adecr_nchan.triggered.connect(partial(self.change_nchan, -10))
28502844
toolbar.addAction(adecr_nchan)
28512845

2852-
aincr_nchan = QAction(_get_std_icon('SP_ArrowUp'),
2853-
'Channels', parent=self)
2846+
aincr_nchan = QAction(QIcon(":/more_channels.svg"), '+ Channels',
2847+
parent=self)
28542848
aincr_nchan.triggered.connect(partial(self.change_nchan, 10))
28552849
toolbar.addAction(aincr_nchan)
28562850

2857-
adecr_nchan = QAction(_get_std_icon('SP_ArrowDown'),
2858-
'Zoom', parent=self)
2851+
adecr_nchan = QAction(QIcon(":/zoom_out.svg"), 'Zoom Out', parent=self)
28592852
adecr_nchan.triggered.connect(partial(self.scale_all, 4 / 5))
28602853
toolbar.addAction(adecr_nchan)
28612854

2862-
aincr_nchan = QAction(_get_std_icon('SP_ArrowUp'),
2863-
'Zoom', parent=self)
2855+
aincr_nchan = QAction(QIcon(":/zoom_in.svg"), 'Zoom In', parent=self)
28642856
aincr_nchan.triggered.connect(partial(self.scale_all, 5 / 4))
28652857
toolbar.addAction(aincr_nchan)
28662858

28672859
if not self.mne.is_epochs:
2868-
atoggle_annot = QAction(_get_std_icon('SP_DialogResetButton'),
2869-
'Annotations', parent=self)
2860+
atoggle_annot = QAction(QIcon(":/annotations.svg"), 'Annotations',
2861+
parent=self)
28702862
atoggle_annot.triggered.connect(self._toggle_annotation_fig)
28712863
toolbar.addAction(atoggle_annot)
28722864

2873-
atoggle_proj = QAction(_get_std_icon('SP_DialogOkButton'),
2874-
'SSP', parent=self)
2865+
atoggle_proj = QAction(QIcon(":/ssp.svg"), 'SSP', parent=self)
28752866
atoggle_proj.triggered.connect(self._toggle_proj_fig)
28762867
toolbar.addAction(atoggle_proj)
28772868

2878-
atoggle_fullscreen = QAction(_get_std_icon('SP_TitleBarMaxButton'),
2879-
'Full-Screen', parent=self)
2869+
atoggle_fullscreen = QAction(QIcon(":/fullscreen.svg"), 'Fullscreen',
2870+
parent=self)
28802871
atoggle_fullscreen.triggered.connect(self._toggle_fullscreen)
28812872
toolbar.addAction(atoggle_fullscreen)
28822873

2883-
asettings = QAction(_get_std_icon('SP_FileDialogDetailedView'),
2884-
'Settings', parent=self)
2874+
asettings = QAction(QIcon(":/settings.svg"), 'Settings',
2875+
parent=self)
28852876
asettings.triggered.connect(self._toggle_settings_fig)
28862877
toolbar.addAction(asettings)
28872878

2888-
ahelp = QAction(_get_std_icon('SP_DialogHelpButton'),
2889-
'Help', parent=self)
2879+
ahelp = QAction(QIcon(":/help.svg"), 'Help', parent=self)
28902880
ahelp.triggered.connect(self._toggle_help_fig)
28912881
toolbar.addAction(ahelp)
28922882

mne_qt_browser/icons/README.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. -*- mode: rst -*-
2+
3+
4+
Documentation
5+
=============
6+
7+
The icons are used for the toolbar.
8+
It is necessary to compile those icons into a resource file for proper use by
9+
the application.
10+
11+
The resource configuration file ``mne-qt-browser.qrc`` describes the location of
12+
the resources in the filesystem and also defines aliases for their use in the code.
13+
14+
To automatically generate the resource file:
15+
16+
.. code-block:: bash
17+
18+
pyrcc5 -o mne/icons/resources.py mne/icons/mne.qrc
19+
20+
These Material design icons are provided by Google under the `Apache 2.0`_ license.
21+
22+
23+
.. _Apache 2.0: https://github.com/google/material-design-icons/blob/master/LICENSE
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 68 additions & 0 deletions
Loading
Lines changed: 81 additions & 0 deletions
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE RCC>
2+
<RCC version="1.0">
3+
<qresource>
4+
<file alias="annotations.svg">border_color_black_18dp.svg</file>
5+
<file alias="help.svg">help_black_18dp.svg</file>
6+
<file alias="less_channels.svg">less_channels_black_18dp.svg</file>
7+
<file alias="less_time.svg">less_time_black_18dp.svg</file>
8+
<file alias="more_channels.svg">more_channels_black_18dp.svg</file>
9+
<file alias="more_time.svg">more_time_black_18dp.svg</file>
10+
<file alias="ssp.svg">north_east_black_18dp.svg</file>
11+
<file alias="fullscreen.svg">open_in_full_black_18dp.svg</file>
12+
<file alias="settings.svg">settings_black_18dp.svg</file>
13+
<file alias="zoom_in.svg">zoom_in_black_18dp.svg</file>
14+
<file alias="zoom_out.svg">zoom_out_black_18dp.svg</file>
15+
</qresource>
16+
</RCC>
Lines changed: 65 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)