MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / UpdateProgress

Method UpdateProgress

src/client/ui/notification_item.cpp:162–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160 }
161
162 void NotificationItem::UpdateProgress(int progress) {
163 context_->PostUITask([=, this]() {
164 if (last_progress_update_time_ == 0) {
165 last_progress_update_time_ = progress_update_time_;
166 }
167 auto diff_time = progress_update_time_ - last_progress_update_time_;
168 if (diff_time > 1000) {
169 auto diff_data_size = progress_data_size_ - last_progress_data_size_;
170 auto diff_time_in_seconds = diff_time / 1000.0f;
171 auto speed = (uint64_t)(diff_data_size / diff_time_in_seconds);
172 last_speed_str_ = NumFormatter::FormatStorageSize(speed);
173 last_progress_data_size_ = progress_data_size_;
174 last_progress_update_time_ = progress_update_time_;
175 transfer_info_->setText(std::format("{}/s {}", last_speed_str_, NumFormatter::FormatStorageSize(progress_data_size_)).c_str());
176 }
177
178 if (progress == 100) {
179 transfer_info_->setText(std::format("{}/s {}", last_speed_str_.empty() ? "0" : last_speed_str_, NumFormatter::FormatStorageSize(progress_data_size_)).c_str());
180 progress_over_ = true;
181 }
182
183 progress_->setValue(progress);
184 progress_info_->setText(std::format("{}/100", progress).c_str());
185 });
186 }
187
188 void NotificationItem::UpdateProgressUpdateTime(uint64_t time) {
189 progress_update_time_ = time;

Callers 1

NotificationPanelMethod · 0.80

Calls 2

setValueMethod · 0.80
PostUITaskMethod · 0.45

Tested by

no test coverage detected