diff options
Diffstat (limited to 'src/core/touch_selection_menu_controller.cpp')
-rw-r--r-- | src/core/touch_selection_menu_controller.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/core/touch_selection_menu_controller.cpp b/src/core/touch_selection_menu_controller.cpp index cdec9a064..3a6d49160 100644 --- a/src/core/touch_selection_menu_controller.cpp +++ b/src/core/touch_selection_menu_controller.cpp @@ -53,17 +53,11 @@ TouchSelectionMenuController::~TouchSelectionMenuController() int TouchSelectionMenuController::buttonCount() { - int buttonCount = 1; - - for (int commandId = 0; commandId <= static_cast<int>(Paste); ++commandId) { - if (m_touchSelectionControllerClient->IsCommandIdEnabled(commandId)) - buttonCount++; - } - - return buttonCount; + // Context menu should be always available + return qPopulationCount(static_cast<quint8>(availableActions())) + 1; } -bool TouchSelectionMenuController::isCommandEnabled(TouchSelectionCommand command) +bool TouchSelectionMenuController::isCommandEnabled(TouchSelectionMenuController::TouchSelectionCommandFlag command) { return m_touchSelectionControllerClient->IsCommandIdEnabled(static_cast<int>(command)); } @@ -88,4 +82,21 @@ void TouchSelectionMenuController::runContextMenu() return m_touchSelectionControllerClient->RunContextMenu(); } +TouchSelectionMenuController::TouchSelectionCommandFlags TouchSelectionMenuController::availableActions() +{ + TouchSelectionCommandFlags availableActions; + + if (m_touchSelectionControllerClient->IsCommandIdEnabled(Cut)) { + availableActions |= TouchSelectionMenuController::Cut; + } + if (m_touchSelectionControllerClient->IsCommandIdEnabled(Copy)) { + availableActions |= TouchSelectionMenuController::Copy; + } + if (m_touchSelectionControllerClient->IsCommandIdEnabled(Paste)) { + availableActions |= TouchSelectionMenuController::Paste; + } + + return availableActions; +} + } // namespace QtWebEngineCore |