Skip to content

Commit 0e7a257

Browse files
committed
penType switch during press issue fix
1 parent 7ec9a63 commit 0e7a257

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/widgets/DrawingWidget.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class CursorStorage {
9494
images[id]->hide();
9595
}
9696
QMap<qint64, bool> drawing;
97+
QMap<qint64, int> penType;
9798

9899
private:
99100
QMap<qint64, QWidget*> images;
@@ -461,16 +462,26 @@ void DrawingWidget::goNext(){
461462
static int num_of_press = 0;
462463
void DrawingWidget::eventHandler(int source, int type, int id, QPointF pos, float pressure){
463464
int ev_pen = penType;
464-
if(source & Qt::RightButton) {
465-
penType = ERASER;
466-
} else if(source & Qt::MiddleButton) {
465+
if(source & Qt::MiddleButton) {
467466
penType = MARKER;
467+
} else if(source & Qt::RightButton) {
468+
penType = ERASER;
468469
}
469470
switch(type) {
470471
case PRESS:
471472
if (curs.drawing[id] && curs.drawing.contains(id)) {
472-
break;
473+
// pen type change during press
474+
// so release pen then repress
475+
if(curs.penType[id] != penType){
476+
int new_pen = penType;
477+
penType = curs.penType[id];
478+
eventHandler(0, RELEASE, id, pos, pressure);
479+
penType = new_pen;
480+
} else {
481+
break;
482+
}
473483
}
484+
curs.penType[id] = penType;
474485
num_of_press++;
475486
curs.drawing[id] = true;
476487
if (num_of_press == 1){

0 commit comments

Comments
 (0)