ability to select a specific backend, and to display or not NSFW videos
This commit is contained in:
parent
35c0c7385b
commit
bc5d9911f1
2 changed files with 35 additions and 2 deletions
|
|
@ -36,8 +36,21 @@ class MainWindow(QtMainWindow):
|
|||
self.weboob = weboob
|
||||
self.minivideos = []
|
||||
|
||||
self.ui.backendEdit.addItem('All backends', '')
|
||||
for backend in self.weboob.iter_backends():
|
||||
self.ui.backendEdit.addItem(backend.name, backend.name)
|
||||
|
||||
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
|
||||
self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL)
|
||||
self.connect(self.ui.nsfwCheckBox, SIGNAL("stateChanged(int)"), self.nsfwChanged)
|
||||
|
||||
def nsfwChanged(self, state):
|
||||
for minivideo in self.minivideos:
|
||||
if minivideo.video.nsfw:
|
||||
if state:
|
||||
minivideo.show()
|
||||
else:
|
||||
minivideo.hide()
|
||||
|
||||
def search(self):
|
||||
pattern = unicode(self.ui.searchEdit.text())
|
||||
|
|
@ -45,15 +58,22 @@ class MainWindow(QtMainWindow):
|
|||
return
|
||||
|
||||
for minivideo in self.minivideos:
|
||||
self.ui.scrollAreaContent.layout.removeWidget(minivideo)
|
||||
self.ui.scrollAreaContent.layout().removeWidget(minivideo)
|
||||
minivideo.hide()
|
||||
|
||||
self.minivideos = []
|
||||
|
||||
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||
|
||||
for backend in self.weboob.iter_backends():
|
||||
if backend_name and backend.name != backend_name:
|
||||
continue
|
||||
for video in backend.iter_search_results(pattern):
|
||||
minivideo = MiniVideo(backend, video)
|
||||
self.ui.scrollAreaContent.layout().addWidget(minivideo)
|
||||
self.minivideos.append(minivideo)
|
||||
if video.nsfw and not self.ui.nsfwCheckBox.isChecked():
|
||||
minivideo.hide()
|
||||
|
||||
def openURL(self):
|
||||
url = unicode(self.ui.urlEdit.text())
|
||||
|
|
|
|||
|
|
@ -34,9 +34,22 @@
|
|||
<item>
|
||||
<widget class="QLineEdit" name="searchEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="backendEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="nsfwCheckBox">
|
||||
<property name="text">
|
||||
<string>Display NSFW videos</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="styleSheet">
|
||||
|
|
@ -51,7 +64,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>763</width>
|
||||
<height>419</height>
|
||||
<height>393</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue