perf(progress): report real progress instead of a bouncing bar
pacman restarts its "(1/24)" counter at every phase of a transaction, so the bar was fed 0 percent, 100 percent, 0 percent again a few times per update — and Flatpak/AUR buffered their whole output, which left it indeterminate for the entire run. A shared ProgressTracker now folds every counter, file percentage and package step into one value that only moves forward, the providers stream their output as it is produced, and each provider owns a slice of the bar so a multi-provider update keeps advancing. pacman -Qu is cached like the other read queries, so the sidebar badge, the updates screen and the update button share a single process. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
ed58e87520
commit
b26e907221
12 files changed
+590
-138
No files matched your search
+18
-3
@@ -227,12 +227,27 @@ BrowsePage::BrowsePage(AppCore* core, QWidget* parent) : Page(core, parent) {
|
||||
});
|
||||
connect(core, &AppCore::busyChanged, this, [this](bool busy) {
|
||||
m_progressBar->setVisible(busy);
|
||||
if (!busy) return;
|
||||
// Start indeterminate; only the status-bar bar turns determinate once
|
||||
// the tool reports a real percentage.
|
||||
if (!busy) {
|
||||
// A band stopped just before the end reads as a cancellation: when
|
||||
// real progress was shown, it is completed first.
|
||||
if (m_progressBar->maximum() > 0) m_progressBar->setValue(100);
|
||||
return;
|
||||
}
|
||||
m_progressValue = 0;
|
||||
// Start indeterminate; the first real percentage reported by the tool
|
||||
// turns the band into a determinate fill.
|
||||
m_progressBar->setRange(0, 0);
|
||||
m_progressBar->setValue(0);
|
||||
});
|
||||
connect(core, &AppCore::actionProgress, this,
|
||||
[this](const QString&, int percent) {
|
||||
if (percent < 0) return;
|
||||
// Providers (and the commands inside one operation) each count
|
||||
// from 0 again, so the band only ever moves forward.
|
||||
if (percent > m_progressValue) m_progressValue = percent;
|
||||
m_progressBar->setRange(0, 100);
|
||||
m_progressBar->setValue(m_progressValue);
|
||||
});
|
||||
connect(core, &AppCore::actionFinished, this,
|
||||
[this](const QString& action, const QString&, bool success, const QString&,
|
||||
bool) {
|
||||
|
||||
@@ -74,6 +74,9 @@ private:
|
||||
QPushButton* m_updateButton = nullptr;
|
||||
QPushButton* m_updateAllButton = nullptr;
|
||||
QProgressBar* m_progressBar = nullptr;
|
||||
// Highest percentage reported by the running operation, so the bar never
|
||||
// moves backwards when a provider restarts its own count.
|
||||
int m_progressValue = 0;
|
||||
QTableWidget* m_table = nullptr;
|
||||
QStackedWidget* m_tableStack = nullptr;
|
||||
QLabel* m_pkgName = nullptr;
|
||||
|
||||
Reference in new issue
Block a user