浏览代码

Merge pull request #2722 from Nordsoft91/launcher-doubleclick

Launcher mod double click behavior
Nordsoft91 2 年之前
父节点
当前提交
48e6e0228c

+ 48 - 0
launcher/modManager/cmodlistview_moc.cpp

@@ -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;
+	}
+}
+

+ 2 - 0
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;
 };

+ 3 - 0
launcher/modManager/cmodlistview_moc.ui

@@ -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>