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

PR: Fix running in dedicated consoles and other UI fixes #4719

Merged
merged 7 commits into from
Jul 8, 2017
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
2 changes: 1 addition & 1 deletion spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def signal_handler(signum, frame=None):
if options.window_title is not None:
title += ' -- ' + options.window_title

if DEV or DEBUG or PYTEST:
if DEBUG or PYTEST:
# Show errors in internal console when developing or testing.
CONF.set('main', 'show_internal_console_if_traceback', True)

Expand Down
17 changes: 10 additions & 7 deletions spyder/plugins/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
from spyder.widgets.sourcecode.codeeditor import CodeEditor


HDPI_QT_PAGE = "http://doc.qt.io/qt-5/highdpi.html"


class ConfigAccessMixin(object):
"""Namespace for methods that access config storage"""
CONF_SECTION = None
Expand Down Expand Up @@ -872,9 +875,6 @@ def setup_page(self):
tear_off_box = newcb(_("Tear off menus"), 'tear_off_menus',
tip=_("Set this to detach any<br> "
"menu from the main window"))
high_dpi_scaling_box = newcb(_("Enable high DPI scaling"),
'high_dpi_scaling',
tip=_("Set this for high DPI displays"))
margin_box = newcb(_("Custom margin for panes:"),
'use_custom_margin')
margin_spin = self.create_spinbox("", _("pixels"), 'custom_margin',
Expand All @@ -901,7 +901,6 @@ def setup_page(self):
interface_layout.addWidget(verttabs_box)
interface_layout.addWidget(animated_box)
interface_layout.addWidget(tear_off_box)
interface_layout.addWidget(high_dpi_scaling_box)
interface_layout.addLayout(margins_layout)
interface_group.setLayout(interface_layout)

Expand Down Expand Up @@ -953,9 +952,13 @@ def setup_page(self):
# --- Screen resolution Group (hidpi)
screen_resolution_group = QGroupBox(_("Screen resolution"))
screen_resolution_bg = QButtonGroup(screen_resolution_group)
screen_resolution_label = QLabel(_("Configurations for highdpi screens, "
"See: <a href=\"http://doc.qt.io/qt-5/highdpi.html\">http://doc.qt.io/qt-5/highdpi.html</a><> "
"for more information"))
screen_resolution_label = QLabel(_("Configuration for high DPI "
"screens<br><br>"
"Please see "
"<a href=\"{0}\">{0}</a><> "
"for more information about "
"these options (in "
"English).").format(HDPI_QT_PAGE))
screen_resolution_label.setWordWrap(True)

normal_radio = self.create_radiobutton(
Expand Down
10 changes: 7 additions & 3 deletions spyder/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,9 @@ def create_client_for_file(self, filename):
def get_client_for_file(self, filename):
"""Get client associated with a given file."""
client = None
for cl in self.get_clients():
if cl.given_name == filename:
for idx, cl in enumerate(self.get_clients()):
if self.filenames[idx] == filename:
self.tabwidget.setCurrentIndex(idx)
client = cl
break
return client
Expand Down Expand Up @@ -1383,6 +1384,7 @@ def move_tab(self, index_from, index_to):
client = self.clients.pop(index_from)
self.filenames.insert(index_to, filename)
self.clients.insert(index_to, client)
self.update_tabs_text()
self.update_plugin_title.emit()

def disambiguate_fname(self, fname):
Expand All @@ -1394,9 +1396,11 @@ def disambiguate_fname(self, fname):
def update_tabs_text(self):
"""Update the text from the tabs."""
for index, fname in enumerate(self.filenames):
client = self.clients[index]
if fname:
client = self.clients[index]
self.rename_client_tab(client, self.disambiguate_fname(fname))
else:
self.rename_client_tab(client, None)

def rename_client_tab(self, client, given_name):
"""Rename client's tab"""
Expand Down
2 changes: 1 addition & 1 deletion spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def load_data(self):
for index in reversed(self.stack_history):
text = self.tabs.tabText(index)
text = text.replace('&', '')
item = QListWidgetItem(ima.icon('FileIcon'), text)
item = QListWidgetItem(ima.icon('TextFileIcon'), text)
self.addItem(item)

def item_selected(self, item=None):
Expand Down
49 changes: 25 additions & 24 deletions spyder/widgets/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

# Third party imports
from qtpy import PYQT5
from qtpy.QtCore import QByteArray, QMimeData, QPoint, Qt, Signal, QEvent
from qtpy.QtCore import (QByteArray, QEvent, QMimeData, QPoint, Qt, Signal,
Slot)
from qtpy.QtGui import QDrag
from qtpy.QtWidgets import (QApplication, QHBoxLayout, QMenu, QTabBar,
QTabWidget, QWidget, QLineEdit)

# Local imports
from spyder.config.base import _
from spyder.config.gui import config_shortcut
from spyder.py3compat import PY2, to_text_string
from spyder.py3compat import PY2, to_binary_string, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.misc import get_common_path
from spyder.utils.qthelpers import (add_actions, create_action,
Expand Down Expand Up @@ -172,51 +173,49 @@ def mouseMoveEvent(self, event):
QApplication.startDragDistance():
drag = QDrag(self)
mimeData = QMimeData()
# Converting id's to long to avoid an OverflowError with PySide
if PY2:
ancestor_id = long(id(self.ancestor))
parent_widget_id = long(id(self.parentWidget()))
self_id = long(id(self))
else:
ancestor_id = id(self.ancestor)
parent_widget_id = id(self.parentWidget())
self_id = id(self)
mimeData.setData("parent-id", QByteArray.number(ancestor_id))

ancestor_id = to_text_string(id(self.ancestor))
parent_widget_id = to_text_string(id(self.parentWidget()))
self_id = to_text_string(id(self))
source_index = to_text_string(self.tabAt(self.__drag_start_pos))

mimeData.setData("parent-id", to_binary_string(ancestor_id))
mimeData.setData("tabwidget-id",
QByteArray.number(parent_widget_id))
mimeData.setData("tabbar-id", QByteArray.number(self_id))
mimeData.setData("source-index",
QByteArray.number(self.tabAt(self.__drag_start_pos)))
to_binary_string(parent_widget_id))
mimeData.setData("tabbar-id", to_binary_string(self_id))
mimeData.setData("source-index", to_binary_string(source_index))

drag.setMimeData(mimeData)
drag.exec_()
QTabBar.mouseMoveEvent(self, event)

def dragEnterEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
formats = list( mimeData.formats() )
formats = list(mimeData.formats())

if "parent-id" in formats and \
mimeData.data("parent-id").toLong()[0] == id(self.ancestor):
int(mimeData.data("parent-id")) == id(self.ancestor):
event.acceptProposedAction()

QTabBar.dragEnterEvent(self, event)

def dropEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
index_from = mimeData.data("source-index").toInt()[0]
index_from = int(mimeData.data("source-index"))
index_to = self.tabAt(event.pos())
if index_to == -1:
index_to = self.count()
if mimeData.data("tabbar-id").toLong()[0] != id(self):
tabwidget_from = str(mimeData.data("tabwidget-id").toLong()[0])
if int(mimeData.data("tabbar-id")) != id(self):
tabwidget_from = to_text_string(mimeData.data("tabwidget-id"))

# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.sig_move_tab[(str, int, int)].emit(tabwidget_from, index_from,
index_to)

event.acceptProposedAction()
elif index_from != index_to:
self.sig_move_tab.emit(index_from, index_to)
Expand Down Expand Up @@ -441,6 +440,7 @@ def tab_navigate(self, delta=1):
index = self.currentIndex()+delta
self.setCurrentIndex(index)

@Slot(int, int)
def move_tab(self, index_from, index_to):
"""Move tab inside a tabwidget"""
self.move_data.emit(index_from, index_to)
Expand All @@ -456,6 +456,7 @@ def move_tab(self, index_from, index_to):
self.setCurrentWidget(current_widget)
self.move_tab_finished.emit()

@Slot(str, int, int)
def move_tab_from_another_tabwidget(self, tabwidget_from,
index_from, index_to):
"""Move tab from a tabwidget to another"""
Expand All @@ -464,5 +465,5 @@ def move_tab_from_another_tabwidget(self, tabwidget_from,
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.sig_move_tab.emit(tabwidget_from, str(id(self)), index_from,
index_to)
self.sig_move_tab.emit(tabwidget_from, to_text_string(id(self)),
index_from, index_to)