class MiniTorrent(QFrame): def __init__(self, weboob, backend, torrent, parent=None): super(MiniTorrent, self).__init__(parent) self.parent = parent self.ui = Ui_MiniTorrent() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.torrent = torrent self.ui.nameLabel.setText(torrent.name) if not empty(torrent.seeders) and not empty(torrent.leechers): self.ui.seedLeechLabel.setText('%s/%s' % (torrent.seeders, torrent.leechers)) if not empty(torrent.size): self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size)) self.ui.backendButton.setText(backend.name) minfo = self.weboob.repositories.get_module_info(backend.NAME) icon_path = self.weboob.repositories.get_module_icon_path(minfo) if icon_path: pixmap = QPixmapCache.find(icon_path) if not pixmap: pixmap = QPixmap(QImage(icon_path)) self.ui.backendButton.setIcon(QIcon(pixmap)) self.ui.newTabButton.clicked.connect(self.newTabPressed) self.ui.viewButton.clicked.connect(self.viewPressed) @Slot() def viewPressed(self): torrent = self.backend.get_torrent(self.torrent.id) if torrent: self.parent.doAction('Torrent "%s"' % torrent.name, self.parent.displayTorrent, [torrent, self.backend]) @Slot() def newTabPressed(self): torrent = self.backend.get_torrent(self.torrent.id) self.parent.parent.newTab(u'Torrent "%s"' % torrent.name, self.backend, torrent=torrent) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 4: self.newTabPressed() else: self.viewPressed()
class MiniTorrent(QFrame): def __init__(self, weboob, backend, torrent, parent=None): super(MiniTorrent, self).__init__(parent) self.parent = parent self.ui = Ui_MiniTorrent() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.torrent = torrent self.ui.nameLabel.setText(torrent.name) if not empty(torrent.seeders) and not empty(torrent.leechers): self.ui.seedLeechLabel.setText('%s/%s' % (torrent.seeders, torrent.leechers)) if not empty(torrent.size): self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size)) self.ui.backendLabel.setText(backend.name) self.ui.newTabButton.clicked.connect(self.newTabPressed) self.ui.viewButton.clicked.connect(self.viewPressed) @Slot() def viewPressed(self): torrent = self.backend.get_torrent(self.torrent.id) if torrent: self.parent.doAction('Details of torrent "%s"' % torrent.name, self.parent.displayTorrent, [torrent, self.backend]) @Slot() def newTabPressed(self): torrent = self.backend.get_torrent(self.torrent.id) self.parent.parent.newTab(u'Details of torrent "%s"' % torrent.name, self.backend, torrent=torrent) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 4: self.newTabPressed() else: self.viewPressed()