summaryrefslogtreecommitdiffstats
path: root/qt-ui/socialnetworks.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-12-28 21:43:38 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-29 09:06:55 -0800
commitb84edad59766e5f59f6c3dcf5bb3a2ec24fc3eec (patch)
tree8d25cfc30bf81c244b9fe9b0b78d2d366790af7b /qt-ui/socialnetworks.cpp
parentecd0f25c04652115477bb1d9fcd78fd7ecaba916 (diff)
downloadsubsurface-b84edad59766e5f59f6c3dcf5bb3a2ec24fc3eec.tar.gz
Facebook integration: Add an interface to select the stuff that's sent
Generate the stub message that will go on the Facebook picture upload. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/socialnetworks.cpp')
-rw-r--r--qt-ui/socialnetworks.cpp65
1 files changed, 57 insertions, 8 deletions
diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp
index b722c34c5..8d24b2269 100644
--- a/qt-ui/socialnetworks.cpp
+++ b/qt-ui/socialnetworks.cpp
@@ -18,6 +18,7 @@
#include "mainwindow.h"
#include "profile/profilewidget2.h"
#include "pref.h"
+#include "ui_socialnetworksdialog.h"
#define GET_TXT(name, field) \
v = s.value(QString(name)); \
@@ -191,13 +192,12 @@ void FacebookManager::setDesiredAlbumName(const QString& a)
* and send erroniously *all* of them to facebook. */
void FacebookManager::sendDive()
{
- bool ok;
- albumName = QInputDialog::getText(qApp->activeWindow(), tr("Enter Facebook Album"),
- tr("Facebook Album:"), QLineEdit::Normal,
- "Subsurface", &ok);
- if (!ok)
+ SocialNetworkDialog dialog(qApp->activeWindow());
+ if (dialog.exec() != QDialog::Accepted)
return;
+
+ setDesiredAlbumName(dialog.album());
requestAlbumId();
ProfileWidget2 *profile = MainWindow::instance()->graphics();
@@ -210,7 +210,7 @@ void FacebookManager::sendDive()
QUrl url("https://graph.facebook.com/v2.2/" + QString(prefs.facebook.album_id) + "/photos?" +
"&access_token=" + QString(prefs.facebook.access_token) +
"&source=image" +
- "&message=" + QString(d->notes).toHtmlEscaped());
+ "&message=" + dialog.text());
QNetworkAccessManager *am = new QNetworkAccessManager(this);
@@ -237,11 +237,60 @@ void FacebookManager::sendDive()
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
- QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll());
+ QByteArray response = reply->readAll();
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(response);
QJsonObject obj = jsonDoc.object();
if (obj.keys().contains("id")){
- QMessageBox::
+ QMessageBox::information(qApp->activeWindow(),
+ tr("Photo Upload Sucessfull"),
+ tr("Your dive profile was updated to facebook."),
+ QMessageBox::Ok);
} else {
+ QMessageBox::information(qApp->activeWindow(),
+ tr("Photo Upload Failed"),
+ tr("Your dive profile was not updated to facebook, \n "
+ "please send the following to the developer. \n"
+ + response),
+ QMessageBox::Ok);
+ }
+}
+SocialNetworkDialog::SocialNetworkDialog(QWidget *parent) : QDialog(parent)
+ , ui( new Ui::SocialnetworksDialog())
+{
+ ui->setupUi(this);
+ connect(ui->date, SIGNAL(clicked()), this, SLOT(selectionChanged()));
+ connect(ui->Buddy, SIGNAL(clicked()), this, SLOT(selectionChanged()));
+ connect(ui->Divemaster, SIGNAL(clicked()), this, SLOT(selectionChanged()));
+ connect(ui->Location, SIGNAL(clicked()), this, SLOT(selectionChanged()));
+ connect(ui->Notes, SIGNAL(clicked()), this, SLOT(selectionChanged()));
+}
+
+void SocialNetworkDialog::selectionChanged() {
+ struct dive *d = current_dive;
+ QString fullText;
+ if (ui->date->isChecked()) {
+ fullText += tr("Dive Date: %1 \n").arg(d->when);
+ }
+ if (ui->Buddy->isChecked()) {
+ fullText += tr("Buddy: %1 \n").arg(d->buddy);
}
+ if (ui->Divemaster->isChecked()) {
+ fullText += tr("Divemaster: %1 \n").arg(d->divemaster);
+ }
+ if (ui->Location->isChecked()) {
+ fullText += tr("Dive Location: %1 \n").arg(d->location);
+ }
+ if (ui->Notes->isChecked()) {
+ fullText += tr("\n %1").arg(d->notes);
+ }
+ ui->text->setPlainText(fullText);
+}
+
+QString SocialNetworkDialog::text() const {
+ return ui->text->toPlainText().toHtmlEscaped();
+}
+
+QString SocialNetworkDialog::album() const {
+ return ui->album->text().toHtmlEscaped();
}