1 #include "InputUtils.h"
2 
3 #include "control/ToolHandler.h"
4 #include "control/settings/ButtonConfig.h"
5 #include "control/settings/Settings.h"
6 #include "control/settings/SettingsEnums.h"
7 
8 
applyButton(ToolHandler * toolHandler,Settings * settings,Button button)9 bool InputUtils::applyButton(ToolHandler* toolHandler, Settings* settings, Button button) {
10     bool toolChanged = false;
11     // if active tool already points to the correct tool nothing needs to be done
12     if (toolHandler->pointActiveToolToButtonTool(button)) {
13         toolChanged = true;
14         ButtonConfig* cfg = settings->getButtonConfig(button);
15 
16         // if ToolChange is not activated for this button stay with ToolBartool
17         if (cfg->getAction() == TOOL_NONE)
18             toolChanged = toolHandler->pointActiveToolToToolbarTool();
19         else
20             cfg->applyNoChangeSettings(toolHandler, button);
21     }
22     return toolChanged;
23 }
24 
touchDrawingDisallowed(ToolHandler * toolHandler,Settings * settings)25 bool InputUtils::touchDrawingDisallowed(ToolHandler* toolHandler, Settings* settings) {
26     static bool warningAlreadyShown{false};
27     ButtonConfig* cfg = settings->getButtonConfig(Button::BUTTON_TOUCH);
28     if (cfg->getDisableDrawing() && cfg->getAction() == TOOL_NONE && toolHandler->isDrawingTool()) {
29         if (!warningAlreadyShown)
30             g_message("Ignoring touchscreen for drawing:\n"
31                       " Please check the settings for Touchscreen.\n"
32                       " The current combination of \"Disable Drawing for this device\"\n"
33                       " together with \"Tool - don't change\"\n"
34                       " prevents any drawing with the selected tool using the TouchScreen.");
35         warningAlreadyShown = true;
36         return true;
37     }
38     // reset warningAlreadyShown this allows the message to be sent multiple times
39     // in case the user switches the settings in between multiple times
40     warningAlreadyShown = false;
41     return false;
42 }
43