[qcineoob] tabification

This commit is contained in:
Julien Veyssier 2013-04-01 21:54:53 +02:00
commit ff0d9ced4d
9 changed files with 428 additions and 299 deletions

View file

@ -21,7 +21,7 @@ import os
import codecs
from PyQt4.QtCore import SIGNAL, Qt, QStringList
from PyQt4.QtGui import QApplication, QCompleter
from PyQt4.QtGui import QApplication, QCompleter, QFrame, QShortcut, QKeySequence
from weboob.capabilities.cinema import ICapCinema
from weboob.capabilities.torrent import ICapTorrent
@ -31,6 +31,7 @@ from weboob.tools.application.qt.backendcfg import BackendCfg
from weboob.applications.suboob.suboob import LANGUAGE_CONV
from weboob.applications.qcineoob.ui.main_window_ui import Ui_MainWindow
from weboob.applications.qcineoob.ui.result_ui import Ui_Result
from .minimovie import MiniMovie
from .miniperson import MiniPerson
@ -42,6 +43,298 @@ from .torrent import Torrent
from .subtitle import Subtitle
class Result(QFrame):
def __init__(self, weboob, app, parent=None):
QFrame.__init__(self, parent)
self.ui = Ui_Result()
self.ui.setupUi(self)
self.parent = parent
self.weboob = weboob
self.app = app
self.minis = []
self.current_info_widget = None
# action history is composed by the last action and the action list
# An action is a function, a list of arguments and a description string
self.action_history = {'last_action': None, 'action_list': []}
self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack)
self.ui.backButton.hide()
def doAction(self, description, fun, args):
''' Call fun with args as arguments
and save it in the action history
'''
self.ui.currentActionLabel.setText(description)
if self.action_history['last_action'] is not None:
self.action_history['action_list'].append(self.action_history['last_action'])
self.ui.backButton.setToolTip(self.action_history['last_action']['description'])
self.ui.backButton.show()
self.action_history['last_action'] = {'function': fun, 'args': args, 'description': description}
return fun(*args)
def doBack(self):
''' Go back in action history
Basically call previous function and update history
'''
if len(self.action_history['action_list']) > 0:
todo = self.action_history['action_list'].pop()
self.ui.currentActionLabel.setText(todo['description'])
self.action_history['last_action'] = todo
if len(self.action_history['action_list']) == 0:
self.ui.backButton.hide()
else:
self.ui.backButton.setToolTip(self.action_history['action_list'][-1]['description'])
return todo['function'](*todo['args'])
def castingAction(self, backend_name, id, role):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.process = QtDo(self.weboob, self.addPerson)
self.process.do('iter_movie_persons', id, role, backends=backend_name, caps=ICapCinema)
self.parent.ui.stopButton.show()
def filmographyAction(self, backend_name, id, role):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.process = QtDo(self.weboob, self.addMovie)
self.process.do('iter_person_movies', id, role, backends=backend_name, caps=ICapCinema)
self.parent.ui.stopButton.show()
def search(self, tosearch, pattern, lang):
if tosearch == 'person':
self.searchPerson(pattern)
elif tosearch == 'movie':
self.searchMovie(pattern)
elif tosearch == 'torrent':
self.searchTorrent(pattern)
elif tosearch == 'subtitle':
self.searchSubtitle(lang, pattern)
def searchMovie(self, pattern):
if not pattern:
return
self.doAction(u'Search movie "%s"' % pattern, self.searchMovieAction, [pattern])
def searchMovieAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addMovie)
#self.process.do('iter_movies', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.parent.getCount(), ('original_title'), 'iter_movies', pattern, backends=backend_name, caps=ICapCinema)
self.parent.ui.stopButton.show()
def stopProcess(self):
self.process.process.finish_event.set()
def addMovie(self, backend, movie):
if not backend:
self.parent.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.parent.ui.stopButton.hide()
return
minimovie = MiniMovie(self.weboob, backend, movie, self)
self.ui.list_content.layout().addWidget(minimovie)
self.minis.append(minimovie)
def displayMovie(self, movie, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wmovie = Movie(movie, backend, self)
self.ui.info_content.layout().addWidget(wmovie)
self.current_info_widget = wmovie
QApplication.restoreOverrideCursor()
def searchPerson(self, pattern):
if not pattern:
return
self.doAction(u'Search person "%s"' % pattern, self.searchPersonAction, [pattern])
def searchPersonAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addPerson)
#self.process.do('iter_persons', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_persons', pattern, backends=backend_name, caps=ICapCinema)
self.parent.ui.stopButton.show()
def addPerson(self, backend, person):
if not backend:
self.parent.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.parent.ui.stopButton.hide()
return
miniperson = MiniPerson(self.weboob, backend, person, self)
self.ui.list_content.layout().addWidget(miniperson)
self.minis.append(miniperson)
def displayPerson(self, person, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wperson = Person(person, backend, self)
self.ui.info_content.layout().addWidget(wperson)
self.current_info_widget = wperson
QApplication.restoreOverrideCursor()
def searchTorrent(self, pattern):
if not pattern:
return
self.doAction(u'Search torrent "%s"' % pattern, self.searchTorrentAction, [pattern])
def searchTorrentAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addTorrent)
#self.process.do('iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
self.parent.ui.stopButton.show()
def addTorrent(self, backend, torrent):
if not backend:
self.parent.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.parent.ui.stopButton.hide()
return
minitorrent = MiniTorrent(self.weboob, backend, torrent, self)
self.ui.list_content.layout().addWidget(minitorrent)
self.minis.append(minitorrent)
def displayTorrent(self, torrent, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wtorrent = Torrent(torrent, backend, self)
self.ui.info_content.layout().addWidget(wtorrent)
self.current_info_widget = wtorrent
def searchSubtitle(self, lang, pattern):
if not pattern:
return
self.doAction(u'Search subtitle "%s" (lang:%s)' % (pattern, lang), self.searchSubtitleAction, [lang, pattern])
def searchSubtitleAction(self, lang, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.parent.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addSubtitle)
#self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
self.parent.ui.stopButton.show()
def addSubtitle(self, backend, subtitle):
if not backend:
self.parent.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.parent.ui.stopButton.hide()
return
minisubtitle = MiniSubtitle(self.weboob, backend, subtitle, self)
self.ui.list_content.layout().addWidget(minisubtitle)
self.minis.append(minisubtitle)
def displaySubtitle(self, subtitle, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wsubtitle = Subtitle(subtitle, backend, self)
self.ui.info_content.layout().addWidget(wsubtitle)
self.current_info_widget = wsubtitle
def searchId(self, id, stype):
QApplication.setOverrideCursor(Qt.WaitCursor)
title_field = 'name'
if stype == 'movie':
cap = ICapCinema
title_field = 'original_title'
elif stype == 'person':
cap = ICapCinema
elif stype == 'torrent':
cap = ICapTorrent
elif stype == 'subtitle':
cap = ICapSubtitle
if '@' in id:
backend_name = id.split('@')[1]
id = id.split('@')[0]
else:
backend_name = None
for backend in self.weboob.iter_backends():
if backend.has_caps(cap) and ((backend_name and backend.name == backend_name) or not backend_name):
exec('object = backend.get_%s(id)' % (stype))
if object:
func_display = 'self.display' + stype[0].upper() + stype[1:]
exec("self.doAction('Details of %s \"%%s\"' %% object.%s, %s, [object, backend])" %
(stype, title_field, func_display))
QApplication.restoreOverrideCursor()
class MainWindow(QtMainWindow):
def __init__(self, config, weboob, app, parent=None):
QtMainWindow.__init__(self, parent)
@ -51,21 +344,11 @@ class MainWindow(QtMainWindow):
self.config = config
self.weboob = weboob
self.app = app
self.minis = []
self.current_info_widget = None
# search history is a list of patterns which have been searched
self.search_history = self.loadSearchHistory()
self.updateCompletion()
# action history is composed by the last action and the action list
# An action is a function, a list of arguments and a description string
self.action_history = {'last_action': None, 'action_list': []}
self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack)
self.ui.backButton.hide()
self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess)
self.ui.stopButton.hide()
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"), self.typeComboChanged)
@ -75,8 +358,20 @@ class MainWindow(QtMainWindow):
showT = self.config.get('settings', 'showthumbnails')
self.ui.showTCheck.setChecked(showT == '1')
self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess)
self.ui.stopButton.hide()
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.actionQuit, SIGNAL("triggered()"), self.close)
q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self)
self.connect(q, SIGNAL("activated()"), self.close)
n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self)
self.connect(n, SIGNAL("activated()"), self.nextTab)
p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self)
self.connect(p, SIGNAL("activated()"), self.prevTab)
w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
self.connect(w, SIGNAL("activated()"), self.closeCurrentTab)
self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"),self.closeTab)
self.loadBackendsList()
@ -90,6 +385,73 @@ class MainWindow(QtMainWindow):
self.ui.langCombo.hide()
self.ui.langLabel.hide()
def stopProcess(self):
self.ui.resultsTab.currentWidget().stopProcess()
def closeTab(self, index):
if self.ui.resultsTab.widget(index) != 0:
tabToClose = self.ui.resultsTab.widget(index)
self.ui.resultsTab.removeTab(index)
del(tabToClose)
def closeCurrentTab(self):
self.closeTab(self.ui.resultsTab.currentIndex())
def prevTab(self):
index = self.ui.resultsTab.currentIndex() - 1
size = self.ui.resultsTab.count()
if size != 0:
self.ui.resultsTab.setCurrentIndex(index % size)
def nextTab(self):
index = self.ui.resultsTab.currentIndex() + 1
size = self.ui.resultsTab.count()
if size != 0:
self.ui.resultsTab.setCurrentIndex(index % size)
def newTab(self, txt, backend, person=None, movie=None, torrent=None, subtitle=None):
id = ''
if person != None:
id = person.id
stype = 'person'
elif movie != None:
id = movie.id
stype = 'movie'
elif subtitle != None:
id = subtitle.id
stype = 'subtitle'
elif torrent != None:
id = torrent.id
stype = 'torrent'
new_res = Result(self.weboob, self.app, self)
self.ui.resultsTab.addTab(new_res, txt)
self.ui.resultsTab.setCurrentWidget(new_res)
new_res.searchId(id, stype)
def search(self):
pattern = unicode(self.ui.searchEdit.text())
# arbitrary max number of completion word
if len(self.search_history) > 50:
self.search_history.pop(0)
if pattern not in self.search_history:
self.search_history.append(pattern)
self.updateCompletion()
tosearch = self.ui.typeCombo.currentText()
lang = self.ui.langCombo.currentText()
new_res = Result(self.weboob, self.app, self)
self.ui.resultsTab.addTab(new_res, pattern)
self.ui.resultsTab.setCurrentWidget(new_res)
new_res.search(tosearch, pattern, lang)
def searchId(self):
id = unicode(self.ui.idEdit.text())
stype = unicode(self.ui.idTypeCombo.currentText())
new_res = Result(self.weboob, self.app, self)
self.ui.resultsTab.addTab(new_res, id)
self.ui.resultsTab.setCurrentWidget(new_res)
new_res.searchId(id, stype)
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapCinema, ICapTorrent, ICapSubtitle,), self)
if bckndcfg.run():
@ -151,295 +513,6 @@ class MainWindow(QtMainWindow):
else:
return num
def doAction(self, description, fun, args):
''' Call fun with args as arguments
and save it in the action history
'''
self.ui.currentActionLabel.setText(description)
if self.action_history['last_action'] is not None:
self.action_history['action_list'].append(self.action_history['last_action'])
self.ui.backButton.setToolTip(self.action_history['last_action']['description'])
self.ui.backButton.show()
self.action_history['last_action'] = {'function': fun, 'args': args, 'description': description}
return fun(*args)
def doBack(self):
''' Go back in action history
Basically call previous function and update history
'''
if len(self.action_history['action_list']) > 0:
todo = self.action_history['action_list'].pop()
self.ui.currentActionLabel.setText(todo['description'])
self.action_history['last_action'] = todo
if len(self.action_history['action_list']) == 0:
self.ui.backButton.hide()
else:
self.ui.backButton.setToolTip(self.action_history['action_list'][-1]['description'])
return todo['function'](*todo['args'])
def castingAction(self, backend_name, id, role):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.process = QtDo(self.weboob, self.addPerson)
self.process.do('iter_movie_persons', id, role, backends=backend_name, caps=ICapCinema)
self.ui.stopButton.show()
def filmographyAction(self, backend_name, id, role):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
self.process = QtDo(self.weboob, self.addMovie)
self.process.do('iter_person_movies', id, role, backends=backend_name, caps=ICapCinema)
self.ui.stopButton.show()
def search(self):
pattern = unicode(self.ui.searchEdit.text())
# arbitrary max number of completion word
if len(self.search_history) > 50:
self.search_history.pop(0)
if pattern not in self.search_history:
self.search_history.append(pattern)
self.updateCompletion()
tosearch = self.ui.typeCombo.currentText()
if tosearch == 'person':
self.searchPerson()
elif tosearch == 'movie':
self.searchMovie()
elif tosearch == 'torrent':
self.searchTorrent()
elif tosearch == 'subtitle':
self.searchSubtitle()
def searchMovie(self):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search movie "%s"' % pattern, self.searchMovieAction, [pattern])
def searchMovieAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addMovie)
#self.process.do('iter_movies', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.getCount(), ('original_title'), 'iter_movies', pattern, backends=backend_name, caps=ICapCinema)
self.ui.stopButton.show()
def stopProcess(self):
self.process.process.finish_event.set()
def addMovie(self, backend, movie):
if not backend:
self.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.ui.stopButton.hide()
return
minimovie = MiniMovie(self.weboob, backend, movie, self)
self.ui.list_content.layout().addWidget(minimovie)
self.minis.append(minimovie)
def displayMovie(self, movie, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wmovie = Movie(movie, backend, self)
self.ui.info_content.layout().addWidget(wmovie)
self.current_info_widget = wmovie
QApplication.restoreOverrideCursor()
def searchPerson(self):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search person "%s"' % pattern, self.searchPersonAction, [pattern])
def searchPersonAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addPerson)
#self.process.do('iter_persons', pattern, backends=backend_name, caps=ICapCinema)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_persons', pattern, backends=backend_name, caps=ICapCinema)
self.ui.stopButton.show()
def addPerson(self, backend, person):
if not backend:
self.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.ui.stopButton.hide()
return
miniperson = MiniPerson(self.weboob, backend, person, self)
self.ui.list_content.layout().addWidget(miniperson)
self.minis.append(miniperson)
def displayPerson(self, person, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wperson = Person(person, backend, self)
self.ui.info_content.layout().addWidget(wperson)
self.current_info_widget = wperson
QApplication.restoreOverrideCursor()
def searchTorrent(self):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search torrent "%s"' % pattern, self.searchTorrentAction, [pattern])
def searchTorrentAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addTorrent)
#self.process.do('iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_torrents', pattern, backends=backend_name, caps=ICapTorrent)
self.ui.stopButton.show()
def addTorrent(self, backend, torrent):
if not backend:
self.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.ui.stopButton.hide()
return
minitorrent = MiniTorrent(self.weboob, backend, torrent, self)
self.ui.list_content.layout().addWidget(minitorrent)
self.minis.append(minitorrent)
def displayTorrent(self, torrent, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wtorrent = Torrent(torrent, backend, self)
self.ui.info_content.layout().addWidget(wtorrent)
self.current_info_widget = wtorrent
def searchSubtitle(self):
pattern = unicode(self.ui.searchEdit.text())
lang = unicode(self.ui.langCombo.currentText())
if not pattern:
return
self.doAction(u'Search subtitle "%s" (lang:%s)' % (pattern, lang), self.searchSubtitleAction, [lang, pattern])
def searchSubtitleAction(self, lang, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
mini.hide()
mini.deleteLater()
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addSubtitle)
#self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
self.process.do(self.app._do_complete, self.getCount(), ('name'), 'iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
self.ui.stopButton.show()
def addSubtitle(self, backend, subtitle):
if not backend:
self.ui.searchEdit.setEnabled(True)
QApplication.restoreOverrideCursor()
self.process = None
self.ui.stopButton.hide()
return
minisubtitle = MiniSubtitle(self.weboob, backend, subtitle, self)
self.ui.list_content.layout().addWidget(minisubtitle)
self.minis.append(minisubtitle)
def displaySubtitle(self, subtitle, backend):
self.ui.stackedWidget.setCurrentWidget(self.ui.info_page)
if self.current_info_widget is not None:
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wsubtitle = Subtitle(subtitle, backend, self)
self.ui.info_content.layout().addWidget(wsubtitle)
self.current_info_widget = wsubtitle
def searchId(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
stype = unicode(self.ui.idTypeCombo.currentText())
title_field = 'name'
if stype == 'movie':
cap = ICapCinema
title_field = 'original_title'
elif stype == 'person':
cap = ICapCinema
elif stype == 'torrent':
cap = ICapTorrent
elif stype == 'subtitle':
cap = ICapSubtitle
id = unicode(self.ui.idEdit.text())
if '@' in id:
backend_name = id.split('@')[1]
id = id.split('@')[0]
else:
backend_name = None
for backend in self.weboob.iter_backends():
if backend.has_caps(cap) and ((backend_name and backend.name == backend_name) or not backend_name):
exec('object = backend.get_%s(id)' % (stype))
if object:
func_display = 'self.display' + stype[0].upper() + stype[1:]
exec("self.doAction('Details of %s \"%%s\"' %% object.%s, %s, [object, backend])" %
(stype, title_field, func_display))
QApplication.restoreOverrideCursor()
def closeEvent(self, ev):
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
self.ui.backendEdit.currentIndex()).toString()))

