Commit aef9d7ce authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

GitWidget: Create ContextMenu for index at pos

Additionally, disable action for staged if staged has no childern.
parent c3014eb7
Pipeline #207527 canceled with stage
in 21 seconds
......@@ -1025,7 +1025,9 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
}
}
const auto idx = m_treeView->currentIndex();
const auto idx = m_treeView->indexAt(e->pos());
if (!idx.isValid())
return;
auto treeItem = idx.data(GitStatusModel::TreeItemType);
if (treeItem == GitStatusModel::NodeChanges || treeItem == GitStatusModel::NodeUntrack) {
......@@ -1128,6 +1130,11 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
QMenu menu;
auto stage = menu.addAction(i18n("Unstage All"));
auto diff = menu.addAction(i18n("Show diff"));
auto model = m_treeView->model();
bool disable = model->rowCount(idx) == 0;
stage->setDisabled(disable);
diff->setDisabled(disable);
auto act = menu.exec(m_treeView->viewport()->mapToGlobal(e->pos()));
if (!act) {
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment