From c17af593581b74c5fee9d6ab717d5d9286ced50b Mon Sep 17 00:00:00 2001 From: leca Date: Sun, 30 Mar 2025 20:50:11 +0300 Subject: [PATCH] add autodetect in ocr scene --- ocrscene.cpp | 13 +++++++++++-- ocrscene.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ocrscene.cpp b/ocrscene.cpp index dc1e782..db45994 100644 --- a/ocrscene.cpp +++ b/ocrscene.cpp @@ -67,7 +67,16 @@ void OCRScene::on_choose_image_button_clicked() { std::string parsed = i.parse_text(); ui->check_text_edit->setPlainText(QString::fromStdString(parsed)); - - +} + + +void OCRScene::on_check_text_edit_textChanged() { + std::string store = parser.try_autodetect_store(ui->check_text_edit->toPlainText().toStdString()); + if (store == "") { + std::cerr << tr("Could not autodetect store. If you beleive that this is an error, please, report to the developer.").toStdString() << std::endl; + return; + } + unsigned int index = ui->store_combo_box->findText(QString::fromStdString(store)); + ui->store_combo_box->setCurrentIndex(index); } diff --git a/ocrscene.h b/ocrscene.h index 2909825..7a1c55f 100644 --- a/ocrscene.h +++ b/ocrscene.h @@ -21,6 +21,8 @@ private slots: void on_choose_image_button_clicked(); + void on_check_text_edit_textChanged(); + private: Ui::OCRScene *ui; Parser parser;