completed requests to ofd.ru

This commit is contained in:
leca 2024-11-24 19:07:28 +03:00
parent 48885daed5
commit 3106479fcc
16 changed files with 1274 additions and 9 deletions

1
.gitignore vendored
View File

@ -99,7 +99,6 @@ cmake_install.cmake
*.moc *.moc
*.moc.cpp *.moc.cpp
*.qrc.cpp *.qrc.cpp
*.ui
# CMake-specific files # CMake-specific files
CMakeCache.txt CMakeCache.txt

View File

@ -56,6 +56,7 @@ else()
adjustpicturedialog.h adjustpicturedialog.cpp adjustpicturedialog.ui adjustpicturedialog.h adjustpicturedialog.cpp adjustpicturedialog.ui
imageview/imageview.h imageview/imageview.cpp imageview/imageview.h imageview/imageview.cpp
image_redactor/imageredactor.h image_redactor/imageredactor.cpp image_redactor/imageredactor.h image_redactor/imageredactor.cpp
solvecaptchadialog.h solvecaptchadialog.cpp solvecaptchadialog.ui
) )

View File

@ -58,7 +58,7 @@ std::string AdjustPictureDialog::decode() {
cv::cvtColor(im, imGray, cv::COLOR_BGR2GRAY); cv::cvtColor(im, imGray, cv::COLOR_BGR2GRAY);
zbar::Image image(im.cols, im.rows, "Y800", (uchar *) imGray.data, im.cols * im.rows); zbar::Image image(im.cols, im.rows, "Y800", (uchar *) imGray.data, im.cols * im.rows);
int n = scanner.scan(image); scanner.scan(image);
std::string result = ""; std::string result = "";
@ -70,3 +70,8 @@ std::string AdjustPictureDialog::decode() {
return result; return result;
} }
void AdjustPictureDialog::on_contrastSlider_sliderMoved(int position) {
}

View File

@ -25,6 +25,8 @@ private slots:
// void on_buttonBox_accepted(); // void on_buttonBox_accepted();
void accept() override; void accept() override;
void on_contrastSlider_sliderMoved(int position);
private: private:
Ui::AdjustPictureDialog *ui; Ui::AdjustPictureDialog *ui;
QGraphicsScene *scene; QGraphicsScene *scene;

