mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Fix progress bar when only one item is loaded/saved
This commit is contained in:
parent
e0a8ce42e5
commit
0daf1bfbf1
2 changed files with 8 additions and 12 deletions
|
|
@ -45,9 +45,9 @@ class WelcomeOverlay(QtWidgets.QWidget):
|
||||||
class BeeProgressDialog(QtWidgets.QProgressDialog):
|
class BeeProgressDialog(QtWidgets.QProgressDialog):
|
||||||
|
|
||||||
def __init__(self, label, maximum=100, parent=None):
|
def __init__(self, label, maximum=100, parent=None):
|
||||||
super().__init__(label, 'Cancel', 0, maximum - 1, parent=parent)
|
super().__init__(label, 'Cancel', 0, maximum, parent=parent)
|
||||||
self.setMinimumDuration(2)
|
self.setMinimumDuration(2)
|
||||||
self.setWindowModality(Qt.WindowModality.WindowModal)
|
self.setWindowModality(Qt.WindowModality.WindowModal)
|
||||||
|
|
||||||
def setMaximum(self, maximum):
|
def setValue(self, value):
|
||||||
super().setMaximum(maximum - 1)
|
super().setValue(value + 1)
|
||||||
|
|
|
||||||
|
|
@ -307,19 +307,15 @@ class BeeGraphicsView(QtWidgets.QGraphicsView):
|
||||||
errors = []
|
errors = []
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
if len(filenames) > 1:
|
progress = BeeProgressDialog(
|
||||||
progress = BeeProgressDialog(
|
'Loading images...', len(filenames), parent=self)
|
||||||
'Loading images...', len(filenames), parent=self)
|
|
||||||
else:
|
|
||||||
progress = None
|
|
||||||
|
|
||||||
for i, filename in enumerate(filenames):
|
for i, filename in enumerate(filenames):
|
||||||
logger.info(f'Loading image from file {filename}')
|
logger.info(f'Loading image from file {filename}')
|
||||||
img = QtGui.QImage(filename)
|
img = QtGui.QImage(filename)
|
||||||
if progress:
|
progress.setValue(i)
|
||||||
progress.setValue(i)
|
if progress.wasCanceled():
|
||||||
if progress.wasCanceled():
|
break
|
||||||
break
|
|
||||||
if img.isNull():
|
if img.isNull():
|
||||||
errors.append(filename)
|
errors.append(filename)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue