2024-11-24 19:07:28 +03:00
|
|
|
#include "solvecaptchadialog.h"
|
|
|
|
#include "ui_solvecaptchadialog.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2024-11-28 00:28:37 +03:00
|
|
|
SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent, std::string* solved_captcha) :
|
2024-11-24 19:07:28 +03:00
|
|
|
QDialog(parent),
|
2024-11-28 00:28:37 +03:00
|
|
|
ui(new Ui::SolveCaptchaDialog),
|
|
|
|
solved_captcha(solved_captcha) {
|
2024-11-24 19:07:28 +03:00
|
|
|
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;
|
2024-12-01 15:01:55 +03:00
|
|
|
infoDialog.setText(tr("Please, enter a valid captcha"));
|
2024-11-24 19:07:28 +03:00
|
|
|
infoDialog.setIcon(QMessageBox::Warning);
|
2024-12-01 15:01:55 +03:00
|
|
|
infoDialog.setWindowTitle(tr("No captcha"));
|
2024-11-24 19:07:28 +03:00
|
|
|
infoDialog.exec();
|
|
|
|
} else {
|
2024-11-28 00:28:37 +03:00
|
|
|
solved_captcha->erase();
|
|
|
|
solved_captcha->append(userInput);
|
2024-11-24 19:07:28 +03:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SolveCaptchaDialog::~SolveCaptchaDialog() {
|
|
|
|
delete ui;
|
|
|
|
}
|