Response to merge review.

1) Fixed by making it optional.

1.5) Fixed by making it optional.

2) Fixed.

3) Not fixed. Can you provide a test file result in the unhandled exception that you describe? The option should be available because (i) the option is off by default and therefore the most novice users (that are least likely to identify the unhandled exception when it occurs) will be unaware of the option and (ii) the option has a larger net value available than not available.

4) Fixed.

5) Fixed.
This commit is contained in:
John Peterson 2012-11-05 06:00:05 +00:00
parent 2772908a3c
commit 8a3ca41c0b
11 changed files with 109 additions and 9 deletions

View File

@ -341,11 +341,12 @@ class FileTypePlugin(Plugin): # {{{
# Default implementation does nothing # Default implementation does nothing
return path_to_ebook return path_to_ebook
def postimport(self, id): def postimport(self, id, db):
''' '''
Run post import. Run post import.
:param id: Library id of the added book. :param id: Library id of the added book.
:param db: Library db.
''' '''
# }}} # }}}

View File

@ -172,6 +172,8 @@ run_plugins_on_postprocess = functools.partial(_run_filetype_plugins,
occasion='postprocess') occasion='postprocess')
def postimport_plugins(id, format): def postimport_plugins(id, format):
from calibre.gui2.ui import get_gui
db = get_gui().current_db
customization = config['plugin_customization'] customization = config['plugin_customization']
format = format.lower() format = format.lower()
for plugin in _on_postimport.get(format, []): for plugin in _on_postimport.get(format, []):
@ -180,7 +182,7 @@ def postimport_plugins(id, format):
plugin.site_customization = customization.get(plugin.name, '') plugin.site_customization = customization.get(plugin.name, '')
with plugin: with plugin:
try: try:
plugin.postimport(id) plugin.postimport(id, db)
except: except:
print 'Running file type plugin %s failed with traceback:'%plugin.name print 'Running file type plugin %s failed with traceback:'%plugin.name
traceback.print_exc() traceback.print_exc()

View File

