gui2 actions receive status messages.

This commit is contained in:
Kovid Goyal 2007-07-20 06:25:32 +00:00
parent 913b4bcf38
commit 1a59652103
2 changed files with 8 additions and 5 deletions

View File

@ -220,6 +220,7 @@ class Main(QObject, Ui_MainWindow):
model.research() model.research()
else: else:
self.upload_books(books, names, infos, on_card=on_card) self.upload_books(books, names, infos, on_card=on_card)
self.status_bar.showMessage('Adding books to device.', 2000)
def upload_books(self, files, names, metadata, on_card=False): def upload_books(self, files, names, metadata, on_card=False):
''' '''
@ -277,7 +278,7 @@ class Main(QObject, Ui_MainWindow):
id = self.remove_paths(paths) id = self.remove_paths(paths)
self.delete_memory[id] = paths self.delete_memory[id] = paths
view.model().mark_for_deletion(id, rows) view.model().mark_for_deletion(id, rows)
self.status_bar.showMessage('Deleting books from device.', 1000)
def remove_paths(self, paths): def remove_paths(self, paths):
return self.job_manager.run_device_job(self.books_deleted, return self.job_manager.run_device_job(self.books_deleted,
@ -326,7 +327,7 @@ class Main(QObject, Ui_MainWindow):
if not p.isNull(): if not p.isNull():
ht = self.device_manager.device_class.THUMBNAIL_HEIGHT if self.device_manager else \ ht = self.device_manager.device_class.THUMBNAIL_HEIGHT if self.device_manager else \
Device.THUMBNAIL_HEIGHT Device.THUMBNAIL_HEIGHT
p = p.scaledToHeight(ht) p = p.scaledToHeight(ht, Qt.SmoothTransformation)
ba = QByteArray() ba = QByteArray()
buf = QBuffer(ba) buf = QBuffer(ba)
buf.open(QBuffer.WriteOnly) buf.open(QBuffer.WriteOnly)
@ -357,7 +358,7 @@ class Main(QObject, Ui_MainWindow):
gf.append(f) gf.append(f)
names.append('%s_%d%s'%(__appname__, id, os.path.splitext(f.name)[1])) names.append('%s_%d%s'%(__appname__, id, os.path.splitext(f.name)[1]))
self.upload_books(gf, names, good, on_card) self.upload_books(gf, names, good, on_card)
self.status_bar.showMessage('Sending books to device.', 5000)
if bad: if bad:
bad = '\n'.join('<li>%s</li>'%(i,) for i in bad) bad = '\n'.join('<li>%s</li>'%(i,) for i in bad)
d = warning_dialog(self.window, 'No suitable formats', 'Could not upload the following books to the device, as no suitable formats were found:<br><ul>%s</ul>'%(bad,)) d = warning_dialog(self.window, 'No suitable formats', 'Could not upload the following books to the device, as no suitable formats were found:<br><ul>%s</ul>'%(bad,))

View File

@ -41,8 +41,9 @@ class BookInfoDisplay(QFrame):
self.setTextInteractionFlags(Qt.TextSelectableByMouse) self.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.setText('')#<table><tr><td>row 1</td><td>row 2</td></tr><tr><td>fsfdsfsfsfsfsfsdfsffsfsd</td></tr></table>') self.setText('')#<table><tr><td>row 1</td><td>row 2</td></tr><tr><td>fsfdsfsfsfsfsfsdfsffsfsd</td></tr></table>')
def __init__(self): def __init__(self, clear_message):
QFrame.__init__(self) QFrame.__init__(self)
self.clear_message = clear_message
self.layout = QHBoxLayout() self.layout = QHBoxLayout()
self.setLayout(self.layout) self.setLayout(self.layout)
self.cover_display = BookInfoDisplay.BookCoverDisplay() self.cover_display = BookInfoDisplay.BookCoverDisplay()
@ -70,6 +71,7 @@ class BookInfoDisplay(QFrame):
rows += '<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt) rows += '<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt)
self.book_data.setText('<table>'+rows+'</table>') self.book_data.setText('<table>'+rows+'</table>')
self.clear_message()
self.setVisible(True) self.setVisible(True)
class MovieButton(QLabel): class MovieButton(QLabel):
@ -85,7 +87,7 @@ class StatusBar(QStatusBar):
QStatusBar.__init__(self) QStatusBar.__init__(self)
self.movie_button = MovieButton(QMovie(':/images/jobs-animated.mng')) self.movie_button = MovieButton(QMovie(':/images/jobs-animated.mng'))
self.addPermanentWidget(self.movie_button) self.addPermanentWidget(self.movie_button)
self.book_info = BookInfoDisplay() self.book_info = BookInfoDisplay(self.clearMessage)
self.addWidget(self.book_info) self.addWidget(self.book_info)
def job_added(self, id): def job_added(self, id):