View file

@ -40,7 +40,7 @@ class MiniMovie(QFrame):
self.ui.shortDescLabel.setText(movie.short_description)
self.ui.backendLabel.setText(backend.name)
if self.parent.ui.showTCheck.isChecked():
if self.parent.parent.ui.showTCheck.isChecked():
self.gotThumbnail()
def gotThumbnail(self):
@ -64,6 +64,10 @@ class MiniMovie(QFrame):
if event.button() == 2:
self.gotThumbnail()
elif event.button() == 4:
movie = self.backend.get_movie(self.movie.id)
self.parent.parent.newTab(u'Details of movie "%s"' %
movie.original_title, self.backend, movie=movie)
else:
QApplication.setOverrideCursor(Qt.WaitCursor)
movie = self.backend.get_movie(self.movie.id)

View file

@ -46,7 +46,7 @@ class MiniPerson(QFrame):
self.ui.shortDescLabel.hide()
self.ui.backendLabel.setText(backend.name)
if self.parent.ui.showTCheck.isChecked():
if self.parent.parent.ui.showTCheck.isChecked():
self.gotThumbnail()
def gotThumbnail(self):
@ -70,6 +70,10 @@ class MiniPerson(QFrame):
if event.button() == 2:
self.gotThumbnail()
if event.button() == 4:
person = self.backend.get_person(self.person.id)
self.parent.parent.newTab(u'Details of person "%s"' %
person.name, self.backend, person=person)
else:
QApplication.setOverrideCursor(Qt.WaitCursor)
person = self.backend.get_person(self.person.id)

