From b379b9e15507098eedccefc689a66007c2ac2df7 Mon Sep 17 00:00:00 2001 From: Jekyll Wu Date: Mon, 12 Mar 2012 17:49:38 +0800 Subject: [PATCH] Simple refactor of method TabbedViewContainer::openTabContextMenu() --- src/ViewContainer.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index 01a8a7846..25077f839 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -667,11 +667,9 @@ void TabbedViewContainer::openTabContextMenu(int index, const QPoint& pos) _contextMenuTabIndex = index; // Enable 'Detach Tab' menu item only if there is more than 1 tab - QList menuActions = _contextPopupMenu->actions(); - if (_tabBar->count() == 1) - menuActions.first()->setEnabled(false); - else - menuActions.first()->setEnabled(true); + // Note: the code is coupled with that action's position within the menu + QAction* detachAction = _contextPopupMenu->actions().first(); + detachAction->setEnabled( _tabBar->count() > 1 ); _contextPopupMenu->exec(pos); }