Added possibility to select image several times without closing SelectionDialog.
This commit is contained in:
parent
4c51e264b5
commit
fb1d25f914
13
Manager.cpp
13
Manager.cpp
@ -34,7 +34,7 @@ Manager::Manager (QObject *parent) :
|
|||||||
|
|
||||||
// Recognizer
|
// Recognizer
|
||||||
Recognizer *recognizer = new Recognizer;
|
Recognizer *recognizer = new Recognizer;
|
||||||
connect (this, SIGNAL (selected (ProcessingItem)),
|
connect (this, SIGNAL (requestRecognize (ProcessingItem)),
|
||||||
recognizer, SLOT (recognize (ProcessingItem)));
|
recognizer, SLOT (recognize (ProcessingItem)));
|
||||||
connect (recognizer, SIGNAL (recognized (ProcessingItem)),
|
connect (recognizer, SIGNAL (recognized (ProcessingItem)),
|
||||||
SIGNAL (recognized (ProcessingItem)));
|
SIGNAL (recognized (ProcessingItem)));
|
||||||
@ -188,8 +188,8 @@ void Manager::capture () {
|
|||||||
selection->setWindowIcon (trayIcon_->icon ());
|
selection->setWindowIcon (trayIcon_->icon ());
|
||||||
connect (this, SIGNAL (closeSelections ()), selection, SLOT (close ()));
|
connect (this, SIGNAL (closeSelections ()), selection, SLOT (close ()));
|
||||||
connect (this, SIGNAL (settingsEdited ()), selection, SLOT (updateMenu ()));
|
connect (this, SIGNAL (settingsEdited ()), selection, SLOT (updateMenu ()));
|
||||||
connect (selection, SIGNAL (selected (ProcessingItem)), SIGNAL (selected (ProcessingItem)));
|
connect (selection, SIGNAL (selected (ProcessingItem)),
|
||||||
connect (selection, SIGNAL (selected (ProcessingItem)), SIGNAL (closeSelections ()));
|
SLOT (handleSelection (ProcessingItem)));
|
||||||
connect (selection, SIGNAL (rejected ()), SIGNAL (closeSelections ()));
|
connect (selection, SIGNAL (rejected ()), SIGNAL (closeSelections ()));
|
||||||
selections_[name] = selection;
|
selections_[name] = selection;
|
||||||
}
|
}
|
||||||
@ -199,6 +199,13 @@ void Manager::capture () {
|
|||||||
updateActionsState ();
|
updateActionsState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Manager::handleSelection (ProcessingItem item) {
|
||||||
|
emit requestRecognize (item);
|
||||||
|
if (!(item.modifiers & Qt::ControlModifier)) {
|
||||||
|
emit closeSelections ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Manager::repeatCapture () {
|
void Manager::repeatCapture () {
|
||||||
if (selections_.isEmpty ()) {
|
if (selections_.isEmpty ()) {
|
||||||
return;
|
return;
|
||||||
|
@ -22,7 +22,7 @@ class Manager : public QObject {
|
|||||||
~Manager ();
|
~Manager ();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selected (ProcessingItem item);
|
void requestRecognize (ProcessingItem item);
|
||||||
void recognized (ProcessingItem item);
|
void recognized (ProcessingItem item);
|
||||||
void requestTranslate (ProcessingItem item);
|
void requestTranslate (ProcessingItem item);
|
||||||
void closeSelections ();
|
void closeSelections ();
|
||||||
@ -41,6 +41,7 @@ class Manager : public QObject {
|
|||||||
|
|
||||||
void processTrayAction (QSystemTrayIcon::ActivationReason reason);
|
void processTrayAction (QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
||||||
|
void handleSelection (ProcessingItem item);
|
||||||
void showResult (ProcessingItem item);
|
void showResult (ProcessingItem item);
|
||||||
void showError (QString text);
|
void showError (QString text);
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ struct ProcessingItem {
|
|||||||
QString ocrLanguage;
|
QString ocrLanguage;
|
||||||
QString sourceLanguage;
|
QString sourceLanguage;
|
||||||
|
|
||||||
|
Qt::KeyboardModifiers modifiers;
|
||||||
|
|
||||||
bool isValid () const;
|
bool isValid () const;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE (ProcessingItem)
|
Q_DECLARE_METATYPE (ProcessingItem)
|
||||||
|
@ -10,7 +10,7 @@ ResultDialog::ResultDialog (QWidget *parent) :
|
|||||||
isShowAtCapturePos_ (true) {
|
isShowAtCapturePos_ (true) {
|
||||||
ui->setupUi (this);
|
ui->setupUi (this);
|
||||||
setWindowFlags (Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint |
|
setWindowFlags (Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint |
|
||||||
Qt::WindowStaysOnTopHint);
|
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||||
|
|
||||||
installEventFilter (this);
|
installEventFilter (this);
|
||||||
}
|
}
|
||||||
@ -21,7 +21,8 @@ ResultDialog::~ResultDialog () {
|
|||||||
|
|
||||||
bool ResultDialog::eventFilter (QObject *object, QEvent *event) {
|
bool ResultDialog::eventFilter (QObject *object, QEvent *event) {
|
||||||
Q_UNUSED (object);
|
Q_UNUSED (object);
|
||||||
if (event->type () == QEvent::MouseButtonRelease) {
|
if (event->type () == QEvent::MouseButtonRelease ||
|
||||||
|
event->type () == QEvent::WindowDeactivate) {
|
||||||
hide ();
|
hide ();
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter (object, event);
|
return QDialog::eventFilter (object, event);
|
||||||
|
@ -19,7 +19,7 @@ win32{
|
|||||||
linux{
|
linux{
|
||||||
QT += x11extras
|
QT += x11extras
|
||||||
INCLUDEPATH += ../linux/include
|
INCLUDEPATH += ../linux/include
|
||||||
LIBS += -L../linux/lib -lX11
|
LIBS += -L../linux/lib -lX11 -Wl,-rpath,.
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBS += -ltesseract -llept
|
LIBS += -ltesseract -llept
|
||||||
@ -70,4 +70,5 @@ OTHER_FILES += \
|
|||||||
app.rc \
|
app.rc \
|
||||||
images/icon.ico \
|
images/icon.ico \
|
||||||
README.md \
|
README.md \
|
||||||
uncrustify.cfg
|
uncrustify.cfg\
|
||||||
|
TODO.md
|
||||||
|
@ -14,7 +14,7 @@ SelectionDialog::SelectionDialog (const LanguageHelper &dictionary, QWidget *par
|
|||||||
languageMenu_ (new QMenu) {
|
languageMenu_ (new QMenu) {
|
||||||
ui->setupUi (this);
|
ui->setupUi (this);
|
||||||
setWindowFlags (Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint |
|
setWindowFlags (Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint |
|
||||||
Qt::WindowStaysOnTopHint);
|
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||||
|
|
||||||
ui->label->setAutoFillBackground (false);
|
ui->label->setAutoFillBackground (false);
|
||||||
ui->label->installEventFilter (this);
|
ui->label->installEventFilter (this);
|
||||||
@ -101,6 +101,7 @@ 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 ();
|
||||||
|
startSelectPos_ = currentSelectPos_ = QPoint ();
|
||||||
QPixmap selectedPixmap = currentPixmap_.copy (selection);
|
QPixmap selectedPixmap = currentPixmap_.copy (selection);
|
||||||
if (selectedPixmap.width () < 3 || selectedPixmap.height () < 3) {
|
if (selectedPixmap.width () < 3 || selectedPixmap.height () < 3) {
|
||||||
reject ();
|
reject ();
|
||||||
@ -109,6 +110,7 @@ bool SelectionDialog::eventFilter (QObject *object, QEvent *event) {
|
|||||||
ProcessingItem item;
|
ProcessingItem item;
|
||||||
item.source = selectedPixmap;
|
item.source = selectedPixmap;
|
||||||
item.screenPos = pos () + selection.topLeft ();
|
item.screenPos = pos () + selection.topLeft ();
|
||||||
|
item.modifiers = mouseEvent->modifiers ();
|
||||||
|
|
||||||
if (mouseEvent->button () == Qt::RightButton &&
|
if (mouseEvent->button () == Qt::RightButton &&
|
||||||
!languageMenu_->children ().isEmpty ()) {
|
!languageMenu_->children ().isEmpty ()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user