36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#include "solvecaptchadialog.h"
|
|
#include "ui_solvecaptchadialog.h"
|
|
#include "utils/utils.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent, std::string* solved_captcha) :
|
|
QDialog(parent),
|
|
ui(new Ui::SolveCaptchaDialog),
|
|
solved_captcha(solved_captcha) {
|
|
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 {
|
|
solved_captcha->erase();
|
|
solved_captcha->append(userInput);
|
|
QDialog::accept();
|
|
}
|
|
}
|
|
|
|
SolveCaptchaDialog::~SolveCaptchaDialog() {
|
|
delete ui;
|
|
}
|