Add progress indicator to search dialog.

This commit is contained in:
John Schember 2011-03-02 20:07:41 -05:00
parent df52819199
commit f64e279767
2 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ from PyQt4.Qt import Qt, QAbstractItemModel, QDialog, QTimer, QVariant, \
from calibre import browser from calibre import browser
from calibre.gui2 import NONE from calibre.gui2 import NONE
from calibre.gui2.progress_indicator import ProgressIndicator
from calibre.gui2.store.search_ui import Ui_Dialog from calibre.gui2.store.search_ui import Ui_Dialog
from calibre.utils.config import DynamicConfig from calibre.utils.config import DynamicConfig
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
@ -56,6 +57,10 @@ class SearchDialog(QDialog, Ui_Dialog):
stores_group_layout.addWidget(cbox) stores_group_layout.addWidget(cbox)
setattr(self, 'store_check_' + x, cbox) setattr(self, 'store_check_' + x, cbox)
stores_group_layout.addStretch() stores_group_layout.addStretch()
# Create and add the progress indicator
self.pi = ProgressIndicator(self, 24)
self.bottom_layout.insertWidget(0, self.pi)
self.search.clicked.connect(self.do_search) self.search.clicked.connect(self.do_search)
self.checker.timeout.connect(self.get_results) self.checker.timeout.connect(self.get_results)
@ -109,6 +114,7 @@ class SearchDialog(QDialog, Ui_Dialog):
self.hang_check = 0 self.hang_check = 0
self.checker.start(100) self.checker.start(100)
self.search_pool.start_threads() self.search_pool.start_threads()
self.pi.startAnimation()
def save_state(self): def save_state(self):
self.config['store_search_geometry'] = self.saveGeometry() self.config['store_search_geometry'] = self.saveGeometry()
@ -151,10 +157,12 @@ class SearchDialog(QDialog, Ui_Dialog):
if self.hang_check >= HANG_TIME: if self.hang_check >= HANG_TIME:
self.search_pool.abort() self.search_pool.abort()
self.checker.stop() self.checker.stop()
self.pi.stopAnimation()
else: else:
# Stop the checker if not threads are running. # Stop the checker if not threads are running.
if not self.search_pool.threads_running() and not self.search_pool.has_tasks(): if not self.search_pool.threads_running() and not self.search_pool.has_tasks():
self.checker.stop() self.checker.stop()
self.pi.stopAnimation()
while self.search_pool.has_results(): while self.search_pool.has_results():
res = self.search_pool.get_result() res = self.search_pool.get_result()

View File

@ -149,7 +149,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="bottom_layout">
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">