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' VERSION = '1.0'
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon' COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
CONFIG = {'settings': {'nsfw': True, CONFIG = {'settings': {'nsfw': True,
'sfw': True,
'sortby': 0, 'sortby': 0,
'backend': '' 'backend': ''
} }

View file

@ -44,20 +44,29 @@ class MainWindow(QtMainWindow):
self.ui.backendEdit.setCurrentIndex(i+1) self.ui.backendEdit.setCurrentIndex(i+1)
self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby'))) self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby')))
self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw'))) 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.searchEdit, SIGNAL("returnPressed()"), self.search)
self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL) self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL)
self.connect(self.ui.nsfwCheckBox, SIGNAL("stateChanged(int)"), self.nsfwChanged) 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) self.connect(self, SIGNAL('newData'), self.gotNewData)
def nsfwChanged(self, state): 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: for minivideo in self.minivideos:
if minivideo.video.nsfw: if (minivideo.video.nsfw and self.ui.nsfwCheckBox.isChecked() or
if state: not minivideo.video.nsfw and self.ui.sfwCheckBox.isChecked()):
minivideo.show() minivideo.show()
else: else:
minivideo.hide() minivideo.hide()
def search(self): def search(self):
pattern = unicode(self.ui.searchEdit.text()) 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()) backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
if backend_name: 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: 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) self.blah = process.callback_thread(cb, eb)
def gotNewData(self, backend, video): def gotNewData(self, backend, video):
@ -94,7 +103,9 @@ class MainWindow(QtMainWindow):
minivideo = MiniVideo(backend, video) minivideo = MiniVideo(backend, video)
self.ui.scrollAreaContent.layout().addWidget(minivideo) self.ui.scrollAreaContent.layout().addWidget(minivideo)
self.minivideos.append(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() minivideo.hide()
def openURL(self): def openURL(self):

View file

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