@ -93,6 +93,7 @@ gprefs.defaults['tag_browser_dont_collapse'] = []
gprefs.defaults['edit_metadata_single_layout'] = 'default' gprefs.defaults['edit_metadata_single_layout'] = 'default'
gprefs.defaults['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}' gprefs.defaults['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}'
gprefs.defaults['preserve_date_on_ctl'] = True gprefs.defaults['preserve_date_on_ctl'] = True
gprefs.defaults['manual_add_auto_convert'] = False
gprefs.defaults['cb_fullscreen'] = False gprefs.defaults['cb_fullscreen'] = False
gprefs.defaults['worker_max_time'] = 0 gprefs.defaults['worker_max_time'] = 0
gprefs.defaults['show_files_after_save'] = True gprefs.defaults['show_files_after_save'] = True

View File

@ -233,7 +233,7 @@ class DBAdder(QObject): # {{{
with open(path, 'rb') as f: with open(path, 'rb') as f:
self.db.add_format(id, fmt, f, index_is_id=True, self.db.add_format(id, fmt, f, index_is_id=True,
notify=False, replace=replace) notify=False, replace=replace)
if gprefs['auto_add_auto_convert']: if gprefs['manual_add_auto_convert']:
of = prefs['output_format'] of = prefs['output_format']
if not of == fmt.lower(): if not of == fmt.lower():
gui = self.parent._parent gui = self.parent._parent

View File

@ -756,8 +756,7 @@ class BooksView(QTableView): # {{{
def keyPressEvent(self, event): def keyPressEvent(self, event):
if event.key() == Qt.Key_Return: if event.key() == Qt.Key_Return:
selected_rows = [r.row() for r in self.selectionModel().selectedRows()] self.display_parent.iactions['View'].view_book(True)
self.display_parent.iactions['View']._view_books(selected_rows)
else: else:
return super(BooksView, self).keyPressEvent(event) return super(BooksView, self).keyPressEvent(event)

View File

@ -28,6 +28,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('swap_author_names', prefs) r('swap_author_names', prefs)
r('add_formats_to_existing', prefs) r('add_formats_to_existing', prefs)
r('preserve_date_on_ctl', gprefs) r('preserve_date_on_ctl', gprefs)
r('manual_add_auto_convert', gprefs)
choices = [ choices = [
(_('Ignore duplicate incoming formats'), 'ignore'), (_('Ignore duplicate incoming formats'), 'ignore'),
(_('Overwrite existing duplicate formats'), 'overwrite'), (_('Overwrite existing duplicate formats'), 'overwrite'),

View File

@ -68,13 +68,37 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0">
<widget class="QCheckBox" name="opt_preserve_date_on_ctl"> <widget class="QCheckBox" name="opt_preserve_date_on_ctl">
<property name="text"> <property name="text">
<string>When using the &quot;&amp;Copy to library&quot; action to copy books between libraries, preserve the date</string> <string>When using the &quot;&amp;Copy to library&quot; action to copy books between libraries, preserve the date</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<item>
<widget class="QCheckBox" name="opt_manual_add_auto_convert">
<property name="text">
<string>Automatically &amp;convert added files to the current output format</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="opt_add_formats_to_existing"> <widget class="QCheckBox" name="opt_add_formats_to_existing">
<property name="toolTip"> <property name="toolTip">

View File

@ -61,6 +61,10 @@ def config(defaults=None):
help=_('Show reading position in fullscreen mode.')) help=_('Show reading position in fullscreen mode.'))
c.add_opt('fullscreen_scrollbar', default=True, action='store_false', c.add_opt('fullscreen_scrollbar', default=True, action='store_false',
help=_('Show the scrollbar in fullscreen mode.')) help=_('Show the scrollbar in fullscreen mode.'))
c.add_opt('fullscreen_message', default=True,
help=_('Show information message when enabling fullscreen.'))
c.add_opt('fullscreen_save_state', default=False,
help=_('Save the fullscreen state.'))
c.add_opt('cols_per_screen', default=1) c.add_opt('cols_per_screen', default=1)
c.add_opt('use_book_margins', default=False, action='store_true') c.add_opt('use_book_margins', default=False, action='store_true')
c.add_opt('top_margin', default=20) c.add_opt('top_margin', default=20)
@ -210,6 +214,8 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.opt_fullscreen_clock.setChecked(opts.fullscreen_clock) self.opt_fullscreen_clock.setChecked(opts.fullscreen_clock)
self.opt_fullscreen_scrollbar.setChecked(opts.fullscreen_scrollbar) self.opt_fullscreen_scrollbar.setChecked(opts.fullscreen_scrollbar)
self.opt_fullscreen_pos.setChecked(opts.fullscreen_pos) self.opt_fullscreen_pos.setChecked(opts.fullscreen_pos)
self.opt_fullscreen_message.setChecked(opts.fullscreen_message)
self.opt_fullscreen_save_state.setChecked(opts.fullscreen_save_state)
self.opt_cols_per_screen.setValue(opts.cols_per_screen) self.opt_cols_per_screen.setValue(opts.cols_per_screen)
self.opt_override_book_margins.setChecked(not opts.use_book_margins) self.opt_override_book_margins.setChecked(not opts.use_book_margins)
for x in ('top', 'bottom', 'side'): for x in ('top', 'bottom', 'side'):
@ -283,6 +289,8 @@ class ConfigDialog(QDialog, Ui_Dialog):
c.set('fullscreen_clock', self.opt_fullscreen_clock.isChecked()) c.set('fullscreen_clock', self.opt_fullscreen_clock.isChecked())
c.set('fullscreen_pos', self.opt_fullscreen_pos.isChecked()) c.set('fullscreen_pos', self.opt_fullscreen_pos.isChecked())
c.set('fullscreen_scrollbar', self.opt_fullscreen_scrollbar.isChecked()) c.set('fullscreen_scrollbar', self.opt_fullscreen_scrollbar.isChecked())
c.set('fullscreen_message', self.opt_fullscreen_message.isChecked())
c.set('fullscreen_save_state', self.opt_fullscreen_save_state.isChecked())
c.set('cols_per_screen', int(self.opt_cols_per_screen.value())) c.set('cols_per_screen', int(self.opt_cols_per_screen.value()))
c.set('use_book_margins', not c.set('use_book_margins', not
self.opt_override_book_margins.isChecked()) self.opt_override_book_margins.isChecked())

View File

@ -402,6 +402,20 @@ QToolBox::tab:hover {
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="opt_fullscreen_message">
<property name="text">
<string>Show fullscreen &amp;message</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="opt_fullscreen_save_state">
<property name="text">
<string>Save fullscreen state</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_6"> <widget class="QWidget" name="page_6">

View File

@ -145,6 +145,8 @@ class Document(QWebPage): # {{{
self.fullscreen_clock = opts.fullscreen_clock self.fullscreen_clock = opts.fullscreen_clock
self.fullscreen_scrollbar = opts.fullscreen_scrollbar self.fullscreen_scrollbar = opts.fullscreen_scrollbar
self.fullscreen_pos = opts.fullscreen_pos self.fullscreen_pos = opts.fullscreen_pos
self.fullscreen_message = opts.fullscreen_message
self.fullscreen_save_state = opts.fullscreen_save_state
self.use_book_margins = opts.use_book_margins self.use_book_margins = opts.use_book_margins
self.cols_per_screen = opts.cols_per_screen self.cols_per_screen = opts.cols_per_screen
self.side_margin = opts.side_margin self.side_margin = opts.side_margin

View File

@ -274,11 +274,36 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
self.tool_bar2.setContextMenuPolicy(Qt.PreventContextMenu) self.tool_bar2.setContextMenuPolicy(Qt.PreventContextMenu)
self.tool_bar.widgetForAction(self.action_bookmark).setPopupMode(QToolButton.MenuButtonPopup) self.tool_bar.widgetForAction(self.action_bookmark).setPopupMode(QToolButton.MenuButtonPopup)
self.action_full_screen.setCheckable(True) self.action_full_screen.setCheckable(True)
self.full_screen_label = QLabel('''
<center>
<h1>%s</h1>
<h3>%s</h3>
<h3>%s</h3>
<h3>%s</h3>
</center>
'''%(_('Full screen mode'),
_('Right click to show controls'),
_('Tap in the left or right page margin to turn pages'),
_('Press Esc to quit')),
self)
self.full_screen_label.setVisible(False)
self.full_screen_label.setStyleSheet('''
QLabel {
text-align: center;
background-color: white;
color: black;
border-width: 1px;
border-style: solid;
border-radius: 20px;
}
''')
self.window_mode_changed = None self.window_mode_changed = None
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self) self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
self.toggle_toolbar_action.setCheckable(True) self.toggle_toolbar_action.setCheckable(True)
self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars) self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars)
self.addAction(self.toggle_toolbar_action) self.addAction(self.toggle_toolbar_action)
self.full_screen_label_anim = QPropertyAnimation(
self.full_screen_label, 'size')
self.clock_label = QLabel('99:99', self) self.clock_label = QLabel('99:99', self)
self.clock_label.setVisible(False) self.clock_label.setVisible(False)
self.clock_label.setFocusPolicy(Qt.NoFocus) self.clock_label.setFocusPolicy(Qt.NoFocus)
@ -300,7 +325,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
self.pos_label.setFocusPolicy(Qt.NoFocus) self.pos_label.setFocusPolicy(Qt.NoFocus)
self.clock_timer = QTimer(self) self.clock_timer = QTimer(self)
self.clock_timer.timeout.connect(self.update_clock) self.clock_timer.timeout.connect(self.update_clock)
self.print_menu = QMenu() self.print_menu = QMenu()
self.print_menu.addAction(QIcon(I('print-preview.png')), _('Print Preview')) self.print_menu.addAction(QIcon(I('print-preview.png')), _('Print Preview'))
self.action_print.setMenu(self.print_menu) self.action_print.setMenu(self.print_menu)
@ -425,7 +450,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
self.toggle_paged_mode(self.action_toggle_paged_mode.isChecked(), self.toggle_paged_mode(self.action_toggle_paged_mode.isChecked(),
at_start=True) at_start=True)
fullscreen = vprefs.get('fullscreen', None) fullscreen = vprefs.get('fullscreen', None)
if fullscreen: if fullscreen and self.view.document.fullscreen_save_state:
self.showFullScreen() self.showFullScreen()
def lookup(self, word): def lookup(self, word):
@ -486,6 +511,25 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
super(EbookViewer, self).showFullScreen() super(EbookViewer, self).showFullScreen()
def show_full_screen_label(self):
f = self.full_screen_label
f.setVisible(True)
height = 200
width = int(0.7*self.view.width())
f.resize(width, height)
f.move((self.view.width() - width)//2, (self.view.height()-height)//2)
a = self.full_screen_label_anim
a.setDuration(500)
a.setStartValue(QSize(width, 0))
a.setEndValue(QSize(width, height))
a.start()
QTimer.singleShot(3500, self.full_screen_label.hide)
self.view.document.switch_to_fullscreen_mode()
if self.view.document.fullscreen_clock:
self.show_clock()
if self.view.document.fullscreen_pos:
self.show_pos_label()
def show_clock(self): def show_clock(self):
self.clock_label.setVisible(True) self.clock_label.setVisible(True)
self.clock_label.setText(QTime(22, 33, self.clock_label.setText(QTime(22, 33,
@ -536,6 +580,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
self.action_full_screen.setChecked(False) self.action_full_screen.setChecked(False)
self.tool_bar.setVisible(True) self.tool_bar.setVisible(True)
self.tool_bar2.setVisible(True) self.tool_bar2.setVisible(True)
self.full_screen_label.setVisible(False)
if hasattr(self, '_original_frame_margins'): if hasattr(self, '_original_frame_margins'):
om = self._original_frame_margins om = self._original_frame_margins
self.centralwidget.layout().setContentsMargins(om[0]) self.centralwidget.layout().setContentsMargins(om[0])
@ -549,7 +594,10 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
if self.window_mode_changed: if self.window_mode_changed:
fs = self.window_mode_changed == 'fullscreen' fs = self.window_mode_changed == 'fullscreen'
self.window_mode_changed = None self.window_mode_changed = None
if not fs: if fs:
if self.view.document.fullscreen_message:
self.show_full_screen_label()
else:
self.view.document.switch_to_window_mode() self.view.document.switch_to_window_mode()
self.view.document.page_position.restore() self.view.document.page_position.restore()
self.scrolled(self.view.scroll_fraction) self.scrolled(self.view.scroll_fraction)