feat(ui): stream search results and show real download progress
Search now publishes provider results in small batches as they arrive, so the first matches appear in the table while slower providers keep running. The bottom status-bar bar is now a determinate indicator: pacman output is streamed live and its (n/Total) package counter is parsed into a percentage that fills the bar during install/update, instead of an indeterminate spinner. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
8 files changed
+246
-112
No files matched your search
@@ -40,14 +40,14 @@ public:
|
||||
|
||||
std::vector<PackageInfo> search(const std::string& query) override;
|
||||
bool install(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback) override;
|
||||
ProgressCallback progressCallback) override;
|
||||
bool remove(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback) override;
|
||||
ProgressCallback progressCallback) override;
|
||||
bool update(const std::string& packageName = "",
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) override;
|
||||
ProgressCallback progressCallback = nullptr) override;
|
||||
std::vector<PackageInfo> listInstalled() override;
|
||||
std::vector<PackageInfo> listUpdates() override;
|
||||
bool refresh(std::function<void(const std::string&)> progressCallback = nullptr) override;
|
||||
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
||||
|
||||
// Make an app appear in the desktop's application launcher (wofi, GNOME,
|
||||
// KDE, ...) regardless of XDG_DATA_DIRS, like a pacman install would: link
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
void run() override;
|
||||
signals:
|
||||
void finished(std::vector<PackageInfo> results);
|
||||
// Emitted as search results are accumulated, so a few packages can be
|
||||
// shown immediately while the remaining searches keep running.
|
||||
void chunk(std::vector<PackageInfo> results);
|
||||
private:
|
||||
std::vector<IPackageManager*> m_providers;
|
||||
std::string m_query;
|
||||
@@ -70,6 +73,9 @@ public:
|
||||
void run() override;
|
||||
signals:
|
||||
void progress(const QString& message);
|
||||
// Real download percentage (0-100) when the provider reports it, used to
|
||||
// fill the determinate progress bar in the status bar.
|
||||
void progressValue(int percent);
|
||||
void finished(bool success);
|
||||
private:
|
||||
std::vector<IPackageManager*> m_providers;
|
||||
@@ -91,7 +97,9 @@ private slots:
|
||||
void onUpdateAll();
|
||||
void onRefresh();
|
||||
void onSearchFinished(std::vector<PackageInfo> results);
|
||||
void onSearchChunk(std::vector<PackageInfo> results);
|
||||
void onListFinished(std::vector<PackageInfo> results);
|
||||
void onInstallProgress(int percent);
|
||||
void onPackageSelected(int row);
|
||||
void onNavChanged(int id);
|
||||
void onClearHistory();
|
||||
@@ -143,6 +151,8 @@ private:
|
||||
void performInstall(const std::string& package);
|
||||
void performRemove(const std::string& package);
|
||||
void populatePackageTable(const std::vector<PackageInfo>& results);
|
||||
void appendPackageRows(const std::vector<PackageInfo>& results);
|
||||
void addPackageRow(int row, const PackageInfo& pkg);
|
||||
void setBusy(bool busy);
|
||||
void reloadCurrentView();
|
||||
void loadInstalled();
|
||||
@@ -184,6 +194,9 @@ private:
|
||||
QPushButton* m_updateButton = nullptr;
|
||||
QPushButton* m_updateAllButton = nullptr;
|
||||
QProgressBar* m_progressBar = nullptr;
|
||||
// Small indeterminate bar anchored in the status bar, shown at the bottom
|
||||
// of the window while any install/search runs.
|
||||
QProgressBar* m_installProgressBar = nullptr;
|
||||
QTableWidget* m_packageTable = nullptr;
|
||||
QLabel* m_packageName = nullptr;
|
||||
QLabel* m_packageVersion = nullptr;
|
||||
|
||||
@@ -108,6 +108,11 @@ inline void sortByProviderThenName(std::vector<PackageInfo>& packages,
|
||||
});
|
||||
}
|
||||
|
||||
// Progress reported during an operation: a human-readable message plus an
|
||||
// optional percentage (0-100) when the tool exposes real progress, or -1 when
|
||||
// the exact position is unknown. -1 lets the UI keep an indeterminate bar.
|
||||
using ProgressCallback = std::function<void(const std::string& message, int percent)>;
|
||||
|
||||
// Abstract interface for the package manager
|
||||
class IPackageManager {
|
||||
public:
|
||||
@@ -128,14 +133,14 @@ public:
|
||||
// Operations
|
||||
virtual std::vector<PackageInfo> search(const std::string& query) = 0;
|
||||
virtual bool install(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) = 0;
|
||||
ProgressCallback progressCallback = nullptr) = 0;
|
||||
virtual bool remove(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) = 0;
|
||||
ProgressCallback progressCallback = nullptr) = 0;
|
||||
virtual bool update(const std::string& packageName = "",
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) = 0;
|
||||
ProgressCallback progressCallback = nullptr) = 0;
|
||||
virtual std::vector<PackageInfo> listInstalled() = 0;
|
||||
virtual std::vector<PackageInfo> listUpdates() = 0;
|
||||
virtual bool refresh(std::function<void(const std::string&)> progressCallback = nullptr) = 0;
|
||||
virtual bool refresh(ProgressCallback progressCallback = nullptr) = 0;
|
||||
|
||||
// Check if the package manager is available on the system
|
||||
virtual bool isAvailable() const = 0;
|
||||
|
||||
@@ -51,14 +51,14 @@ public:
|
||||
|
||||
std::vector<PackageInfo> search(const std::string& query) override;
|
||||
bool install(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback) override;
|
||||
ProgressCallback progressCallback) override;
|
||||
bool remove(const std::string& packageName,
|
||||
std::function<void(const std::string&)> progressCallback) override;
|
||||
ProgressCallback progressCallback) override;
|
||||
bool update(const std::string& packageName = "",
|
||||
std::function<void(const std::string&)> progressCallback = nullptr) override;
|
||||
ProgressCallback progressCallback = nullptr) override;
|
||||
std::vector<PackageInfo> listInstalled() override;
|
||||
std::vector<PackageInfo> listUpdates() override;
|
||||
bool refresh(std::function<void(const std::string&)> progressCallback = nullptr) override;
|
||||
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
||||
|
||||
private:
|
||||
bool isPackageInstalled(const std::string& name);
|
||||
|
||||
Reference in new issue
Block a user