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