Last showing item now stores only in ResultDialog.
This commit is contained in:
parent
1f5d6c73bd
commit
283b596ef1
20
Manager.cpp
20
Manager.cpp
@ -111,8 +111,9 @@ void Manager::updateActionsState (bool isEnabled) {
|
||||
#endif
|
||||
captureAction_->setEnabled (isEnabled);
|
||||
repeatCaptureAction_->setEnabled (isEnabled && !selections_.isEmpty ());
|
||||
repeatAction_->setEnabled (isEnabled && lastItem_.isValid ());
|
||||
clipboardAction_->setEnabled (isEnabled && lastItem_.isValid ());
|
||||
const ProcessingItem &lastItem = resultDialog_->item ();
|
||||
repeatAction_->setEnabled (isEnabled && lastItem.isValid ());
|
||||
clipboardAction_->setEnabled (isEnabled && lastItem.isValid ());
|
||||
#ifdef Q_OS_LINUX
|
||||
for (int i = 0, end = actions.size (); i < end; ++i) {
|
||||
if (states.at (i) != actions.at (i)->isEnabled ()) {
|
||||
@ -266,17 +267,19 @@ void Manager::processTrayAction (QSystemTrayIcon::ActivationReason reason) {
|
||||
}
|
||||
|
||||
void Manager::showLast () {
|
||||
if (lastItem_.isValid ()) {
|
||||
showResult (lastItem_);
|
||||
const ProcessingItem &item = resultDialog_->item ();
|
||||
if (item.isValid ()) {
|
||||
showResult (item);
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::copyLastToClipboard () {
|
||||
if (lastItem_.isValid ()) {
|
||||
const ProcessingItem &item = resultDialog_->item ();
|
||||
if (item.isValid ()) {
|
||||
QClipboard *clipboard = QApplication::clipboard ();
|
||||
QString message = lastItem_.recognized;
|
||||
if (!lastItem_.translated.isEmpty ()) {
|
||||
message += " - " + lastItem_.translated;
|
||||
QString message = item.recognized;
|
||||
if (!item.translated.isEmpty ()) {
|
||||
message += " - " + item.translated;
|
||||
}
|
||||
clipboard->setText (message);
|
||||
trayIcon_->showMessage (tr ("Результат"),
|
||||
@ -287,7 +290,6 @@ void Manager::copyLastToClipboard () {
|
||||
|
||||
void Manager::showResult (ProcessingItem item) {
|
||||
ST_ASSERT (item.isValid ());
|
||||
lastItem_ = item;
|
||||
if (useResultDialog_) {
|
||||
resultDialog_->showResult (item);
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ class Manager : public QObject {
|
||||
QAction *repeatCaptureAction_;
|
||||
QAction *repeatAction_;
|
||||
QAction *clipboardAction_;
|
||||
ProcessingItem lastItem_;
|
||||
bool useResultDialog_;
|
||||
//! Used threads. For proper termination.
|
||||
QList<QThread *> threads_;
|
||||
|
@ -26,6 +26,10 @@ ResultDialog::~ResultDialog () {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
const ProcessingItem &ResultDialog::item () const {
|
||||
return item_;
|
||||
}
|
||||
|
||||
void ResultDialog::applySettings () {
|
||||
dictionary_.updateMenu (recognizeSubMenu_, dictionary_.availableOcrLanguagesUi ());
|
||||
}
|
||||
@ -43,7 +47,7 @@ bool ResultDialog::eventFilter (QObject *object, QEvent *event) {
|
||||
QAction *action = contextMenu_->exec (QCursor::pos ());
|
||||
QWidget *subMenu = action->parentWidget ();
|
||||
if (recognizeSubMenu_->isAncestorOf (subMenu)) {
|
||||
ProcessingItem item = lastItem_;
|
||||
ProcessingItem item = item_;
|
||||
item.translated = item.recognized = QString ();
|
||||
item.ocrLanguage = dictionary_.ocrUiToCode (action->text ());
|
||||
emit requestRecognize (item);
|
||||
@ -59,7 +63,7 @@ bool ResultDialog::eventFilter (QObject *object, QEvent *event) {
|
||||
|
||||
void ResultDialog::showResult (ProcessingItem item) {
|
||||
ST_ASSERT (item.isValid ());
|
||||
lastItem_ = item;
|
||||
item_ = item;
|
||||
ui->sourceLabel->setPixmap (item.source);
|
||||
ui->recognizeLabel->setText (item.recognized);
|
||||
ui->translateLabel->setText (item.translated);
|
||||
|
@ -22,6 +22,7 @@ class ResultDialog : public QDialog {
|
||||
void requestRecognize (ProcessingItem item);
|
||||
|
||||
public:
|
||||
const ProcessingItem &item () const;
|
||||
bool eventFilter (QObject *object, QEvent *event);
|
||||
|
||||
public slots:
|
||||
@ -37,7 +38,7 @@ class ResultDialog : public QDialog {
|
||||
bool isShowAtCapturePos_;
|
||||
QMenu *contextMenu_;
|
||||
QMenu *recognizeSubMenu_;
|
||||
ProcessingItem lastItem_;
|
||||
ProcessingItem item_;
|
||||
};
|
||||
|
||||
#endif // RESULTDIALOG_H
|
||||
|
Loading…
Reference in New Issue
Block a user