diff --git a/src/calibre/gui2/actions/fts.py b/src/calibre/gui2/actions/fts.py index bdfd2f0ed0..ccf960ccb9 100644 --- a/src/calibre/gui2/actions/fts.py +++ b/src/calibre/gui2/actions/fts.py @@ -28,6 +28,6 @@ class FullTextSearchAction(InterfaceAction): self.dialog.show() self.dialog.raise_() - def library_about_to_change(self, olddb, db): + def library_changed(self, db): if self._dialog is not None: self._dialog.library_changed() diff --git a/src/calibre/gui2/fts/dialog.py b/src/calibre/gui2/fts/dialog.py index faf9ac02bf..b396d61232 100644 --- a/src/calibre/gui2/fts/dialog.py +++ b/src/calibre/gui2/fts/dialog.py @@ -37,12 +37,16 @@ class FTSDialog(Dialog): self.results_panel = rp = ResultsPanel(self) rp.switch_to_scan_panel.connect(self.show_scan_status) s.addWidget(ss), s.addWidget(rp) - if ss.indexing_progress.almost_complete: + self.show_appropriate_panel() + self.update_indexing_label() + self.scan_status.indexing_progress_changed.connect(self.update_indexing_label) + + def show_appropriate_panel(self): + ss = self.scan_status + if ss.indexing_enabled and ss.indexing_progress.almost_complete: self.show_results_panel() else: self.show_scan_status() - self.update_indexing_label() - self.scan_status.indexing_progress_changed.connect(self.update_indexing_label) def update_indexing_label(self): ip = self.scan_status.indexing_progress @@ -52,12 +56,11 @@ class FTSDialog(Dialog): self.indexing_label.setVisible(True) try: p = (ip.total - ip.left) / ip.total - p = int(100 * p) except Exception: self.indexing_label.setVisible(False) else: if p < 100: - t = _('Indexing is only {0}% done').format(p) + t = _('Indexing is only {0:.0%} done').format(p) ss = '' if p < 90: ss = 'QLabel { color: red }' @@ -79,6 +82,8 @@ class FTSDialog(Dialog): def library_changed(self): self.results_panel.clear_results() + self.scan_status.reset_indexing_state_for_current_db() + self.show_appropriate_panel() def sizeHint(self): return QSize(1000, 680) diff --git a/src/calibre/gui2/fts/scan.py b/src/calibre/gui2/fts/scan.py index fc07ee0099..50b2ea2fc5 100644 --- a/src/calibre/gui2/fts/scan.py +++ b/src/calibre/gui2/fts/scan.py @@ -101,7 +101,7 @@ class ScanProgress(QWidget): self.switch_anyway.setText(_('Start &searching')) else: done = total - left - t = _('{0} of {1} book files ({2:.0%}) have been indexed').format( + t = _('{0} of {1} book files, {2:.0%} have been indexed').format( done, total, done / (total or 1)) self.warn_label.setVisible(True) self.switch_anyway.setIcon(QIcon.ic('dialog_warning.png')) @@ -187,9 +187,21 @@ class ScanStatus(QWidget): with BusyCursor(): self.db.reindex_fts() + @property + def indexing_enabled(self): + return self.enable_fts.isChecked() + + def reset_indexing_state_for_current_db(self): + self.enable_fts.blockSignals(True) + self.enable_fts.setChecked(self.db.is_fts_enabled()) + self.enable_fts.blockSignals(False) + self.update_stats() + self.apply_fts_state() + def shutdown(self): self.indexing_status_timer.stop() self.scan_progress.slow_button.setChecked(True) + self.reset_indexing_state_for_current_db() if __name__ == '__main__':