1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #2722 from Nordsoft91/launcher-doubleclick

Launcher mod double click behavior
This commit is contained in:
Nordsoft91 2023-09-02 19:42:28 +04:00 committed by GitHub
commit 48e6e0228c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View File

@ -888,3 +888,51 @@ QString CModListView::getTranslationModName(const QString & language)
return QString();
}
void CModListView::on_allModsView_doubleClicked(const QModelIndex &index)
{
if(!index.isValid())
return;
auto modName = index.data(ModRoles::ModNameRole).toString();
auto mod = modModel->getMod(modName);
bool hasInvalidDeps = !findInvalidDependencies(modName).empty();
bool hasBlockingMods = !findBlockingMods(modName).empty();
bool hasDependentMods = !findDependentMods(modName, true).empty();
if(!hasInvalidDeps && mod.isAvailable() && !mod.getName().contains('.'))
{
on_installButton_clicked();
return;
}
if(!hasInvalidDeps && !hasDependentMods && mod.isUpdateable() && index.column() == ModFields::STATUS_UPDATE)
{
on_updateButton_clicked();
return;
}
if(index.column() == ModFields::NAME)
{
if(ui->allModsView->isExpanded(index))
ui->allModsView->collapse(index);
else
ui->allModsView->expand(index);
return;
}
if(!hasBlockingMods && !hasInvalidDeps && mod.isDisabled())
{
on_enableButton_clicked();
return;
}
if(!hasDependentMods && !mod.isEssential() && mod.isEnabled())
{
on_disableButton_clicked();
return;
}
}

View File

@ -126,6 +126,8 @@ private slots:
void on_screenshotsList_clicked(const QModelIndex & index);
void on_allModsView_doubleClicked(const QModelIndex &index);
private:
Ui::CModListView * ui;
};

View File

@ -119,6 +119,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>12</number>
</property>
<widget class="QTreeView" name="allModsView">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>