mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:News scheduler dialog. Show error message if user fails to input required username/password
This commit is contained in:
parent
f89c8134be
commit
dc0a4d9db3
@ -14,7 +14,7 @@ from PyQt4.Qt import QDialog, QApplication, SIGNAL, Qt, QTime, QObject, QMenu, \
|
|||||||
|
|
||||||
from calibre.gui2.dialogs.scheduler_ui import Ui_Dialog
|
from calibre.gui2.dialogs.scheduler_ui import Ui_Dialog
|
||||||
from calibre.gui2.search_box import SearchBox2
|
from calibre.gui2.search_box import SearchBox2
|
||||||
from calibre.gui2 import config as gconf
|
from calibre.gui2 import config as gconf, error_dialog
|
||||||
from calibre.web.feeds.recipes.model import RecipeModel
|
from calibre.web.feeds.recipes.model import RecipeModel
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
|||||||
self.connect(self.recipe_model, SIGNAL('searched(PyQt_PyObject)'),
|
self.connect(self.recipe_model, SIGNAL('searched(PyQt_PyObject)'),
|
||||||
self.search_done)
|
self.search_done)
|
||||||
self.search.setFocus(Qt.OtherFocusReason)
|
self.search.setFocus(Qt.OtherFocusReason)
|
||||||
|
self.commit_on_change = True
|
||||||
|
|
||||||
self.recipes.setModel(self.recipe_model)
|
self.recipes.setModel(self.recipe_model)
|
||||||
self.detail_box.setVisible(False)
|
self.detail_box.setVisible(False)
|
||||||
@ -72,25 +73,32 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
|||||||
self.last_downloaded.setVisible(enabled)
|
self.last_downloaded.setVisible(enabled)
|
||||||
|
|
||||||
def current_changed(self, current, previous):
|
def current_changed(self, current, previous):
|
||||||
if previous.isValid():
|
if self.commit_on_change:
|
||||||
self.commit(urn=getattr(previous.internalPointer(), 'urn', None))
|
if previous.isValid():
|
||||||
|
if not self.commit(urn=getattr(previous.internalPointer(),
|
||||||
|
'urn', None)):
|
||||||
|
self.commit_on_change = False
|
||||||
|
self.recipes.setCurrentIndex(previous)
|
||||||
|
else:
|
||||||
|
self.commit_on_change = True
|
||||||
|
|
||||||
urn = self.current_urn
|
urn = self.current_urn
|
||||||
if urn is not None:
|
if urn is not None:
|
||||||
self.initialize_detail_box(urn)
|
self.initialize_detail_box(urn)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.commit()
|
if not self.commit():
|
||||||
|
return False
|
||||||
return QDialog.accept(self)
|
return QDialog.accept(self)
|
||||||
|
|
||||||
def download_clicked(self):
|
def download_clicked(self):
|
||||||
self.commit()
|
self.commit()
|
||||||
if self.current_urn:
|
if self.commit() and self.current_urn:
|
||||||
self.emit(SIGNAL('download(PyQt_PyObject)'), self.current_urn)
|
self.emit(SIGNAL('download(PyQt_PyObject)'), self.current_urn)
|
||||||
|
|
||||||
def download_all_clicked(self):
|
def download_all_clicked(self):
|
||||||
self.commit()
|
if self.commit() and self.commit():
|
||||||
self.emit(SIGNAL('download(PyQt_PyObject)'), None)
|
self.emit(SIGNAL('download(PyQt_PyObject)'), None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_urn(self):
|
def current_urn(self):
|
||||||
@ -101,10 +109,15 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
|||||||
def commit(self, urn=None):
|
def commit(self, urn=None):
|
||||||
urn = self.current_urn if urn is None else urn
|
urn = self.current_urn if urn is None else urn
|
||||||
if not self.detail_box.isVisible() or urn is None:
|
if not self.detail_box.isVisible() or urn is None:
|
||||||
return
|
return True
|
||||||
|
|
||||||
if self.account.isVisible():
|
if self.account.isVisible():
|
||||||
un, pw = map(unicode, (self.username.text(), self.password.text()))
|
un, pw = map(unicode, (self.username.text(), self.password.text()))
|
||||||
|
if not un and not pw and self.schedule.isChecked():
|
||||||
|
error_dialog(self, _('Need username and password'),
|
||||||
|
_('You must provide a username and/or password to '
|
||||||
|
'use this news source.'), show=True)
|
||||||
|
return False
|
||||||
self.recipe_model.set_account_info(urn, un.strip(), pw.strip())
|
self.recipe_model.set_account_info(urn, un.strip(), pw.strip())
|
||||||
|
|
||||||
if self.schedule.isChecked():
|
if self.schedule.isChecked():
|
||||||
@ -126,6 +139,7 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
|||||||
custom_tags = unicode(self.custom_tags.text()).strip()
|
custom_tags = unicode(self.custom_tags.text()).strip()
|
||||||
custom_tags = [x.strip() for x in custom_tags.split(',')]
|
custom_tags = [x.strip() for x in custom_tags.split(',')]
|
||||||
self.recipe_model.customize_recipe(urn, add_title_tag, custom_tags)
|
self.recipe_model.customize_recipe(urn, add_title_tag, custom_tags)
|
||||||
|
return True
|
||||||
|
|
||||||
def initialize_detail_box(self, urn):
|
def initialize_detail_box(self, urn):
|
||||||
self.detail_box.setVisible(True)
|
self.detail_box.setVisible(True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user