new checkbox 'SFW'

This commit is contained in:
Romain Bignon 2010-04-29 22:44:46 +02:00
commit 404db79007
3 changed files with 74 additions and 16 deletions

View file

@ -28,6 +28,7 @@ class QVideoob(QtApplication):
VERSION = '1.0'
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
CONFIG = {'settings': {'nsfw': True,
'sfw': True,
'sortby': 0,
'backend': ''
}

View file

@ -44,20 +44,29 @@ class MainWindow(QtMainWindow):
self.ui.backendEdit.setCurrentIndex(i+1)
self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby')))
self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw')))
self.ui.sfwCheckBox.setChecked(int(self.config.get('settings', 'sfw')))
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)
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', self.ui.nsfwCheckBox.isChecked())
self.config.set('settings', 'nsfw', int(self.ui.nsfwCheckBox.isChecked()))
self.updateVideosDisplay()
def sfwChanged(self, state):
self.config.set('settings', 'sfw', int(self.ui.sfwCheckBox.isChecked()))
self.updateVideosDisplay()
def updateVideosDisplay(self):
for minivideo in self.minivideos:
if minivideo.video.nsfw:
if state:
minivideo.show()
else:
minivideo.hide()
if (minivideo.video.nsfw and self.ui.nsfwCheckBox.isChecked() or
not minivideo.video.nsfw and self.ui.sfwCheckBox.isChecked()):
minivideo.show()
else:
minivideo.hide()
def search(self):
pattern = unicode(self.ui.searchEdit.text())
@ -82,9 +91,9 @@ class MainWindow(QtMainWindow):
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())
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())
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):
@ -94,7 +103,9 @@ class MainWindow(QtMainWindow):
minivideo = MiniVideo(backend, video)
self.ui.scrollAreaContent.layout().addWidget(minivideo)
self.minivideos.append(minivideo)
if video.nsfw and not self.ui.nsfwCheckBox.isChecked():
print backend
if (video.nsfw and not self.ui.nsfwCheckBox.isChecked() or
not video.nsfw and not self.ui.sfwCheckBox.isChecked()):
minivideo.hide()
def openURL(self):

View file

@ -71,14 +71,60 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="nsfwCheckBox">
<property name="text">
<string>Display NSFW videos</string>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>10</number>
</property>
<property name="checked">
<bool>true</bool>
<property name="topMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Display:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sfwCheckBox">
<property name="text">
<string>SFW</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="nsfwCheckBox">
<property name="text">
<string>NSFW</string>
</property>
<property name="checked">
<bool>true</bool>
</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>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
@ -94,7 +140,7 @@
<x>0</x>
<y>0</y>
<width>763</width>
<height>393</height>
<height>391</height>
</rect>
</property>
<property name="styleSheet">