Added ability to copy selected image to clipboard.
This commit is contained in:
parent
350fa4cd72
commit
a7977a1f0e
10
Manager.cpp
10
Manager.cpp
@ -70,6 +70,8 @@ Manager::Manager (QObject *parent) :
|
||||
connect (resultDialog_, SIGNAL (requestTranslate (ProcessingItem)),
|
||||
this, SIGNAL (requestTranslate (ProcessingItem)));
|
||||
connect (resultDialog_, SIGNAL (requestClipboard ()), SLOT (copyLastToClipboard ()));
|
||||
connect (resultDialog_, SIGNAL (requestImageClipboard ()),
|
||||
SLOT (copyLastImageToClipboard ()));
|
||||
connect (resultDialog_, SIGNAL (requestEdition (ProcessingItem)),
|
||||
this, SLOT (editRecognized (ProcessingItem)));
|
||||
|
||||
@ -293,6 +295,14 @@ void Manager::copyLastToClipboard () {
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::copyLastImageToClipboard () {
|
||||
const ProcessingItem &item = resultDialog_->item ();
|
||||
if (item.isValid ()) {
|
||||
QClipboard *clipboard = QApplication::clipboard ();
|
||||
clipboard->setPixmap (item.source);
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::showResult (ProcessingItem item) {
|
||||
ST_ASSERT (item.isValid ());
|
||||
if (useResultDialog_) {
|
||||
|
@ -35,6 +35,7 @@ class Manager : public QObject {
|
||||
void about ();
|
||||
void showLast ();
|
||||
void copyLastToClipboard ();
|
||||
void copyLastImageToClipboard ();
|
||||
|
||||
void applySettings ();
|
||||
|
||||
|
@ -12,7 +12,7 @@ ResultDialog::ResultDialog (const LanguageHelper &dictionary, QWidget *parent) :
|
||||
ui (new Ui::ResultDialog),
|
||||
dictionary_ (dictionary),
|
||||
contextMenu_ (NULL), recognizeSubMenu_ (NULL), translateSubMenu_ (NULL),
|
||||
clipboardAction_ (NULL), correctAction_ (NULL) {
|
||||
clipboardAction_ (NULL), imageClipboardAction_ (NULL), correctAction_ (NULL) {
|
||||
ui->setupUi (this);
|
||||
setWindowFlags (Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint |
|
||||
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||
@ -41,6 +41,7 @@ void ResultDialog::createContextMenu () {
|
||||
recognizeSubMenu_ = contextMenu_->addMenu (tr ("Распознать другой язык"));
|
||||
translateSubMenu_ = contextMenu_->addMenu (tr ("Перевести на другой язык"));
|
||||
clipboardAction_ = contextMenu_->addAction (tr ("Скопировать в буфер"));
|
||||
imageClipboardAction_ = contextMenu_->addAction (tr ("Скопировать рисунок в буфер"));
|
||||
correctAction_ = contextMenu_->addAction (tr ("Исправить распознанный текст"));
|
||||
}
|
||||
|
||||
@ -65,6 +66,9 @@ bool ResultDialog::eventFilter (QObject *object, QEvent *event) {
|
||||
else if (action == clipboardAction_) {
|
||||
emit requestClipboard ();
|
||||
}
|
||||
else if (action == imageClipboardAction_) {
|
||||
emit requestImageClipboard ();
|
||||
}
|
||||
else if (action == correctAction_) {
|
||||
emit requestEdition (item_);
|
||||
// Return because Manager calls showResult() before hide() otherwise.
|
||||
|
@ -22,6 +22,7 @@ class ResultDialog : public QDialog {
|
||||
void requestRecognize (ProcessingItem item);
|
||||
void requestTranslate (ProcessingItem item);
|
||||
void requestClipboard (); // Assume that slot will be called immediately.
|
||||
void requestImageClipboard (); // Assume that slot will be called immediately.
|
||||
void requestEdition (ProcessingItem item);
|
||||
|
||||
public:
|
||||
@ -42,6 +43,7 @@ class ResultDialog : public QDialog {
|
||||
QMenu *recognizeSubMenu_;
|
||||
QMenu *translateSubMenu_;
|
||||
QAction *clipboardAction_;
|
||||
QAction *imageClipboardAction_;
|
||||
QAction *correctAction_;
|
||||
ProcessingItem item_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user