diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py index 1f57305945..75ef4b0bd0 100644 --- a/src/calibre/customize/__init__.py +++ b/src/calibre/customize/__init__.py @@ -341,11 +341,12 @@ class FileTypePlugin(Plugin): # {{{ # Default implementation does nothing return path_to_ebook - def postimport(self, id): + def postimport(self, id, db): ''' Run post import. :param id: Library id of the added book. + :param db: Library db. ''' # }}} diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py index 15d448161e..987a6fbb84 100644 --- a/src/calibre/customize/ui.py +++ b/src/calibre/customize/ui.py @@ -172,6 +172,8 @@ run_plugins_on_postprocess = functools.partial(_run_filetype_plugins, occasion='postprocess') def postimport_plugins(id, format): + from calibre.gui2.ui import get_gui + db = get_gui().current_db customization = config['plugin_customization'] format = format.lower() for plugin in _on_postimport.get(format, []): @@ -180,7 +182,7 @@ def postimport_plugins(id, format): plugin.site_customization = customization.get(plugin.name, '') with plugin: try: - plugin.postimport(id) + plugin.postimport(id, db) except: print 'Running file type plugin %s failed with traceback:'%plugin.name traceback.print_exc() diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 895bb5a6b2..14776d1363 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -93,6 +93,7 @@ gprefs.defaults['tag_browser_dont_collapse'] = [] gprefs.defaults['edit_metadata_single_layout'] = 'default' gprefs.defaults['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}' gprefs.defaults['preserve_date_on_ctl'] = True +gprefs.defaults['manual_add_auto_convert'] = False gprefs.defaults['cb_fullscreen'] = False gprefs.defaults['worker_max_time'] = 0 gprefs.defaults['show_files_after_save'] = True diff --git a/src/calibre/gui2/add.py b/src/calibre/gui2/add.py index 4336148816..eb4a2105d7 100644 --- a/src/calibre/gui2/add.py +++ b/src/calibre/gui2/add.py @@ -233,7 +233,7 @@ class DBAdder(QObject): # {{{ with open(path, 'rb') as f: self.db.add_format(id, fmt, f, index_is_id=True, notify=False, replace=replace) - if gprefs['auto_add_auto_convert']: + if gprefs['manual_add_auto_convert']: of = prefs['output_format'] if not of == fmt.lower(): gui = self.parent._parent diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 85636104cb..edfc0dc762 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -756,8 +756,7 @@ class BooksView(QTableView): # {{{ def keyPressEvent(self, event): if event.key() == Qt.Key_Return: - selected_rows = [r.row() for r in self.selectionModel().selectedRows()] - self.display_parent.iactions['View']._view_books(selected_rows) + self.display_parent.iactions['View'].view_book(True) else: return super(BooksView, self).keyPressEvent(event) diff --git a/src/calibre/gui2/preferences/adding.py b/src/calibre/gui2/preferences/adding.py index fafc5b5a1c..266b0ca9cc 100644 --- a/src/calibre/gui2/preferences/adding.py +++ b/src/calibre/gui2/preferences/adding.py @@ -28,6 +28,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('swap_author_names', prefs) r('add_formats_to_existing', prefs) r('preserve_date_on_ctl', gprefs) + r('manual_add_auto_convert', gprefs) choices = [ (_('Ignore duplicate incoming formats'), 'ignore'), (_('Overwrite existing duplicate formats'), 'overwrite'), diff --git a/src/calibre/gui2/preferences/adding.ui b/src/calibre/gui2/preferences/adding.ui index abf5d5f7a5..703d2de1a9 100644 --- a/src/calibre/gui2/preferences/adding.ui +++ b/src/calibre/gui2/preferences/adding.ui @@ -68,13 +68,37 @@ - + When using the "&Copy to library" action to copy books between libraries, preserve the date + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Automatically &convert added files to the current output format + + + + + diff --git a/src/calibre/gui2/viewer/config.py b/src/calibre/gui2/viewer/config.py index e3726c1ecb..10c519cad9 100644 --- a/src/calibre/gui2/viewer/config.py +++ b/src/calibre/gui2/viewer/config.py @@ -61,6 +61,10 @@ def config(defaults=None): help=_('Show reading position in fullscreen mode.')) c.add_opt('fullscreen_scrollbar', default=True, action='store_false', 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('use_book_margins', default=False, action='store_true') 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_scrollbar.setChecked(opts.fullscreen_scrollbar) 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_override_book_margins.setChecked(not opts.use_book_margins) 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_pos', self.opt_fullscreen_pos.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('use_book_margins', not self.opt_override_book_margins.isChecked()) diff --git a/src/calibre/gui2/viewer/config.ui b/src/calibre/gui2/viewer/config.ui index abc5391ebf..23e31dd93f 100644 --- a/src/calibre/gui2/viewer/config.ui +++ b/src/calibre/gui2/viewer/config.ui @@ -402,6 +402,20 @@ QToolBox::tab:hover { + + + + Show fullscreen &message + + + + + + + Save fullscreen state + + + diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index c1927e1907..6bd6c7c740 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -145,6 +145,8 @@ class Document(QWebPage): # {{{ self.fullscreen_clock = opts.fullscreen_clock self.fullscreen_scrollbar = opts.fullscreen_scrollbar 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.cols_per_screen = opts.cols_per_screen self.side_margin = opts.side_margin diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index c11fda7437..d1cb7b3d86 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -274,11 +274,36 @@ class EbookViewer(MainWindow, Ui_EbookViewer): self.tool_bar2.setContextMenuPolicy(Qt.PreventContextMenu) self.tool_bar.widgetForAction(self.action_bookmark).setPopupMode(QToolButton.MenuButtonPopup) self.action_full_screen.setCheckable(True) + self.full_screen_label = QLabel(''' +
+

%s

+

%s

+

%s

+

%s

+
+ '''%(_('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.toggle_toolbar_action = QAction(_('Show/hide controls'), self) self.toggle_toolbar_action.setCheckable(True) self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars) 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.setVisible(False) self.clock_label.setFocusPolicy(Qt.NoFocus) @@ -300,7 +325,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer): self.pos_label.setFocusPolicy(Qt.NoFocus) self.clock_timer = QTimer(self) self.clock_timer.timeout.connect(self.update_clock) - + self.print_menu = QMenu() self.print_menu.addAction(QIcon(I('print-preview.png')), _('Print Preview')) 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(), at_start=True) fullscreen = vprefs.get('fullscreen', None) - if fullscreen: + if fullscreen and self.view.document.fullscreen_save_state: self.showFullScreen() def lookup(self, word): @@ -486,6 +511,25 @@ class EbookViewer(MainWindow, Ui_EbookViewer): 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): self.clock_label.setVisible(True) self.clock_label.setText(QTime(22, 33, @@ -536,6 +580,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer): self.action_full_screen.setChecked(False) self.tool_bar.setVisible(True) self.tool_bar2.setVisible(True) + self.full_screen_label.setVisible(False) if hasattr(self, '_original_frame_margins'): om = self._original_frame_margins self.centralwidget.layout().setContentsMargins(om[0]) @@ -549,7 +594,10 @@ class EbookViewer(MainWindow, Ui_EbookViewer): if self.window_mode_changed: fs = self.window_mode_changed == 'fullscreen' 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.page_position.restore() self.scrolled(self.view.scroll_fraction)