Show a busy cursor when running the search in the match books dialog

This commit is contained in:
Kovid Goyal 2016-02-23 09:13:06 +05:30
parent 37eacf65b0
commit 9e775f3cb7

View File

@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
from PyQt5.Qt import (Qt, QDialog, QAbstractItemView, QTableWidgetItem,
QByteArray)
QByteArray, QApplication, QCursor)
from calibre.gui2 import gprefs, error_dialog
from calibre.gui2.dialogs.match_books_ui import Ui_MatchBooks
@ -129,6 +129,9 @@ class MatchBooks(QDialog, Ui_MatchBooks):
_('You must enter a search expression into the search box'))
d.exec_()
return
try:
self.search_button.setEnabled(False)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
books = self.library_db.data.search(query, return_matches=True)
self.books_table.setRowCount(len(books))
@ -148,6 +151,9 @@ class MatchBooks(QDialog, Ui_MatchBooks):
self.books_table.setRowHeight(row, self.books_table_row_height)
self.books_table.setSortingEnabled(True)
finally:
self.search_button.setEnabled(True)
QApplication.restoreOverrideCursor()
# Deal with sizing the table columns. Done here because the numbers are not
# correct until the first paint.