mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-08 09:09:46 +00:00
patch_manager: add expand and collapse
Also reorder the context menu and remove some options if not applicable
This commit is contained in:
parent
695cfead16
commit
3ea33763bc
1 changed files with 64 additions and 35 deletions
|
@ -478,41 +478,11 @@ void patch_manager_dialog::on_custom_context_menu_requested(const QPoint &pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const node_level level = static_cast<node_level>(item->data(0, node_level_role).toInt());
|
||||||
|
|
||||||
QMenu* menu = new QMenu(this);
|
QMenu* menu = new QMenu(this);
|
||||||
|
|
||||||
QAction* collapse_all = new QAction(tr("Collapse All"));
|
if (level == node_level::patch_level)
|
||||||
menu->addAction(collapse_all);
|
|
||||||
connect(collapse_all, &QAction::triggered, ui->patch_tree, &QTreeWidget::collapseAll);
|
|
||||||
|
|
||||||
QAction* expand_all = new QAction(tr("Expand All"));
|
|
||||||
menu->addAction(expand_all);
|
|
||||||
connect(expand_all, &QAction::triggered, ui->patch_tree, &QTreeWidget::expandAll);
|
|
||||||
|
|
||||||
menu->addSeparator();
|
|
||||||
|
|
||||||
if (item->childCount() > 0)
|
|
||||||
{
|
|
||||||
QAction* collapse_children = new QAction(tr("Collapse Children"));
|
|
||||||
menu->addAction(collapse_children);
|
|
||||||
connect(collapse_children, &QAction::triggered, this, [&item](bool)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < item->childCount(); i++)
|
|
||||||
{
|
|
||||||
item->child(i)->setExpanded(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
QAction* expand_children = new QAction(tr("Expand Children"));
|
|
||||||
menu->addAction(expand_children);
|
|
||||||
connect(expand_children, &QAction::triggered, this, [&item](bool)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < item->childCount(); i++)
|
|
||||||
{
|
|
||||||
item->child(i)->setExpanded(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Find the patch for this item and add menu items accordingly
|
// Find the patch for this item and add menu items accordingly
|
||||||
const std::string hash = item->data(0, hash_role).toString().toStdString();
|
const std::string hash = item->data(0, hash_role).toString().toStdString();
|
||||||
|
@ -533,10 +503,10 @@ void patch_manager_dialog::on_custom_context_menu_requested(const QPoint &pos)
|
||||||
gui::utils::open_dir(info.source_path);
|
gui::utils::open_dir(info.source_path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
if (info.source_path == patch_engine::get_imported_patch_path())
|
if (info.source_path == patch_engine::get_imported_patch_path())
|
||||||
{
|
{
|
||||||
menu->addSeparator();
|
|
||||||
|
|
||||||
QAction* remove_patch = new QAction(tr("Remove Patch"));
|
QAction* remove_patch = new QAction(tr("Remove Patch"));
|
||||||
menu->addAction(remove_patch);
|
menu->addAction(remove_patch);
|
||||||
connect(remove_patch, &QAction::triggered, this, [info, this](bool)
|
connect(remove_patch, &QAction::triggered, this, [info, this](bool)
|
||||||
|
@ -562,11 +532,70 @@ void patch_manager_dialog::on_custom_context_menu_requested(const QPoint &pos)
|
||||||
QMessageBox::warning(this, tr("Failure"), tr("The patch could not be removed!"));
|
QMessageBox::warning(this, tr("Failure"), tr("The patch could not be removed!"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item->childCount() > 0)
|
||||||
|
{
|
||||||
|
if (item->isExpanded())
|
||||||
|
{
|
||||||
|
QAction* collapse = new QAction(tr("Collapse"));
|
||||||
|
menu->addAction(collapse);
|
||||||
|
connect(collapse, &QAction::triggered, this, [&item](bool)
|
||||||
|
{
|
||||||
|
item->setExpanded(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (level < (node_level::patch_level - 1))
|
||||||
|
{
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
QAction* expand_children = new QAction(tr("Expand Children"));
|
||||||
|
menu->addAction(expand_children);
|
||||||
|
connect(expand_children, &QAction::triggered, this, [&item](bool)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < item->childCount(); i++)
|
||||||
|
{
|
||||||
|
item->child(i)->setExpanded(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QAction* collapse_children = new QAction(tr("Collapse Children"));
|
||||||
|
menu->addAction(collapse_children);
|
||||||
|
connect(collapse_children, &QAction::triggered, this, [&item](bool)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < item->childCount(); i++)
|
||||||
|
{
|
||||||
|
item->child(i)->setExpanded(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QAction* expand = new QAction(tr("Expand"));
|
||||||
|
menu->addAction(expand);
|
||||||
|
connect(expand, &QAction::triggered, this, [&item](bool)
|
||||||
|
{
|
||||||
|
item->setExpanded(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction* expand_all = new QAction(tr("Expand All"));
|
||||||
|
menu->addAction(expand_all);
|
||||||
|
connect(expand_all, &QAction::triggered, ui->patch_tree, &QTreeWidget::expandAll);
|
||||||
|
|
||||||
|
QAction* collapse_all = new QAction(tr("Collapse All"));
|
||||||
|
menu->addAction(collapse_all);
|
||||||
|
connect(collapse_all, &QAction::triggered, ui->patch_tree, &QTreeWidget::collapseAll);
|
||||||
|
|
||||||
menu->exec(ui->patch_tree->viewport()->mapToGlobal(pos));
|
menu->exec(ui->patch_tree->viewport()->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue