From 31956549e68bee82219b9a196b59c42605417ad6 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Fri, 1 Sep 2023 03:29:50 +0400 Subject: [PATCH 1/2] Double click behavior --- launcher/modManager/cmodlistview_moc.cpp | 31 ++++++++++++++++++++++++ launcher/modManager/cmodlistview_moc.h | 2 ++ launcher/modManager/cmodlistview_moc.ui | 3 +++ 3 files changed, 36 insertions(+) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 7ecf53ab3..cfab9c50a 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -888,3 +888,34 @@ QString CModListView::getTranslationModName(const QString & language) return QString(); } + +void CModListView::on_allModsView_doubleClicked(const QModelIndex &index) +{ + if(!index.isValid()) + return; + + auto mod = modModel->getMod(index.data(ModRoles::ModNameRole).toString()); + + if(mod.isAvailable() && !mod.getName().contains('.')) + { + on_installButton_clicked(); + return; + } + + if(mod.isUpdateable()) + { + on_updateButton_clicked(); + } + + if(mod.isDisabled()) + { + on_enableButton_clicked(); + return; + } + + if(mod.isEnabled()) + { + on_disableButton_clicked(); + } +} + diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index e6ede36c1..c645d503f 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -126,6 +126,8 @@ private slots: void on_screenshotsList_clicked(const QModelIndex & index); + void on_allModsView_doubleClicked(const QModelIndex &index); + private: Ui::CModListView * ui; }; diff --git a/launcher/modManager/cmodlistview_moc.ui b/launcher/modManager/cmodlistview_moc.ui index 72961f923..d5bfa0b34 100644 --- a/launcher/modManager/cmodlistview_moc.ui +++ b/launcher/modManager/cmodlistview_moc.ui @@ -119,6 +119,9 @@ Qt::Horizontal + + 12 + QAbstractItemView::SingleSelection From 5875dc6b8f031cd3b1f7fff07ef9863730967604 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Fri, 1 Sep 2023 17:40:52 +0400 Subject: [PATCH 2/2] Smarter double-click --- launcher/modManager/cmodlistview_moc.cpp | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index cfab9c50a..236627ef7 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -893,29 +893,46 @@ void CModListView::on_allModsView_doubleClicked(const QModelIndex &index) { if(!index.isValid()) return; - - auto mod = modModel->getMod(index.data(ModRoles::ModNameRole).toString()); - - if(mod.isAvailable() && !mod.getName().contains('.')) + + 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(mod.isUpdateable()) + 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(mod.isDisabled()) + if(!hasBlockingMods && !hasInvalidDeps && mod.isDisabled()) { on_enableButton_clicked(); return; } - if(mod.isEnabled()) + if(!hasDependentMods && !mod.isEssential() && mod.isEnabled()) { on_disableButton_clicked(); + return; } }