Skip to content
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

Improve package manager UX #1710

Open
wants to merge 6 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 @@ -21,7 +21,6 @@ PluginSettingsModel::PluginSettingsModel(
QSettings& set, const score::ApplicationContext& ctx)
: score::SettingsDelegateModel{}
, localPlugins{ctx}
, remoteSelection{&remotePlugins}
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once
#include <score/plugins/settingsdelegate/SettingsDelegateModel.hpp>

#include <QItemSelectionModel>

#include <PackageManager/PluginItemModel.hpp>

class QAbstractItemModel;
Expand All @@ -19,6 +17,5 @@ class PluginSettingsModel : public score::SettingsDelegateModel

LocalPackagesModel localPlugins;
RemotePackagesModel remotePlugins;
QItemSelectionModel remoteSelection;
};
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include <QApplication>
#include <QDebug>
#include <QHeaderView>
#include <QItemSelectionModel>
#include <QListView>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QStyle>

Expand All @@ -37,27 +39,44 @@ PluginSettingsPresenter::PluginSettingsPresenter(
auto& ps_model = static_cast<PluginSettingsModel&>(model);
auto& ps_view = static_cast<PluginSettingsView&>(view);

ps_view.localView()->setModel(&ps_model.localPlugins);
ps_view.m_remoteModel = &ps_model.remotePlugins;
ps_view.m_localModel = &ps_model.localPlugins;

QSortFilterProxyModel* localProxyModel = new QSortFilterProxyModel(this);
localProxyModel->setSourceModel(&ps_model.localPlugins);
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);

QSortFilterProxyModel* remoteProxyModel = new QSortFilterProxyModel(this);
remoteProxyModel->setSourceModel(&ps_model.remotePlugins);
remoteProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);

ps_view.localView()->setModel(localProxyModel);
ps_view.localView()->setColumnWidth(0, 200);
ps_view.localView()->setColumnWidth(1, 40);
ps_view.localView()->setColumnWidth(2, 40);
ps_view.localView()->setColumnWidth(3, 300);
ps_view.localView()->setColumnWidth(4, 30);
ps_view.localView()->horizontalHeader()->setStretchLastSection(true);

ps_view.remoteView()->setModel(&ps_model.remotePlugins);
ps_view.remoteView()->setModel(remoteProxyModel);
ps_view.remoteView()->setColumnWidth(0, 200);
ps_view.remoteView()->setColumnWidth(1, 40);
ps_view.remoteView()->setColumnWidth(2, 40);
ps_view.remoteView()->setColumnWidth(1, 50);
ps_view.remoteView()->setColumnWidth(2, 50);
ps_view.remoteView()->setColumnWidth(3, 300);
ps_view.remoteView()->setColumnWidth(4, 30);
ps_view.remoteView()->horizontalHeader()->setStretchLastSection(true);

ps_view.remoteView()->setSelectionModel(&ps_model.remoteSelection);

auto selection = new QItemSelectionModel{remoteProxyModel, this};
ps_view.remoteView()->setSelectionModel(selection);
connect(
&ps_model.remoteSelection, &QItemSelectionModel::currentRowChanged, this,
[&](const QModelIndex& current, const QModelIndex& previous) {
Package& addon = ps_model.remotePlugins.addons().at(current.row());
selection, &QItemSelectionModel::currentRowChanged, this,
[remoteProxyModel, &ps_model,
&ps_view](const QModelIndex& current, const QModelIndex& previous) {
auto selected = remoteProxyModel->mapToSource(current);
Package& addon = ps_model.remotePlugins.addons().at(selected.row());

ps_view.installButton().setEnabled(!addon.files.empty() || addon.kind == "sdk");
});
});

ps_view.installButton().setEnabled(false);

Expand Down
Loading
Loading