mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2024-11-22 03:00:15 +00:00
Added a torrent details screen
This commit is contained in:
parent
ce5790be3c
commit
6b106c6e56
3 changed files with 165 additions and 12 deletions
|
@ -129,11 +129,10 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
|
|||
# Exit button
|
||||
self.shutDown()
|
||||
if (controlID == 20):
|
||||
return
|
||||
# A torrent was chosen, show details
|
||||
item = list.getSelectedItem()
|
||||
w = TorrentInfoGUI("script-Transmission-main.xml",os.getcwd() ,"default")
|
||||
w.setTorrent(int(item.getProperty('TorrentID')))
|
||||
w = TorrentInfoGUI("script-Transmission-details.xml",os.getcwd() ,"Default")
|
||||
w.setTorrent(self.transmission, int(item.getProperty('TorrentID')))
|
||||
w.doModal()
|
||||
del w
|
||||
def onFocus(self, controlID):
|
||||
|
@ -147,17 +146,54 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog):
|
|||
|
||||
class TorrentInfoGUI(xbmcgui.WindowXMLDialog):
|
||||
def __init__(self, strXMLname, strFallbackPath, strDefaultName, bforeFallback=0):
|
||||
help(xbmcgui)
|
||||
self.transmission = None
|
||||
self.torrent_id = None
|
||||
pass
|
||||
def setTorrent(t_id):
|
||||
self.list = {}
|
||||
self.repeater = Repeater(1.0, self.updateTorrent)
|
||||
def setTorrent(self, transmission, t_id):
|
||||
self.transmission = transmission
|
||||
self.torrent_id = t_id
|
||||
self.repeater.start()
|
||||
def updateTorrent(self):
|
||||
pbar = self.getControl(219)
|
||||
list = self.getControl(220)
|
||||
labelName = self.getControl(1)
|
||||
labelStatus = self.getControl(2)
|
||||
torrent = self.transmission.info()[self.torrent_id]
|
||||
files = self.transmission.get_files(self.torrent_id)[self.torrent_id]
|
||||
|
||||
statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
|
||||
{'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
|
||||
'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
|
||||
'status': torrent.status}
|
||||
if torrent.status is 'downloading':
|
||||
statusline += " ETA: %(eta)s" % \
|
||||
{'eta': torrent.eta}
|
||||
|
||||
labelName.setLabel(torrent.name)
|
||||
labelStatus.setLabel(statusline)
|
||||
pbar.setPercent(torrent.progress)
|
||||
|
||||
for i, file in files.iteritems():
|
||||
if i not in self.list:
|
||||
# Create a new list item
|
||||
l = xbmcgui.ListItem(label=file['name'])
|
||||
list.addItem(l)
|
||||
self.list[i] = l
|
||||
else:
|
||||
# Update existing list item
|
||||
l = self.list[i]
|
||||
l.setProperty('Progress', '[%3d%%]' % (file['completed'] * 100 / file['size']))
|
||||
def onInit(self):
|
||||
pass
|
||||
self.updateTorrent()
|
||||
def close(self):
|
||||
self.repeater.stop()
|
||||
super(TorrentInfoGUI, self).close()
|
||||
def onAction(self, action):
|
||||
buttonCode = action.getButtonCode()
|
||||
actionID = action.getId()
|
||||
if (buttonCode == KEY_BUTTON_BACK or buttonCode == KEY_KEYBOARD_ESC):
|
||||
if (action.getButtonCode() in CANCEL_DIALOG):
|
||||
self.close()
|
||||
pass
|
||||
def onClick(self, controlID):
|
||||
pass
|
||||
def onFocus(self, controlID):
|
||||
|
|
|
@ -1,13 +1,27 @@
|
|||
<window>
|
||||
<defaultcontrol>20</defaultcontrol>
|
||||
<defaultcontrol>220</defaultcontrol>
|
||||
<allowoverlay>yes</allowoverlay>
|
||||
<coordinates>
|
||||
<system>1</system>
|
||||
<posx>120</posx>
|
||||
<posy>70</posy>
|
||||
</coordinates>
|
||||
<controls>
|
||||
<control type="image">
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>960</width>
|
||||
<height>540</height>
|
||||
<texture>transmission-dialog.png</texture>
|
||||
<animation effect="fade" time="200">WindowOpen</animation>
|
||||
<animation effect="fade" time="200">WindowClose</animation>
|
||||
</control>
|
||||
<control type="label">
|
||||
<description>textarea</description>
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>720</width>
|
||||
<height>40</height>
|
||||
<width>960</width>
|
||||
<height>30</height>
|
||||
<visible>true</visible>
|
||||
<label>Transmission XBMC - Details</label>
|
||||
<font>font11</font>
|
||||
|
@ -15,6 +29,109 @@
|
|||
<align>center</align>
|
||||
</control>
|
||||
<control type="group">
|
||||
<posx>20</posx>
|
||||
<posy>40</posy>
|
||||
<control type="label">
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>140</width>
|
||||
<height>20</height>
|
||||
<label>Name:</label>
|
||||
</control>
|
||||
<control type="label" id="1">
|
||||
<posx>140</posx>
|
||||
<posy>0</posy>
|
||||
<width>800</width>
|
||||
<height>20</height>
|
||||
<label></label>
|
||||
</control>
|
||||
<control type="label">
|
||||
<posx>0</posx>
|
||||
<posy>20</posy>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
<label>Status:</label>
|
||||
</control>
|
||||
<control type="label" id="2">
|
||||
<posx>140</posx>
|
||||
<posy>20</posy>
|
||||
<width>800</width>
|
||||
<height>30</height>
|
||||
<label></label>
|
||||
</control>
|
||||
<control type="progress" id="219">
|
||||
<description>Torrent progress</description>
|
||||
<posx>20</posx>
|
||||
<posy>70</posy>
|
||||
<width>890</width>
|
||||
<height>30</height>
|
||||
<visible>true</visible>
|
||||
</control>
|
||||
</control>
|
||||
<control type="list" id="220">
|
||||
<description>File list</description>
|
||||
<posx>5</posx>
|
||||
<posy>185</posy>
|
||||
<width>950</width>
|
||||
<height>330</height>
|
||||
<viewtype label="File List">list</viewtype>
|
||||
<orientation>vertical</orientation>
|
||||
<visible>true</visible>
|
||||
<itemlayout width="560" height="30">
|
||||
<control type="image">
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>950</width>
|
||||
<height>30</height>
|
||||
<texture>list-bg.png</texture>
|
||||
</control>
|
||||
<control type="label">
|
||||
<posx>10</posx>
|
||||
<posy>0</posy>
|
||||
<width>800</width>
|
||||
<height>30</height>
|
||||
<info>ListItem.label</info>
|
||||
</control>
|
||||
<control type="label">
|
||||
<posx>830</posx>
|
||||
<posy>0</posy>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<info>ListItem.Property(Progress)</info>
|
||||
</control>
|
||||
</itemlayout>
|
||||
<focusedlayout width="560" height="30">
|
||||
<control type="image">
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>950</width>
|
||||
<height>30</height>
|
||||
<visible>Control.HasFocus(20)</visible>
|
||||
<texture border="5">list-bg-selected.png</texture>
|
||||
</control>
|
||||
<control type="image">
|
||||
<posx>0</posx>
|
||||
<posy>0</posy>
|
||||
<width>950</width>
|
||||
<height>30</height>
|
||||
<visible>!Control.HasFocus(20)</visible>
|
||||
<texture border="5">list-bg-selected-nofocus.png</texture>
|
||||
</control>
|
||||
<control type="label">
|
||||
<posx>10</posx>
|
||||
<posy>0</posy>
|
||||
<width>800</width>
|
||||
<height>30</height>
|
||||
<info>ListItem.label</info>
|
||||
</control>
|
||||
<control type="label">
|
||||
<posx>830</posx>
|
||||
<posy>0</posy>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<info>ListItem.Property(Progress)</info>
|
||||
</control>
|
||||
</focusedlayout>
|
||||
</control>
|
||||
</controls>
|
||||
</window>
|
||||
|
|
BIN
resources/skins/Default/media/transmission-dialog.png
Normal file
BIN
resources/skins/Default/media/transmission-dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
Loading…
Reference in a new issue