MCPcopy Create free account
hub / github.com/ckaiser/Lightscreen / authorize

Method authorize

widgets/imguroptionswidget.cpp:57–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void ImgurOptionsWidget::authorize()
58{
59 if (!mCurrentUser.isEmpty()) {
60 setUser("");
61 return;
62 }
63
64 QDesktopServices::openUrl(QUrl("https://api.imgur.com/oauth2/authorize?client_id=" + ImgurUploader::clientId() + "&response_type=pin"));
65
66 bool ok;
67 QString pin = QInputDialog::getText(this, tr("Imgur Authorization"),
68 tr("Authentication PIN:"), QLineEdit::Normal,
69 "", &ok);
70 if (ok) {
71 ui.authButton->setText(tr("Authorizing.."));
72 ui.authButton->setEnabled(false);
73
74 QPointer<QWidget> guard(parentWidget());
75 ImgurUploader::authorize(pin, [&, guard](bool result) {
76 if (guard.isNull()) return;
77
78 ui.authButton->setEnabled(true);
79
80 if (result) {
81 setUser(settings()->value("upload/imgur/account_username").toString());
82 QTimer::singleShot(0, this, &ImgurOptionsWidget::requestAlbumList);
83 } else {
84 QMessageBox::critical(this, tr("Imgur Authorization Error"), tr("There's been an error authorizing your account with Imgur, please try again."));
85 setUser("");
86 }
87 });
88 }
89}
90
91void ImgurOptionsWidget::requestAlbumList()
92{

Callers

nothing calls this directly

Calls 1

QUrlClass · 0.85

Tested by

no test coverage detected