LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
vkcaptchadialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "vkcaptchadialog.h"
10#include <QNetworkAccessManager>
11#include <QNetworkRequest>
12#include <QNetworkReply>
13#include "ui_vkcaptchadialog.h"
14
15namespace LC::Util::SvcAuth
16{
17 VkCaptchaDialog::VkCaptchaDialog (const QVariantMap& errorMap,
18 QNetworkAccessManager *nam, QWidget *w)
20 {
21 errorMap [QStringLiteral ("captcha_img")].toString (),
22 errorMap [QStringLiteral ("captcha_sid")].toString (),
23 nam,
24 w
25 }
26 {
27 }
28
30 const QString& cid, QNetworkAccessManager *manager, QWidget *parent)
31 : QDialog (parent)
32 , Ui_ (std::make_unique<Ui::VkCaptchaDialog> ())
33 , Cid_ (cid)
34 {
35 Ui_->setupUi (this);
36
37 auto reply = manager->get (QNetworkRequest (url));
38 connect (reply,
39 &QNetworkReply::finished,
40 this,
41 [this, reply]
42 {
43 reply->deleteLater ();
44
45 QPixmap px;
46 px.loadFromData (reply->readAll ());
47 Ui_->ImageLabel_->setPixmap (px);
48 });
49 }
50
52
53 void VkCaptchaDialog::SetContextName (const QString& context)
54 {
55 setWindowTitle (tr ("CAPTCHA required for %1").arg (context));
56 }
57
59 {
60 QDialog::done (r);
61
62 if (r == DialogCode::Rejected)
63 emit gotCaptcha (Cid_, {});
64 else
65 emit gotCaptcha (Cid_, Ui_->Text_->text ());
66
67 deleteLater ();
68 }
69}
VkCaptchaDialog(const QVariantMap &errorMap, QNetworkAccessManager *, QWidget *=nullptr)
void gotCaptcha(const QString &cid, const QString &value)
STL namespace.