mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Start work on a GUI for FTS
This commit is contained in:
parent
568e931dff
commit
d4e85f06c5
0
src/calibre/gui2/fts/__init__.py
Normal file
0
src/calibre/gui2/fts/__init__.py
Normal file
50
src/calibre/gui2/fts/scan.py
Normal file
50
src/calibre/gui2/fts/scan.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
from qt.core import QCheckBox, QVBoxLayout, QWidget
|
||||
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.fts.utils import get_db
|
||||
|
||||
|
||||
class ScanStatus(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.l = l = QVBoxLayout(self)
|
||||
|
||||
self.enable_fts = b = QCheckBox(self)
|
||||
b.setText(_('Index books in this library to allow searching their full text'))
|
||||
l.addWidget(b)
|
||||
self.apply_fts_state()
|
||||
b.toggled.connect(self.change_fts_state)
|
||||
|
||||
def change_fts_state(self):
|
||||
if not self.enable_fts.isChecked():
|
||||
if not confirm(_('Disabling indexing will mean that all books will have to be re-scanned when re-enabling indexing.'
|
||||
' Are you sure?'), 'disable-fts-indexing', self):
|
||||
return
|
||||
self.db.enable_fts(enabled=self.enable_fts.isChecked())
|
||||
self.apply_fts_state()
|
||||
|
||||
def apply_fts_state(self):
|
||||
b = self.enable_fts
|
||||
f = b.font()
|
||||
f.setBold(not b.isChecked())
|
||||
b.setFont(f)
|
||||
|
||||
@property
|
||||
def db(self):
|
||||
return get_db()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from calibre.gui2 import Application
|
||||
from calibre.library import db
|
||||
get_db.db = db(os.path.expanduser('~/test library'))
|
||||
app = Application([])
|
||||
w = ScanStatus()
|
||||
w.show()
|
||||
app.exec_()
|
12
src/calibre/gui2/fts/utils.py
Normal file
12
src/calibre/gui2/fts/utils.py
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from calibre.gui2.ui import get_gui
|
||||
|
||||
|
||||
def get_db():
|
||||
if hasattr(get_db, 'db'):
|
||||
return get_db.db.new_api
|
||||
return get_gui().current_db.new_api
|
Loading…
x
Reference in New Issue
Block a user