34 lines
986 B
C++
34 lines
986 B
C++
|
#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;
|
||
|
}
|