checks-parser/solvecaptchadialog.cpp

37 lines
1.1 KiB
C++
Raw Normal View History

2024-11-24 19:07:28 +03:00
#include "solvecaptchadialog.h"
#include "ui_solvecaptchadialog.h"
#include "utils/utils.h"
#include <iostream>
2024-11-24 19:07:28 +03:00
#include <QMessageBox>
SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent, std::string* solved_captcha) :
2024-11-24 19:07:28 +03:00
QDialog(parent),
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.jpg"));
std::cout << captcha_path.toStdString() << std::endl;
2024-11-24 19:07:28 +03:00
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 {
solved_captcha->erase();
solved_captcha->append(userInput);
2024-11-24 19:07:28 +03:00
QDialog::accept();
}
}
SolveCaptchaDialog::~SolveCaptchaDialog() {
delete ui;
}