Truly independent web browser
UI/Qt: Adjust context menu text based on tab layout
Timothy Flynne2cafc562c82
diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cppindex 2e0e2dddbe1..4de3de41dad 100644--- a/UI/Qt/Tab.cpp+++ b/UI/Qt/Tab.cpp@@ -888,8 +888,8 @@ void Tab::create_tab_context_menu()m_window->pin_tab(*this);});- auto* new_tab_to_the_right_action = new QAction("New Tab to the &Right", this);- QObject::connect(new_tab_to_the_right_action, &QAction::triggered, this, [this]() {+ auto* new_tab_action = new QAction(this);+ QObject::connect(new_tab_action, &QAction::triggered, this, [this]() {m_window->new_tab_from_url(Application::settings().new_tab_page_url(), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_tab(*this));});@@ -918,8 +918,8 @@ void Tab::create_tab_context_menu()request_close();});- auto* close_tabs_to_right_action = new QAction("Close Tabs to the R&ight", this);- QObject::connect(close_tabs_to_right_action, &QAction::triggered, this, [this]() {+ auto* close_following_tabs_action = new QAction(this);+ QObject::connect(close_following_tabs_action, &QAction::triggered, this, [this]() {// Closing the current tab selects a neighbor, which may be a tab about to close too, and selecting a tab that// hasn't loaded loads it. So, this tab, which stays open, becomes the current tab first.if (auto* current = m_window->current_tab(); current && m_window->tab_index(current) > tab_index() && !current->is_pinned())@@ -932,7 +932,7 @@ void Tab::create_tab_context_menu()auto* close_other_tabs_action = new QAction("Cl&ose Other Tabs", this);QObject::connect(close_other_tabs_action, &QAction::triggered, this, [this]() {- // As in Close Tabs to Right, this tab becomes the current tab first if the current tab is among those closing.+ // As with closing the following tabs, activate this tab first if the current tab is among those closing.if (auto* current = m_window->current_tab(); current && current != this && !current->is_pinned())m_window->activate_tab(tab_index());for (auto i = m_window->tab_count() - 1; i >= 0; i--) {@@ -944,7 +944,7 @@ void Tab::create_tab_context_menu()});m_context_menu = new QMenu("Context menu", this);- m_context_menu->addAction(new_tab_to_the_right_action);+ m_context_menu->addAction(new_tab_action);m_context_menu->addSeparator();m_context_menu->addAction(create_application_action(*this, application.reload_action(), IncludeActionIcon::No));m_context_menu->addAction(duplicate_tab_action);@@ -956,12 +956,16 @@ void Tab::create_tab_context_menu()m_context_menu->addSeparator();m_context_menu->addAction(close_tab_action);m_context_menu->addAction(close_other_tabs_action);- m_context_menu->addAction(close_tabs_to_right_action);+ m_context_menu->addAction(close_following_tabs_action);m_context_menu->addSeparator();m_context_menu->addAction(Application::the().reopen_recently_closed_tab_action());- QObject::connect(m_context_menu, &QMenu::aboutToShow, this, [this, mute_tab_action, move_to_new_window_action]() {- // NB: A tab that hasn't loaded has no page to mute yet.+ QObject::connect(m_context_menu, &QMenu::aboutToShow, this, [this, new_tab_action, close_following_tabs_action, mute_tab_action, move_to_new_window_action]() {+ auto is_horizontal = m_window->tab_widget().tab_bar()->tab_layout() == TabLayout::Horizontal;+ new_tab_action->setText(is_horizontal ? "New Tab to the &Right" : "New Tab &Below");+ close_following_tabs_action->setText(is_horizontal ? "Close Tabs to the R&ight" : "Close Tabs B&elow");++ // A tab that hasn't loaded has no page to mute yet.mute_tab_action->setEnabled(is_loaded());mute_tab_action->setText(is_loaded() && view().page_mute_state() == Web::HTML::MuteState::Muted ? "Un&mute Tab" : "&Mute Tab");move_to_new_window_action->setEnabled(m_window->tab_count() > 1);