feat(ui): redesign main window with sidebar navigation
Replace the single-screen layout with a sidebar and stacked pages: Search, Installed, Updates, History and Logs. Also fix the update-all and refresh actions, which previously called install with an empty package name instead of running the proper pacman commands. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
5054f04c54
commit
0f7c3a6c2b
4 files changed
+1095
-756
No files matched your search
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QStackedWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QProgressBar>
|
||||
@@ -14,15 +12,18 @@
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QTabWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QThread>
|
||||
|
||||
#include "IPackageManager.h"
|
||||
#include "PluginManager.h"
|
||||
#include "HistoryManager.h"
|
||||
#include "PackageModel.h"
|
||||
#include "package-manager.h"
|
||||
#include "pacman-manager.h"
|
||||
#include "history-manager.h"
|
||||
|
||||
class QStackedWidget;
|
||||
class QButtonGroup;
|
||||
class QTableWidget;
|
||||
class QTextEdit;
|
||||
|
||||
// Runs a package search off the UI thread.
|
||||
class SearchWorker : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -35,18 +36,34 @@ private:
|
||||
std::string m_query;
|
||||
};
|
||||
|
||||
// Loads a package list (installed or outdated) off the UI thread.
|
||||
class ListWorker : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Mode { Installed, Updates };
|
||||
ListWorker(IPackageManager* pm, Mode mode);
|
||||
void run() override;
|
||||
signals:
|
||||
void finished(std::vector<PackageInfo> results);
|
||||
private:
|
||||
IPackageManager* m_pm;
|
||||
Mode m_mode;
|
||||
};
|
||||
|
||||
// Runs an install/remove/update/refresh action off the UI thread.
|
||||
class InstallWorker : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InstallWorker(IPackageManager* pm, const std::string& package, bool remove = false);
|
||||
enum class Op { Install, Remove, Update, UpdateAll, Refresh };
|
||||
InstallWorker(IPackageManager* pm, Op op, const std::string& package);
|
||||
void run() override;
|
||||
signals:
|
||||
void progress(const QString& message);
|
||||
void finished(bool success);
|
||||
private:
|
||||
IPackageManager* m_pm;
|
||||
Op m_op;
|
||||
std::string m_package;
|
||||
bool m_remove;
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
@@ -62,49 +79,67 @@ private slots:
|
||||
void onUpdate();
|
||||
void onUpdateAll();
|
||||
void onRefresh();
|
||||
void onPluginChanged(int index);
|
||||
void onSearchFinished(std::vector<PackageInfo> results);
|
||||
void onInstallFinished(bool success);
|
||||
void onListFinished(std::vector<PackageInfo> results);
|
||||
void onPackageSelected(int row);
|
||||
void onToggleInstalledView();
|
||||
void onShowHistory();
|
||||
void onNavChanged(int id);
|
||||
void onClearHistory();
|
||||
void onRefreshLogs();
|
||||
|
||||
private:
|
||||
enum BrowseMode { ModeSearch, ModeInstalled, ModeUpdates };
|
||||
|
||||
void setupUI();
|
||||
void setupBrowsePage();
|
||||
void setupHistoryPage();
|
||||
void setupLogsPage();
|
||||
void setupMenuBar();
|
||||
void updatePackageInfo(const PackageInfo& pkg);
|
||||
void updateStatusBar();
|
||||
void loadPlugins();
|
||||
void performSearch(const std::string& query);
|
||||
void setBrowseMode(BrowseMode mode);
|
||||
void performInstall(const std::string& package);
|
||||
void performRemove(const std::string& package);
|
||||
void populatePackageList(const std::vector<PackageInfo>& results);
|
||||
QListWidgetItem* makePackageRow(const PackageInfo& pkg);
|
||||
void setBusy(bool busy);
|
||||
void reloadCurrentView();
|
||||
void loadInstalled();
|
||||
void loadUpdates();
|
||||
void refreshHistoryTable();
|
||||
void loadLogs();
|
||||
|
||||
// UI Elements
|
||||
// Sidebar
|
||||
QButtonGroup* m_navGroup;
|
||||
QStackedWidget* m_pages;
|
||||
QPushButton* m_refreshButton;
|
||||
|
||||
// Browse page
|
||||
QWidget* m_searchRowWidget;
|
||||
QLabel* m_browseTitle;
|
||||
QLineEdit* m_searchBar;
|
||||
QPushButton* m_searchButton;
|
||||
QComboBox* m_pluginSelector;
|
||||
QPushButton* m_installButton;
|
||||
QPushButton* m_removeButton;
|
||||
QPushButton* m_updateButton;
|
||||
QPushButton* m_updateAllButton;
|
||||
QProgressBar* m_progressBar;
|
||||
QListWidget* m_packageList;
|
||||
QLabel* m_packageName;
|
||||
QLabel* m_packageVersion;
|
||||
QLabel* m_packageRepo;
|
||||
QLabel* m_packageSize;
|
||||
QLabel* m_packageDescription;
|
||||
QPushButton* m_installButton;
|
||||
QPushButton* m_removeButton;
|
||||
QPushButton* m_updateButton;
|
||||
QPushButton* m_updateAllButton;
|
||||
QPushButton* m_refreshButton;
|
||||
QPushButton* m_historyButton;
|
||||
QProgressBar* m_progressBar;
|
||||
QTabWidget* m_mainTabs;
|
||||
QTextEdit* m_historyView;
|
||||
QStackedWidget* m_stackedWidget;
|
||||
|
||||
// History page
|
||||
QTableWidget* m_historyTable;
|
||||
|
||||
// Logs page
|
||||
QTextEdit* m_logsText;
|
||||
|
||||
// Backend
|
||||
PluginManager* m_pluginManager;
|
||||
PacmanManager* m_pacman;
|
||||
HistoryManager* m_historyManager;
|
||||
PackageModel* m_packageModel;
|
||||
IPackageManager* m_currentPlugin;
|
||||
BrowseMode m_browseMode = ModeSearch;
|
||||
|
||||
std::vector<PackageInfo> m_currentResults;
|
||||
PackageInfo m_selectedPackage;
|
||||
Reference in new issue
Block a user