From e7811e990f6a155d88dc751bb09e9a93715f4781 Mon Sep 17 00:00:00 2001 From: SofianElmotiem Date: Sun, 17 May 2026 10:36:33 +0200 Subject: [PATCH 1/2] Add preference to disable automatic pen/eraser switching Fixes the annoyance where Openboard auto-switches to the eraser tool when a tablet device (like the Promethean Activ Panel) detects the eraser pointer type. There is now a checkbox in the Pen preferences tab to turn this off. Defaults to on so nothing changes for existing users. Closes #1432 --- resources/forms/preferences.ui | 7 +++++++ src/board/UBBoardView.cpp | 7 +++++-- src/core/UBPreferencesController.cpp | 3 +++ src/core/UBSettings.cpp | 1 + src/core/UBSettings.h | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/forms/preferences.ui b/resources/forms/preferences.ui index 45a2fc180..e89cf4ca1 100644 --- a/resources/forms/preferences.ui +++ b/resources/forms/preferences.ui @@ -948,6 +948,13 @@ + + + + Automatically switch to eraser when tablet eraser is detected + + + diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 74b41215c..cb3508574 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -350,13 +350,16 @@ void UBBoardView::tabletEvent (QTabletEvent * event) UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) { + const bool autoSwitch = UBSettings::settings()->boardAutoSwitchToEraser->get().toBool(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) if (event->pointerType () == QPointingDevice::PointerType::Eraser) { #else if (event->pointerType () == QTabletEvent::Eraser) { #endif - dc->setStylusTool (UBStylusTool::Eraser); - mUsingTabletEraser = true; + if (autoSwitch) { + dc->setStylusTool (UBStylusTool::Eraser); + mUsingTabletEraser = true; + } } else { if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser) diff --git a/src/core/UBPreferencesController.cpp b/src/core/UBPreferencesController.cpp index ed0e393d8..636c9dc7b 100644 --- a/src/core/UBPreferencesController.cpp +++ b/src/core/UBPreferencesController.cpp @@ -271,6 +271,8 @@ void UBPreferencesController::wire() connect(mPenProperties->circleCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setPenPreviewCircle(bool))); connect(mPenProperties->circleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penPreviewFromSizeChanged(int))); + connect(mPreferencesUI->autoSwitchToEraserCheckBox, SIGNAL(clicked(bool)), settings->boardAutoSwitchToEraser, SLOT(setBool(bool))); + // marker QList markerLightBackgroundColors = settings->boardMarkerLightBackgroundColors->colors(); QList markerDarkBackgroundColors = settings->boardMarkerDarkBackgroundColors->colors(); @@ -342,6 +344,7 @@ void UBPreferencesController::init() mPenProperties->pressureSensitiveCheckBox->setChecked(settings->boardPenPressureSensitive->get().toBool()); mPenProperties->circleCheckBox->setChecked(settings->showPenPreviewCircle->get().toBool()); mPenProperties->circleSpinBox->setValue(settings->penPreviewFromSize->get().toInt()); + mPreferencesUI->autoSwitchToEraserCheckBox->setChecked(settings->boardAutoSwitchToEraser->get().toBool()); // marker tab mMarkerProperties->fineSlider->setValue(settings->boardMarkerFineWidth->get().toDouble() * sSliderRatio); diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 22ec9c940..cd25b6761 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -285,6 +285,7 @@ void UBSettings::init() boardMarkerPressureSensitive = new UBSetting(this, "Board", "MarkerPressureSensitive", false); boardUseHighResTabletEvent = new UBSetting(this, "Board", "UseHighResTabletEvent", true); + boardAutoSwitchToEraser = new UBSetting(this, "Board", "AutoSwitchToEraser", true); boardInterpolatePenStrokes = new UBSetting(this, "Board", "InterpolatePenStrokes", true); boardSimplifyPenStrokes = new UBSetting(this, "Board", "SimplifyPenStrokes", true); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index fa16a0270..b35988611 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -287,6 +287,7 @@ class UBSettings : public QObject UBSetting* boardMarkerPressureSensitive; UBSetting* boardUseHighResTabletEvent; + UBSetting* boardAutoSwitchToEraser; UBSetting* boardInterpolatePenStrokes; UBSetting* boardSimplifyPenStrokes; From 6dd85541e051870b02ad60bb9a5ce7a9f5e4d8cc Mon Sep 17 00:00:00 2001 From: SofianElmotiem Date: Sun, 17 May 2026 10:36:33 +0200 Subject: [PATCH 2/2] Address review: rename setting and flip default for eraser workaround Rename boardAutoSwitchToEraser -> boardIgnoreBrokenEraserDetection to make it clear this is a workaround for broken eraser detection, not a general preference. Default is now false (opt-in). Update the checkbox label to "Ignore broken eraser detection for tablets". Signed-off-by: SofianElmotiem --- resources/forms/preferences.ui | 2 +- src/board/UBBoardView.cpp | 4 ++-- src/core/UBPreferencesController.cpp | 4 ++-- src/core/UBSettings.cpp | 2 +- src/core/UBSettings.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/forms/preferences.ui b/resources/forms/preferences.ui index e89cf4ca1..c873ecf78 100644 --- a/resources/forms/preferences.ui +++ b/resources/forms/preferences.ui @@ -951,7 +951,7 @@ - Automatically switch to eraser when tablet eraser is detected + Ignore broken eraser detection for tablets diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index cb3508574..9c611b1b6 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -350,13 +350,13 @@ void UBBoardView::tabletEvent (QTabletEvent * event) UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) { - const bool autoSwitch = UBSettings::settings()->boardAutoSwitchToEraser->get().toBool(); + const bool ignoreBrokenEraser = UBSettings::settings()->boardIgnoreBrokenEraserDetection->get().toBool(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) if (event->pointerType () == QPointingDevice::PointerType::Eraser) { #else if (event->pointerType () == QTabletEvent::Eraser) { #endif - if (autoSwitch) { + if (!ignoreBrokenEraser) { dc->setStylusTool (UBStylusTool::Eraser); mUsingTabletEraser = true; } diff --git a/src/core/UBPreferencesController.cpp b/src/core/UBPreferencesController.cpp index 636c9dc7b..b068f6f97 100644 --- a/src/core/UBPreferencesController.cpp +++ b/src/core/UBPreferencesController.cpp @@ -271,7 +271,7 @@ void UBPreferencesController::wire() connect(mPenProperties->circleCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setPenPreviewCircle(bool))); connect(mPenProperties->circleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penPreviewFromSizeChanged(int))); - connect(mPreferencesUI->autoSwitchToEraserCheckBox, SIGNAL(clicked(bool)), settings->boardAutoSwitchToEraser, SLOT(setBool(bool))); + connect(mPreferencesUI->autoSwitchToEraserCheckBox, SIGNAL(clicked(bool)), settings->boardIgnoreBrokenEraserDetection, SLOT(setBool(bool))); // marker QList markerLightBackgroundColors = settings->boardMarkerLightBackgroundColors->colors(); @@ -344,7 +344,7 @@ void UBPreferencesController::init() mPenProperties->pressureSensitiveCheckBox->setChecked(settings->boardPenPressureSensitive->get().toBool()); mPenProperties->circleCheckBox->setChecked(settings->showPenPreviewCircle->get().toBool()); mPenProperties->circleSpinBox->setValue(settings->penPreviewFromSize->get().toInt()); - mPreferencesUI->autoSwitchToEraserCheckBox->setChecked(settings->boardAutoSwitchToEraser->get().toBool()); + mPreferencesUI->autoSwitchToEraserCheckBox->setChecked(settings->boardIgnoreBrokenEraserDetection->get().toBool()); // marker tab mMarkerProperties->fineSlider->setValue(settings->boardMarkerFineWidth->get().toDouble() * sSliderRatio); diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index cd25b6761..b9af2ffbd 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -285,7 +285,7 @@ void UBSettings::init() boardMarkerPressureSensitive = new UBSetting(this, "Board", "MarkerPressureSensitive", false); boardUseHighResTabletEvent = new UBSetting(this, "Board", "UseHighResTabletEvent", true); - boardAutoSwitchToEraser = new UBSetting(this, "Board", "AutoSwitchToEraser", true); + boardIgnoreBrokenEraserDetection = new UBSetting(this, "Board", "IgnoreBrokenEraserDetection", false); boardInterpolatePenStrokes = new UBSetting(this, "Board", "InterpolatePenStrokes", true); boardSimplifyPenStrokes = new UBSetting(this, "Board", "SimplifyPenStrokes", true); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index b35988611..0357256c8 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -287,7 +287,7 @@ class UBSettings : public QObject UBSetting* boardMarkerPressureSensitive; UBSetting* boardUseHighResTabletEvent; - UBSetting* boardAutoSwitchToEraser; + UBSetting* boardIgnoreBrokenEraserDetection; UBSetting* boardInterpolatePenStrokes; UBSetting* boardSimplifyPenStrokes;