From c2ecb3e9d28e495035611bc359edd4f1ec20548b Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 16 Aug 2016 18:06:31 -0500 Subject: [PATCH 1/5] Tabs: Remove browse tabs button --- spyderlib/widgets/tabs.py | 52 ++------------------------------------- 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/spyderlib/widgets/tabs.py b/spyderlib/widgets/tabs.py index e664ffde0d9..f1cd55ed094 100644 --- a/spyderlib/widgets/tabs.py +++ b/spyderlib/widgets/tabs.py @@ -12,7 +12,6 @@ # pylint: disable=R0201 # Standard library imports -import os.path as osp import sys # Third party imports @@ -24,11 +23,9 @@ # Local imports from spyderlib.config.base import _ from spyderlib.config.gui import fixed_shortcut -from spyderlib.py3compat import PY2, to_text_string +from spyderlib.py3compat import PY2 from spyderlib.utils import icon_manager as ima -from spyderlib.utils.misc import get_common_path -from spyderlib.utils.qthelpers import (add_actions, create_action, - create_toolbutton) +from spyderlib.utils.qthelpers import add_actions, create_toolbutton class TabBar(QTabBar): @@ -141,53 +138,8 @@ def __init__(self, parent, actions=None, menu=None, corner_widgets = {} corner_widgets.setdefault(Qt.TopLeftCorner, []) corner_widgets.setdefault(Qt.TopRightCorner, []) - self.browse_button = create_toolbutton(self, - icon=ima.icon('browse_tab'), - tip=_("Browse tabs")) - self.browse_tabs_menu = QMenu(self) - self.browse_button.setMenu(self.browse_tabs_menu) - self.browse_button.setPopupMode(self.browse_button.InstantPopup) - self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu) - corner_widgets[Qt.TopLeftCorner] += [self.browse_button] - self.set_corner_widgets(corner_widgets) - def update_browse_tabs_menu(self): - """Update browse tabs menu""" - self.browse_tabs_menu.clear() - names = [] - dirnames = [] - for index in range(self.count()): - if self.menu_use_tooltips: - text = to_text_string(self.tabToolTip(index)) - else: - text = to_text_string(self.tabText(index)) - names.append(text) - if osp.isfile(text): - # Testing if tab names are filenames - dirnames.append(osp.dirname(text)) - offset = None - - # If tab names are all filenames, removing common path: - if len(names) == len(dirnames): - common = get_common_path(dirnames) - if common is None: - offset = None - else: - offset = len(common)+1 - if offset <= 3: - # Common path is not a path but a drive letter... - offset = None - - for index, text in enumerate(names): - tab_action = create_action(self, text[offset:], - icon=self.tabIcon(index), - toggled=lambda state, index=index: - self.setCurrentIndex(index), - tip=self.tabToolTip(index)) - tab_action.setChecked(index == self.currentIndex()) - self.browse_tabs_menu.addAction(tab_action) - def set_corner_widgets(self, corner_widgets): """ Set tabs corner widgets From 9d10bb63c5dbd1c519239ce4b1816f16373695e1 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 16 Aug 2016 18:22:58 -0500 Subject: [PATCH 2/5] Editor: Remove icons from its tabs --- spyderlib/widgets/editor.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spyderlib/widgets/editor.py b/spyderlib/widgets/editor.py index 0f5156eb475..bbdd0661705 100644 --- a/spyderlib/widgets/editor.py +++ b/spyderlib/widgets/editor.py @@ -32,14 +32,12 @@ from spyderlib.config.gui import (config_shortcut, fixed_shortcut, RUN_CELL_SHORTCUT, RUN_CELL_AND_ADVANCE_SHORTCUT) -from spyderlib.config.utils import get_edit_extensions from spyderlib.py3compat import qbytearray_to_str, to_text_string, u from spyderlib.utils import icon_manager as ima from spyderlib.utils import (codeanalysis, encoding, sourcecode, syntaxhighlighters) from spyderlib.utils.qthelpers import (add_actions, create_action, - create_toolbutton, get_filetype_icon, - mimedata2url) + create_toolbutton, mimedata2url) from spyderlib.widgets.editortools import OutlineExplorerWidget from spyderlib.widgets.fileswitcher import FileSwitcher from spyderlib.widgets.findreplace import FindReplace @@ -978,8 +976,7 @@ def add_to_data(self, finfo, set_current): self.data.sort(key=self.__get_sorting_func()) index = self.data.index(finfo) fname, editor = finfo.filename, finfo.editor - self.tabs.insertTab(index, editor, get_filetype_icon(fname), - self.get_tab_text(fname)) + self.tabs.insertTab(index, editor, self.get_tab_text(fname)) self.set_stack_title(index, False) if set_current: self.set_stack_index(index) @@ -991,14 +988,13 @@ def __repopulate_stack(self): self.tabs.blockSignals(True) self.tabs.clear() for finfo in self.data: - icon = get_filetype_icon(finfo.filename) if finfo.newly_created: is_modified = True else: is_modified = None tab_text = self.get_tab_text(finfo.filename, is_modified) tab_tip = self.get_tab_tip(finfo.filename) - index = self.tabs.addTab(finfo.editor, icon, tab_text) + index = self.tabs.addTab(finfo.editor, tab_text) self.tabs.setTabToolTip(index, tab_tip) self.tabs.blockSignals(False) self.update_fileswitcher_dlg() From 4abaec3481dfb8a0aca41f2ca9f409c7169589c6 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 16 Aug 2016 18:24:02 -0500 Subject: [PATCH 3/5] IPython Console: Remove icons from its tabs --- spyderlib/plugins/ipythonconsole.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spyderlib/plugins/ipythonconsole.py b/spyderlib/plugins/ipythonconsole.py index 88cc8c57719..c9b193ce5a1 100644 --- a/spyderlib/plugins/ipythonconsole.py +++ b/spyderlib/plugins/ipythonconsole.py @@ -1160,8 +1160,7 @@ def get_shellwidget_by_kernelwidget_id(self, kernel_id): def add_tab(self, widget, name): """Add tab""" self.clients.append(widget) - index = self.tabwidget.addTab(widget, ima.icon('ipython_console'), - name) + index = self.tabwidget.addTab(widget, name) self.tabwidget.setCurrentIndex(index) if self.dockwidget and not self.ismaximized: self.dockwidget.setVisible(True) From 9ac92f9537459a89aa69dc87e9fdd3b9b94e3820 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 16 Aug 2016 18:24:38 -0500 Subject: [PATCH 4/5] History Log: Remove icons from its tabs --- spyderlib/plugins/history.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/spyderlib/plugins/history.py b/spyderlib/plugins/history.py index 800d5c32037..2e9349062fb 100644 --- a/spyderlib/plugins/history.py +++ b/spyderlib/plugins/history.py @@ -13,8 +13,8 @@ # Third party imports from qtpy import PYQT5 from qtpy.QtCore import Signal, Slot -from qtpy.QtWidgets import (QFontDialog, QGroupBox, QHBoxLayout, QInputDialog, - QMenu, QToolButton, QVBoxLayout, QWidget) +from qtpy.QtWidgets import (QGroupBox, QHBoxLayout, QInputDialog, QMenu, + QToolButton, QVBoxLayout, QWidget) # Local imports @@ -78,7 +78,6 @@ def __init__(self, parent): self.editors = [] self.filenames = [] - self.icons = [] if PYQT5: SpyderPluginWidget.__init__(self, parent, main = parent) else: @@ -203,11 +202,9 @@ def move_tab(self, index_from, index_to): """ filename = self.filenames.pop(index_from) editor = self.editors.pop(index_from) - icon = self.icons.pop(index_from) self.filenames.insert(index_to, filename) self.editors.insert(index_to, editor) - self.icons.insert(index_to, icon) #------ Public API --------------------------------------------------------- def add_history(self, filename): @@ -221,10 +218,8 @@ def add_history(self, filename): editor = codeeditor.CodeEditor(self) if osp.splitext(filename)[1] == '.py': language = 'py' - icon = ima.icon('python') else: language = 'bat' - icon = ima.icon('cmdprompt') editor.setup_editor(linenumbers=False, language=language, scrollflagarea=False) editor.focus_changed.connect(lambda: self.focus_changed.emit()) @@ -239,11 +234,9 @@ def add_history(self, filename): self.editors.append(editor) self.filenames.append(filename) - self.icons.append(icon) index = self.tabwidget.addTab(editor, osp.basename(filename)) self.find_widget.set_editor(editor) self.tabwidget.setTabToolTip(index, filename) - self.tabwidget.setTabIcon(index, icon) self.tabwidget.setCurrentIndex(index) def append_to_history(self, filename, command): From 1cfc3d504a0396b52e7d2b52019aa193f203b527 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Mon, 22 Aug 2016 16:53:14 -0500 Subject: [PATCH 5/5] Tabs: Restore browse tabs button per review --- spyderlib/widgets/tabs.py | 52 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/spyderlib/widgets/tabs.py b/spyderlib/widgets/tabs.py index f1cd55ed094..fed2206cee9 100644 --- a/spyderlib/widgets/tabs.py +++ b/spyderlib/widgets/tabs.py @@ -12,6 +12,7 @@ # pylint: disable=R0201 # Standard library imports +import os.path as osp import sys # Third party imports @@ -23,9 +24,11 @@ # Local imports from spyderlib.config.base import _ from spyderlib.config.gui import fixed_shortcut -from spyderlib.py3compat import PY2 +from spyderlib.py3compat import PY2, to_text_string from spyderlib.utils import icon_manager as ima -from spyderlib.utils.qthelpers import add_actions, create_toolbutton +from spyderlib.utils.misc import get_common_path +from spyderlib.utils.qthelpers import (add_actions, create_action, + create_toolbutton) class TabBar(QTabBar): @@ -138,8 +141,53 @@ def __init__(self, parent, actions=None, menu=None, corner_widgets = {} corner_widgets.setdefault(Qt.TopLeftCorner, []) corner_widgets.setdefault(Qt.TopRightCorner, []) + self.browse_button = create_toolbutton(self, + icon=ima.icon('browse_tab'), + tip=_("Browse tabs")) + self.browse_tabs_menu = QMenu(self) + self.browse_button.setMenu(self.browse_tabs_menu) + self.browse_button.setPopupMode(self.browse_button.InstantPopup) + self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu) + corner_widgets[Qt.TopLeftCorner] += [self.browse_button] + self.set_corner_widgets(corner_widgets) + + def update_browse_tabs_menu(self): + """Update browse tabs menu""" + self.browse_tabs_menu.clear() + names = [] + dirnames = [] + for index in range(self.count()): + if self.menu_use_tooltips: + text = to_text_string(self.tabToolTip(index)) + else: + text = to_text_string(self.tabText(index)) + names.append(text) + if osp.isfile(text): + # Testing if tab names are filenames + dirnames.append(osp.dirname(text)) + offset = None + # If tab names are all filenames, removing common path: + if len(names) == len(dirnames): + common = get_common_path(dirnames) + if common is None: + offset = None + else: + offset = len(common)+1 + if offset <= 3: + # Common path is not a path but a drive letter... + offset = None + + for index, text in enumerate(names): + tab_action = create_action(self, text[offset:], + icon=self.tabIcon(index), + toggled=lambda state, index=index: + self.setCurrentIndex(index), + tip=self.tabToolTip(index)) + tab_action.setChecked(index == self.currentIndex()) + self.browse_tabs_menu.addAction(tab_action) + def set_corner_widgets(self, corner_widgets): """ Set tabs corner widgets