115
adjustpicturedialog.ui Normal file
View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdjustPictureDialog</class>
<widget class="QDialog" name="AdjustPictureDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>825</width>
<height>497</height>
</rect>
</property>
<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>
<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="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<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>15</x>
<y>41</y>
<width>791</width>
<height>391</height>
</rect>
</property>
</widget>
<zorder>buttonBox</zorder>
<zorder>label</zorder>
<zorder>contrastSlider</zorder>
<zorder>graphicsView</zorder>
</widget>
<customwidgets>
<customwidget>
<class>ImageRedactor</class>
<extends>QGraphicsView</extends>
<header>imageredactor.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AdjustPictureDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AdjustPictureDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -5,6 +5,7 @@
#include "outputdialog.h" #include "outputdialog.h"
#include "adjustpicturedialog.h" #include "adjustpicturedialog.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "solvecaptchadialog.h"
#include <iostream> #include <iostream>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
@ -46,15 +47,42 @@ void MainWindow::setupStoresList() {
#endif #endif
} }
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::receiveSolvedCaptcha(std::string captcha) {
std::string check_content = makeRequestToOfd(captcha);
}
void MainWindow::on_parseButton_clicked() { void MainWindow::on_parseButton_clicked() {
QString s; QString s;
switch (ui->checkType->currentIndex()) { switch (ui->tabWidget->currentIndex()) {
case 0: case 0:
s = ui->checkContent->toPlainText(); s = ui->checkContent->toPlainText();
break; break;
case 1: case 1:
s = ui->checkContentFromImage->toPlainText(); s = ui->checkContentFromImage->toPlainText();
break; break;
case 2:
Net().get_captcha_from_ofdru();
SolveCaptchaDialog dialog = SolveCaptchaDialog(this);
connect(&dialog, &SolveCaptchaDialog::solvedCaptcha, this, &MainWindow::receiveSolvedCaptcha);
dialog.exec();
return;
} }
std::wstring check_plaintext = s.toStdWString(); std::wstring check_plaintext = s.toStdWString();
@ -118,6 +146,12 @@ void MainWindow::onDecodedData(std::string data) {
QDateTime datetime = QDateTime::fromString(extractedDateTime, "yyyyMMddThhmm"); QDateTime datetime = QDateTime::fromString(extractedDateTime, "yyyyMMddThhmm");
ui->dateTimeEdit->setDateTime(datetime); 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() void MainWindow::on_chooseImageButton_ocr_clicked()

View File

@ -26,13 +26,13 @@ public:
Check get_check(); Check get_check();
void onDecodedData(std::string); void onDecodedData(std::string);
std::string makeRequestToOfd(std::string captcha);
void receiveSolvedCaptcha(std::string);
private slots: private slots:
void on_parseButton_clicked(); void on_parseButton_clicked();
void on_storeType_currentIndexChanged(int index); void on_storeType_currentIndexChanged(int index);
// void on_chooseImageButton_clicked();
void on_preferencesButton_clicked(); void on_preferencesButton_clicked();
void on_chooseImageButton_ofd_clicked(); void on_chooseImageButton_ofd_clicked();

401
mainwindow.ui Normal file
View File

@ -0,0 +1,401 @@
<?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</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>2</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>0</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>23</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>

6
nano.42371.save Normal file
View File

@ -0,0 +1,6 @@
t=20240828T2033
s=895.50
fn=7380440700069236
i=21386
fp=1292383731
n=1

View File

@ -1,5 +1,6 @@
#include "net.h" #include "net.h"
#include <curl/curl.h> #include <curl/curl.h>
#include "../utils/utils.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <regex> #include <regex>
@ -32,6 +33,12 @@ void write_modules(void *buffer, size_t size, size_t nmemb, void *modules) {
} }
} }
size_t writeCallback(void* contents, size_t size, size_t nmemb, void* userp) {
size_t totalSize = size * nmemb;
((std::string*)userp)->append(std::string((char*)contents));
return totalSize;
}
std::vector<std::string> Net::get_all_modules(std::string url) { std::vector<std::string> Net::get_all_modules(std::string url) {
CURL *handle = curl_easy_init(); CURL *handle = curl_easy_init();
@ -47,7 +54,7 @@ std::vector<std::string> Net::get_all_modules(std::string url) {
return modules; return modules;
} }
std::string Net::get_file(std::string url, std::string filename) { void Net::get_file(std::string url, std::string filename) {
CURL *handle = curl_easy_init(); CURL *handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
@ -58,6 +65,45 @@ std::string Net::get_file(std::string url, std::string filename) {
auto success = curl_easy_perform(handle); auto success = curl_easy_perform(handle);
curl_easy_cleanup(handle); curl_easy_cleanup(handle);
}
return "";
std::string Net::fetch_check_data_from_ofdru(std::string fn, std::string fd, std::string fi, std::string datetime, int operation, int total, std::string captcha) {
CURL *handle = curl_easy_init();
if (handle == nullptr) {
std::cerr << "cannot initialize curl" << std::endl;
return "";
}
struct curl_slist *headers = NULL;
std::string readBuffer = "";
curl_easy_setopt(handle, CURLOPT_URL, "https://check.ofd.ru/Document/FetchReceiptFromFns");
headers = curl_slist_append(headers, "Content-Type: application/json;charset=UTF-8");
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
std::string dataJSON =
"{"
"\"TotalSum\":" + std::to_string(total) + ","
"\"FnNumber\":\"" + fn + "\","
"\"ReceiptOperationType\":\"" + std::to_string(operation) + "\","
"\"DocNumber\":\"" + fd + "\","
"\"DocFiscalSign\":\"" + fi + "\","
"\"Captcha\":\"" + captcha + "\","
"\"DocDateTime\":\"" + datetime + ".000Z\""
"}";
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, dataJSON.c_str());
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writeCallback);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &readBuffer);
auto answer = curl_easy_perform(handle);
delete headers;
curl_easy_cleanup(handle);
return readBuffer;
}
void Net::get_captcha_from_ofdru() {
get_file("https://check.ofd.ru/api/captcha/common/img", get_path_relative_to_home(".local/share/checks_parser/captcha.png"));
} }

View File

@ -11,7 +11,9 @@ class Net
public: public:
Net(); Net();
std::vector<std::string> get_all_modules(std::string url); std::vector<std::string> get_all_modules(std::string url);
std::string get_file(std::string url, std::string filename); void get_file(std::string url, std::string filename);
std::string fetch_check_data_from_ofdru(std::string fn, std::string fd, std::string fi, std::string datetime, int operation, int total, std::string captcha);
void get_captcha_from_ofdru();
}; };
#endif // NET_H #endif // NET_H

