Skip to content

Commit e7811e9

Browse files
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
1 parent 30d120c commit e7811e9

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

resources/forms/preferences.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,13 @@
948948
</property>
949949
</widget>
950950
</item>
951+
<item row="1" column="0" colspan="2">
952+
<widget class="QCheckBox" name="autoSwitchToEraserCheckBox">
953+
<property name="text">
954+
<string>Automatically switch to eraser when tablet eraser is detected</string>
955+
</property>
956+
</widget>
957+
</item>
951958
</layout>
952959
</widget>
953960
<widget class="QWidget" name="markerTab">

src/board/UBBoardView.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,16 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
350350
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool ();
351351

352352
if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) {
353+
const bool autoSwitch = UBSettings::settings()->boardAutoSwitchToEraser->get().toBool();
353354
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
354355
if (event->pointerType () == QPointingDevice::PointerType::Eraser) {
355356
#else
356357
if (event->pointerType () == QTabletEvent::Eraser) {
357358
#endif
358-
dc->setStylusTool (UBStylusTool::Eraser);
359-
mUsingTabletEraser = true;
359+
if (autoSwitch) {
360+
dc->setStylusTool (UBStylusTool::Eraser);
361+
mUsingTabletEraser = true;
362+
}
360363
}
361364
else {
362365
if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser)

src/core/UBPreferencesController.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ void UBPreferencesController::wire()
271271
connect(mPenProperties->circleCheckBox, SIGNAL(clicked(bool)), settings, SLOT(setPenPreviewCircle(bool)));
272272
connect(mPenProperties->circleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penPreviewFromSizeChanged(int)));
273273

274+
connect(mPreferencesUI->autoSwitchToEraserCheckBox, SIGNAL(clicked(bool)), settings->boardAutoSwitchToEraser, SLOT(setBool(bool)));
275+
274276
// marker
275277
QList<QColor> markerLightBackgroundColors = settings->boardMarkerLightBackgroundColors->colors();
276278
QList<QColor> markerDarkBackgroundColors = settings->boardMarkerDarkBackgroundColors->colors();
@@ -342,6 +344,7 @@ void UBPreferencesController::init()
342344
mPenProperties->pressureSensitiveCheckBox->setChecked(settings->boardPenPressureSensitive->get().toBool());
343345
mPenProperties->circleCheckBox->setChecked(settings->showPenPreviewCircle->get().toBool());
344346
mPenProperties->circleSpinBox->setValue(settings->penPreviewFromSize->get().toInt());
347+
mPreferencesUI->autoSwitchToEraserCheckBox->setChecked(settings->boardAutoSwitchToEraser->get().toBool());
345348

346349
// marker tab
347350
mMarkerProperties->fineSlider->setValue(settings->boardMarkerFineWidth->get().toDouble() * sSliderRatio);

src/core/UBSettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ void UBSettings::init()
285285
boardMarkerPressureSensitive = new UBSetting(this, "Board", "MarkerPressureSensitive", false);
286286

287287
boardUseHighResTabletEvent = new UBSetting(this, "Board", "UseHighResTabletEvent", true);
288+
boardAutoSwitchToEraser = new UBSetting(this, "Board", "AutoSwitchToEraser", true);
288289

289290
boardInterpolatePenStrokes = new UBSetting(this, "Board", "InterpolatePenStrokes", true);
290291
boardSimplifyPenStrokes = new UBSetting(this, "Board", "SimplifyPenStrokes", true);

src/core/UBSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ class UBSettings : public QObject
287287
UBSetting* boardMarkerPressureSensitive;
288288

289289
UBSetting* boardUseHighResTabletEvent;
290+
UBSetting* boardAutoSwitchToEraser;
290291

291292
UBSetting* boardInterpolatePenStrokes;
292293
UBSetting* boardSimplifyPenStrokes;

0 commit comments

Comments
 (0)