remove keyboard
parent
e1360e2b97
commit
5adeab3e24
170
searchwindow.py
170
searchwindow.py
|
@ -46,29 +46,21 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
right_buttons_count = 7
|
right_buttons_count = 7
|
||||||
right_label_count = 7
|
right_label_count = 7
|
||||||
last_right_buttons_count = 0
|
last_right_buttons_count = 0
|
||||||
last_link = None
|
|
||||||
last_query = None
|
|
||||||
last_top_button = None
|
last_top_button = None
|
||||||
last_right_button = None
|
last_right_button = None
|
||||||
last_listing_mode = None
|
last_listing_mode = None
|
||||||
count = 0
|
count = 0
|
||||||
navi_right_menu = []
|
navi_right_menu = []
|
||||||
navi_top_menu = []
|
navi_top_menu = []
|
||||||
navi = {
|
|
||||||
'last_top_button' : 4,
|
|
||||||
'last_right_button' : 1,
|
|
||||||
'contentList' : [],
|
|
||||||
'searchersList' : [],
|
|
||||||
'addtime' : None,
|
|
||||||
'route':[{'mode':'close', 'params':{}, 'last_listing_item': 0}]
|
|
||||||
}
|
|
||||||
|
|
||||||
icon = __root__ + '/icons/searchwindow/%s.png'
|
icon = __root__ + '/icons/searchwindow/%s.png'
|
||||||
icon_tc = __root__ + '/icons/searchwindow/%s' + getTorrentClientIcon()
|
icon_tc = __root__ + '/icons/searchwindow/%s' + getTorrentClientIcon()
|
||||||
|
|
||||||
def __init__(self, params = None):
|
def __init__(self, params = None):
|
||||||
|
log('SearchWindow init params: '+str(params))
|
||||||
super(SearchWindow, self).__init__(self.localize('Torrenter Search Window'))
|
super(SearchWindow, self).__init__(self.localize('Torrenter Search Window'))
|
||||||
self.setGeometry(1280, 720, 9, 16)
|
self.setGeometry(1280, 720, 9, 16)
|
||||||
|
self.set_navi()
|
||||||
self.set_controls()
|
self.set_controls()
|
||||||
self.connect_controls()
|
self.connect_controls()
|
||||||
if params and params.get('mode'):
|
if params and params.get('mode'):
|
||||||
|
@ -77,14 +69,27 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
elif params.get('mode') == 'search':
|
elif params.get('mode') == 'search':
|
||||||
self.search(params)
|
self.search(params)
|
||||||
else:
|
else:
|
||||||
#self.navi_load()
|
self.navi_load()
|
||||||
self.history()
|
#self.history()
|
||||||
|
|
||||||
if self.listing.size():
|
if self.listing.size():
|
||||||
self.setFocus(self.listing)
|
self.setFocus(self.listing)
|
||||||
else:
|
else:
|
||||||
self.setFocus(self.input_search)
|
self.setFocus(self.input_search)
|
||||||
|
|
||||||
|
def set_navi(self):
|
||||||
|
self.navi = {
|
||||||
|
'last_top_button': 4,
|
||||||
|
'last_right_button': 1,
|
||||||
|
'contentList': [],
|
||||||
|
'searchersList': [],
|
||||||
|
'filesList': [],
|
||||||
|
'last_addtime': None,
|
||||||
|
'last_query': None,
|
||||||
|
'last_link': None,
|
||||||
|
'route': [{'mode': 'close', 'params': {}, 'last_listing_item': 0}]
|
||||||
|
}
|
||||||
|
|
||||||
def set_controls(self):
|
def set_controls(self):
|
||||||
if not __settings__.getSetting('debug') == 'true':
|
if not __settings__.getSetting('debug') == 'true':
|
||||||
self.background.setImage('%s/icons/%s.png' % (__root__, 'ContentPanel'))
|
self.background.setImage('%s/icons/%s.png' % (__root__, 'ContentPanel'))
|
||||||
|
@ -95,38 +100,37 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
self.button_downloadstatus = pyxbmct.Button("",
|
self.button_downloadstatus = pyxbmct.Button("",
|
||||||
focusTexture=self.icon % 'fdownloadstatus',
|
focusTexture=self.icon % 'fdownloadstatus',
|
||||||
noFocusTexture=self.icon % 'nfdownloadstatus')
|
noFocusTexture=self.icon % 'nfdownloadstatus')
|
||||||
self.placeControl(self.button_downloadstatus, 0, 1, 1, 1)
|
self.placeControl(self.button_downloadstatus, 0, 2, 1, 1)
|
||||||
|
|
||||||
self.button_browser = pyxbmct.Button("",
|
self.button_browser = pyxbmct.Button("",
|
||||||
focusTexture=self.icon_tc % 'f',
|
focusTexture=self.icon_tc % 'f',
|
||||||
noFocusTexture=self.icon_tc % 'nf')
|
noFocusTexture=self.icon_tc % 'nf')
|
||||||
self.placeControl(self.button_browser, 0, 2, 1, 1)
|
self.placeControl(self.button_browser, 0, 3, 1, 1)
|
||||||
self.button_keyboard = pyxbmct.Button("", focusTexture=self.icon % 'fkeyboard',
|
|
||||||
noFocusTexture=self.icon % 'nfkeyboard')
|
|
||||||
self.placeControl(self.button_keyboard, 0, 3, 1, 1)
|
|
||||||
self.input_search = pyxbmct.Edit("", _alignment=pyxbmct.ALIGN_CENTER_X | pyxbmct.ALIGN_CENTER_Y)
|
|
||||||
self.placeControl(self.input_search, 0, 4, 1, 5)
|
|
||||||
self.button_search = pyxbmct.Button("", focusTexture=self.icon % 'fsearch',
|
|
||||||
noFocusTexture=self.icon % 'nfsearch')
|
|
||||||
self.placeControl(self.button_search, 0, 9, 1, 1)
|
|
||||||
self.button_history = pyxbmct.Button("", focusTexture=self.icon % 'fhistory',
|
|
||||||
noFocusTexture=self.icon % 'nfhistory')
|
|
||||||
self.placeControl(self.button_history, 0, 10, 1, 1)
|
|
||||||
self.button_watched = pyxbmct.Button("", focusTexture=self.icon % 'fwatched',
|
|
||||||
noFocusTexture=self.icon % 'nfwatched')
|
|
||||||
self.placeControl(self.button_watched, 0, 11, 1, 1)
|
|
||||||
self.button_controlcenter = pyxbmct.Button("", focusTexture=self.icon % 'fcontrolcenter',
|
self.button_controlcenter = pyxbmct.Button("", focusTexture=self.icon % 'fcontrolcenter',
|
||||||
noFocusTexture=self.icon % 'nfcontrolcenter')
|
noFocusTexture=self.icon % 'nfcontrolcenter')
|
||||||
self.placeControl(self.button_controlcenter, 0, 12, 1, 1)
|
self.placeControl(self.button_controlcenter, 0, 4, 1, 1)
|
||||||
|
#self.button_keyboard = pyxbmct.Button("", focusTexture=self.icon % 'fkeyboard',
|
||||||
|
# noFocusTexture=self.icon % 'nfkeyboard')
|
||||||
|
#self.placeControl(self.button_keyboard, 0, 3, 1, 1)
|
||||||
|
self.input_search = pyxbmct.Edit("", _alignment=pyxbmct.ALIGN_CENTER_X | pyxbmct.ALIGN_CENTER_Y)
|
||||||
|
self.placeControl(self.input_search, 0, 5, 1, 6)
|
||||||
|
self.button_search = pyxbmct.Button("", focusTexture=self.icon % 'fsearch',
|
||||||
|
noFocusTexture=self.icon % 'nfsearch')
|
||||||
|
self.placeControl(self.button_search, 0, 11, 1, 1)
|
||||||
|
self.button_history = pyxbmct.Button("", focusTexture=self.icon % 'fhistory',
|
||||||
|
noFocusTexture=self.icon % 'nfhistory')
|
||||||
|
self.placeControl(self.button_history, 0, 12, 1, 1)
|
||||||
|
self.button_watched = pyxbmct.Button("", focusTexture=self.icon % 'fwatched',
|
||||||
|
noFocusTexture=self.icon % 'nfwatched')
|
||||||
|
self.placeControl(self.button_watched, 0, 13, 1, 1)
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
self.listing = pyxbmct.List(_imageWidth=60, _imageHeight=60, _itemTextXOffset=1,
|
self.listing = pyxbmct.List(_imageWidth=60, _imageHeight=60, _itemTextXOffset=1,
|
||||||
_itemTextYOffset=0, _itemHeight=60, _space=0, _alignmentY=4)
|
_itemTextYOffset=0, _itemHeight=60, _space=0, _alignmentY=4)
|
||||||
self.placeControl(self.listing, 1, 0, 8, 14)
|
self.placeControl(self.listing, 1, 0, 8, 14)
|
||||||
|
|
||||||
self.navi_top_menu = [self.button_downloadstatus, self.button_browser, self.button_keyboard,
|
self.navi_top_menu = [self.button_downloadstatus, self.button_browser, self.button_controlcenter,
|
||||||
self.input_search, self.button_search, self.button_history, self.button_watched,
|
self.input_search, self.button_search, self.button_history, self.button_watched]
|
||||||
self.button_controlcenter]
|
|
||||||
|
|
||||||
# Right menu
|
# Right menu
|
||||||
self.right_menu()
|
self.right_menu()
|
||||||
|
@ -157,12 +161,12 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
def set_navigation(self):
|
def set_navigation(self):
|
||||||
# Top menu
|
# Top menu
|
||||||
self.button_browser.setNavigation(self.listing, self.listing, self.button_downloadstatus,
|
self.button_browser.setNavigation(self.listing, self.listing, self.button_downloadstatus,
|
||||||
self.button_keyboard)
|
self.button_controlcenter)
|
||||||
self.button_keyboard.setNavigation(self.listing, self.listing, self.button_browser, self.input_search)
|
self.button_controlcenter.setNavigation(self.listing, self.listing, self.button_browser, self.input_search)
|
||||||
self.input_search.setNavigation(self.listing, self.listing, self.button_keyboard, self.button_search)
|
#self.button_keyboard.setNavigation(self.listing, self.listing, self.button_browser, self.input_search)
|
||||||
|
self.input_search.setNavigation(self.listing, self.listing, self.button_controlcenter, self.button_search)
|
||||||
self.button_search.setNavigation(self.listing, self.listing, self.input_search, self.button_history)
|
self.button_search.setNavigation(self.listing, self.listing, self.input_search, self.button_history)
|
||||||
self.button_history.setNavigation(self.listing, self.listing, self.button_search, self.button_watched)
|
self.button_history.setNavigation(self.listing, self.listing, self.button_search, self.button_watched)
|
||||||
self.button_watched.setNavigation(self.listing, self.listing, self.button_history, self.button_controlcenter)
|
|
||||||
|
|
||||||
self.update_navigation()
|
self.update_navigation()
|
||||||
|
|
||||||
|
@ -175,7 +179,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
# Top menu
|
# Top menu
|
||||||
self.button_downloadstatus.setNavigation(self.listing, self.listing, self.last_right_button,
|
self.button_downloadstatus.setNavigation(self.listing, self.listing, self.last_right_button,
|
||||||
self.button_browser)
|
self.button_browser)
|
||||||
self.button_controlcenter.setNavigation(self.listing, self.listing, self.button_watched, self.last_right_button)
|
self.button_watched.setNavigation(self.listing, self.listing, self.button_history, self.last_right_button)
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
self.listing.setNavigation(self.last_top_button, self.input_search, self.button_downloadstatus,
|
self.listing.setNavigation(self.last_top_button, self.input_search, self.button_downloadstatus,
|
||||||
|
@ -189,20 +193,27 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
def navi_back(self):
|
def navi_back(self):
|
||||||
log('navi_back init')
|
log('navi_back init')
|
||||||
self.navi['route'].pop(-1)
|
self.navi['route'].pop(-1)
|
||||||
|
self.navi['route'][-1]['params']['back'] = True
|
||||||
self.navi_restore()
|
self.navi_restore()
|
||||||
|
|
||||||
def navi_restore(self):
|
def navi_restore(self):
|
||||||
log('navi_restore init')
|
log('navi_restore init')
|
||||||
route = self.navi['route'][-1]
|
route = self.navi['route'][-1]
|
||||||
action = getattr(self, route['mode'])
|
action = getattr(self, route['mode'])
|
||||||
if route['params']:
|
try:
|
||||||
action(route['params'])
|
if route['params']:
|
||||||
else:
|
action(route['params'])
|
||||||
action()
|
else:
|
||||||
self.setFocus(self.listing)
|
action()
|
||||||
log('route[last_listing_item]: '+str(route['last_listing_item']))
|
self.setFocus(self.listing)
|
||||||
if route['last_listing_item'] > 0:
|
log('route[last_listing_item]: ' + str(route['last_listing_item']))
|
||||||
self.listing.selectItem(route['last_listing_item'])
|
if route['last_listing_item'] > 0:
|
||||||
|
self.listing.selectItem(route['last_listing_item'])
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
log('navi_restore ERROR '+traceback.format_exc())
|
||||||
|
self.set_navi()
|
||||||
|
self.history()
|
||||||
|
|
||||||
def navi_load(self):
|
def navi_load(self):
|
||||||
log('navi_load init')
|
log('navi_load init')
|
||||||
|
@ -214,15 +225,15 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
navi = read.read()
|
navi = read.read()
|
||||||
read.close()
|
read.close()
|
||||||
|
|
||||||
log('navi: '+str(navi))
|
log('navi_load navi: '+str(navi))
|
||||||
|
|
||||||
if navi and len(navi) > 0:
|
if navi and len(navi) > 0:
|
||||||
self.navi = json.loads(urllib.unquote_plus(navi))
|
self.navi = json.loads(navi)
|
||||||
self.navi_restore()
|
self.navi_restore()
|
||||||
|
|
||||||
def navi_save(self):
|
def navi_save(self):
|
||||||
log('navi_save init')
|
log('navi_save init')
|
||||||
navi = urllib.quote_plus(json.dumps(self.navi))
|
navi = json.dumps(self.navi)
|
||||||
|
|
||||||
__tmppath__ = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'plugin.video.torrenter')
|
__tmppath__ = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'plugin.video.torrenter')
|
||||||
if not xbmcvfs.exists(__tmppath__):
|
if not xbmcvfs.exists(__tmppath__):
|
||||||
|
@ -232,8 +243,6 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
write.write(navi)
|
write.write(navi)
|
||||||
write.close()
|
write.close()
|
||||||
|
|
||||||
#__settings__.setSetting("navi", navi)
|
|
||||||
|
|
||||||
def navi_update(self):
|
def navi_update(self):
|
||||||
log('navi_update init')
|
log('navi_update init')
|
||||||
try:
|
try:
|
||||||
|
@ -246,7 +255,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
if focused_control == self.listing:
|
if focused_control == self.listing:
|
||||||
item_index = self.listing.getSelectedPosition()
|
item_index = self.listing.getSelectedPosition()
|
||||||
self.navi['route'][-1]['last_listing_item'] = item_index
|
self.navi['route'][-1]['last_listing_item'] = item_index
|
||||||
debug('self.listing getSelectedPosition ' + str(item_index))
|
log('self.listing getSelectedPosition ' + str(item_index))
|
||||||
|
|
||||||
item = self.listing.getSelectedItem()
|
item = self.listing.getSelectedItem()
|
||||||
params = json.loads(item.getfilename())
|
params = json.loads(item.getfilename())
|
||||||
|
@ -284,55 +293,53 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
else:
|
else:
|
||||||
params['back'] = True
|
params['back'] = True
|
||||||
|
|
||||||
|
if focused_control == self.listing:
|
||||||
|
item_index = self.listing.getSelectedPosition()
|
||||||
|
else:
|
||||||
|
item_index = 0
|
||||||
|
self.navi['route'][-1]['last_listing_item'] == item_index
|
||||||
|
|
||||||
self.navi['route'].append({'mode': mode,
|
self.navi['route'].append({'mode': mode,
|
||||||
'params': params,
|
'params': params,
|
||||||
'last_listing_item': 0})
|
'last_listing_item': 0})
|
||||||
|
|
||||||
self.right_menu(mode if not right_menu else right_menu)
|
self.right_menu(mode if not right_menu else right_menu)
|
||||||
self.listing.reset()
|
self.listing.reset()
|
||||||
|
|
||||||
def search(self, params = {}):
|
def search(self, params = {}):
|
||||||
|
log('search init params: ' + str(params))
|
||||||
self.navi_route('search', params)
|
self.navi_route('search', params)
|
||||||
|
|
||||||
get = params.get
|
get = params.get
|
||||||
addtime = get('addtime')
|
addtime = get('addtime')
|
||||||
query = get('query')
|
query = get('query')
|
||||||
|
route = self.navi['route'][-1]
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
search = urllib.unquote_plus(query)
|
self.input_search.setText(query)
|
||||||
external = get("return_name")
|
|
||||||
if external:
|
|
||||||
searcher = 'landing from : %s ' % str(external)
|
|
||||||
else:
|
|
||||||
searcher = ''
|
|
||||||
#self.setWindowTitle(title='%s %s' % ('Torrenter Search Window', searcher))
|
|
||||||
if get('showKey') == 'true':
|
|
||||||
self.input_search.setText(search)
|
|
||||||
self.setFocus(self.input_search)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.input_search.setText(search)
|
|
||||||
query = search
|
|
||||||
else:
|
else:
|
||||||
query = self.input_search.getText()
|
query = self.input_search.getText()
|
||||||
|
|
||||||
log('Search query: ' + str(query))
|
log('Search query: ' + str(query))
|
||||||
|
|
||||||
if not addtime and query == self.last_query:
|
if not addtime and query == self.navi['last_query']:
|
||||||
addtime = self.navi['addtime']
|
addtime = self.navi['last_addtime']
|
||||||
|
|
||||||
searchersList = get_searchersList(addtime)
|
searchersList = get_searchersList(addtime)
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
self.navi['route'][-1]['query'] = query
|
route['params']['query'] = query
|
||||||
if (query != self.last_query or self.navi['searchersList'] != searchersList) and len(query) > 0:
|
if (query != self.navi['last_query'] or self.navi['searchersList'] != searchersList) and len(query) > 0:
|
||||||
self.filesList = get_filesList(query, searchersList, addtime)
|
self.navi['filesList'] = get_filesList(query, searchersList, addtime)
|
||||||
self.navi['addtime'] = addtime
|
route['params']['addtime'] = addtime
|
||||||
|
self.navi['last_addtime'] = addtime
|
||||||
self.navi['searchersList'] = searchersList
|
self.navi['searchersList'] = searchersList
|
||||||
self.last_query = query
|
self.navi['last_query'] = query
|
||||||
elif len(query) == 0:
|
elif len(query) == 0:
|
||||||
self.filesList = []
|
self.navi['filesList'] = []
|
||||||
|
|
||||||
if self.filesList:
|
if self.navi['filesList']:
|
||||||
for (order, seeds, leechers, size, title, link, image) in self.filesList:
|
for (order, seeds, leechers, size, title, link, image) in self.navi['filesList']:
|
||||||
title = titleMake(seeds, leechers, size, title)
|
title = titleMake(seeds, leechers, size, title)
|
||||||
self.drawItem(title, {'mode': 'search_item', 'filename': link}, image)
|
self.drawItem(title, {'mode': 'search_item', 'filename': link}, image)
|
||||||
self.setFocus(self.listing)
|
self.setFocus(self.listing)
|
||||||
|
@ -768,23 +775,20 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
|
|
||||||
def open_torrent(self, params):
|
def open_torrent(self, params):
|
||||||
self.navi_route('open_torrent', params)
|
self.navi_route('open_torrent', params)
|
||||||
# def open_torrent(self, link, tdir=None):
|
|
||||||
get = params.get
|
get = params.get
|
||||||
link = get('link')
|
link = get('link')
|
||||||
tdir = get('tdir')
|
tdir = get('tdir')
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
if link != self.last_link:
|
if link != self.navi['last_link']:
|
||||||
self.navi['contentList'] = get_contentList(link)
|
self.navi['contentList'] = get_contentList(link)
|
||||||
self.last_link = link
|
self.navi['last_link'] = link
|
||||||
|
|
||||||
dirList, contentListNew = cutFolder(self.navi['contentList'], tdir)
|
dirList, contentListNew = cutFolder(self.navi['contentList'], tdir)
|
||||||
|
|
||||||
if not tdir:
|
self.drawItem('..', {'mode': 'torrent_moveup', 'filename': link},
|
||||||
params = {'mode': 'torrent_moveup', 'filename': link}
|
image = 'DefaultFolderBack.png', isFolder=True)
|
||||||
else:
|
|
||||||
params = {'mode': 'torrent_subfolder', 'filename': link}
|
|
||||||
self.drawItem('..', params, image = 'DefaultFolderBack.png', isFolder=True)
|
|
||||||
|
|
||||||
dirList = sorted(dirList, key=lambda x: x[0], reverse=False)
|
dirList = sorted(dirList, key=lambda x: x[0], reverse=False)
|
||||||
for title in dirList:
|
for title in dirList:
|
||||||
|
|
Loading…
Reference in New Issue