Skip to content

Commit 162d5d3

Browse files
committed
Disable current branch in 'Switch to' context menu
1 parent c738ee2 commit 162d5d3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/MainWindow.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4845,6 +4845,8 @@ void MainWindow::on_tableWidget_log_customContextMenuRequested(const QPoint &pos
48454845

48464846
std::set<QAction *> switch_to_actions;
48474847
{
4848+
QString current_branch = (misc::str)currentBranchName();
4849+
48484850
std::vector<QString> local_branches;
48494851
for (BranchLabel const &label : labels) {
48504852
if (label.kind == BranchLabel::LocalBranch) {
@@ -4853,8 +4855,14 @@ void MainWindow::on_tableWidget_log_customContextMenuRequested(const QPoint &pos
48534855
}
48544856
if (!local_branches.empty()) {
48554857
auto *switch_to = menu.addMenu(tr("Switch to"));
4856-
for (QString const &label : local_branches) {
4858+
for (QString label : local_branches) {
4859+
bool enabled = true;
4860+
if (label == current_branch) { // 現在のブランチは選択できないようにする
4861+
label = QString("%1 (%2)").arg(label).arg(tr("current"));
4862+
enabled = false;
4863+
}
48574864
QAction *a = switch_to->addAction(label);
4865+
a->setEnabled(enabled);
48584866
a->setData(label);
48594867
switch_to_actions.insert(switch_to_actions.end(), a);
48604868
}

0 commit comments

Comments
 (0)