Start search functionality
Multiple fixes
This commit is contained in:
1
TODO
1
TODO
@@ -83,6 +83,7 @@ TODO
|
|||||||
Deselecting all directories in the settings dialog also filters out manually added books
|
Deselecting all directories in the settings dialog also filters out manually added books
|
||||||
Clean up 'switch' page layout
|
Clean up 'switch' page layout
|
||||||
Colors aren't loaded properly for annotation previews
|
Colors aren't loaded properly for annotation previews
|
||||||
|
Cover page shouldn't be scolled midway
|
||||||
|
|
||||||
Secondary:
|
Secondary:
|
||||||
Graphical themes
|
Graphical themes
|
||||||
|
@@ -182,6 +182,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.profileBox.currentIndexChanged.connect(
|
self.bookToolBar.profileBox.currentIndexChanged.connect(
|
||||||
self.profile_functions.format_contentView)
|
self.profile_functions.format_contentView)
|
||||||
self.bookToolBar.profileBox.setCurrentIndex(self.current_profile_index)
|
self.bookToolBar.profileBox.setCurrentIndex(self.current_profile_index)
|
||||||
|
self.bookToolBar.searchBar.textChanged.connect(self.search_book)
|
||||||
|
|
||||||
self.bookToolBar.fontBox.currentFontChanged.connect(self.modify_font)
|
self.bookToolBar.fontBox.currentFontChanged.connect(self.modify_font)
|
||||||
self.bookToolBar.fontSizeBox.currentIndexChanged.connect(self.modify_font)
|
self.bookToolBar.fontSizeBox.currentIndexChanged.connect(self.modify_font)
|
||||||
@@ -211,6 +212,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.tocBox.currentIndexChanged.connect(self.set_toc_position)
|
self.bookToolBar.tocBox.currentIndexChanged.connect(self.set_toc_position)
|
||||||
self.addToolBar(self.bookToolBar)
|
self.addToolBar(self.bookToolBar)
|
||||||
|
|
||||||
|
# Get the stylesheet of the default QLineEdit
|
||||||
|
self.lineEditStyleSheet = self.bookToolBar.searchBar.styleSheet()
|
||||||
|
|
||||||
# Make the correct toolbar visible
|
# Make the correct toolbar visible
|
||||||
self.current_tab = self.tabWidget.currentIndex()
|
self.current_tab = self.tabWidget.currentIndex()
|
||||||
self.tab_switch()
|
self.tab_switch()
|
||||||
@@ -330,6 +334,11 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
def process_post_hoc_files(self, file_list, open_files_after_processing):
|
def process_post_hoc_files(self, file_list, open_files_after_processing):
|
||||||
# Takes care of both dragged and dropped files
|
# Takes care of both dragged and dropped files
|
||||||
# As well as files sent as command line arguments
|
# As well as files sent as command line arguments
|
||||||
|
|
||||||
|
file_list = [i for i in file_list if os.path.exists(i)]
|
||||||
|
if not file_list:
|
||||||
|
return
|
||||||
|
|
||||||
books = sorter.BookSorter(
|
books = sorter.BookSorter(
|
||||||
file_list,
|
file_list,
|
||||||
('addition', 'manual'),
|
('addition', 'manual'),
|
||||||
@@ -338,7 +347,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.temp_dir.path())
|
self.temp_dir.path())
|
||||||
|
|
||||||
parsed_books = books.initiate_threads()
|
parsed_books = books.initiate_threads()
|
||||||
if not parsed_books:
|
if not parsed_books and not open_files_after_processing:
|
||||||
return
|
return
|
||||||
|
|
||||||
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
||||||
@@ -618,6 +627,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.statusMessage.setText(
|
self.statusMessage.setText(
|
||||||
str(self.lib_ref.itemProxyModel.rowCount()) +
|
str(self.lib_ref.itemProxyModel.rowCount()) +
|
||||||
self._translate('Main_UI', ' Books'))
|
self._translate('Main_UI', ' Books'))
|
||||||
|
|
||||||
|
if self.libraryToolBar.searchBar.text() != '':
|
||||||
|
self.statusBar.setVisible(True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if self.settings['show_bars']:
|
if self.settings['show_bars']:
|
||||||
@@ -631,8 +644,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
if self.bookToolBar.fontButton.isChecked():
|
if self.bookToolBar.fontButton.isChecked():
|
||||||
self.bookToolBar.customize_view_on()
|
self.bookToolBar.customize_view_on()
|
||||||
|
|
||||||
current_title = current_metadata['title']
|
|
||||||
current_author = current_metadata['author']
|
|
||||||
current_position = current_metadata['position']
|
current_position = current_metadata['position']
|
||||||
current_toc = [i[0] for i in current_metadata['content']]
|
current_toc = [i[0] for i in current_metadata['content']]
|
||||||
|
|
||||||
@@ -648,8 +659,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
self.profile_functions.format_contentView()
|
self.profile_functions.format_contentView()
|
||||||
|
|
||||||
self.statusMessage.setText(
|
self.statusBar.setVisible(False)
|
||||||
current_author + ' - ' + current_title)
|
|
||||||
|
|
||||||
def tab_close(self, tab_index=None):
|
def tab_close(self, tab_index=None):
|
||||||
if not tab_index:
|
if not tab_index:
|
||||||
@@ -748,6 +758,30 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
#____________________________________________
|
#____________________________________________
|
||||||
|
|
||||||
|
def search_book(self, search_text):
|
||||||
|
current_tab = self.tabWidget.currentIndex()
|
||||||
|
if not (current_tab != 0 and not self.tabWidget.widget(
|
||||||
|
current_tab).are_we_doing_images_only):
|
||||||
|
return
|
||||||
|
|
||||||
|
contentView = self.tabWidget.widget(current_tab).contentView
|
||||||
|
|
||||||
|
text_cursor = contentView.textCursor()
|
||||||
|
something_found = True
|
||||||
|
if search_text:
|
||||||
|
text_cursor.setPosition(0, QtGui.QTextCursor.MoveAnchor)
|
||||||
|
contentView.setTextCursor(text_cursor)
|
||||||
|
contentView.verticalScrollBar().setValue(contentView.verticalScrollBar().maximum())
|
||||||
|
something_found = contentView.find(search_text)
|
||||||
|
else:
|
||||||
|
text_cursor.clearSelection()
|
||||||
|
contentView.setTextCursor(text_cursor)
|
||||||
|
|
||||||
|
if not something_found:
|
||||||
|
self.bookToolBar.searchBar.setStyleSheet("QLineEdit {color: red;}")
|
||||||
|
else:
|
||||||
|
self.bookToolBar.searchBar.setStyleSheet(self.lineEditStyleSheet)
|
||||||
|
|
||||||
def generate_library_context_menu(self, position):
|
def generate_library_context_menu(self, position):
|
||||||
index = self.sender().indexAt(position)
|
index = self.sender().indexAt(position)
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
@@ -791,8 +825,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
if action == editAction:
|
if action == editAction:
|
||||||
edit_book = selected_indexes[0]
|
edit_book = selected_indexes[0]
|
||||||
metadata = self.lib_ref.libraryModel.data(
|
|
||||||
edit_book, QtCore.Qt.UserRole + 3)
|
|
||||||
is_cover_loaded = self.lib_ref.libraryModel.data(
|
is_cover_loaded = self.lib_ref.libraryModel.data(
|
||||||
edit_book, QtCore.Qt.UserRole + 8)
|
edit_book, QtCore.Qt.UserRole + 8)
|
||||||
|
|
||||||
@@ -805,15 +837,19 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.database_path).fetch_covers_only([book_hash])[0][1]
|
self.database_path).fetch_covers_only([book_hash])[0][1]
|
||||||
self.cover_functions.cover_loader(book_item, book_cover)
|
self.cover_functions.cover_loader(book_item, book_cover)
|
||||||
|
|
||||||
cover = self.lib_ref.libraryModel.item(edit_book.row()).icon()
|
cover = self.lib_ref.libraryModel.item(
|
||||||
title = metadata['title']
|
edit_book.row()).icon()
|
||||||
author = metadata['author']
|
title = self.lib_ref.libraryModel.data(
|
||||||
year = str(metadata['year'])
|
edit_book, QtCore.Qt.UserRole)
|
||||||
tags = metadata['tags']
|
author = self.lib_ref.libraryModel.data(
|
||||||
|
edit_book, QtCore.Qt.UserRole + 1)
|
||||||
|
year = str(self.lib_ref.libraryModel.data(
|
||||||
|
edit_book, QtCore.Qt.UserRole + 2)) # Text cannot be int
|
||||||
|
tags = self.lib_ref.libraryModel.data(
|
||||||
|
edit_book, QtCore.Qt.UserRole + 4)
|
||||||
|
|
||||||
self.metadataDialog.load_book(
|
self.metadataDialog.load_book(
|
||||||
cover, title, author, year, tags, edit_book)
|
cover, title, author, year, tags, edit_book)
|
||||||
|
|
||||||
self.metadataDialog.show()
|
self.metadataDialog.show()
|
||||||
|
|
||||||
if action == deleteAction:
|
if action == deleteAction:
|
||||||
|
@@ -228,7 +228,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
try:
|
try:
|
||||||
required_position = self.metadata['position']['cursor_position']
|
required_position = self.metadata['position']['cursor_position']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print(f'Database: Cursor position error. Recommend retry.')
|
print('Database: Cursor position error. Recommend retry.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if cursor_position:
|
if cursor_position:
|
||||||
|
2
setup.py
2
setup.py
@@ -6,7 +6,7 @@ HERE = path.abspath(path.dirname(__file__))
|
|||||||
|
|
||||||
MAJOR_VERSION = '0'
|
MAJOR_VERSION = '0'
|
||||||
MINOR_VERSION = '4'
|
MINOR_VERSION = '4'
|
||||||
MICRO_VERSION = '0'
|
MICRO_VERSION = '1'
|
||||||
VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
|
VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
|
||||||
|
|
||||||
# Get the long description from the README file
|
# Get the long description from the README file
|
||||||
|
Reference in New Issue
Block a user