View file

@ -50,6 +50,10 @@ class MiniSubtitle(QFrame):
QFrame.mousePressEvent(self, event)
subtitle = self.backend.get_subtitle(self.subtitle.id)
if subtitle:
self.parent.doAction('Details of subtitle "%s"' %
subtitle.name, self.parent.displaySubtitle, [subtitle, self.backend])
if event.button() == 4:
self.parent.parent.newTab(u'Details of subtitle "%s"' %
subtitle.name, self.backend, subtitle=subtitle)
else:
if subtitle:
self.parent.doAction('Details of subtitle "%s"' %
subtitle.name, self.parent.displaySubtitle, [subtitle, self.backend])

View file

@ -53,6 +53,10 @@ class MiniTorrent(QFrame):
QFrame.mousePressEvent(self, event)
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])
if event.button() == 4:
self.parent.parent.newTab(u'Details of torrent "%s"' %
torrent.name, self.backend, torrent=torrent)
else:
if torrent:
self.parent.doAction('Details of torrent "%s"' %
torrent.name, self.parent.displayTorrent, [torrent, self.backend])

View file

@ -128,141 +128,27 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<widget class="QTabWidget" name="resultsTab">
<property name="currentIndex">
<number>-1</number>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="showTCheck">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;might slow search process&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Show thumbnails</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="backButton">
<property name="maximumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>&lt;&lt;back</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="currentActionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="list_page">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="list_content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>708</width>
<height>260</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="info_page">
<layout class="QVBoxLayout" name="movieInfoLayout">
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="info_content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>26</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8"/>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="showTCheck">
<property name="text">
<string>Show thumbnails</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
@ -323,21 +209,12 @@
<bool>false</bool>
</attribute>
<addaction name="actionBackends"/>
<addaction name="actionQuit"/>
</widget>
<action name="actionBackends">
<property name="text">
<string>Backends</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
</widget>
<resources/>
<connections/>

View file

@ -102,7 +102,7 @@
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>

View file

@ -102,7 +102,7 @@
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>

View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Result</class>
<widget class="QFrame" name="Result">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>645</width>
<height>733</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>10000</width>
<height>10000</height>
</size>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="backButton">
<property name="maximumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>&lt;&lt;back</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="currentActionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="list_page">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="list_content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>663</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="info_page">
<layout class="QVBoxLayout" name="movieInfoLayout">
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="info_content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>26</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8"/>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>