feat: 联调接口
依据联调结果,调整展示方案 Log: 联调 Change-Id: Id8bd869b9565f628bf29d929daaf8a5d10b89a42
This commit is contained in:
parent
ecfc9f3f64
commit
affb98dccf
|
@ -75,6 +75,10 @@ MainWidget::~MainWidget()
|
||||||
m_tipIconLabel->deleteLater();
|
m_tipIconLabel->deleteLater();
|
||||||
m_tipIconLabel = nullptr;
|
m_tipIconLabel = nullptr;
|
||||||
}
|
}
|
||||||
|
if (m_currentImg) {
|
||||||
|
delete m_currentImg;
|
||||||
|
m_currentImg = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +178,10 @@ void MainWidget::setupConnect()
|
||||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, this, &MainWidget::setIcons);
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, this, &MainWidget::setIcons);
|
||||||
connect(m_exportBtn, &DIconButton::clicked, this, &MainWidget::slotExport);
|
connect(m_exportBtn, &DIconButton::clicked, this, &MainWidget::slotExport);
|
||||||
connect(m_copyBtn, &DIconButton::clicked, this, &MainWidget::slotCopy);
|
connect(m_copyBtn, &DIconButton::clicked, this, &MainWidget::slotCopy);
|
||||||
|
connect(this, &MainWidget::sigResult, this, [ = ](const QString & result) {
|
||||||
|
loadString(result);
|
||||||
|
deleteLoadingUi();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::retranslateUi(QWidget *Widget)
|
void MainWidget::retranslateUi(QWidget *Widget)
|
||||||
|
@ -243,9 +251,8 @@ void MainWidget::openImage(const QString &path)
|
||||||
if (!m_loadImagethread) {
|
if (!m_loadImagethread) {
|
||||||
m_loadImagethread = QThread::create([ = ]() {
|
m_loadImagethread = QThread::create([ = ]() {
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_result = TessOcrUtils::instance()->getRecogitionResult(path, ResultType::RESULT_HTML);
|
m_result = TessOcrUtils::instance()->getRecogitionResult(path, ResultType::RESULT_STRING);
|
||||||
loadHtml(m_result.result);
|
emit sigResult(m_result.result);
|
||||||
deleteLoadingUi();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,13 +268,16 @@ void MainWidget::openImage(const QImage &img)
|
||||||
m_imageview->fitWindow();
|
m_imageview->fitWindow();
|
||||||
m_imgName = "";
|
m_imgName = "";
|
||||||
}
|
}
|
||||||
|
if (m_currentImg) {
|
||||||
|
delete m_currentImg;
|
||||||
|
m_currentImg = nullptr;
|
||||||
|
}
|
||||||
|
m_currentImg = new QImage(img);
|
||||||
if (!m_loadImagethread) {
|
if (!m_loadImagethread) {
|
||||||
m_loadImagethread = QThread::create([ = ]() {
|
m_loadImagethread = QThread::create([ = ]() {
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
QImage a = img;
|
m_result = TessOcrUtils::instance()->getRecogitionResult(m_currentImg, ResultType::RESULT_STRING);
|
||||||
m_result = TessOcrUtils::instance()->getRecogitionResult(&a, ResultType::RESULT_HTML);
|
emit sigResult(m_result.result);
|
||||||
loadHtml(m_result.result);
|
|
||||||
deleteLoadingUi();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
|
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
|
||||||
|
@ -284,10 +294,7 @@ void MainWidget::loadHtml(const QString &html)
|
||||||
void MainWidget::loadString(const QString &string)
|
void MainWidget::loadString(const QString &string)
|
||||||
{
|
{
|
||||||
if (!string.isEmpty()) {
|
if (!string.isEmpty()) {
|
||||||
QStringList templist = string.split("\r\n", QString::KeepEmptyParts);
|
m_plainTextEdit->appendPlainText(string);
|
||||||
for (int i = 0; i < templist.size(); i++) {
|
|
||||||
m_plainTextEdit->appendPlainText(templist.at(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ private:
|
||||||
QThread *m_loadImagethread{nullptr};
|
QThread *m_loadImagethread{nullptr};
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
RecognitionResult m_result;
|
RecognitionResult m_result;
|
||||||
|
QImage *m_currentImg{nullptr};
|
||||||
|
signals:
|
||||||
|
void sigResult(const QString &);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user