mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
more work on fts ui
This commit is contained in:
parent
5321c544f0
commit
9fff268150
@ -28,9 +28,13 @@ class FTSDialog(Dialog):
|
|||||||
l.addLayout(h)
|
l.addLayout(h)
|
||||||
h.addWidget(self.bb)
|
h.addWidget(self.bb)
|
||||||
self.scan_status = ss = ScanStatus(self)
|
self.scan_status = ss = ScanStatus(self)
|
||||||
|
ss.switch_to_search_panel.connect(self.show_results_panel)
|
||||||
self.results_panel = rp = ResultsPanel(self)
|
self.results_panel = rp = ResultsPanel(self)
|
||||||
s.addWidget(ss), s.addWidget(rp)
|
s.addWidget(ss), s.addWidget(rp)
|
||||||
self.show_scan_status()
|
if ss.indexing_progress.almost_complete:
|
||||||
|
self.show_results_panel()
|
||||||
|
else:
|
||||||
|
self.show_scan_status()
|
||||||
|
|
||||||
def show_scan_status(self):
|
def show_scan_status(self):
|
||||||
self.stack.setCurrentWidget(self.scan_status)
|
self.stack.setCurrentWidget(self.scan_status)
|
||||||
@ -39,6 +43,7 @@ class FTSDialog(Dialog):
|
|||||||
def show_results_panel(self):
|
def show_results_panel(self):
|
||||||
self.stack.setCurrentWidget(self.results_panel)
|
self.stack.setCurrentWidget(self.results_panel)
|
||||||
self.results_panel.specialize_button_box(self.bb)
|
self.results_panel.specialize_button_box(self.bb)
|
||||||
|
self.results_panel.on_show()
|
||||||
|
|
||||||
def library_changed(self):
|
def library_changed(self):
|
||||||
self.results_panel.clear_results()
|
self.results_panel.clear_results()
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, QRadioButton,
|
QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, QPushButton,
|
||||||
QTimer, QVBoxLayout, QWidget, pyqtSignal
|
QRadioButton, QTimer, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import detect_ncpus
|
from calibre import detect_ncpus
|
||||||
@ -28,9 +28,15 @@ class IndexingProgress:
|
|||||||
def complete(self):
|
def complete(self):
|
||||||
return not self.left or not self.total
|
return not self.left or not self.total
|
||||||
|
|
||||||
|
@property
|
||||||
|
def almost_complete(self):
|
||||||
|
return self.complete or (self.left / self.total) > 0.9
|
||||||
|
|
||||||
|
|
||||||
class ScanProgress(QWidget):
|
class ScanProgress(QWidget):
|
||||||
|
|
||||||
|
switch_to_search_panel = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.l = l = QVBoxLayout(self)
|
self.l = l = QVBoxLayout(self)
|
||||||
@ -68,6 +74,9 @@ class ScanProgress(QWidget):
|
|||||||
' Searching will yield incomplete results.')))
|
' Searching will yield incomplete results.')))
|
||||||
la.setWordWrap(True)
|
la.setWordWrap(True)
|
||||||
l.addWidget(la)
|
l.addWidget(la)
|
||||||
|
self.switch_anyway = sa = QPushButton(self)
|
||||||
|
sa.clicked.connect(self.switch_to_search_panel)
|
||||||
|
l.addWidget(sa)
|
||||||
|
|
||||||
def change_speed(self):
|
def change_speed(self):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
@ -82,17 +91,22 @@ class ScanProgress(QWidget):
|
|||||||
if complete:
|
if complete:
|
||||||
t = _('All book files indexed')
|
t = _('All book files indexed')
|
||||||
self.warn_label.setVisible(False)
|
self.warn_label.setVisible(False)
|
||||||
|
self.switch_anyway.setIcon(QIcon.ic('search.png'))
|
||||||
|
self.switch_anyway.setText(_('Start &searching'))
|
||||||
else:
|
else:
|
||||||
done = total - left
|
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))
|
done, total, done / (total or 1))
|
||||||
self.warn_label.setVisible(True)
|
self.warn_label.setVisible(True)
|
||||||
|
self.switch_anyway.setIcon(QIcon.ic('dialog_warning.png'))
|
||||||
|
self.switch_anyway.setText(_('Start &searching even with incomplete indexing'))
|
||||||
self.status_label.setText(t)
|
self.status_label.setText(t)
|
||||||
|
|
||||||
|
|
||||||
class ScanStatus(QWidget):
|
class ScanStatus(QWidget):
|
||||||
|
|
||||||
indexing_progress_changed = pyqtSignal(bool, int, int)
|
indexing_progress_changed = pyqtSignal(bool, int, int)
|
||||||
|
switch_to_search_panel = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -112,6 +126,7 @@ class ScanStatus(QWidget):
|
|||||||
la.setWordWrap(True)
|
la.setWordWrap(True)
|
||||||
l.addWidget(la)
|
l.addWidget(la)
|
||||||
self.scan_progress = sc = ScanProgress(self)
|
self.scan_progress = sc = ScanProgress(self)
|
||||||
|
sc.switch_to_search_panel.connect(self.switch_to_search_panel)
|
||||||
self.indexing_progress_changed.connect(self.scan_progress.update)
|
self.indexing_progress_changed.connect(self.scan_progress.update)
|
||||||
l.addWidget(sc)
|
l.addWidget(sc)
|
||||||
|
|
||||||
|
@ -637,6 +637,9 @@ class ResultsPanel(QWidget):
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.clear_results()
|
self.clear_results()
|
||||||
|
|
||||||
|
def on_show(self):
|
||||||
|
self.sip.search_box.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
|
Loading…
x
Reference in New Issue
Block a user