mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow the progress dialog to have an icon
This commit is contained in:
parent
916b1f5666
commit
dd0ed12cfb
@ -283,7 +283,7 @@ class Adder(QObject): # {{{
|
||||
|
||||
def __init__(self, parent, db, callback, spare_server=None):
|
||||
QObject.__init__(self, parent)
|
||||
self.pd = ProgressDialog(_('Adding...'), parent=parent)
|
||||
self.pd = ProgressDialog(_('Adding...'), parent=parent, icon='add_book.png')
|
||||
self.pd.setMaximumWidth(min(600, int(available_width()*0.75)))
|
||||
self.spare_server = spare_server
|
||||
self.db = db
|
||||
|
@ -5,7 +5,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QDialog, pyqtSignal, Qt, QVBoxLayout, QLabel, QFont, QProgressBar,
|
||||
QDialogButtonBox, QApplication, QFontMetrics)
|
||||
QDialogButtonBox, QApplication, QFontMetrics, QHBoxLayout, QIcon)
|
||||
|
||||
from calibre.gui2 import elided_text
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
@ -14,9 +14,20 @@ class ProgressDialog(QDialog):
|
||||
|
||||
canceled_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, title, msg=u'\u00a0', min=0, max=99, parent=None, cancelable=True):
|
||||
def __init__(self, title, msg=u'\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None):
|
||||
QDialog.__init__(self, parent)
|
||||
self.l = l = QVBoxLayout(self)
|
||||
if icon is None:
|
||||
self.l = l = QVBoxLayout(self)
|
||||
else:
|
||||
self.h = h = QHBoxLayout(self)
|
||||
self.icon = i = QLabel(self)
|
||||
if not isinstance(icon, QIcon):
|
||||
icon = QIcon(I(icon))
|
||||
i.setPixmap(icon.pixmap(64))
|
||||
h.addWidget(i)
|
||||
self.l = l = QVBoxLayout()
|
||||
h.addLayout(l)
|
||||
self.setWindowIcon(icon)
|
||||
|
||||
self.title = t = QLabel(title)
|
||||
self.setWindowTitle(title)
|
||||
@ -144,6 +155,6 @@ class BlockingBusy(QDialog):
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
d = ProgressDialog('A title', 'A message ' * 100)
|
||||
d = ProgressDialog('A title', 'A message ' * 100, icon='lt.png')
|
||||
d.show(), d.canceled_signal.connect(app.quit)
|
||||
app.exec_()
|
||||
|
Loading…
x
Reference in New Issue
Block a user