Removed some buttons

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-11-07 09:44:27 +02:00
parent 011e87b421
commit 6506e93e4a
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
2 changed files with 65 additions and 59 deletions

View File

@ -70,6 +70,9 @@
</layout> </layout>
</widget> </widget>
<widget class="WideBar" name="actionsToolbar"> <widget class="WideBar" name="actionsToolbar">
<property name="useDefaultAction" stdset="0">
<bool>true</bool>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Actions</string> <string>Actions</string>
</property> </property>
@ -146,28 +149,6 @@
<string>Download a new resource</string> <string>Download a new resource</string>
</property> </property>
</action> </action>
<action name="actionUpdateItem">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Check for &amp;Updates</string>
</property>
<property name="toolTip">
<string>Try to check or update all selected resources (all resources if none are selected)</string>
</property>
</action>
<action name="actionUpdateDepsItem">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Verify Dependencies</string>
</property>
<property name="toolTip">
<string>Try to update and check for missing dependencies all selected resources (all resources if none are selected)</string>
</property>
</action>
<action name="actionVisitItemPage"> <action name="actionVisitItemPage">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -179,15 +160,15 @@
<string>Go to mods home page</string> <string>Go to mods home page</string>
</property> </property>
</action> </action>
<action name="actionRemoveItemMetadata"> <action name="actionUpdateItem">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Remove metadata</string> <string>Check for &amp;Updates</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Remove mod's metadata</string> <string>Try to check or update all selected resources (all resources if none are selected)</string>
</property> </property>
</action> </action>
</widget> </widget>

View File

@ -84,28 +84,56 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods); connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods);
ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); auto updateMenu = ui->actionUpdateItem->menu();
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem); if (updateMenu) {
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); updateMenu->clear();
} else {
updateMenu = new QMenu(this);
}
ui->actionUpdateDepsItem->setToolTip( {
auto update = updateMenu->addAction(tr("Check for Updates"));
update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)"));
connect(update, &QAction::triggered, this, &ModFolderPage::updateMods);
}
{
auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies"));
updateWithDeps->setToolTip(
tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)"));
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionUpdateDepsItem); connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); });
connect(ui->actionUpdateDepsItem, &QAction::triggered, this, [this] { updateMods(true); }); }
ui->actionUpdateItem->setMenu(updateMenu);
ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)"));
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
ui->actionsToolbar->insertActionBefore(ui->actionAddItem, ui->actionUpdateItem);
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
ui->actionsToolbar->addAction(ui->actionVisitItemPage); ui->actionsToolbar->addAction(ui->actionVisitItemPage);
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages); connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); auto removeMenu = ui->actionRemoveItem->menu();
ui->actionsToolbar->insertActionAfter(ui->actionRemoveItem, ui->actionRemoveItemMetadata); if (removeMenu) {
connect(ui->actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); removeMenu->clear();
} else {
removeMenu = new QMenu(this);
}
{
auto remove = removeMenu->addAction("Remove");
remove->setToolTip(tr("Remove selected item"));
connect(remove, &QAction::triggered, this, &ModFolderPage::removeItem);
}
auto actionRemoveItemMetadata = removeMenu->addAction(tr("Remove metadata"));
actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata"));
connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata);
ui->actionRemoveItem->setMenu(removeMenu);
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); }; auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] { connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
[this, check_allow_update, actionRemoveItemMetadata] {
ui->actionUpdateItem->setEnabled(check_allow_update()); ui->actionUpdateItem->setEnabled(check_allow_update());
ui->actionUpdateDepsItem->setEnabled(check_allow_update());
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
auto mods_list = m_model->selectedMods(selection); auto mods_list = m_model->selectedMods(selection);
@ -115,21 +143,18 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ui->actionVisitItemPage->setText(tr("Visit mod's page")); ui->actionVisitItemPage->setText(tr("Visit mod's page"));
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata"));
} else { } else {
ui->actionVisitItemPage->setText(tr("Visit mods' pages")); ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods")); ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata")); actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata"));
} }
ui->actionVisitItemPage->setEnabled(selected != 0); ui->actionVisitItemPage->setEnabled(selected != 0);
ui->actionRemoveItemMetadata->setEnabled(selected != 0); actionRemoveItemMetadata->setEnabled(selected != 0);
}); });
auto updateButtons = [this, check_allow_update] { auto updateButtons = [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); };
ui->actionUpdateItem->setEnabled(check_allow_update());
ui->actionUpdateDepsItem->setEnabled(check_allow_update());
};
connect(mods.get(), &ModFolderModel::rowsInserted, this, updateButtons); connect(mods.get(), &ModFolderModel::rowsInserted, this, updateButtons);
connect(mods.get(), &ModFolderModel::rowsRemoved, this, updateButtons); connect(mods.get(), &ModFolderModel::rowsRemoved, this, updateButtons);