mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
MTP: Add a way to get device info in the GUI easily
This commit is contained in:
parent
50e9e1f768
commit
c87508d20e
@ -196,6 +196,19 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
self.current_serial_num = snum
|
self.current_serial_num = snum
|
||||||
self.currently_connected_dev = connected_device
|
self.currently_connected_dev = connected_device
|
||||||
|
|
||||||
|
@synchronous
|
||||||
|
def device_debug_info(self):
|
||||||
|
ans = self.get_gui_name()
|
||||||
|
ans += '\nSerial number: %s'%self.current_serial_num
|
||||||
|
ans += '\nManufacturer: %s'%self.dev.manufacturer_name
|
||||||
|
ans += '\nModel: %s'%self.dev.model_name
|
||||||
|
ans += '\nids: %s'%(self.dev.ids,)
|
||||||
|
ans += '\nDevice version: %s'%self.dev.device_version
|
||||||
|
ans += '\nStorage:\n'
|
||||||
|
storage = sorted(self.dev.storage_info, key=operator.itemgetter('id'))
|
||||||
|
ans += pprint.pformat(storage)
|
||||||
|
return ans
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filesystem_cache(self):
|
def filesystem_cache(self):
|
||||||
if self._filesystem_cache is None:
|
if self._filesystem_cache is None:
|
||||||
|
@ -52,6 +52,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
self.start_thread = None
|
self.start_thread = None
|
||||||
self._filesystem_cache = None
|
self._filesystem_cache = None
|
||||||
self.eject_dev_on_next_scan = False
|
self.eject_dev_on_next_scan = False
|
||||||
|
self.current_device_data = {}
|
||||||
|
|
||||||
def startup(self):
|
def startup(self):
|
||||||
self.start_thread = threading.current_thread()
|
self.start_thread = threading.current_thread()
|
||||||
@ -303,6 +304,11 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
_('Unknown MTP device'))
|
_('Unknown MTP device'))
|
||||||
self.currently_connected_pnp_id = connected_device
|
self.currently_connected_pnp_id = connected_device
|
||||||
self.current_serial_num = snum
|
self.current_serial_num = snum
|
||||||
|
self.current_device_data = devdata.copy()
|
||||||
|
|
||||||
|
def device_debug_info(self):
|
||||||
|
import pprint
|
||||||
|
return pprint.pformat(self.current_device_data)
|
||||||
|
|
||||||
@same_thread
|
@same_thread
|
||||||
def get_basic_device_information(self):
|
def get_basic_device_information(self):
|
||||||
|
@ -12,7 +12,8 @@ import weakref
|
|||||||
from PyQt4.Qt import (QWidget, QListWidgetItem, Qt, QToolButton, QLabel,
|
from PyQt4.Qt import (QWidget, QListWidgetItem, Qt, QToolButton, QLabel,
|
||||||
QTabWidget, QGridLayout, QListWidget, QIcon, QLineEdit, QVBoxLayout,
|
QTabWidget, QGridLayout, QListWidget, QIcon, QLineEdit, QVBoxLayout,
|
||||||
QPushButton, QGroupBox, QScrollArea, QHBoxLayout, QComboBox,
|
QPushButton, QGroupBox, QScrollArea, QHBoxLayout, QComboBox,
|
||||||
pyqtSignal, QSizePolicy, QDialog, QDialogButtonBox)
|
pyqtSignal, QSizePolicy, QDialog, QDialogButtonBox, QPlainTextEdit,
|
||||||
|
QApplication)
|
||||||
|
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
@ -372,15 +373,19 @@ class MTPConfig(QTabWidget):
|
|||||||
_('&Ignore the %s in calibre')%device.current_friendly_name,
|
_('&Ignore the %s in calibre')%device.current_friendly_name,
|
||||||
self.base)
|
self.base)
|
||||||
b.clicked.connect(self.ignore_device)
|
b.clicked.connect(self.ignore_device)
|
||||||
|
self.show_debug_button = bd = QPushButton(QIcon(I('debug.png')),
|
||||||
|
_('Show device information'))
|
||||||
|
bd.clicked.connect(self.show_debug_info)
|
||||||
|
|
||||||
l.addWidget(b, 0, 0, 1, 2)
|
l.addWidget(b, 0, 0, 1, 2)
|
||||||
l.addWidget(la, 1, 0, 1, 1)
|
l.addWidget(la, 1, 0, 1, 1)
|
||||||
l.addWidget(self.formats, 2, 0, 3, 1)
|
l.addWidget(self.formats, 2, 0, 4, 1)
|
||||||
l.addWidget(self.send_to, 2, 1, 1, 1)
|
l.addWidget(self.send_to, 2, 1, 1, 1)
|
||||||
l.addWidget(self.template, 3, 1, 1, 1)
|
l.addWidget(self.template, 3, 1, 1, 1)
|
||||||
l.setRowStretch(4, 10)
|
l.addWidget(self.show_debug_button, 4, 1, 1, 1)
|
||||||
l.addWidget(r, 5, 0, 1, 2)
|
l.setRowStretch(5, 10)
|
||||||
l.setRowStretch(5, 100)
|
l.addWidget(r, 6, 0, 1, 2)
|
||||||
|
l.setRowStretch(6, 100)
|
||||||
|
|
||||||
self.igntab = IgnoredDevices(self.device.prefs['history'],
|
self.igntab = IgnoredDevices(self.device.prefs['history'],
|
||||||
self.device.prefs['blacklist'])
|
self.device.prefs['blacklist'])
|
||||||
@ -388,6 +393,26 @@ class MTPConfig(QTabWidget):
|
|||||||
|
|
||||||
self.setCurrentIndex(1 if msg else 0)
|
self.setCurrentIndex(1 if msg else 0)
|
||||||
|
|
||||||
|
def show_debug_info(self):
|
||||||
|
info = self.device.device_debug_info()
|
||||||
|
d = QDialog(self)
|
||||||
|
d.l = l = QVBoxLayout()
|
||||||
|
d.setLayout(l)
|
||||||
|
d.v = v = QPlainTextEdit()
|
||||||
|
d.setWindowTitle(self.device.get_gui_name())
|
||||||
|
v.setPlainText(info)
|
||||||
|
v.setMinimumWidth(400)
|
||||||
|
v.setMinimumHeight(350)
|
||||||
|
l.addWidget(v)
|
||||||
|
bb = d.bb = QDialogButtonBox(QDialogButtonBox.Close)
|
||||||
|
bb.accepted.connect(d.accept)
|
||||||
|
bb.rejected.connect(d.reject)
|
||||||
|
l.addWidget(bb)
|
||||||
|
bb.addButton(_('Copy to clipboard'), bb.ActionRole)
|
||||||
|
bb.clicked.connect(lambda :
|
||||||
|
QApplication.clipboard().setText(v.toPlainText()))
|
||||||
|
d.exec_()
|
||||||
|
|
||||||
def ignore_device(self):
|
def ignore_device(self):
|
||||||
self.igntab.ignore_device(self.device.current_serial_num)
|
self.igntab.ignore_device(self.device.current_serial_num)
|
||||||
self.base.b.setEnabled(False)
|
self.base.b.setEnabled(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user