215
outputdialog.ui Normal file
View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OutputDialog</class>
<widget class="QDialog" name="OutputDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>410</x>
<y>390</y>
<width>166</width>
<height>26</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="pathLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>271</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Path to export: </string>
</property>
</widget>
<widget class="QPushButton" name="chooseFileButton">
<property name="geometry">
<rect>
<x>290</x>
<y>20</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
<widget class="QCheckBox" name="printHeaderCheckBox">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>111</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Print header</string>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>401</width>
<height>221</height>
</rect>
</property>
<row>
<property name="text">
<string>Goods name</string>
</property>
</row>
<row>
<property name="text">
<string>Goods price</string>
</property>
</row>
<row>
<property name="text">
<string>Goods quantity</string>
</property>
</row>
<row>
<property name="text">
<string>Goods net weight</string>
</property>
</row>
<row>
<property name="text">
<string>Goods total</string>
</property>
</row>
<column>
<property name="text">
<string>position</string>
</property>
</column>
<column>
<property name="text">
<string>name</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>1</string>
</property>
</item>
<item row="0" column="1">
<property name="text">
<string>Name</string>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string>2</string>
</property>
</item>
<item row="1" column="1">
<property name="text">
<string>Price</string>
</property>
</item>
<item row="2" column="0">
<property name="text">
<string>3</string>
</property>
</item>
<item row="2" column="1">
<property name="text">
<string>Quantity</string>
</property>
</item>
<item row="3" column="0">
<property name="text">
<string>4</string>
</property>
</item>
<item row="3" column="1">
<property name="text">
<string>Net weight</string>
</property>
</item>
<item row="4" column="0">
<property name="text">
<string>5</string>
</property>
</item>
<item row="4" column="1">
<property name="text">
<string>Total price</string>
</property>
</item>
</widget>
<widget class="QCheckBox" name="printTotalCheckBox">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>111</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Print total</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OutputDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OutputDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

285
settingsdialog.ui Normal file
View File

@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>settingsdialog</class>
<widget class="QDialog" name="settingsdialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>599</width>
<height>727</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>310</x>
<y>690</y>
<width>251</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Save</set>
</property>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>541</width>
<height>661</height>
</rect>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>659</height>
</rect>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>651</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="11" column="1">
<widget class="QLineEdit" name="goodsNetWeightAliasEdit"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="storesModulesDirEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Goods name position</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Goods price per unit alias</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="storedModulesDirChooseButton">
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="goodsTotalAliasEdit"/>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Print header</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Goods net weight alias</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Stores modules url</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="storesModulesURLEdit"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Goods total alias</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Goods name alias</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="goodsTotalPositionSpin"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Goods quantity alias</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Stores modules directory</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="goodsNameAliasEdit"/>
</item>
<item row="10" column="1">
<widget class="QSpinBox" name="goodsNetWeightPositionSpin"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>OFD modules directory</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="goodsNamePositionSpin"/>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="goodsQuantityAliasEdit"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="goodsPricePerUnitAliasEdit"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Goods price per unit position</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Goods net weight position</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>OFD modules url</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="OFDModulesDirEdit"/>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Goods total position</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Goods quantity position</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="OFDModulesURLEdit"/>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="goodsQuantityPositionSpin"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="OFDModulesDirChooseButton">
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="goodsPricePerUnitPositionSpin"/>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Print total</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="printHeaderCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="printTotalCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>settingsdialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>settingsdialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

33
solvecaptchadialog.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "solvecaptchadialog.h"
#include "ui_solvecaptchadialog.h"
#include "utils/utils.h"
#include <QMessageBox>
SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SolveCaptchaDialog) {
ui->setupUi(this);
QString captcha_path = QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/captcha.png"));
ui->captcha_picture->setPixmap(captcha_path);
ui->captcha_picture->setScaledContents(true);
}
void SolveCaptchaDialog::accept() {
std::string userInput = ui->captcha_edit->text().toStdString();
if (userInput.length() < 6) {
QMessageBox infoDialog;
infoDialog.setText("Please, enter a valid captcha");
infoDialog.setIcon(QMessageBox::Warning);
infoDialog.setWindowTitle("No captcha");
infoDialog.exec();
} else {
emit solvedCaptcha(userInput);
QDialog::accept();
}
}
SolveCaptchaDialog::~SolveCaptchaDialog() {
delete ui;
}

30
solvecaptchadialog.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef SOLVECAPTCHADIALOG_H
#define SOLVECAPTCHADIALOG_H
#include <QDialog>
namespace Ui {
class SolveCaptchaDialog;
}
class SolveCaptchaDialog : public QDialog
{
Q_OBJECT
public:
explicit SolveCaptchaDialog(QWidget *parent = nullptr);
~SolveCaptchaDialog();
signals:
void solvedCaptcha(std::string);
private:
Ui::SolveCaptchaDialog *ui;
private slots:
void accept() override;
};
#endif // SOLVECAPTCHADIALOG_H

91
solvecaptchadialog.ui Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SolveCaptchaDialog</class>
<widget class="QDialog" name="SolveCaptchaDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>130</x>
<y>310</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>
<widget class="QLabel" name="captcha_picture">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>451</width>
<height>221</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="captcha_edit">
<property name="geometry">
<rect>
<x>80</x>
<y>260</y>
<width>321</width>
<height>26</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SolveCaptchaDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SolveCaptchaDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>