diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/preferences.cpp | 21 | ||||
-rw-r--r-- | qt-ui/preferences.h | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 7f288ab1f..2378a1fd6 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -30,10 +30,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial // Facebook stuff: QUrl urlLogin("https://www.facebook.com/dialog/oauth?" "client_id=427722490709000" - "&redirect_uri=http://www.facebook.com/connect/login_success.html"); + "&redirect_uri=http://www.facebook.com/connect/login_success.html" + "&response_type=token"); ui.facebookWebView->setUrl(urlLogin); + connect(ui.facebookWebView, &QWebView::urlChanged, this, &PreferencesDialog::facebookLoginResponse); + connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int))); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int))); @@ -47,6 +50,22 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial rememberPrefs(); } +void PreferencesDialog::facebookLoginResponse(const QUrl &url) +{ + QString result = url.toString(); + if (result.contains("access_token")){ // Login Successfull. + int from = result.indexOf("access_token=") + strlen("access_token="); + int to = result.indexOf("&expires_in"); + QString securityToken = result.mid(from, to-from); + + QSettings settings; + settings.beginGroup("WebApps"); + settings.beginGroup("Facebook"); + settings.setValue("ConnectToken", securityToken); + ui.facebookWebView->setHtml("We need a better 'you re connected' page. but, YEY. "); + } +} + #define DANGER_GF (gf > 100) ? "* { color: red; }" : "" void PreferencesDialog::gflowChanged(int gf) { diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h index 2a909db17..d7755bad4 100644 --- a/qt-ui/preferences.h +++ b/qt-ui/preferences.h @@ -30,7 +30,7 @@ slots: void gfhighChanged(int gf); void proxyType_changed(int idx); void on_btnUseDefaultFile_toggled(bool toggle); - + void facebookLoginResponse(const QUrl& url); private: explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); void setUiFromPrefs(); |