use QtDo
This commit is contained in:
parent
a672c146c9
commit
429c43ab64
3 changed files with 16 additions and 26 deletions
|
|
@ -21,6 +21,7 @@ from PyQt4.QtGui import QWidget, QTreeWidgetItem, QListWidgetItem
|
|||
from PyQt4.QtCore import SIGNAL, Qt
|
||||
|
||||
from weboob.capabilities.messages import ICapMessages
|
||||
from weboob.tools.application.qt import QtDo
|
||||
|
||||
from .ui.messages_manager_ui import Ui_MessagesManager
|
||||
|
||||
|
|
@ -70,18 +71,12 @@ class MessagesManager(QWidget):
|
|||
|
||||
self.ui.backendsList.setEnabled(False)
|
||||
|
||||
def cb(backend, message):
|
||||
self.emit(SIGNAL('gotMessage'), backend, message)
|
||||
|
||||
def eb(backend, err, backtrace):
|
||||
print err
|
||||
print backtrace
|
||||
self.process = QtDo(self.weboob, self._gotMessage)
|
||||
|
||||
if self.backend:
|
||||
process = self.weboob.do_backends(self.backend.name, command)
|
||||
self.process.do_backends(self.backend.name, command)
|
||||
else:
|
||||
process = self.weboob.do_caps(ICapMessages, command)
|
||||
self.process = process.callback_thread(cb, eb)
|
||||
self.process.do_caps(ICapMessages, command)
|
||||
|
||||
def _gotMessage(self, backend, message):
|
||||
if message is None:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
</property>
|
||||
</widget>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
|
||||
from weboob.tools.application.qt import QtMainWindow
|
||||
from weboob.tools.application.qt import QtMainWindow, QtDo
|
||||
|
||||
from weboob.frontends.qvideoob.ui.main_window_ui import Ui_MainWindow
|
||||
|
||||
|
|
@ -48,7 +48,6 @@ class MainWindow(QtMainWindow):
|
|||
self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL)
|
||||
self.connect(self.ui.nsfwCheckBox, SIGNAL("stateChanged(int)"), self.nsfwChanged)
|
||||
self.connect(self.ui.sfwCheckBox, SIGNAL("stateChanged(int)"), self.sfwChanged)
|
||||
self.connect(self, SIGNAL('newData'), self.gotNewData)
|
||||
|
||||
def nsfwChanged(self, state):
|
||||
self.config.set('settings', 'nsfw', int(self.ui.nsfwCheckBox.isChecked()))
|
||||
|
|
@ -78,31 +77,21 @@ class MainWindow(QtMainWindow):
|
|||
self.minivideos = []
|
||||
self.ui.searchEdit.setEnabled(False)
|
||||
|
||||
def cb(backend, video):
|
||||
if backend and backend_name and backend.name != backend_name:
|
||||
return
|
||||
|
||||
self.emit(SIGNAL('newData'), backend, video)
|
||||
|
||||
def eb(backend, err, backtrace):
|
||||
print err
|
||||
print backtrace
|
||||
|
||||
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||
if backend_name:
|
||||
process = self.weboob.do_backends(backend_name, 'iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
else:
|
||||
process = self.weboob.do('iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
self.blah = process.callback_thread(cb, eb)
|
||||
|
||||
def gotNewData(self, backend, video):
|
||||
self.process = QtDo(self.weboob, self.addVideo)
|
||||
if backend_name:
|
||||
self.process.do_backends(backend_name, 'iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
else:
|
||||
self.process.do('iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
|
||||
def addVideo(self, backend, video):
|
||||
if not backend:
|
||||
self.ui.searchEdit.setEnabled(True)
|
||||
return
|
||||
minivideo = MiniVideo(backend, video)
|
||||
self.ui.scrollAreaContent.layout().addWidget(minivideo)
|
||||
self.minivideos.append(minivideo)
|
||||
print backend
|
||||
if (video.nsfw and not self.ui.nsfwCheckBox.isChecked() or
|
||||
not video.nsfw and not self.ui.sfwCheckBox.isChecked()):
|
||||
minivideo.hide()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue