Fix the progress labels close to 100%

This commit is contained in:
Kovid Goyal 2022-06-15 15:22:53 +05:30
parent 152145e1ad
commit 6e86eb53f3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 5 deletions

View File

@ -60,10 +60,11 @@ class FTSDialog(Dialog):
except Exception:
self.indexing_label.setVisible(False)
else:
if p < 100:
t = _('Indexing is only {0:.0%} done').format(p)
if p < 1:
q = f'{p:.0%}'
t = _('Indexing is almost complete') if q == '100%' else _('Indexing is only {} done').format(q)
ss = ''
if p < 90:
if p < 0.9:
ss = 'QLabel { color: red }'
self.indexing_label.setStyleSheet(ss)
self.indexing_label.setText(t)

View File

@ -103,8 +103,11 @@ class ScanProgress(QWidget):
self.switch_anyway.setText(_('Start &searching'))
else:
done = total - left
t = _('{0} of {1} book files, {2:.0%} have been indexed').format(
done, total, done / (total or 1))
p = done / (total or 1)
p = f'{p:.0%}'
if p == '100%':
p = _('almost 100%')
t = _('{0} of {1} book files, {2} have been indexed').format(done, total, p)
self.warn_label.setVisible(True)
self.switch_anyway.setIcon(QIcon.ic('dialog_warning.png'))
self.switch_anyway.setText(_('Start &searching even with incomplete indexing'))