From 88d849bee96dbb2028b33f4f2c765ca562a91b54 Mon Sep 17 00:00:00 2001 From: leca Date: Sun, 1 Dec 2024 18:53:16 +0300 Subject: [PATCH] ensured building on ubuntu 18.04 --- CMakeLists.txt | 6 +- README.md | 1 + adjustpicturedialog.cpp | 3 +- imageview/imageview.cpp | 51 ------------- imageview/imageview.h | 19 ----- main.cpp | 10 ++- output/output_options.h | 6 +- parser/parser.cpp | 27 ++++--- settings/settings.cpp | 15 +++- translations/en_US.ts | 157 +++++++++++++++++++--------------------- translations/ru_RU.ts | 151 +++++++++++++++++++------------------- 11 files changed, 194 insertions(+), 252 deletions(-) delete mode 100644 imageview/imageview.cpp delete mode 100644 imageview/imageview.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b5c3eda..ba41eb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.10) project(checks-parser VERSION 0.1 LANGUAGES CXX) @@ -71,7 +71,6 @@ else() settings/settings.h settings/settings.cpp settingsdialog.h settingsdialog.cpp settingsdialog.ui adjustpicturedialog.h adjustpicturedialog.cpp adjustpicturedialog.ui - imageview/imageview.h imageview/imageview.cpp image_redactor/imageredactor.h image_redactor/imageredactor.cpp solvecaptchadialog.h solvecaptchadialog.cpp solvecaptchadialog.ui exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp @@ -119,3 +118,6 @@ target_link_libraries(checks-parser PRIVATE -lzbar) target_link_libraries(checks-parser PRIVATE -ltesseract) target_link_libraries(checks-parser PRIVATE -lcurl) target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS} ) +if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) +target_link_libraries(checks-parser PRIVATE -lstdc++fs) +endif() diff --git a/README.md b/README.md index 7bdb7a2..5274e20 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ make -j{nproc} sudo make install ``` ##### Debian +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 TODO ### Windows Maybe diff --git a/adjustpicturedialog.cpp b/adjustpicturedialog.cpp index 098465c..3ac00c4 100644 --- a/adjustpicturedialog.cpp +++ b/adjustpicturedialog.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +//#include #include #include #include @@ -53,7 +53,6 @@ std::string AdjustPictureDialog::decode() { zbar::ImageScanner scanner; scanner.set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1); - scanner.set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_TEST_INVERTED, 1); cv::Mat imGray; cv::cvtColor(im, imGray, cv::COLOR_BGR2GRAY); diff --git a/imageview/imageview.cpp b/imageview/imageview.cpp deleted file mode 100644 index 919e55c..0000000 --- a/imageview/imageview.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include "imageview.h" -#include - - -ImageView::ImageView(QWidget *parent) : - QLabel(parent) { - - // std::cout << this->geometry().height() << " " << this->geometry().width() << std::endl; -} - -// ImageView::ImageView(QWidget *parent, std::string path): -// QLabel(parent) { -// this->setPixmap(QPixmap(QString::fromStdString(path))); -// } - -void ImageView::wheelEvent(QWheelEvent *event) { - QPointF shift = event->position(); - QRegion r = QRegion(); - // this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(10, 10, this->rect(), &r); - this->scroll(shift.x(), shift.y(), this->rect()); - // this->setPixmap(QPixmap()); - // pm.scroll(shift.x(), shift.y(), this->rect()); - - // pm.scroll(); - // this->setPixmap(pm); - - //this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(shift.x(), shift.y(), this->pixmap()->rect()); - - QPoint numDegrees = event->angleDelta() / 8; - std::cout << numDegrees.x() << std::endl; - event->accept(); -} - -void ImageView::setImage(std::string image){ - //Commented is a way of scaling that is, as I understand, is lossless. If there'll be problems with current method's losses, I'll return to commented method - - maxHeight = this->height(); - maxWidth = this->width(); - - QPixmap pixmap = QPixmap(QString::fromStdString(image)); - // double scaleFactor = pixmap.height() > pixmap.width()? static_cast(maxHeight) / pixmap.height() : static_cast(maxWidth) / pixmap.width(); - - pixmap = pixmap.scaled(maxWidth, maxHeight, Qt::AspectRatioMode::KeepAspectRatio); - - - this->setPixmap(pixmap); - - // this->setGeometry(this->geometry().x(), this->geometry().y(), pixmap.width() * scaleFactor, pixmap.height() * scaleFactor); - // this->setScaledContents(true); -} diff --git a/imageview/imageview.h b/imageview/imageview.h deleted file mode 100644 index b182a82..0000000 --- a/imageview/imageview.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef IMAGEVIEW_H -#define IMAGEVIEW_H - -#include -#include -#include - -class ImageView : public QLabel -{ - Q_OBJECT - - double maxHeight, maxWidth; -public: - ImageView(QWidget *parent=nullptr); - // ImageView(QWidget *parent=nullptr, std::string path=""); - void wheelEvent(QWheelEvent*); - void setImage(std::string); -}; -#endif // IMAGEVIEW_H diff --git a/main.cpp b/main.cpp index 6366855..318d3ac 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,13 @@ #include #include #include -#include +#if __GNUC__ < 8 +# include + using namespace std::experimental::filesystem; +#else +# include + using std::filesystem; +#endif #include #include @@ -25,7 +31,7 @@ int main(int argc, char *argv[]) { curl_global_init(CURL_GLOBAL_ALL); std::string program_data_path = get_path_relative_to_home(".local/share/checks_parser"); - std::filesystem::create_directories(program_data_path); + create_directories(program_data_path); std::string settings_file_path = get_path_relative_to_home(".local/share/checks_parser/settings.json"); diff --git a/output/output_options.h b/output/output_options.h index 1c66b40..eeaa86b 100644 --- a/output/output_options.h +++ b/output/output_options.h @@ -3,7 +3,11 @@ #include #include -#include +#if __GNUC__ < 8 +# include +#else +# include +#endif #include #include #include diff --git a/parser/parser.cpp b/parser/parser.cpp index 5e2a731..3b866b5 100644 --- a/parser/parser.cpp +++ b/parser/parser.cpp @@ -3,18 +3,25 @@ #include "../net/net.h" #include "../settings/settings.h" #include "../utils/utils.h" -#include #include +#if __GNUC__ < 8 +# include + using namespace std::experimental; +#else +# include + using std::filesystem; +#endif + Parser::Parser() {} std::vector Parser::search_modules() { Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json")); std::string path = get_path_relative_to_home(s.get_setting("stores_modules_dir"));//std::string(std::getenv("HOME")) + "/" + STORES_MODULES_DIR; - std::filesystem::directory_entry modules_dir(path); + filesystem::directory_entry modules_dir(path); - if (!modules_dir.exists()) { - std::filesystem::create_directories(path); + if (!exists(modules_dir)) { + filesystem::create_directories(path); std::cout << "No modules directory found. Created one at " << path << std::endl; std::cout << "Please, download modules to that directory from my git." @@ -23,7 +30,7 @@ std::vector Parser::search_modules() { std::vector modules_files; - for (auto file : std::filesystem::directory_iterator(path)) { + for (auto file : filesystem::directory_iterator(path)) { modules_files.push_back(file.path()); } @@ -67,12 +74,12 @@ std::vector Parser::check_updates() { std::vector to_download; std::vector stored_modules; - std::filesystem::directory_entry modules_dir(path); - if (!modules_dir.exists()) { - std::filesystem::create_directories(path); + filesystem::directory_entry modules_dir(path); + if (!exists(modules_dir)) { + filesystem::create_directories(path); } - for (const auto& file : std::filesystem::directory_iterator(path)) { - if (!file.is_regular_file()) continue; + for (const auto& file : filesystem::directory_iterator(path)) { + if (!is_regular_file(file)) continue; stored_modules.push_back(file.path().filename()); std::cout << file.path().filename() << " detected store module" << std::endl; } diff --git a/settings/settings.cpp b/settings/settings.cpp index 5c69419..e70fed8 100644 --- a/settings/settings.cpp +++ b/settings/settings.cpp @@ -1,14 +1,21 @@ #include "settings.h" -#include #include #include #include #include "../utils/utils.h" +#if __GNUC__ < 8 +# include + using namespace std::experimental; +#else +# include + using std::filesystem; +#endif + Settings::Settings(std::string path) { this->settings_file_path = path; - if (!std::filesystem::exists(path)) { + if (!filesystem::exists(path)) { std::ofstream output(path); nlohmann::json settings = R"({ @@ -53,8 +60,8 @@ Settings::Settings(std::string path) { this->settings = settings; } - std::filesystem::create_directories(get_path_relative_to_home(this->settings["ofds_modules_dir"])); - std::filesystem::create_directories(get_path_relative_to_home(this->settings["stores_modules_dir"])); + filesystem::create_directories(get_path_relative_to_home(this->settings["ofds_modules_dir"])); + filesystem::create_directories(get_path_relative_to_home(this->settings["stores_modules_dir"])); } void Settings::write_setting(std::string setting, std::string value) { diff --git a/translations/en_US.ts b/translations/en_US.ts index 6dd312a..9db8a45 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -1,27 +1,27 @@ - + AdjustPictureDialog Dialog - Dialog + Please, zoom to qr code and adjust contrast so that qr code looks sharp - Please, zoom to qr code and adjust contrast so that qr code looks sharp + QR code was not detected on that image. Please edit it again or enter data manually - QR code was not detected on that image. Please edit it again or enter data manually + No QR code - No QR code + @@ -29,144 +29,135 @@ MainWindow - Главное окно + Store type - Store type + Parse - Parse + Preferences - Preferences + Text - Text + Check content - Check content + OCR - OCR = Optical Character Recognition - OCR + Choose - Choose + Path to image: - Path to image: + Here is recognised check text. Please, edit it if something's wrong: - Here is recognised check text. Please, edit it if something's wrong: + OFD - OFD = Оператор Фискальных Данных - OFD + 0000000000000000 - 0000000000000000 + FN (Fiscal Number) - FN = Фискальный Номер - FN (Fiscal Number) + FD (Fiscal Document) - FD = Фискальный Документ - FD (Fiscal Document) + 0000000000 - 000000000 + FI (Fiscal Identifier) - FI = Фискальный Признак - FI (Fiscal Identifier) + Funds income - Приход средств - Funds incode + Funds return - Возврат средств - Funds return + Funds spend - Расход средств - Funds spend + Spends return - Возврат расхода - Spends return + Total - Total + checks parser - checks parser + Captcha was not solved correctly! - Captcha was not solved correctly! + Captcha is incorrect - Captcha is incorrect + Check not found. Please, ensure correctness of entered data. - Check not found. Please, ensure correctness of entered data. + Check was not found - + @@ -174,112 +165,112 @@ Dialog - Dialog + Path to export: - Path to export: + Choose - Choose + Print header - Print header + Goods name - Goods name + Goods price - Goods price + Goods quantity - Goods quality + Goods net weight - Goods net weight + Goods total - Goods total + position - position + name - name + 1 - 1 + Name - Name + 2 - 2 + Price - Price + 3 - 3 + Quantity - Quantity + 4 - 4 + Net weight - Net Weight + 5 - 5 + Total price - Total price + Print total - Print total + @@ -287,17 +278,17 @@ Dialog - Dialog + Please, enter a valid captcha - Please, enter a valid captcha + No captcha - No captcha + @@ -305,93 +296,93 @@ Dialog - Dialog + Goods name position - Goods name position + Goods price per unit alias - Goods price per unit alias + Choose - Choose + Print header - Print header + Goods net weight alias - Goods net weight alias + Stores modules url - Stores modules url + Goods total alias - Goods total alias + Goods name alias - Goods name alias + Goods quantity alias - Goods quantity alias + Stores modules directory - Stores modules directory + OFD modules directory - OFD modules directory + Goods price per unit position - Goods price per unit position + Goods net weight position - Goods net weight position + OFD modules url - OFD modules url + Goods total position - Goods total position + Goods quantity position - Goods quantity position + Print total - Print total + diff --git a/translations/ru_RU.ts b/translations/ru_RU.ts index e10c2aa..e60a8ca 100644 --- a/translations/ru_RU.ts +++ b/translations/ru_RU.ts @@ -6,22 +6,22 @@ Dialog - Диалог + Please, zoom to qr code and adjust contrast so that qr code looks sharp - Пожалуйста, приблизьте QR код и настройте контраст, чтобы он читался + QR code was not detected on that image. Please edit it again or enter data manually - QR код не найден на этом изображении. Пожалуйста, попытайтесь снова или введите данные вручную + No QR code - QR код не найден + @@ -29,140 +29,135 @@ MainWindow - ГлавноеОкно + Store type - Магазин + Parse - Парсить + Preferences - Настройки + Text - Текст + Check content - Контент чека + OCR - Оптическое Распознавание Символов - ОСР + Choose - Выбрать + Path to image: - Путь к изображению: + Here is recognised check text. Please, edit it if something's wrong: - Ниже приведён распознанный текст. Пожалуйста, отредактируйте его: + OFD - Оператор Фискальных Данных - ОФД + 0000000000000000 - 0000000000000000 + FN (Fiscal Number) - Фискальный Норма - ФН + FD (Fiscal Document) - Фискальный Документ - ФД + 0000000000 - 000000000 + FI (Fiscal Identifier) - Фискальный Признак - ФП + Funds income - Приход средств + Funds return - Возврат средств + Funds spend - Расход средств + Spends return - Возврат расхода + Total - Итого + checks parser - Парсер чеков + Captcha was not solved correctly! - Капча была решена неверно! + Captcha is incorrect - Капча введена неверно + Check not found. Please, ensure correctness of entered data. - Чек не найден. Пожалуйста, убедитесь в правильности введённых данных. + Check was not found - Чек не найден + @@ -170,112 +165,112 @@ Dialog - Диалог + Path to export: - Путь для экспорта: + Choose - Выбрать + Print header - Печатать заголовок + Goods name - Имя товара + Goods price - Цена товара + Goods quantity - Количество товара + Goods net weight - Масса нетто товара + Goods total - Всего за товар + position - позиция + name - алиас + 1 - 1 + Name - Имя + 2 - 2 + Price - Цена + 3 - 3 + Quantity - Количество + 4 - 4 + Net weight - Масса нетто + 5 - 5 + Total price - Всего + Print total - Печатать Итого + @@ -283,17 +278,17 @@ Dialog - Диалог + Please, enter a valid captcha - Пожалуйста, введите верную капчу + No captcha - Нет капчи + @@ -301,93 +296,93 @@ Dialog - Диалог + Goods name position - Позиция имени товара + Goods price per unit alias - Алиас цены товара + Choose - Выбрать + Print header - Печатать заголовок + Goods net weight alias - Алиас массы нетто товара + Stores modules url - URL модулей магазина + Goods total alias - Алиас всего за продукт + Goods name alias - Алиас имени товара + Goods quantity alias - Алиас количества товара + Stores modules directory - Директория модулей магазина + OFD modules directory - Директория модулей ОФД + Goods price per unit position - Позиция центы товара + Goods net weight position - Позиция массы нетто товара + OFD modules url - URL модулей ОФД + Goods total position - Позиция всего за товар + Goods quantity position - Позиция количества товара + Print total - Печатать Итого +