Skip to content

Improve package manager UX #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ PackagesModel::headerData(int section, Qt::Orientation orientation, int role) co
case Column::ShortDesc:
return tr("Description");
break;
case Column::Kind:
return tr("Kind");
break;
case Column::Version:
return tr("Version");
break;
Expand Down Expand Up @@ -108,12 +111,15 @@ QVariant PackagesModel::data(const QModelIndex& index, int role) const
case Column::ShortDesc:
return addon.shortDescription;
break;
case Column::Version:
return addon.version;
case Column::Kind:
return addon.kind;
break;
case Column::Size:
return addon.size;
break;
case Column::Version:
return addon.version;
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ struct Package
kind; // what kind of package it is (for now: "addon", "sdk", "library", "media", "presets")
std::vector<QUrl> files; // URL to a file containing the current version.
QMap<QString, std::vector<QUrl>> arch_files; // if there are per-architecture files
QString url; // Link to the homepage of the package if any

QString url; // Link to the homepage of the package if any
QString shortDescription;
QString longDescription;
QString smallImagePath;
Expand Down Expand Up @@ -66,9 +65,10 @@ class PackagesModel : public QAbstractItemModel
Name,
Version,
Size,
ShortDesc
ShortDesc,
Kind
};
static constexpr const int ColumnCount = 4;
static constexpr const int ColumnCount = 5;

QModelIndex index(int row, int column, const QModelIndex& parent) const override;
QModelIndex parent(const QModelIndex& child) const override;
Expand Down
105 changes: 101 additions & 4 deletions src/plugins/score-plugin-packagemanager/PackageManager/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

#include <score/application/GUIApplicationContext.hpp>
#include <score/widgets/MessageBox.hpp>
#include <score/widgets/SetIcons.hpp>

#include <core/application/ApplicationInterface.hpp>

#include <QApplication>
#include <QBuffer>
#include <QComboBox>
#include <QDesktopServices>
#include <QDir>
#include <QFile>
Expand All @@ -17,6 +19,7 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QLabel>
#include <QMessageBox>
#include <QNetworkReply>
#include <QNetworkRequest>
Expand Down Expand Up @@ -93,7 +96,7 @@ PluginSettingsView::PluginSettingsView()
local_widget->setLayout(local_layout);
local_layout->addWidget(m_addonsOnSystem);

tab_widget->addTab(local_widget, tr("Local"));
tab_widget->addTab(local_widget, tr("Local packages"));
}

{
Expand All @@ -102,17 +105,35 @@ PluginSettingsView::PluginSettingsView()
remote_widget->setLayout(remote_layout);
remote_layout->addWidget(m_remoteAddons);

tab_widget->addTab(remote_widget, tr("Browse"));
tab_widget->addTab(remote_widget, tr("Available packages"));
}

auto side_widget = new QWidget;
auto vlay = new QVBoxLayout{side_widget};
grid->addWidget(side_widget, 0, 1, 2, 1);

auto categoryLabel = new QLabel("Select Kind:");
vlay->addWidget(categoryLabel);

m_categoryComboBox = new QComboBox(m_widget);
vlay->addWidget(m_categoryComboBox);
vlay->addSpacing(20);

m_link->setToolTip(tr("Open external package link in default browser."));
auto icon = makeIcons(
QStringLiteral(":/icons/undock_on.png"), QStringLiteral(":/icons/undock_off.png"),
QStringLiteral(":/icons/undock_off.png"));
m_link->setIcon(icon);

vlay->addWidget(m_link);

vlay->addSpacing(20);

vlay->addWidget(m_uninstall);
m_install->setVisible(false);
vlay->addWidget(m_install);
vlay->addSpacing(20);

vlay->addWidget(m_update);
vlay->addWidget(m_updateAll);
vlay->addStretch();
Expand Down Expand Up @@ -148,13 +169,15 @@ PluginSettingsView::PluginSettingsView()
m_progress->setValue(0);

refresh();
updateCategoryComboBox(1);
}
else // Local
{
m_uninstall->setVisible(true);
m_install->setVisible(false);
m_update->setVisible(true);
m_updateAll->setVisible(true);
updateCategoryComboBox(0);
}
});

Expand All @@ -170,6 +193,10 @@ PluginSettingsView::PluginSettingsView()

