11 Commits

25 changed files with 648 additions and 1110 deletions

View File

@@ -1,10 +1,54 @@
cmake_minimum_required(VERSION 3.10)
project(checks-parser VERSION 0.1 LANGUAGES CXX)
project(checks-parser VERSION 0.0.4 LANGUAGES CXX)
option(BUILD_TRANSLATIONS "Build translations?" ON)
option(BUILD_EMAIL_TO_TEXT_MODE "Build email-to-text mode?" ON)
option(BUILD_OCR_MODE "Build OCR mode?" ON)
option(BUILD_OFD_LOCAL_QR_SCAN "Build OFDs' local qr scanner?" ON)
option(BUILD_OFD_BINARYEYE_SCAN "Build OFDs' binaryeye scanner?" ON)
include(FetchContent)
if (NOT (BUILD_EMAIL_TO_TEXT_MODE OR BUILD_OCR_MODE OR BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN))
message(FATAL_ERROR "You must specify at least one of the modes of data input!")
return()
endif()
if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(BUILD_OFD_MODE)
else()
add_compile_definitions(BUILD_OFD_MODE)
endif()
endif()
if (BUILD_EMAIL_TO_TEXT_MODE)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(BUILD_EMAIL_TO_TEXT_MODE)
else()
add_compile_definitions(BUILD_EMAIL_TO_TEXT_MODE)
endif()
endif()
if (BUILD_OCR_MODE)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(BUILD_OCR_MODE)
else()
add_compile_definitions(BUILD_OCR_MODE)
endif()
endif()
if (BUILD_OFD_LOCAL_QR_SCAN)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(BUILD_OFD_LOCAL_QR_SCAN)
else()
add_compile_definitions(BUILD_OFD_LOCAL_QR_SCAN)
endif()
endif()
if (BUILD_OFD_BINARYEYE_SCAN)
if(CMAKE_VERSION VERSION_LESS 3.12)
add_definitions(BUILD_OFD_BINARYEYE_SCAN)
else()
add_compile_definitions(BUILD_OFD_BINARYEYE_SCAN)
endif()
endif()
SET(CMAKE_BUILD_TYPE Debug)
@@ -18,15 +62,35 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5Core REQUIRED)
if (BUILD_TRANSLATIONS)
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)
endif()
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5UiTools REQUIRED)
set(PROJECT_SOURCES
set(TRANSLATION_SOURCES
main.cpp
mainwindow.h mainwindow.cpp scenes/mainwindow.ui
mainwindow.cpp mainwindow.h scenes/mainwindow.ui
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
)
if (BUILD_EMAIL_TO_TEXT_MODE)
list(APPEND TRANSLATION_SOURCES emailtextscene.cpp emailtextscene.h scenes/emailtextscene.ui)
endif()
if (BUILD_OCR_MODE)
list(APPEND TRANSLATION_SOURCES ocrscene.cpp ocrscene.h scenes/ocrscene.ui)
endif()
if (BUILD_OFD_LOCAL_QR_SCAN)
list(APPEND TRANSLATION_SOURCES adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui)
endif()
if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
list(APPEND TRANSLATION_SOURCES solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui)
list(APPEND TRANSLATION_SOURCES ofdscene.cpp ofdscene.h scenes/ofdscene.ui)
endif()
set(PROJECT_SOURCES
goods/goods.h goods/goods.cpp
check/check.h check/check.cpp
parser/parser.h parser/parser.cpp
@@ -35,37 +99,36 @@ set(PROJECT_SOURCES
output/output_options.h output/output_options.cpp
utils/utils.h utils/utils.cpp
image/checkimage.h image/checkimage.cpp
net/net.h net/net.cpp
settings/settings.h settings/settings.cpp
exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp
emailtextscene.h emailtextscene.cpp scenes/emailtextscene.ui
ocrscene.h ocrscene.cpp scenes/ocrscene.ui
ofdscene.h ofdscene.cpp scenes/ofdscene.ui
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui
image_redactor/imageredactor.h image_redactor/imageredactor.cpp
solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui
${TRANSLATION_SOURCES}
)
set(TRANSLATION_SOURCES
main.cpp
mainwindow.cpp mainwindow.h scenes/mainwindow.ui
emailtextscene.cpp emailtextscene.h scenes/emailtextscene.ui
ocrscene.cpp ocrscene.h scenes/ocrscene.ui
ofdscene.cpp ofdscene.h scenes/ofdscene.ui
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui
solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui
)
if (BUILD_OCR_MODE)
list(APPEND PROJECT_SOURCES image/checkimage.h image/checkimage.cpp)
endif()
if (BUILD_OFD_LOCAL_QR_SCAN)
list(APPEND PROJECT_SOURCES image_redactor/imageredactor.h image_redactor/imageredactor.cpp)
endif()
if (BUILD_OFD_BINARYEYE_SCAN OR BUILD_OFD_LOCAL_QR_SCAN)
list(APPEND PROJECT_SOURCES exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp)
endif()
if (BUILD_OFD_BINARYEYE_SCAN)
list(APPEND PROJECT_SOURCES http_server/http_server.h http_server/http_server.cpp)
endif()
if (BUILD_TRANSLATIONS)
set(TS_FILES
translations/en_US.ts
translations/ru_RU.ts
)
if (BUILD_TRANSLATIONS)
qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" ${TS_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc COPYONLY)
qt5_add_resources(TRANSLATIONQRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
@@ -109,7 +172,9 @@ endif()
target_link_libraries(checks-parser PRIVATE Qt5::Widgets Qt5::UiTools)
if (BUILD_OFD_LOCAL_QR_SCAN)
target_include_directories(checks-parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/image_redactor)
endif()
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER org.foxarmy.checks-parser)
@@ -133,28 +198,29 @@ if(WIN32)
set(OpenCV_DIR /usr/local/lib/cmake/opencv4)
endif()
FetchContent_Declare(httplib SYSTEM
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib
GIT_TAG c765584e6b1055fe0dfe3e9e6d1b4b09aa305070
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(httplib)
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
if (BUILD_OFD_BINARYEYE_SCAN)
find_package(PkgConfig)
pkg_check_modules(QRENCODE REQUIRED libqrencode)
include_directories(${QRENCODE_INCLUDE_DIRS})
link_directories(${QRENCODE_LIBRARY_DIRS})
target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES})
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
endif()
if (BUILD_OFD_LOCAL_QR_SCAN)
target_link_libraries(checks-parser PRIVATE -lzbar)
endif()
if (BUILD_OCR_MODE)
target_link_libraries(checks-parser PRIVATE -ltesseract)
endif()
target_link_libraries(checks-parser PRIVATE -lcurl)
if (BUILD_OCR_MODE OR BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
target_link_libraries(checks-parser PRIVATE httplib)
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
include_directories( ${OpenCV_INCLUDE_DIRS} )
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
target_link_libraries(checks-parser PRIVATE -lstdc++fs)

View File

@@ -29,6 +29,7 @@
* curl
* nlohmann-json
* qt5
* qrencode
Пожалуйста, не стесняйтесь и открывайте issue, если вы не можете собрать приложение. Я помогу вам, и если вы собираете приложение на дистрибутиве, который здесь не перечислен, как только мы решим вашу проблему, я добавлю новый дистрибутив в этот список!
@@ -53,9 +54,9 @@ sudo make install
Установка зависимостей для различных debian дистрибутивов:
###### Ubuntu 18.04
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json-dev libcurl4-openssl-dev libtesseract-dev```
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json-dev libcurl4-openssl-dev libtesseract-dev libqrencode-dev```
###### Ubuntu 20.04, LMDE (проверил только 6), Debian (проверил только 12)
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json3-dev libcurl4-openssl-dev libtesseract-dev```
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json3-dev libcurl4-openssl-dev libtesseract-dev libqrencode-dev```
Следующие шаги идеинтичны для всех дистрибутивов, основанных на debian:
```

View File

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

View File

Before

Width:  |  Height:  |  Size: 649 KiB

After

Width:  |  Height:  |  Size: 649 KiB

View File

@@ -1,4 +1,5 @@
#!/bin/bash
export TESSDATA_PREFIX=\$APPDIR/usr/share/tesseract-ocr/4.00/tessdata
export TESSDATA_PREFIX=$APPDIR/usr/share/tesseract-ocr/4.00/tessdata
export LD_LIBRARY_PATH=$APPDIR/usr/lib
\$APPDIR/usr/bin/checks-parser
$APPDIR/usr/bin/checks-parser

View File

@@ -16,15 +16,17 @@ WORKDIR /
RUN wget https://mirror.linux-ia64.org/gnu/gcc/releases/gcc-12.3.0/gcc-12.3.0.tar.gz
RUN tar xf gcc-12.3.0.tar.gz
RUN rm gcc-12.3.0.tar.gz
WORKDIR /gcc-12.3.0
RUN ./configure --disable-multilib
RUN ./configure --disable-multilib --prefix=/usr
RUN make -j $(nproc) && make install
RUN cp /lib64/* /lib/x86_64-linux-gnu || :
WORKDIR /
RUN rm -rf gcc-12.3.0
ENTRYPOINT bash
# Download linuxdeployqt
RUN wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage -O /usr/bin/linuxdeployqt && \
chmod +x /usr/bin/linuxdeployqt
@@ -34,7 +36,7 @@ WORKDIR /appimage
RUN mkdir -p AppDir
COPY deploy/appimage/checks-parser.desktop AppDir
COPY icon.png AppDir/checks-parser.png
COPY assets/icons/icon.png AppDir/checks-parser.png
COPY deploy/appimage/AppRun AppDir
RUN chmod +x AppDir/AppRun
@@ -66,6 +68,9 @@ RUN cp /appimage/build/checks-parser .
WORKDIR /appimage
RUN LD_LIBRARY_PATH=LD_LIBRARY_PATH=/usr/local/lib64 linuxdeployqt AppDir/usr/bin/checks-parser -no-copy-copyright-files -appimage
RUN linuxdeployqt --appimage-extract-and-run AppDir/usr/bin/checks-parser -no-copy-copyright-files -appimage
RUN mkdir -p /appimage/output
RUN cp Checks_parser-x86_64.AppImage /appimage/output
ENTRYPOINT bash

View File

@@ -1,6 +1,6 @@
# Maintainer: Leca <leca@foxarmy.org>
pkgname=checks-parser-git
pkgver=alpha_0.0.2
pkgver=alpha_0.0.4
pkgrel=1
epoch=
pkgdesc="Utility for parsing checks(receipts) to csv"
@@ -8,7 +8,7 @@ arch=('x86_64')
url="https://git.foxarmy.org/leca/checks-parser"
license=('GPL-3.0-or-later')
groups=()
depends=('qt5-base' 'opencv' 'zbar' 'nlohmann-json' 'tesseract')
depends=('qt5-base' 'opencv' 'zbar' 'nlohmann-json' 'tesseract' 'qrencode')
makedepends=('cmake' 'make' 'gcc' 'git' 'qt5-tools')
checkdepends=()
optdepends=('tesseract-data-rus: scan russian checks with OCR')

112
http_server/http_server.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include "http_server.h"
#include <qobjectdefs.h>
#include <unistd.h>
#include <utils/utils.h>
#include <iostream>
#include <ofdscene.h>
#include <thread>
void HttpServer::generateRandomPort() {
port = rand() % (65535 - 1024) + 1024;
}
HttpServer::HttpServer(QWidget *caller) : caller(caller) {
started = false;
port = 8080;
}
HttpServer::~HttpServer() {
started = false;
shutdown(serverSocket, SHUT_RDWR);
close(serverSocket);
for (auto &thread : clientHandlersThreads) {
thread.join();
}
listenClientsThread.join();
}
int HttpServer::start() {
unsigned short number_of_retries = 0;
while (number_of_retries < 10) {
serverSocket = socket(AF_INET, SOCK_STREAM, 0);
if (serverSocket < 0) {
std::cerr << "Could not obtain socket." << std::endl;
number_of_retries ++;
continue;
}
serverAddress.sin_family = AF_INET;
serverAddress.sin_port = htons(port);
serverAddress.sin_addr.s_addr = INADDR_ANY;
if (bind(serverSocket, (sockaddr *)&serverAddress, sizeof(serverAddress)) < 0) {
std::cerr << "Port " << port << " seems to be occupied. Trying to generate another one" << std::endl;
number_of_retries ++;
generateRandomPort();
continue;
}
if (listen(serverSocket, 1) < 0) {
std::cerr << "Could not listen port." << std::endl;
number_of_retries ++;
generateRandomPort();
continue;
}
started = true;
std::cout << "Listening on port: " << port << std::endl;
listenClientsThread = std::thread(&HttpServer::acceptClients, this);
return 0;
}
return -1;
}
void HttpServer::handleClient(int clientSocket) {
std::string localIp;
try {
localIp = get_local_ip_address();
} catch(std::exception e) {
std::cerr << e.what() << std::endl;
close(clientSocket);
return;
}
char buffer[256] = {0};
recv(clientSocket, buffer, 256, 0);
std::string response = "HTTP/1.1 301 Moved Permanently\r\n"
"Content-Length: 0\r\n"
"Keep-Alive: timeout=5, max=100\r\n"
"Location: binaryeye://scan/?ret=http://" + get_local_ip_address() + ":" + std::to_string(port) + "/?result={RESULT}\r\n"
"\r\n";
if (send(clientSocket, response.c_str(), response.length(), 0) < 0) {
std::cerr << response.c_str() << std::endl;
std::cerr << response.length() << std::endl;
std::cerr << "Could not send message" << std::endl;
}
emit ((OFDScene *)caller)->httpNewMessage(QString::fromStdString(std::string(buffer)));
}
void HttpServer::acceptClients() {
while (true) {
if (!started) return;
int clientSocket = accept(serverSocket, nullptr, nullptr);
if (!started) return;
clientHandlersThreads.push_back (
std::thread(&HttpServer::handleClient, this, clientSocket)
);
}
}
unsigned short HttpServer::getPort() {
return port;
}
bool HttpServer::isStarted() {
return started;
}

37
http_server/http_server.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef CHECKS_PARSER_HTTP_SERVER
#define CHECKS_PARSER_HTTP_SERVER
#include <netinet/in.h>
#include <QWidget>
#include <thread>
#include <vector>
class HttpServer {
private:
unsigned short port;
int serverSocket;
sockaddr_in serverAddress;
QWidget* caller;
std::thread listenClientsThread;
std::vector<std::thread> clientHandlersThreads;
bool started;
void generateRandomPort();
public:
HttpServer(QWidget *caller);
~HttpServer();
int start();
void stop();
void handleClient(int clientSocket);
void acceptClients();
unsigned short getPort();
bool isStarted();
};
#endif //CHECKS_PARSER_HTTP_SERVER

153
main.cpp
View File

@@ -3,7 +3,10 @@
#include "settings/settings.h"
#include "utils/utils.h"
#include <QApplication>
#ifdef BUILD_OFD_MODE
# include <curl/curl.h>
# include <ofdscene.h>
#endif
#include <iostream>
#if __GNUC__ < 8 && __clang_major__ < 17
# include <experimental/filesystem>
@@ -17,9 +20,12 @@
#include <QStackedLayout>
#include <QTextStream>
#include <QTranslator>
#ifdef BUILD_EMAIL_TO_TEXT_MODE
# include <emailtextscene.h>
#endif
#ifdef BUILD_OCR_MODE
# include <ocrscene.h>
#include <ofdscene.h>
#endif
#include <qpushbutton.h>
#include <parser/parser.h>
@@ -66,37 +72,50 @@ int main(int argc, char *argv[]) {
// Main Window setup
QWidget *mainwindowscene = loadUI(window, ":/scenes/scenes/mainwindow.ui");
// Main Window buttons setup
QPushButton *text_from_email_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("text_from_email_button");
QPushButton *ocr_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ocr_button");
QPushButton *ofd_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ofd_button");
sceneLayout->addWidget(mainwindowscene);
for (auto btn : ((MainWindow *)mainwindowscene)->findChildren<QPushButton *>()) {
btn->hide();
}
// Main Window buttons setup
#ifdef BUILD_EMAIL_TO_TEXT_MODE
QPushButton *text_from_email_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("text_from_email_button");
text_from_email_button->show();
EmailTextScene *emailTextScene = new EmailTextScene();
sceneLayout->addWidget(emailTextScene);
QObject::connect(text_from_email_button, &QPushButton::clicked, [&]() {
// Text from email scene
sceneLayout->setCurrentIndex(1);
sceneLayout->widget(1)->show();
int index = sceneLayout->indexOf(emailTextScene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
#endif
#ifdef BUILD_OCR_MODE
QPushButton *ocr_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ocr_button");
ocr_button->show();
OCRScene *ocrscene = new OCRScene();
sceneLayout->addWidget(ocrscene);
QObject::connect(ocr_button, &QPushButton::clicked, [&]() {
// OCR scene
sceneLayout->setCurrentIndex(2);
sceneLayout->widget(2)->show();
int index = sceneLayout->indexOf(ocrscene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
#endif
#ifdef BUILD_OFD_MODE
QPushButton *ofd_button = ((MainWindow *)mainwindowscene)->findChild<QPushButton *>("ofd_button");
ofd_button->show();
OFDScene *ofdscene = new OFDScene();
sceneLayout->addWidget(ofdscene);
QObject::connect(ofd_button, &QPushButton::clicked, [&]() {
// OFD scene
sceneLayout->setCurrentIndex(3);
sceneLayout->widget(3)->show();
int index = sceneLayout->indexOf(ofdscene);
sceneLayout->setCurrentIndex(index);
sceneLayout->widget(index)->show();
});
EmailTextScene *emailTextScene = new EmailTextScene();
OCRScene *ocrscene = new OCRScene();
OFDScene *ofdscene = new OFDScene();
sceneLayout->addWidget(mainwindowscene);
sceneLayout->addWidget(emailTextScene);
sceneLayout->addWidget(ocrscene);
sceneLayout->addWidget(ofdscene);
#endif
//Setting all back buttons
for (uint32_t sceneIndex = 0; sceneIndex < sceneLayout->count(); sceneIndex ++) {
@@ -110,98 +129,8 @@ int main(int argc, char *argv[]) {
});
}
window->setLayout(sceneLayout);
window->show();
app.exec();
return 0;
// QApplication app(argc, argv);
// QWidget *window = new QWidget;
// QStackedLayout *stackedLayout = new QStackedLayout;
// QWidget *scene1 = new QWidget;
// QWidget *scene2 = new QWidget;
// // Add some widgets to each scene
// QPushButton *button1 = new QPushButton("Switch to Scene 2");
// scene1->setLayout(new QVBoxLayout);
// scene1->layout()->addWidget(button1);
// QPushButton *button2 = new QPushButton("Switch to Scene 1");
// scene2->setLayout(new QVBoxLayout);
// scene2->layout()->addWidget(button2);
// // Add the scenes to the stacked layout
// stackedLayout->addWidget(scene1);
// stackedLayout->addWidget(scene2);
// // Set the layout of the window
// window->setLayout(stackedLayout);
// // Connect the buttons to switch scenes
// QObject::connect(button1, &QPushButton::clicked, [&]() {
// stackedLayout->setCurrentIndex(1);
// });
// QObject::connect(button2, &QPushButton::clicked, [&]() {
// stackedLayout->setCurrentIndex(0);
// });
// window->show();
// app.exec();
// return 0;
curl_global_init(CURL_GLOBAL_ALL);
std::string program_data_path = get_path_relative_to_home(".local/share/checks_parser");
create_directories(program_data_path);
// std::string settings_file_path =
// get_path_relative_to_home(".local/share/checks_parser/settings.json");
// Settings s(settings_file_path);
Net n;
Parser p;
std::vector<std::string> stores_updates = p.check_updates();
for (const std::string &update : stores_updates) {
std::cout << "Downloading "
<< s.get_setting("stores_modules_url") + update << " to "
<< get_path_relative_to_home(s.get_setting("stores_modules_dir") +
"/" + update)
<< std::endl;
n.get_file(s.get_setting("stores_modules_url") + "/" + update,
get_path_relative_to_home(s.get_setting("stores_modules_dir") +
"/" + update));
}
QApplication a(argc, argv);
// QTranslator translator;
// QString lang = "en_US";
// if (s.get_all_settings().contains("language")) {
// lang = QString::fromStdString(s.get_all_settings()["language"]);
// } else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) {
// lang = QLocale::system().name();
// } else {
// lang = QString::fromStdString("en_US");
// }
// std::cout << "Using locale: " << lang.toStdString() << std::endl;
// translator.load(":/translation/" + lang + ".qm");
// a.installTranslator(&translator);
MainWindow w;
w.update();
w.show();
return a.exec();
return app.exec();
}

View File

@@ -6,8 +6,6 @@ MainWindow::MainWindow(QWidget *parent)
: QWidget(parent)
, ui(new Ui::MainWindow) {
ui->setupUi(this);
std::cout << "test" << std::endl;
}
MainWindow::~MainWindow() {

View File

@@ -1,219 +0,0 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "check/check.h"
#include "exceptions/ofdrequestexception.h"
#include "goods/goods.h"
#include "outputdialog.h"
#include "adjustpicturedialog.h"
#include "settingsdialog.h"
#include "solvecaptchadialog.h"
#include <QFileDialog>
#include <QMessageBox>
#include "image/checkimage.h"
#include "utils/utils.h"
#include <opencv2/objdetect.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <zbar.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
// this->setupStoresList();
}
MainWindow::~MainWindow() { delete ui; }
// void MainWindow::setupStoresList() {
// parser = *(new Parser());
// std::vector<std::string> modules_names = parser.search_modules();
// for (std::string name : modules_names) {
// StoreModule m(name);
// std::wstring module_name = m.get_name();
// QString s = QString::fromStdWString(module_name);
// ui->storeType->addItem(s);
// }
// }
// std::string MainWindow::makeRequestToOfd(std::string captcha) {
// std::string checkContent = Net().fetch_check_data_from_ofdru(
// ui->fn_edit->text().toStdString(),
// ui->fd_edit->text().toStdString(),
// ui->fi_edit->text().toStdString(),
// ui->dateTimeEdit->dateTime().toString(Qt::ISODate).toStdString(),
// ui->fundIncomeCombo->currentIndex() + 1,
// // In the request to ofd.ru, total is in a strange format, like a string of a format where 2 last digits represent decimal part of a number.
// ui->total_edit->text().toDouble() * 100,
// captcha);
// return checkContent;
// }
// void MainWindow::on_parseButton_clicked() {
// QString s;
// switch (ui->tabWidget->currentIndex()) {
// case 0:
// s = ui->checkContent->toPlainText();
// break;
// case 1:
// s = ui->checkContentFromImage->toPlainText();
// break;
// case 2:
// Net().get_captcha_from_ofdru();
// std::string solved_captcha = "";
// bool success = true;
// bool is_captcha_solved = true;
// do {
// SolveCaptchaDialog dialog = SolveCaptchaDialog(this, &solved_captcha);
// dialog.exec();
// is_captcha_solved = true;
// try {
// std::string check_content = makeRequestToOfd(solved_captcha);
// check = parseOfdRuAnswer(check_content);
// } catch(OfdRequestException e) {
// success = false;
// if (!strcmp(e.what(), "Incorrect captcha")) {
// is_captcha_solved = false;
// QMessageBox infoDialog;
// infoDialog.setText(tr("Captcha was not solved correctly!"));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Captcha is incorrect"));
// infoDialog.exec();
// break;
// } else if (!strcmp(e.what(), "Internal server error")) {
// QMessageBox infoDialog;
// infoDialog.setText(tr("Internal server error. Please, try again later."));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Internal server error"));
// infoDialog.exec();
// return;
// } else if (!strcmp(e.what(), "Does not exist")) {
// QMessageBox infoDialog;
// infoDialog.setText(tr("Check not found. Please, ensure correctness of entered data."));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Check was not found"));
// infoDialog.exec();
// return;
// }
// }
// } while (!is_captcha_solved);
// if (success) {
// OutputDialog d = OutputDialog(this, check);
// d.exec();
// }
// return;
// }
// std::wstring check_plaintext = s.toStdWString();
// parser.set_module(parser.search_modules()[0]);
// std::vector<Goods> c = parser.parse(check_plaintext);
// if (c.size() == 0) {
// QMessageBox infoDialog;
// infoDialog.setText(tr("An error has occured. Check was matched incorrectly. Vector sizes are different. Please, contact the developer."));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Error in parsing"));
// infoDialog.exec();
// return;
// }
// for (auto& g : c) {
// check.add_goods(g);
// }
// OutputDialog d = OutputDialog(this, check);
// d.show();
// d.exec();
// }
// void MainWindow::on_storeType_currentIndexChanged(int index) {
// std::string module = parser.search_modules()[index];
// parser.set_module(module);
// }
// void MainWindow::on_preferencesButton_clicked() {
// SettingsDialog s = SettingsDialog();
// s.show();
// s.exec();
// }
// void MainWindow::on_chooseImageButton_ofd_clicked() {
// QString filename = QFileDialog::getOpenFileName();
// if (filename == "") {
// QMessageBox infoDialog;
// infoDialog.setText(tr("Please, select a picture where QR code that contains info about check is present"));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Picture was not selected"));
// infoDialog.exec();
// return;
// }
// std::string new_text = "Selected: " + filename.toStdString();
// ui->pathLabel_ofd->setText(QString::fromStdString(new_text));
// AdjustPictureDialog dialog = AdjustPictureDialog(this, filename.toStdString());
// connect(&dialog, &AdjustPictureDialog::decodedData, this, &MainWindow::onDecodedData);
// dialog.exec();
// ui->picture_ofd->setPixmap(QPixmap(filename));
// ui->picture_ofd->setScaledContents(true);
// }
// void MainWindow::onDecodedData(std::string data) {
// std::string delimiter = "&";
// std::vector<std::string> dataSplit = split(data, delimiter);
// std::cout << data << std::endl;
// ui->fn_edit->setText(QString::fromStdString(dataSplit[2]));
// ui->fd_edit->setText(QString::fromStdString(dataSplit[3]));
// ui->fi_edit->setText(QString::fromStdString(dataSplit[4]));
// QString extractedDateTime = QString::fromStdString(split(dataSplit[0], "=")[1]);
// QDateTime datetime = QDateTime::fromString(extractedDateTime, "yyyyMMddThhmm");
// ui->dateTimeEdit->setDateTime(datetime);
// int type = std::stoi(split(dataSplit[5], "=")[1]);
// ui->fundIncomeCombo->setCurrentIndex(type - 1);
// std::string total = split(dataSplit[1], "=")[1];
// ui->total_edit->setText(QString::fromStdString(total));
// }
// void MainWindow::on_chooseImageButton_ocr_clicked()
// {
// QString filename = QFileDialog::getOpenFileName();
// if (filename == "") {
// QMessageBox infoDialog;
// infoDialog.setText(tr("Please, select a picture to scan"));
// infoDialog.setIcon(QMessageBox::Critical);
// infoDialog.setWindowTitle(tr("Picture was not selected"));
// infoDialog.exec();
// return;
// }
// std::string new_text = "Selected: " + filename.toStdString();
// ui->pathLabel_ocr->setText(QString::fromStdString(new_text));
// CheckImage i(filename.toStdString());
// std::string parsed = i.parse_text();
// ui->picture_ocr->setPixmap(QPixmap(filename));
// ui->picture_ocr->setScaledContents(true);
// ui->checkContentFromImage->setPlainText(QString::fromStdString(parsed));
// }

View File

@@ -1,44 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "check/check.h"
#include "parser/parser.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow {
Q_OBJECT
Check check;
Parser parser;
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
// void setupStoresList();
// Check get_check();
// void onDecodedData(std::string);
// std::string makeRequestToOfd(std::string captcha);
private slots:
// void on_parseButton_clicked();
// void on_storeType_currentIndexChanged(int index);
// void on_preferencesButton_clicked();
// void on_chooseImageButton_ofd_clicked();
// void on_chooseImageButton_ocr_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@@ -3,5 +3,7 @@
<file>assets/icons/email-text.svg</file>
<file>assets/icons/OCR.svg</file>
<file>assets/icons/OFD.svg</file>
<file>assets/icons/icon.png</file>
<file>assets/icons/icon.svg</file>
</qresource>
</RCC>

View File

@@ -1,37 +1,70 @@
#include "ofdscene.h"
#include "scenes/ui_ofdscene.h"
#include "ui_ofdscene.h"
#include "utils/utils.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QPixmap>
#ifdef BUILD_OFD_LOCAL_QR_SCAN
# include <adjustpicturedialog.h>
#include <httplib.h>
#endif
#include <outputdialog.h>
#include <qpixmap.h>
#include <solvecaptchadialog.h>
#include <net/net.h>
#include <utils/utils.h>
#include <exceptions/ofdrequestexception.h>
#include <bits/basic_string.h>
#include <qrencode.h>
#include <bits/basic_string.h>
#ifdef BUILD_OFD_BINARYEYE_SCAN
# include <qrencode.h>
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
#endif
OFDScene::OFDScene(QWidget *parent)
: QWidget(parent)
, ui(new Ui::OFDScene) {
ui->setupUi(this);
ui->stop_server_button->hide();
// std::string message = "GET /?result=t=20171112T153500&s=834.25&fn=8712000101054551&i=32332&fp=2169935838&n=1 HTTP/1.1\nHost: localhost:8080\nUser-Agent: curl/8.12.1\nAccept: */*";
// emit this->httpNewMessage(message);
#ifdef BUILD_OFD_BINARYEYE_SCAN
QObject::connect(this, &OFDScene::httpErrorOccured, this, &OFDScene::notifyHttpServerFailure);
connect(this, SIGNAL(httpNewMessage(QString)), this, SLOT(httpNewMessageHandler(QString)));
#endif
}
Ui::OFDScene *OFDScene::getUI() {
return ui;
}
OFDScene::~OFDScene() {
delete ui;
}
#ifdef BUILD_OFD_BINARYEYE_SCAN
void OFDScene::startHttpServer() {
std::string localIp = "";
server = new HttpServer(this);
if (server->start() < 0) {
emit httpErrorOccured();
}
}
void OFDScene::on_binary_eye_button_clicked() {
httpServerThread = new std::thread(&OFDScene::startHttpServer, this);
ui->binary_eye_button->setEnabled(false);
ui->stop_server_button->show();
while (!server->isStarted()) {}
std::string localIp;
try {
localIp = get_local_ip_address();
} catch(std::exception e) {
@@ -39,45 +72,54 @@ void OFDScene::startHttpServer() {
return;
}
unsigned short number_of_retries = 0;
std::string connectionString = "binaryeye://scan?ret=http://" + localIp + ":" + std::to_string(server->getPort()) + "/?result={RESULT}";
do {
if (number_of_retries == 10) {
emit httpErrorOccured();
return;
generate_qr_code(connectionString);
QMessageBox infoDialog = QMessageBox();
infoDialog.setText(QString::fromStdString(connectionString));
infoDialog.setIconPixmap(QPixmap(QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/binaryeye_connection.png"))).scaled(400, 400, Qt::KeepAspectRatio));
infoDialog.setWindowTitle(tr("QR code for binaryeye to connect"));
infoDialog.setButtonText(1, tr("I've scanned"));
infoDialog.exec();
}
this->port = rand() % (65535 - 1024) + 1024;
std::string connectionString = "binaryeye://scan/?ret=http://"+ localIp +":"+ std::to_string(port) +"/?result={RESULT}";
void OFDScene::notifyHttpServerFailure() {
QMessageBox infoDialog = QMessageBox();
infoDialog.setText(tr("Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn't lucky, please, contact the developer."));
infoDialog.setIcon(QMessageBox::Warning);
infoDialog.setWindowTitle(tr("Could not start http server."));
infoDialog.exec();
}
void OFDScene::on_stop_server_button_clicked() {
delete server;
ui->stop_server_button->hide();
ui->binary_eye_button->setEnabled(true);
}
void OFDScene::httpNewMessageHandler(QString message) {
std::string parametersString = split(message.toStdString(), " ")[1];
//erase /?result= from the string
parametersString.erase(0, parametersString.find("=") + 1);
std::vector<std::string> parameters = split(parametersString, "&");
server.Get("/", [&](const httplib::Request &req, httplib::Response &res){
std::map<std::string, std::string> paramsMap;
if (req.params.size() < 1) {
res.set_redirect(connectionString, 301);
std::cerr << "Too few params: " << req.params.size() << std::endl;
return;
}
std::string result = req.params.find("result")->second;
std::vector<std::string> dataSplit = split(result, "&");
for (std::string &pair : dataSplit) {
std::vector<std::string> values = split(pair, "=");
for (auto &parameter : parameters) {
std::vector<std::string> values = split(parameter, "=");
paramsMap.insert(std::pair<std::string, std::string> (values[0], values[1]));
}
emit onDataDecode(paramsMap);
res.set_redirect(connectionString, 301);
});
std::cerr << "Listening on port: " << this->port << std::endl;
if (!server.listen("0.0.0.0", this->port)) {
std::cerr << "Random port seems to be occupied. Trying to generate another one" << std::endl;
number_of_retries ++;
continue;
}
} while(true);
}
#endif //ifdef BUILD_OFD_BINARYEYE_SCAN
#ifdef BUILD_OFD_LOCAL_QR_SCAN
void OFDScene::on_choose_image_button_clicked() {
QString filename = QFileDialog::getOpenFileName();
@@ -96,6 +138,7 @@ void OFDScene::on_choose_image_button_clicked() {
connect(&dialog, &AdjustPictureDialog::decodedData, this, &OFDScene::onDataDecode);
dialog.exec();
}
#endif //ifdef BUILD_OFD_LOCAL_QR_SCAN
void OFDScene::onDataDecode(std::map<std::string, std::string> data) {
ui->fn_line_edit->setText(QString::fromStdString(data["fn"]));
@@ -173,44 +216,9 @@ void OFDScene::on_parse_button_clicked() {
} while (!is_captcha_solved);
if (success) {
OutputDialog d = OutputDialog(this, check);
d.exec();
OutputDialog *d = new OutputDialog(this, check);
d->exec();
delete d;
}
}
void OFDScene::on_binary_eye_button_clicked() {
http_thread = new std::thread(&OFDScene::startHttpServer, this);
ui->binary_eye_button->setEnabled(false);
while (!server.is_running());
std::string localIp;
try {
localIp = get_local_ip_address();
} catch(std::exception e) {
std::cerr << e.what() << std::endl;
return;
}
std::string connectionString = "binaryeye://scan?ret=http://" + localIp + ":" + std::to_string(port) + "/?result={RESULT}";
generate_qr_code(connectionString);
QMessageBox infoDialog = QMessageBox();
infoDialog.setText(QString::fromStdString(connectionString));
infoDialog.setIconPixmap(QPixmap(QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/binaryeye_connection.png"))).scaled(400, 400, Qt::KeepAspectRatio));
infoDialog.setWindowTitle(tr("QR code for binaryeye to connect"));
infoDialog.setButtonText(1, tr("I've scanned"));
infoDialog.exec();
}
void OFDScene::notifyHttpServerFailure() {
QMessageBox infoDialog = QMessageBox();
infoDialog.setText(tr("Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn't lucky, please, contact the developer."));
infoDialog.setIcon(QMessageBox::Warning);
infoDialog.setWindowTitle(tr("Could not start http server."));
infoDialog.exec();
}
unsigned int OFDScene::getPort() {
return port;
}

View File

@@ -2,9 +2,12 @@
#define OFDSCENE_H
#include <QWidget>
#include <httplib.h>
#include <thread>
#ifdef BUILD_OFD_BINARYEYE_SCAN
# include <thread>
# include <netinet/in.h>
# include <http_server/http_server.h>
#endif
namespace Ui {
class OFDScene;
}
@@ -15,29 +18,40 @@ class OFDScene : public QWidget
public:
explicit OFDScene(QWidget *parent = nullptr);
Ui::OFDScene *getUI();
~OFDScene();
#ifdef BUILD_OFD_BINARYEYE_SCAN
void startHttpServer();
unsigned int getPort();
#endif
private slots:
#ifdef BUILD_OFD_LOCAL_QR_SCAN
void on_choose_image_button_clicked();
void onDataDecode(std::map<std::string, std::string>);
#endif
void onDataDecode(std::map<std::string, std::string>);
void on_parse_button_clicked();
#ifdef BUILD_OFD_BINARYEYE_SCAN
void on_binary_eye_button_clicked();
void notifyHttpServerFailure();
void on_stop_server_button_clicked();
// public slots:
void httpNewMessageHandler(QString message);
signals:
void httpNewMessage(QString message);
void httpErrorOccured();
#endif
private:
Ui::OFDScene *ui;
std::thread *http_thread;
unsigned int port;
httplib::Server server;
#ifdef BUILD_OFD_BINARYEYE_SCAN
std::thread *httpServerThread;
HttpServer *server = NULL;
#endif
};
#endif // OFDSCENE_H

View File

@@ -1,401 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>817</width>
<height>659</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QComboBox" name="storeType">
<property name="geometry">
<rect>
<x>90</x>
<y>10</y>
<width>211</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="storeTypeLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Store type</string>
</property>
</widget>
<widget class="QPushButton" name="parseButton">
<property name="geometry">
<rect>
<x>30</x>
<y>560</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Parse</string>
</property>
</widget>
<widget class="QPushButton" name="preferencesButton">
<property name="geometry">
<rect>
<x>730</x>
<y>0</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Preferences</string>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>801</width>
<height>511</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="Text">
<attribute name="title">
<string>Text</string>
</attribute>
<widget class="QLabel" name="checkContentLabel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>101</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Check content</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContent">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>611</width>
<height>441</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="OCR">
<attribute name="title">
<string>OCR</string>
</attribute>
<widget class="QPushButton" name="chooseImageButton_ocr">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContentFromImage">
<property name="geometry">
<rect>
<x>0</x>
<y>60</y>
<width>511</width>
<height>401</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="pathLabel_ocr">
<property name="geometry">
<rect>
<x>100</x>
<y>0</y>
<width>381</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Path to image: </string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>571</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Here is recognised check text. Please, edit it if something's wrong:</string>
</property>
</widget>
<widget class="QLabel" name="picture_ocr">
<property name="geometry">
<rect>
<x>490</x>
<y>10</y>
<width>291</width>
<height>421</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<widget class="QWidget" name="OFD">
<attribute name="title">
<string>OFD</string>
</attribute>
<widget class="QLabel" name="picture_ofd">
<property name="geometry">
<rect>
<x>490</x>
<y>10</y>
<width>291</width>
<height>421</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="pathLabel_ofd">
<property name="geometry">
<rect>
<x>100</x>
<y>0</y>
<width>381</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Path to image: </string>
</property>
</widget>
<widget class="QPushButton" name="chooseImageButton_ofd">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
<widget class="QLineEdit" name="fn_edit">
<property name="geometry">
<rect>
<x>180</x>
<y>50</y>
<width>261</width>
<height>26</height>
</rect>
</property>
<property name="inputMask">
<string>0000000000000000</string>
</property>
</widget>
<widget class="QLabel" name="fn_label">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FN (Fiscal Number)</string>
</property>
</widget>
<widget class="QLabel" name="fd_label">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FD (Fiscal Document)</string>
</property>
</widget>
<widget class="QLineEdit" name="fd_edit">
<property name="geometry">
<rect>
<x>180</x>
<y>90</y>
<width>261</width>
<height>26</height>
</rect>
</property>
<property name="inputMask">
<string>0000000000</string>
</property>
</widget>
<widget class="QLabel" name="fi_label">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FI (Fiscal Identifier)</string>
</property>
</widget>
<widget class="QLineEdit" name="fi_edit">
<property name="geometry">
<rect>
<x>180</x>
<y>130</y>
<width>261</width>
<height>26</height>
</rect>
</property>
<property name="inputMask">
<string>0000000000</string>
</property>
</widget>
<widget class="QDateTimeEdit" name="dateTimeEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>194</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fundIncomeCombo">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>191</width>
<height>26</height>
</rect>
</property>
<item>
<property name="text">
<string>Funds income</string>
</property>
</item>
<item>
<property name="text">
<string>Funds return</string>
</property>
</item>
<item>
<property name="text">
<string>Funds spend</string>
</property>
</item>
<item>
<property name="text">
<string>Spends return</string>
</property>
</item>
</widget>
<widget class="QLineEdit" name="total_edit">
<property name="geometry">
<rect>
<x>90</x>
<y>250</y>
<width>113</width>
<height>26</height>
</rect>
</property>
<property name="inputMask">
<string/>
</property>
</widget>
<widget class="QLabel" name="total_label">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>66</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Total</string>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>817</width>
<height>33</height>
</rect>
</property>
<widget class="QMenu" name="menuchecks_parser">
<property name="title">
<string>checks parser</string>
</property>
</widget>
<addaction name="menuchecks_parser"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -91,7 +91,7 @@ std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
goods_names.size() != goods_quantities.size() ||
goods_prices.size() != goods_quantities.size()) {
dumpVectorsToStdErr(goods_names, goods_prices, goods_quantities);
// dumpVectorsToStdErr(goods_names, goods_prices, goods_quantities);
//Error. Amount of names, prices or quantities are not equal. That means, that some regex(es) has mismatched.
return {};

View File

@@ -13,65 +13,42 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>450</x>
<y>450</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="ImageRedactor" name="graphicsView"/>
</item>
<item row="2" column="0">
<widget class="QSlider" name="contrastSlider">
<property name="geometry">
<rect>
<x>10</x>
<y>460</y>
<width>591</width>
<height>16</height>
</rect>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>511</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Please, zoom to qr code and adjust contrast so that qr code looks sharp</string>
</property>
</widget>
<widget class="ImageRedactor" name="graphicsView">
<property name="geometry">
<rect>
<x>5</x>
<y>21</y>
<width>801</width>
<height>421</height>
</rect>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
<zorder>buttonBox</zorder>
</item>
</layout>
<zorder>label</zorder>
<zorder>contrastSlider</zorder>
<zorder>graphicsView</zorder>
<zorder>buttonBox</zorder>
</widget>
<customwidgets>
<customwidget>

View File

@@ -33,6 +33,12 @@
</property>
<item row="0" column="1">
<widget class="QPushButton" name="ocr_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Optical Character Recognition</string>
</property>
@@ -40,7 +46,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../build/Desktop-Debug/media.qrc">
<normaloff>:/icons/assets/icons/OCR.svg</normaloff>:/icons/assets/icons/OCR.svg</iconset>
</property>
<property name="iconSize">
@@ -54,7 +60,7 @@
<item row="0" column="0">
<widget class="QPushButton" name="text_from_email_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -69,7 +75,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../build/Desktop-Debug/media.qrc">
<normaloff>:/icons/assets/icons/email-text.svg</normaloff>:/icons/assets/icons/email-text.svg</iconset>
</property>
<property name="iconSize">
@@ -97,11 +103,17 @@
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="ofd_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../build/Desktop-Debug/media.qrc">
<normaloff>:/icons/assets/icons/OFD.svg</normaloff>:/icons/assets/icons/OFD.svg</iconset>
</property>
<property name="iconSize">
@@ -116,6 +128,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../build/Desktop-Debug/media.qrc"/>
<include location="../build/Desktop-Debug/media.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -17,10 +17,10 @@
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item row="8" column="0">
<widget class="QLabel" name="total_label">
<item row="5" column="0">
<widget class="QLabel" name="fi_label">
<property name="text">
<string>Total</string>
<string>FI (Fiscal Identifier)</string>
</property>
</widget>
</item>
@@ -37,6 +37,20 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="datetime_label">
<property name="text">
<string>Date and time of purchase</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="binary_eye_button">
<property name="text">
<string>Use your phone as a QR code scanner</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="or_label">
<property name="sizePolicy">
@@ -50,12 +64,8 @@
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QDoubleSpinBox" name="total_spin_box">
<property name="maximum">
<double>4294967296.000000000000000</double>
</property>
</widget>
<item row="4" column="2">
<widget class="QLineEdit" name="fd_line_edit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="fd_label">
@@ -70,10 +80,23 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="datetime_label">
<item row="9" column="0" colspan="3">
<widget class="QPushButton" name="parse_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Date and time of purchase</string>
<string>Parse</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="operation_type_label">
<property name="text">
<string>Operation type</string>
</property>
</widget>
</item>
@@ -101,22 +124,6 @@
</item>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="fd_line_edit"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="info_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="fn_line_edit">
<property name="sizePolicy">
@@ -130,13 +137,6 @@
<item row="5" column="2">
<widget class="QLineEdit" name="fi_line_edit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="binary_eye_button">
<property name="text">
<string>Use your phone as a QR code scanner</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="fn_label">
<property name="sizePolicy">
@@ -150,16 +150,29 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fi_label">
<item row="8" column="0">
<widget class="QLabel" name="total_label">
<property name="text">
<string>FI (Fiscal Identifier)</string>
<string>Total</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDateTimeEdit" name="purchase_datetime_edit"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="info_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="choose_image_button">
<property name="text">
@@ -167,23 +180,23 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="operation_type_label">
<property name="text">
<string>Operation type</string>
<item row="8" column="2">
<widget class="QDoubleSpinBox" name="total_spin_box">
<property name="maximum">
<double>4294967296.000000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QPushButton" name="parse_button">
<item row="0" column="2" alignment="Qt::AlignmentFlag::AlignRight">
<widget class="QPushButton" name="stop_server_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Parse</string>
<string>Stop server</string>
</property>
</widget>
</item>

View File

@@ -9,7 +9,7 @@
<translation>Dialog</translation>
</message>
<message>
<location filename="../scenes/adjustpicturedialog.ui" line="58"/>
<location filename="../scenes/adjustpicturedialog.ui" line="33"/>
<source>Please, zoom to qr code and adjust contrast so that qr code looks sharp</source>
<translation>Please, zoom to qr code and adjust contrast so that qr code looks sharp</translation>
</message>
@@ -211,12 +211,12 @@
<translation>Form</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="37"/>
<location filename="../scenes/mainwindow.ui" line="43"/>
<source>Optical Character Recognition</source>
<translation>Optical Character Recognition</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="63"/>
<location filename="../scenes/mainwindow.ui" line="69"/>
<source>Text from E-Mail</source>
<translation>Text from E-Mail</translation>
</message>
@@ -292,7 +292,7 @@
<translation>Form</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="23"/>
<location filename="../scenes/ofdscene.ui" line="156"/>
<source>Total</source>
<translation>Total</translation>
</message>
@@ -302,42 +302,47 @@
<translation>Back</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="49"/>
<location filename="../scenes/ofdscene.ui" line="63"/>
<source>or</source>
<translation>or</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="69"/>
<location filename="../scenes/ofdscene.ui" line="79"/>
<source>FD (Fiscal Document)</source>
<translation>FD (Fiscal Document)</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="76"/>
<location filename="../scenes/ofdscene.ui" line="43"/>
<source>Date and time of purchase</source>
<translation>Date and time of purchase</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="84"/>
<location filename="../scenes/ofdscene.ui" line="199"/>
<source>Stop server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="107"/>
<source>Funds income</source>
<translation>Funds income</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="89"/>
<location filename="../scenes/ofdscene.ui" line="112"/>
<source>Funds return</source>
<translation>Funds return</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="94"/>
<location filename="../scenes/ofdscene.ui" line="117"/>
<source>Funds spend</source>
<translation>Funds spend</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="99"/>
<location filename="../scenes/ofdscene.ui" line="122"/>
<source>Spends return</source>
<translation>Spends return</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="136"/>
<location filename="../scenes/ofdscene.ui" line="50"/>
<source>Use your phone as a QR code scanner</source>
<translation>Use your phone as a QR code scanner</translation>
</message>
@@ -347,87 +352,87 @@
<translation>FN (Fiscal Number)</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="156"/>
<location filename="../scenes/ofdscene.ui" line="23"/>
<source>FI (Fiscal Identifier)</source>
<translation>FI (Fiscal Identifier)</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="166"/>
<location filename="../scenes/ofdscene.ui" line="179"/>
<source>Choose image on your PC</source>
<translation>Choose image on your PC</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="173"/>
<location filename="../scenes/ofdscene.ui" line="99"/>
<source>Operation type</source>
<translation>Operation type</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="186"/>
<location filename="../scenes/ofdscene.ui" line="92"/>
<source>Parse</source>
<translation>Parse</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="205"/>
<location filename="../ofdscene.cpp" line="89"/>
<source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="207"/>
<location filename="../ofdscene.cpp" line="91"/>
<source>Could not start http server.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="84"/>
<location filename="../ofdscene.cpp" line="129"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Please, select a picture where QR code that contains info about check is present</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="86"/>
<location filename="../ofdscene.cpp" line="131"/>
<source>Picture was not selected</source>
<translation>Picture was not selected</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="91"/>
<location filename="../ofdscene.cpp" line="136"/>
<source>Selected image: </source>
<translation>Selected image: </translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="150"/>
<location filename="../ofdscene.cpp" line="196"/>
<source>Captcha was not solved correctly!</source>
<translation>Captcha was not solved correctly!</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="152"/>
<location filename="../ofdscene.cpp" line="198"/>
<source>Captcha is incorrect</source>
<translation>Captcha is incorrect</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="157"/>
<location filename="../ofdscene.cpp" line="203"/>
<source>Internal server error. Please, try again later.</source>
<translation>Internal server error. Please, try again later.</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="159"/>
<location filename="../ofdscene.cpp" line="205"/>
<source>Internal server error</source>
<translation>Internal server error</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="164"/>
<location filename="../ofdscene.cpp" line="210"/>
<source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Check not found. Please, ensure correctness of entered data.</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="166"/>
<location filename="../ofdscene.cpp" line="212"/>
<source>Check was not found</source>
<translation>Check was not found</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="198"/>
<location filename="../ofdscene.cpp" line="82"/>
<source>QR code for binaryeye to connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="199"/>
<location filename="../ofdscene.cpp" line="83"/>
<source>I&apos;ve scanned</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -9,7 +9,7 @@
<translation>Диалог</translation>
</message>
<message>
<location filename="../scenes/adjustpicturedialog.ui" line="58"/>
<location filename="../scenes/adjustpicturedialog.ui" line="33"/>
<source>Please, zoom to qr code and adjust contrast so that qr code looks sharp</source>
<translation>Пожалуйста, приблизьте QR код и настройте контраст, чтобы он читался</translation>
</message>
@@ -211,12 +211,12 @@
<translation>Форма</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="37"/>
<location filename="../scenes/mainwindow.ui" line="43"/>
<source>Optical Character Recognition</source>
<translation>Оптическое распознавание символов</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="63"/>
<location filename="../scenes/mainwindow.ui" line="69"/>
<source>Text from E-Mail</source>
<translation>Текст из электронного письма</translation>
</message>
@@ -292,7 +292,7 @@
<translation>Форма</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="23"/>
<location filename="../scenes/ofdscene.ui" line="156"/>
<source>Total</source>
<translation>Итого</translation>
</message>
@@ -302,42 +302,47 @@
<translation>Назад</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="49"/>
<location filename="../scenes/ofdscene.ui" line="63"/>
<source>or</source>
<translation>или</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="69"/>
<location filename="../scenes/ofdscene.ui" line="79"/>
<source>FD (Fiscal Document)</source>
<translation>ФД</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="76"/>
<location filename="../scenes/ofdscene.ui" line="43"/>
<source>Date and time of purchase</source>
<translation>Дата и время покупки</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="84"/>
<location filename="../scenes/ofdscene.ui" line="199"/>
<source>Stop server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="107"/>
<source>Funds income</source>
<translation>Приход средств</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="89"/>
<location filename="../scenes/ofdscene.ui" line="112"/>
<source>Funds return</source>
<translation>Возврат средств</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="94"/>
<location filename="../scenes/ofdscene.ui" line="117"/>
<source>Funds spend</source>
<translation>Расход средств</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="99"/>
<location filename="../scenes/ofdscene.ui" line="122"/>
<source>Spends return</source>
<translation>Возврат расхода</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="136"/>
<location filename="../scenes/ofdscene.ui" line="50"/>
<source>Use your phone as a QR code scanner</source>
<translation>Использовать телефон как сканнер QR</translation>
</message>
@@ -347,87 +352,87 @@
<translation>ФН</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="156"/>
<location filename="../scenes/ofdscene.ui" line="23"/>
<source>FI (Fiscal Identifier)</source>
<translation>ФП</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="166"/>
<location filename="../scenes/ofdscene.ui" line="179"/>
<source>Choose image on your PC</source>
<translation>Выбрать изображение на компьютере</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="173"/>
<location filename="../scenes/ofdscene.ui" line="99"/>
<source>Operation type</source>
<translation>Тип операции</translation>
</message>
<message>
<location filename="../scenes/ofdscene.ui" line="186"/>
<location filename="../scenes/ofdscene.ui" line="92"/>
<source>Parse</source>
<translation>Парсить</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="205"/>
<location filename="../ofdscene.cpp" line="89"/>
<source>Could not start http server. 10 times in a row random port was occupied. Either you should run for a lottery ticket, or the problem is in the program. If the lottery ticket wasn&apos;t lucky, please, contact the developer.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="207"/>
<location filename="../ofdscene.cpp" line="91"/>
<source>Could not start http server.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="84"/>
<location filename="../ofdscene.cpp" line="129"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation>Пожалуйста, выберете изображение, содержащее QR код с информацией о чеке</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="86"/>
<location filename="../ofdscene.cpp" line="131"/>
<source>Picture was not selected</source>
<translation>Изображение не было выбрано</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="91"/>
<location filename="../ofdscene.cpp" line="136"/>
<source>Selected image: </source>
<translation>Выбранное изображение: </translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="150"/>
<location filename="../ofdscene.cpp" line="196"/>
<source>Captcha was not solved correctly!</source>
<translation>Капча была решена неверно!</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="152"/>
<location filename="../ofdscene.cpp" line="198"/>
<source>Captcha is incorrect</source>
<translation>Капча введена неверно</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="157"/>
<location filename="../ofdscene.cpp" line="203"/>
<source>Internal server error. Please, try again later.</source>
<translation>Внутренняя ошибка сервера. Пожалуйста, попробуйте снова позже.</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="159"/>
<location filename="../ofdscene.cpp" line="205"/>
<source>Internal server error</source>
<translation>Внутренняя ошибка сервера</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="164"/>
<location filename="../ofdscene.cpp" line="210"/>
<source>Check not found. Please, ensure correctness of entered data.</source>
<translation>Чек не найден. Пожалуйста, убедитесь в правильности введённых данных.</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="166"/>
<location filename="../ofdscene.cpp" line="212"/>
<source>Check was not found</source>
<translation>Чек не найден</translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="198"/>
<location filename="../ofdscene.cpp" line="82"/>
<source>QR code for binaryeye to connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ofdscene.cpp" line="199"/>
<location filename="../ofdscene.cpp" line="83"/>
<source>I&apos;ve scanned</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -1,24 +1,30 @@
#include "utils.h"
#ifdef BUILD_OFD_BINARYEYE_SCAN
# include <arpa/inet.h>
# include <qrencode.h>
# include <ifaddrs.h>
# include <netinet/in.h>
#endif
#ifdef BUILD_OFD_MODE
# include "../exceptions/ofdrequestexception.h"
#endif
#include <codecvt>
#include <cstring>
#include <iostream>
#include <locale>
#if defined(BUILD_OCR_MODE) || defined(BUILD_OFD_MODE)
# include <opencv2/core/mat.hpp>
# include <opencv2/imgcodecs.hpp>
# include <opencv2/imgproc.hpp>
#include <qrencode.h>
#endif
#include <regex>
#include <string>
#include "../exceptions/ofdrequestexception.h"
#include "settings/settings.h"
#include <QWidget>
#include <fstream>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <opencv2/opencv.hpp>
#ifdef BUILD_OFD_BINARYEYE_SCAN
std::string get_local_ip_address() {
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;
@@ -44,6 +50,7 @@ std::string get_local_ip_address() {
throw std::runtime_error(QWidget::tr("Could not find any usable local IP address. If you beleive that this is problem with the program, please, contact the developer.").toStdString());
}
#endif
std::string to_utf8(std::wstring wide_string) {
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
@@ -114,7 +121,7 @@ std::wstring substring_from_to(std::wstring& text, std::wstring from, std::wstri
return substring;
}
#ifdef BUILD_OFD_MODE
std::wstring trim_html_response(std::wstring& check) {
std::wstring begin_check_marker = from_utf8("<!-- Products -->");
std::wstring end_check_marker = from_utf8("<!-- \\/Products -->");
@@ -219,7 +226,9 @@ Check parseOfdRuAnswer(std::string html) {
return c;
}
#endif // ifdef BUILD_OFD_MODE
#ifdef BUILD_OFD_BINARYEYE_SCAN
void generate_qr_code(std::string data) {
QRcode *qrCode = QRcode_encodeString(data.c_str(), 2, QR_ECLEVEL_L, QR_MODE_8, 1);
if (qrCode == NULL) {
@@ -244,3 +253,4 @@ void generate_qr_code(std::string data) {
cv::imwrite(get_path_relative_to_home(".local/share/checks_parser/binaryeye_connection.png"), qrCodeImage);
QRcode_free(qrCode);
}
#endif // ifdef BUILD_OFD_BINARYEYE_SCAN

View File

@@ -5,7 +5,6 @@
#include <vector>
#include "../check/check.h"
std::string get_local_ip_address();
std::string to_utf8(std::wstring wide_string);
std::wstring from_utf8(std::string string);
@@ -16,10 +15,15 @@ bool vector_contains_element(const std::vector<T> &vector, const T &to_find);
std::vector<std::string> split(std::string, std::string);
#ifdef BUILD_OFD_MODE
Check parseOfdRuAnswer(std::string);
std::wstring trim_html_response(std::wstring& check);
#endif
#ifdef BUILD_OFD_BINARYEYE_SCAN
void generate_qr_code(std::string data);
std::string get_local_ip_address();
#endif
#endif // UTILS_H