mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 06:58:42 +00:00
Merge branch 'master' into multiuser-oldprefs
This commit is contained in:
commit
e6773dfce1
3 changed files with 75 additions and 11 deletions
|
@ -43,7 +43,23 @@ import deluge.common
|
||||||
|
|
||||||
import os,base64,glob
|
import os,base64,glob
|
||||||
|
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def __bracket_fixup(path):
|
||||||
|
if (path.find("[") == -1 and
|
||||||
|
path.find("]") == -1):
|
||||||
|
return path
|
||||||
|
sentinal = 256
|
||||||
|
while (path.find(unichr(sentinal)) != -1):
|
||||||
|
sentinal+=1
|
||||||
|
if sentinal > 65535:
|
||||||
|
log.error("Can't fix brackets in path, path contains all possible sentinal characters")
|
||||||
|
return path
|
||||||
|
newpath = path.replace("]",unichr(sentinal))
|
||||||
|
newpath = newpath.replace("[","[[]")
|
||||||
|
newpath = newpath.replace(unichr(sentinal),"[]]")
|
||||||
|
return newpath
|
||||||
|
|
||||||
def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
||||||
t_options = {}
|
t_options = {}
|
||||||
|
@ -57,7 +73,7 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
||||||
if is_url or is_mag:
|
if is_url or is_mag:
|
||||||
files = [t_file]
|
files = [t_file]
|
||||||
else:
|
else:
|
||||||
files = glob.glob(t_file)
|
files = glob.glob(__bracket_fixup(t_file))
|
||||||
num_files = len(files)
|
num_files = len(files)
|
||||||
ress["total"] = num_files
|
ress["total"] = num_files
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ this one) using the up/down arrows.
|
||||||
All popup windows can be closed/canceled by hitting the Esc key \
|
All popup windows can be closed/canceled by hitting the Esc key \
|
||||||
(you might need to wait a second for an Esc to register)
|
(you might need to wait a second for an Esc to register)
|
||||||
|
|
||||||
The actions you can perform and the keys to perform them are as follows: \
|
The actions you can perform and the keys to perform them are as follows:
|
||||||
|
|
||||||
{!info!}'h'{!normal!} - Show this help
|
{!info!}'h'{!normal!} - Show this help
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ about the currently selected torrent, as well as a view of the \
|
||||||
files in the torrent and the ability to set file priorities.
|
files in the torrent and the ability to set file priorities.
|
||||||
|
|
||||||
{!info!}Enter{!normal!} - Show torrent actions popup. Here you can do things like \
|
{!info!}Enter{!normal!} - Show torrent actions popup. Here you can do things like \
|
||||||
pause/resume, remove, recheck and so one. These actions \
|
pause/resume, remove, recheck and so on. These actions \
|
||||||
apply to all currently marked torrents. The currently \
|
apply to all currently marked torrents. The currently \
|
||||||
selected torrent is automatically marked when you press enter.
|
selected torrent is automatically marked when you press enter.
|
||||||
|
|
||||||
|
@ -274,6 +274,8 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
self.__cols_to_show = [pref for pref in column_pref_names if self.config["show_%s"%pref]]
|
self.__cols_to_show = [pref for pref in column_pref_names if self.config["show_%s"%pref]]
|
||||||
self.__columns = [prefs_to_names[col] for col in self.__cols_to_show]
|
self.__columns = [prefs_to_names[col] for col in self.__cols_to_show]
|
||||||
self.__status_fields = column.get_required_fields(self.__columns)
|
self.__status_fields = column.get_required_fields(self.__columns)
|
||||||
|
for rf in ["state","name","queue"]: # we always need these, even if we're not displaying them
|
||||||
|
if not rf in self.__status_fields: self.__status_fields.append(rf)
|
||||||
self.__update_columns()
|
self.__update_columns()
|
||||||
|
|
||||||
def __split_help(self):
|
def __split_help(self):
|
||||||
|
@ -293,6 +295,7 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
else:
|
else:
|
||||||
rem = self.cols - req
|
rem = self.cols - req
|
||||||
var_cols = len(filter(lambda x: x < 0,self.column_widths))
|
var_cols = len(filter(lambda x: x < 0,self.column_widths))
|
||||||
|
if (var_cols > 0):
|
||||||
vw = int(rem/var_cols)
|
vw = int(rem/var_cols)
|
||||||
for i in range(0, len(self.column_widths)):
|
for i in range(0, len(self.column_widths)):
|
||||||
if (self.column_widths[i] < 0):
|
if (self.column_widths[i] < 0):
|
||||||
|
@ -813,8 +816,12 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
effected_lines = [self.cursel-1]
|
effected_lines = [self.cursel-1]
|
||||||
elif chr(c) == 'M':
|
elif chr(c) == 'M':
|
||||||
if self.last_mark >= 0:
|
if self.last_mark >= 0:
|
||||||
self.marked.extend(range(self.last_mark,self.cursel+1))
|
if (self.cursel+1) > self.last_mark:
|
||||||
effected_lines = range(self.last_mark,self.cursel)
|
mrange = range(self.last_mark,self.cursel+1)
|
||||||
|
else:
|
||||||
|
mrange = range(self.cursel-1,self.last_mark)
|
||||||
|
self.marked.extend(mrange[1:])
|
||||||
|
effected_lines = mrange
|
||||||
else:
|
else:
|
||||||
self._mark_unmark(self.cursel)
|
self._mark_unmark(self.cursel)
|
||||||
effected_lines = [self.cursel-1]
|
effected_lines = [self.cursel-1]
|
||||||
|
|
|
@ -59,6 +59,35 @@ except ImportError:
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Big help string that gets displayed when the user hits 'h'
|
||||||
|
HELP_STR = """\
|
||||||
|
This screen shows detailed information about a torrent, and also the \
|
||||||
|
information about the individual files in the torrent.
|
||||||
|
|
||||||
|
You can navigate the file list with the Up/Down arrows and use space to \
|
||||||
|
collapse/expand the file tree.
|
||||||
|
|
||||||
|
All popup windows can be closed/canceled by hitting the Esc key \
|
||||||
|
(you might need to wait a second for an Esc to register)
|
||||||
|
|
||||||
|
The actions you can perform and the keys to perform them are as follows:
|
||||||
|
|
||||||
|
{!info!}'h'{!normal!} - Show this help
|
||||||
|
|
||||||
|
{!info!}'a'{!normal!} - Show torrent actions popup. Here you can do things like \
|
||||||
|
pause/resume, remove, recheck and so on.
|
||||||
|
|
||||||
|
{!info!}'m'{!normal!} - Mark a file
|
||||||
|
{!info!}'c'{!normal!} - Un-mark all files
|
||||||
|
|
||||||
|
{!info!}Space{!normal!} - Expand/Collapse currently selected folder
|
||||||
|
|
||||||
|
{!info!}Enter{!normal!} - Show priority popup in which you can set the \
|
||||||
|
download priority of selected files.
|
||||||
|
|
||||||
|
{!info!}Left Arrow{!normal!} - Go back to torrent overview.
|
||||||
|
"""
|
||||||
|
|
||||||
class TorrentDetail(BaseMode, component.Component):
|
class TorrentDetail(BaseMode, component.Component):
|
||||||
def __init__(self, alltorrentmode, torrentid, stdscr, encoding=None):
|
def __init__(self, alltorrentmode, torrentid, stdscr, encoding=None):
|
||||||
self.alltorrentmode = alltorrentmode
|
self.alltorrentmode = alltorrentmode
|
||||||
|
@ -106,6 +135,8 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
BaseMode.__init__(self, stdscr, encoding)
|
BaseMode.__init__(self, stdscr, encoding)
|
||||||
component.Component.__init__(self, "TorrentDetail", 1, depend=["SessionProxy"])
|
component.Component.__init__(self, "TorrentDetail", 1, depend=["SessionProxy"])
|
||||||
|
|
||||||
|
self.__split_help()
|
||||||
|
|
||||||
self.column_names = ["Filename", "Size", "Progress", "Priority"]
|
self.column_names = ["Filename", "Size", "Progress", "Priority"]
|
||||||
self._update_columns()
|
self._update_columns()
|
||||||
|
|
||||||
|
@ -137,6 +168,9 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
self.torrent_state = state
|
self.torrent_state = state
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
def __split_help(self):
|
||||||
|
self.__help_lines = format_utils.wrap_string(HELP_STR,(self.cols/2)-2)
|
||||||
|
|
||||||
# split file list into directory tree. this function assumes all files in a
|
# split file list into directory tree. this function assumes all files in a
|
||||||
# particular directory are returned together. it won't work otherwise.
|
# particular directory are returned together. it won't work otherwise.
|
||||||
# returned list is a list of lists of the form:
|
# returned list is a list of lists of the form:
|
||||||
|
@ -288,6 +322,7 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
def on_resize(self, *args):
|
def on_resize(self, *args):
|
||||||
BaseMode.on_resize_norefresh(self, *args)
|
BaseMode.on_resize_norefresh(self, *args)
|
||||||
self._update_columns()
|
self._update_columns()
|
||||||
|
self.__split_help()
|
||||||
if self.popup:
|
if self.popup:
|
||||||
self.popup.handle_resize()
|
self.popup.handle_resize()
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
@ -447,6 +482,10 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
self.back_to_overview()
|
self.back_to_overview()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.torrent_state:
|
||||||
|
# actions below only makes sense if there is a torrent state
|
||||||
|
return
|
||||||
|
|
||||||
# Navigate the torrent list
|
# Navigate the torrent list
|
||||||
if c == curses.KEY_UP:
|
if c == curses.KEY_UP:
|
||||||
self.file_list_up()
|
self.file_list_up()
|
||||||
|
@ -470,10 +509,12 @@ class TorrentDetail(BaseMode, component.Component):
|
||||||
if chr(c) == 'm':
|
if chr(c) == 'm':
|
||||||
if self.current_file:
|
if self.current_file:
|
||||||
self._mark_unmark(self.current_file[1])
|
self._mark_unmark(self.current_file[1])
|
||||||
if chr(c) == 'c':
|
elif chr(c) == 'c':
|
||||||
self.marked = {}
|
self.marked = {}
|
||||||
if chr(c) == 'a':
|
elif chr(c) == 'a':
|
||||||
torrent_actions_popup(self,[self.torrentid],details=False)
|
torrent_actions_popup(self,[self.torrentid],details=False)
|
||||||
return
|
return
|
||||||
|
elif chr(c) == 'h':
|
||||||
|
self.popup = Popup(self,"Help",init_lines=self.__help_lines)
|
||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue