refactor(pages): group the screens by what the user is doing
pages/ was a flat row of eight screens, so a change to one meant scanning the whole folder to see what else was in it. The screens now sit in packages/ (browse, cleanup), overview/ (dashboard, history), system/ (logs, settings) and extensions/ (plugins), with the scaffolding they all build on — the Page base and the shared widgets — in base/.
This commit is contained in:
19 files changed
+19
-19
No files matched your search
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
#include "page.h"
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QProgressBar;
|
||||
class QPushButton;
|
||||
class QStackedWidget;
|
||||
class QTableWidget;
|
||||
|
||||
// The browsing screen. Search, installed and updates share this page because
|
||||
// they are the same table with a different query behind it; the sidebar exposes
|
||||
// three entries, all landing here with a different mode.
|
||||
class BrowsePage : public Page {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Mode { Search, Installed, Updates };
|
||||
|
||||
explicit BrowsePage(AppCore* core, QWidget* parent = nullptr);
|
||||
|
||||
QString navTitle() const override;
|
||||
QString navSubtitle() const override;
|
||||
void refresh() override;
|
||||
|
||||
// Entry points used by the sidebar, the dashboard shortcuts and the menu.
|
||||
void showSearch();
|
||||
void showInstalled(const QString& select = QString());
|
||||
void showUpdates();
|
||||
// Package to select once the next listing arrives: lets the frame open a
|
||||
// package from the dashboard without loading the list twice.
|
||||
void selectOnNextLoad(const QString& name) { m_pendingSelect = name; }
|
||||
// Puts the caret in the search field (Ctrl+F), selecting the current term.
|
||||
void focusSearch();
|
||||
|
||||
int resultCount() const { return static_cast<int>(m_results.size()); }
|
||||
// Exports the displayed list to a CSV file (the file dialog is the frame's
|
||||
// business, the content is this page's).
|
||||
void exportCsv();
|
||||
|
||||
private:
|
||||
void setMode(Mode mode);
|
||||
void reloadCurrentView();
|
||||
void onSearch();
|
||||
void onPackageSelected(int row);
|
||||
void onFilterChanged(const QString& text);
|
||||
void populateTable(const std::vector<PackageInfo>& packages);
|
||||
void appendRows(const std::vector<PackageInfo>& packages);
|
||||
void addRow(int row, const PackageInfo& pkg);
|
||||
// Which installations of the selected package to remove, asked only when
|
||||
// the provider holds it more than once. Nothing (std::nullopt) when the
|
||||
// user cancels, an empty list when they tick nothing.
|
||||
std::optional<std::vector<std::string>> chooseInstancesToRemove();
|
||||
void updateDetails(const PackageInfo& pkg);
|
||||
void resetDetails();
|
||||
|
||||
Mode m_mode = Mode::Search;
|
||||
|
||||
// Everything the current query returned, and the last installed listing
|
||||
// kept aside for the instant local filter.
|
||||
std::vector<PackageInfo> m_results;
|
||||
std::vector<PackageInfo> m_installed;
|
||||
PackageInfo m_selected;
|
||||
// Package to select once the next listing arrives (after a click on the
|
||||
// dashboard history, or after an operation).
|
||||
QString m_pendingSelect;
|
||||
|
||||
QWidget* m_searchRow = nullptr;
|
||||
QLineEdit* m_searchBar = nullptr;
|
||||
QPushButton* m_searchButton = nullptr;
|
||||
QWidget* m_filterRow = nullptr;
|
||||
QLineEdit* m_filterBar = nullptr;
|
||||
QLabel* m_resultCount = nullptr;
|
||||
QPushButton* m_installButton = nullptr;
|
||||
QPushButton* m_removeButton = nullptr;
|
||||
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;
|
||||
QLabel* m_pkgVersion = nullptr;
|
||||
QLabel* m_pkgRepo = nullptr;
|
||||
QLabel* m_pkgSize = nullptr;
|
||||
QLabel* m_pkgProvider = nullptr;
|
||||
// The copies a multi-installed package is made of, shown only when there is
|
||||
// more than one.
|
||||
QLabel* m_pkgInstances = nullptr;
|
||||
QLabel* m_pkgDescription = nullptr;
|
||||
};
|
||||
Reference in new issue
Block a user