summaryrefslogtreecommitdiffstats
path: root/src/core/touch_selection_menu_controller.cpp
diff options
context:
space:
mode:
authorBalazs Egedi <egedib@inf.u-szeged.hu>2021-09-20 13:50:50 +0200
committerBalazs Egedi <egedib@inf.u-szeged.hu>2021-10-26 21:14:15 +0200
commit79f5f290c1eead991e4267a431de9b519abd9834 (patch)
treecb2c119e6a97c5bdca625ca07cc8cef378933dd9 /src/core/touch_selection_menu_controller.cpp
parent974bc6b7d7110df50d6cc46e7eaea12742b9ff66 (diff)
Add onTouchSelectionMenuRequested QML handler
Task-number: QTBUG-85043 Change-Id: Iecd2f5ae20fcf031937a1d44cc154f2e2a3ff52f Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/touch_selection_menu_controller.cpp')
-rw-r--r--src/core/touch_selection_menu_controller.cpp29
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