diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-12-28 21:06:07 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-29 09:05:53 -0800 |
commit | ed903c42b9aac5a87cdbef0c888782b4985724b0 (patch) | |
tree | 939c9bff15f65d34d387ac7fd3187454eba570bb /qt-ui | |
parent | 571f86485d6063f86901487bca62e79b6383db45 (diff) | |
download | subsurface-ed903c42b9aac5a87cdbef0c888782b4985724b0.tar.gz |
Facebook integration: Always ask for a folder before sending the photo
This way we are sure that the upload was made in the correct folder.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 1 | ||||
-rw-r--r-- | qt-ui/socialnetworks.cpp | 29 | ||||
-rw-r--r-- | qt-ui/socialnetworks.h | 2 |
3 files changed, 25 insertions, 7 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 6edc5fa8e..302c0b210 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -190,6 +190,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), FacebookManager *fb = FacebookManager::instance(); connect(fb, &FacebookManager::justLoggedIn, ui.facebookPublish, &QPushButton::show); connect(fb, &FacebookManager::justLoggedOut, ui.facebookPublish, &QPushButton::hide); + connect(ui.facebookPublish, &QPushButton::clicked, fb, &FacebookManager::sendDive); ui.facebookPublish->setVisible(fb->loggedIn()); } diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp index 75d292ba6..b722c34c5 100644 --- a/qt-ui/socialnetworks.cpp +++ b/qt-ui/socialnetworks.cpp @@ -13,6 +13,8 @@ #include <QFile> #include <QBuffer> #include <QDebug> +#include <QMessageBox> +#include <QInputDialog> #include "mainwindow.h" #include "profile/profilewidget2.h" #include "pref.h" @@ -85,8 +87,6 @@ void FacebookManager::tryLogin(const QUrl& loginResponse) sync(); requestUserId(); sync(); - requestAlbumId(); - sync(); emit justLoggedIn(); qDebug() << "End try login"; } @@ -150,6 +150,7 @@ void FacebookManager::requestAlbumId() if (album.contains("id")) { s.setValue("AlbumId", album.value("id").toString()); qDebug() << "Got album ID"; + sync(); return; } @@ -188,18 +189,28 @@ void FacebookManager::setDesiredAlbumName(const QString& a) /* to be changed to export the currently selected dive as shown on the profile. * Much much easier, and its also good to people do not select all the dives * and send erroniously *all* of them to facebook. */ -void FacebookManager::sendDive(int divenr) +void FacebookManager::sendDive() { + bool ok; + albumName = QInputDialog::getText(qApp->activeWindow(), tr("Enter Facebook Album"), + tr("Facebook Album:"), QLineEdit::Normal, + "Subsurface", &ok); + if (!ok) + return; + + requestAlbumId(); + ProfileWidget2 *profile = MainWindow::instance()->graphics(); QPixmap pix = QPixmap::grabWidget(profile); - + struct dive* d = current_dive; QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); pix.save(&buffer, "PNG"); QUrl url("https://graph.facebook.com/v2.2/" + QString(prefs.facebook.album_id) + "/photos?" + "&access_token=" + QString(prefs.facebook.access_token) + - "&source=image"); + "&source=image" + + "&message=" + QString(d->notes).toHtmlEscaped()); QNetworkAccessManager *am = new QNetworkAccessManager(this); @@ -226,5 +237,11 @@ void FacebookManager::sendDive(int divenr) connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); - qDebug() << reply->readAll(); + QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); + QJsonObject obj = jsonDoc.object(); + if (obj.keys().contains("id")){ + QMessageBox:: + } else { + + } } diff --git a/qt-ui/socialnetworks.h b/qt-ui/socialnetworks.h index 8c474c906..66a95f22a 100644 --- a/qt-ui/socialnetworks.h +++ b/qt-ui/socialnetworks.h @@ -22,7 +22,7 @@ public slots: void tryLogin(const QUrl& loginResponse); void logout(); void setDesiredAlbumName(const QString& albumName); - void sendDive(int divenr); + void sendDive(); private: explicit FacebookManager(QObject *parent = 0); |