Skip to content

Commit 1518f16

Browse files
Merge pull request #80 from DazedNConfused-/develop
2 parents 3b3517c + 9f5a9c5 commit 1518f16

File tree

4 files changed

+62
-42
lines changed

4 files changed

+62
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ SPDX-License-Identifier: MIT
88

99
A [Cataclysm: Dark Days Ahead](https://cataclysmdda.org/) launcher with additional features.
1010

11-
![GitHub Workflow Status (master)](https://img.shields.io/github/workflow/status/DazedNConfused-/CDDA-Game-Launcher/build/master?label=master)
12-
![GitHub Workflow Status (develop)](https://img.shields.io/github/workflow/status/DazedNConfused-/CDDA-Game-Launcher/build/develop?label=develop)
11+
![GitHub Workflow Status (master)](https://img.shields.io/github/actions/workflow/status/DazedNConfused-/CDDA-Game-Launcher/build.yml?branch=master)
12+
![GitHub Workflow Status (develop)](https://img.shields.io/github/actions/workflow/status/DazedNConfused-/CDDA-Game-Launcher/build.yml?branch=develop)
1313

1414
![GitHub release (latest by date)](https://img.shields.io/github/v/release/DazedNConfused-/CDDA-Game-Launcher)
1515
![GitHub all releases](https://img.shields.io/github/downloads/DazedNConfused-/CDDA-Game-Launcher/total)

cddagl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.8
1+
1.6.9

cddagl/ui/views/backups.py

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def __init__(self):
4646
self.backup_compressing = False
4747

4848
self.compressing_timer = None
49+
self.scale_factor = 0 # Number of bits to shift file size right so we don't overflow the QProgressBar
50+
self.filestep = 0 # File counter so we don't update the progress bar every single file
4951

5052
current_backups_gb = QGroupBox()
5153
self.current_backups_gb = current_backups_gb
@@ -526,7 +528,9 @@ def restore_backup(self):
526528
extracting_size_label)
527529

528530
progress_bar = QProgressBar()
529-
progress_bar.setRange(0, self.total_extract_size)
531+
self.filestep = 0
532+
self.scale_factor = max(0,int(self.total_extract_size.bit_length()) - 31)
533+
progress_bar.setRange(0, self.total_extract_size >> self.scale_factor)
530534
progress_bar.setValue(0)
531535
status_bar.addWidget(progress_bar)
532536
self.extracting_progress_bar = progress_bar
@@ -594,22 +598,26 @@ def extract_next_file():
594598

595599
def completed_extract():
596600
self.extract_size += self.next_extract_file.file_size
597-
self.extracting_progress_bar.setValue(self.extract_size)
598-
599-
self.extracting_size_label.setText(
600-
'{bytes_read}/{total_bytes}'
601-
.format(bytes_read=sizeof_fmt(self.extract_size),
602-
total_bytes=sizeof_fmt(self.total_extract_size))
603-
)
604-
605-
delta_bytes = self.extract_size - self.last_extract_bytes
606-
delta_time = datetime.utcnow() - self.last_extract
607-
if delta_time.total_seconds() == 0:
608-
delta_time = timedelta.resolution
609-
610-
bytes_secs = delta_bytes / delta_time.total_seconds()
611-
self.extracting_speed_label.setText(_('{bytes_sec}/s'
612-
).format(bytes_sec=sizeof_fmt(bytes_secs)))
601+
602+
self.filestep += 1
603+
if self.filestep == 100:
604+
self.filestep = 0
605+
self.extracting_progress_bar.setValue(self.extract_size >> self.scale_factor)
606+
607+
self.extracting_size_label.setText(
608+
'{bytes_read}/{total_bytes}'
609+
.format(bytes_read=sizeof_fmt(self.extract_size),
610+
total_bytes=sizeof_fmt(self.total_extract_size))
611+
)
612+
613+
delta_bytes = self.extract_size - self.last_extract_bytes
614+
delta_time = datetime.utcnow() - self.last_extract
615+
if delta_time.total_seconds() == 0:
616+
delta_time = timedelta.resolution
617+
618+
bytes_secs = delta_bytes / delta_time.total_seconds()
619+
self.extracting_speed_label.setText(_('{bytes_sec}/s'
620+
).format(bytes_sec=sizeof_fmt(bytes_secs)))
613621

614622
self.last_extract_bytes = self.extract_size
615623
self.last_extract = datetime.utcnow()
@@ -907,6 +915,7 @@ def backup_saves(self, name, single=False):
907915

908916
self.total_backup_size = 0
909917
self.total_files = 0
918+
self.filestep = 0
910919

911920
self.disable_tab()
912921
self.get_main_tab().disable_tab()
@@ -929,10 +938,13 @@ def timeout():
929938
entry = next(self.backup_scan)
930939

931940
if entry.is_file():
932-
self.compressing_label.setText(
933-
_('Found {filename} in {path}').format(
934-
filename=entry.name,
935-
path=os.path.dirname(entry.path)))
941+
self.filestep += 1
942+
if self.filestep == 100:
943+
self.filestep = 0
944+
self.compressing_label.setText(
945+
_('Found {filename} in {path}').format(
946+
filename=entry.name,
947+
path=os.path.dirname(entry.path)))
936948
self.backup_files.append(entry.path)
937949
self.total_backup_size += entry.stat().st_size
938950
self.backup_file_sizes[entry.path
@@ -969,7 +981,9 @@ def timeout():
969981
compressing_size_label)
970982

971983
progress_bar = QProgressBar()
972-
progress_bar.setRange(0, self.total_backup_size)
984+
self.filestep = 0
985+
self.scale_factor = max(0,int(self.total_backup_size.bit_length()) - 31)
986+
progress_bar.setRange(0, self.total_backup_size >> self.scale_factor)
973987
progress_bar.setValue(0)
974988
status_bar.addWidget(progress_bar)
975989
self.compressing_progress_bar = progress_bar
@@ -1044,25 +1058,29 @@ def backup_next_file():
10441058

10451059
def completed_compress():
10461060
self.comp_size += self.backup_file_sizes[self.next_backup_file]
1047-
self.compressing_progress_bar.setValue(self.comp_size)
1061+
self.filestep += 1
1062+
if self.filestep == 100:
1063+
self.filestep = 0
1064+
1065+
self.compressing_progress_bar.setValue(self.comp_size >> self.scale_factor)
10481066

1049-
self.compressing_size_label.setText(
1050-
'{bytes_read}/{total_bytes}'
1051-
.format(bytes_read=sizeof_fmt(self.comp_size),
1052-
total_bytes=sizeof_fmt(self.total_backup_size))
1053-
)
1067+
self.compressing_size_label.setText(
1068+
'{bytes_read}/{total_bytes}'
1069+
.format(bytes_read=sizeof_fmt(self.comp_size),
1070+
total_bytes=sizeof_fmt(self.total_backup_size))
1071+
)
10541072

1055-
delta_bytes = self.comp_size - self.last_comp_bytes
1056-
delta_time = datetime.utcnow() - self.last_comp
1057-
if delta_time.total_seconds() == 0:
1058-
delta_time = timedelta.resolution
1073+
delta_bytes = self.comp_size - self.last_comp_bytes
1074+
delta_time = datetime.utcnow() - self.last_comp
1075+
if delta_time.total_seconds() == 0:
1076+
delta_time = timedelta.resolution
10591077

1060-
bytes_secs = delta_bytes / delta_time.total_seconds()
1061-
self.compressing_speed_label.setText(_('{bytes_sec}/s'
1062-
).format(bytes_sec=sizeof_fmt(bytes_secs)))
1078+
bytes_secs = delta_bytes / delta_time.total_seconds()
1079+
self.compressing_speed_label.setText(_('{bytes_sec}/s'
1080+
).format(bytes_sec=sizeof_fmt(bytes_secs)))
10631081

1064-
self.last_comp_bytes = self.comp_size
1065-
self.last_comp = datetime.utcnow()
1082+
self.last_comp_bytes = self.comp_size
1083+
self.last_comp = datetime.utcnow()
10661084

10671085
backup_next_file()
10681086

cddagl/ui/views/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,7 @@ def __init__(self, src, dst, skips, status_bar, name):
36603660
self.analysing = False
36613661
self.copying = False
36623662
self.copy_completed = False
3663+
self.scale_factor = 0 # Number of bits to shift file size right so we don't overflow the QProgressBar
36633664

36643665
def step(self):
36653666
if self.analysing:
@@ -3713,7 +3714,8 @@ def step(self):
37133714
self.copying_size_label = copying_size_label
37143715

37153716
progress_bar = QProgressBar()
3716-
progress_bar.setRange(0, self.total_copy_size)
3717+
self.scale_factor = max(0,int(self.total_copy_size.bit_length()) - 31)
3718+
progress_bar.setRange(0, self.total_copy_size >> self.scale_factor)
37173719
progress_bar.setValue(0)
37183720
self.status_bar.addWidget(progress_bar)
37193721
self.progress_bar = progress_bar
@@ -3769,7 +3771,7 @@ def step(self):
37693771
self.destination_file.write(buf)
37703772

37713773
self.copied_size += buf_len
3772-
self.progress_bar.setValue(self.copied_size)
3774+
self.progress_bar.setValue(self.copied_size >> self.scale_factor)
37733775

37743776
self.copy_speed_count += 1
37753777

0 commit comments

Comments
 (0)