connect(&mgr, &QNetworkAccessManager::finished, this, &PluginSettingsView::on_message);

connect(m_categoryComboBox, &QComboBox::currentIndexChanged, this, [this](int index) {
onCategoryChanged(index);
});

refresh();
}

Expand Down Expand Up @@ -222,7 +249,10 @@ void PluginSettingsView::refresh()
if(qEnvironmentVariableIsSet("SCORE_SANITIZE_SKIP_CHECKS"))
return;
QNetworkRequest rqst{
QUrl("https://raw.githubusercontent.com/ossia/score-addons/master/addons.json")};
QUrl("https://raw.githubusercontent.com/ossia/score-addons/refs/heads/"
Copy link
Contributor Author

@samamou samamou Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO: Change back when this branch is merged with main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still pointing to my branch for testing purposes, should point to master when merged

"add-ai-models/addons.json")};
// QNetworkRequest rqst{
// QUrl("https://raw.githubusercontent.com/ossia/score-addons/master/addons.json")};
mgr.get(rqst);
}

Expand Down Expand Up @@ -306,6 +336,11 @@ void PluginSettingsView::on_message(QNetworkReply* rep)
}
rep->deleteLater();

if(m_install->isVisible())
updateCategoryComboBox(1);
else
updateCategoryComboBox(0);

if(!m_firstTimeCheck)
{
m_firstTimeCheck = true;
Expand Down Expand Up @@ -390,7 +425,7 @@ void PluginSettingsView::uninstall()

const auto& library{score::AppContext().settings<Library::Settings::Model>()};

if(addon.kind == "addon" || addon.kind == "nodes" || addon.kind == "media")
if(addon.kind == "addon" || addon.kind == "nodes" || addon.kind == "media" || addon.kind == "ai-model")
{
success = QDir{library.getPackagesPath() + '/' + addon.raw_name}.removeRecursively();
}
Expand Down Expand Up @@ -689,4 +724,66 @@ void PluginSettingsView::progress_from_bytes(qint64 bytesReceived, qint64 bytesT
m_progress->setValue(((bytesReceived / 1024.) / (bytesTotal / 1024.)) * 100);
}

void PluginSettingsView::updateCategoryComboBox(int tabIndex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looking good!

{
m_categoryComboBox->clear();
m_categoryComboBox->addItem("All");

PackagesModel* model = nullptr;
if(tabIndex == 0) // Local packages tab
{
model = static_cast<PackagesModel*>(m_addonsOnSystem->model());
}
else if(tabIndex == 1) // Remote packages tab
{
model = static_cast<PackagesModel*>(m_remoteAddons->model());
}

// If the model exists, add uniqueKind
if(model)
{
QList<QString> uniqueKinds;

for(const auto& addon : model->addons())
{
if(!uniqueKinds.contains(addon.kind))
{
uniqueKinds.append(addon.kind);
}
}

for(const QString& kind : uniqueKinds)
{
m_categoryComboBox->addItem(kind);
}
}
}

void PluginSettingsView::onCategoryChanged(int index)
{
// Filter table view to show only packages of the selected kind
QString selectedKind = m_categoryComboBox->itemText(index);

QTableView* activeView = m_install->isVisible() ? m_remoteAddons : m_addonsOnSystem;
PackagesModel* model = static_cast<PackagesModel*>(activeView->model());

if(!model)
return;

if(selectedKind == "All")
{
for(int row = 0; row < model->addons().size(); ++row)
{
activeView->setRowHidden(row, false);
}
return;
}

for(int row = 0; row < model->addons().size(); ++row)
{
QString rowKind = model->addons()[row].kind;
activeView->setRowHidden(row, rowKind != selectedKind);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class PluginSettingsView : public score::GlobalSettingsView
void set_info();
void reset_progress();
void progress_from_bytes(qint64 bytesReceived, qint64 bytesTotal);
void updateCategoryComboBox(int tabIndex);
void onCategoryChanged(int index);

QWidget* m_widget{new QWidget};

Expand All @@ -84,6 +86,7 @@ class PluginSettingsView : public score::GlobalSettingsView

QStorageInfo storage;
QLabel* m_storage{new QLabel};
QComboBox* m_categoryComboBox = nullptr;

bool m_firstTimeCheck{false};
};
Expand Down
Loading