Ignore small selection (less 3x3).
This commit is contained in:
parent
3109444805
commit
4c51e264b5
@ -102,25 +102,27 @@ bool SelectionDialog::eventFilter (QObject *object, QEvent *event) {
|
|||||||
QPoint endPos = mouseEvent->pos ();
|
QPoint endPos = mouseEvent->pos ();
|
||||||
QRect selection = QRect (startSelectPos_, endPos).normalized ();
|
QRect selection = QRect (startSelectPos_, endPos).normalized ();
|
||||||
QPixmap selectedPixmap = currentPixmap_.copy (selection);
|
QPixmap selectedPixmap = currentPixmap_.copy (selection);
|
||||||
if (!selectedPixmap.isNull ()) {
|
if (selectedPixmap.width () < 3 || selectedPixmap.height () < 3) {
|
||||||
ProcessingItem item;
|
reject ();
|
||||||
item.source = selectedPixmap;
|
return QDialog::eventFilter (object, event);
|
||||||
item.screenPos = pos () + selection.topLeft ();
|
|
||||||
|
|
||||||
if (mouseEvent->button () == Qt::RightButton &&
|
|
||||||
!languageMenu_->children ().isEmpty ()) {
|
|
||||||
QAction *action = languageMenu_->exec (QCursor::pos ());
|
|
||||||
if (action == NULL) {
|
|
||||||
reject ();
|
|
||||||
return QDialog::eventFilter (object, event);
|
|
||||||
}
|
|
||||||
item.ocrLanguage = dictionary_.ocrUiToCode (action->text ());
|
|
||||||
ST_ASSERT (!item.ocrLanguage.isEmpty ());
|
|
||||||
item.sourceLanguage = dictionary_.translateForOcrCode (item.ocrLanguage);
|
|
||||||
ST_ASSERT (!item.sourceLanguage.isEmpty ());
|
|
||||||
}
|
|
||||||
emit selected (item);
|
|
||||||
}
|
}
|
||||||
|
ProcessingItem item;
|
||||||
|
item.source = selectedPixmap;
|
||||||
|
item.screenPos = pos () + selection.topLeft ();
|
||||||
|
|
||||||
|
if (mouseEvent->button () == Qt::RightButton &&
|
||||||
|
!languageMenu_->children ().isEmpty ()) {
|
||||||
|
QAction *action = languageMenu_->exec (QCursor::pos ());
|
||||||
|
if (action == NULL) {
|
||||||
|
reject ();
|
||||||
|
return QDialog::eventFilter (object, event);
|
||||||
|
}
|
||||||
|
item.ocrLanguage = dictionary_.ocrUiToCode (action->text ());
|
||||||
|
ST_ASSERT (!item.ocrLanguage.isEmpty ());
|
||||||
|
item.sourceLanguage = dictionary_.translateForOcrCode (item.ocrLanguage);
|
||||||
|
ST_ASSERT (!item.sourceLanguage.isEmpty ());
|
||||||
|
}
|
||||||
|
emit selected (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter (object, event);
|
return QDialog::eventFilter (object, event);
|
||||||
|
Loading…
Reference in New Issue
Block a user