feat(ui): make selected mods in downloader bold with underline

Makes it easier to find which mods are selected in case you want to
change those.
This commit is contained in:
flow 2022-04-28 20:14:03 -03:00 committed by flow
parent 613f2fc447
commit 8f2c485c92
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
4 changed files with 44 additions and 21 deletions

View File

@ -134,6 +134,12 @@ bool ModDownloadDialog::isModSelected(const QString &name, const QString& filena
return iter != modTask.end() && (iter.value()->getFilename() == filename);
}
bool ModDownloadDialog::isModSelected(const QString &name) const
{
auto iter = modTask.find(name);
return iter != modTask.end();
}
ModDownloadDialog::~ModDownloadDialog()
{
}

View File

@ -32,6 +32,7 @@ public:
void addSelectedMod(const QString & name = QString(), ModDownloadTask * task = nullptr);
void removeSelectedMod(const QString & name = QString());
bool isModSelected(const QString & name, const QString & filename) const;
bool isModSelected(const QString & name) const;
const QList<ModDownloadTask*> getTasks();
const std::shared_ptr<ModFolderModel> &mods;
@ -41,8 +42,6 @@ public slots:
void accept() override;
void reject() override;
//private slots:
private:
Ui::ModDownloadDialog *ui = nullptr;
PageContainer * m_container = nullptr;

View File

@ -38,27 +38,44 @@ auto ListModel::data(const QModelIndex& index, int role) const -> QVariant
}
ModPlatform::IndexedPack pack = modpacks.at(pos);
if (role == Qt::DisplayRole) {
return pack.name;
} else if (role == Qt::ToolTipRole) {
if (pack.description.length() > 100) {
// some magic to prevent to long tooltips and replace html linebreaks
QString edit = pack.description.left(97);
edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
return edit;
switch (role) {
case Qt::DisplayRole: {
return pack.name;
}
return pack.description;
} else if (role == Qt::DecorationRole) {
if (m_logoMap.contains(pack.logoName)) {
return (m_logoMap.value(pack.logoName));
case Qt::ToolTipRole: {
if (pack.description.length() > 100) {
// some magic to prevent to long tooltips and replace html linebreaks
QString edit = pack.description.left(97);
edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
return edit;
}
return pack.description;
}
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
return icon;
} else if (role == Qt::UserRole) {
QVariant v;
v.setValue(pack);
return v;
case Qt::DecorationRole: {
if (m_logoMap.contains(pack.logoName)) {
return (m_logoMap.value(pack.logoName));
}
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
// un-const-ify this
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
return icon;
}
case Qt::UserRole: {
QVariant v;
v.setValue(pack);
return v;
}
case Qt::FontRole: {
QFont font;
if (m_parent->getDialog()->isModSelected(pack.name)) {
font.setBold(true);
font.setUnderline(true);
}
return font;
}
default:
break;
}
return {};

View File

@ -41,6 +41,7 @@ class ModPage : public QWidget, public BasePage {
auto apiProvider() const -> const ModAPI* { return api.get(); };
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
auto getDialog() const -> const ModDownloadDialog* { return dialog; }
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
void updateModVersions(int prev_count = -1);