mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
ecd0f25c04
commit
b84edad597
4 changed files with 120 additions and 37 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "profile/profilewidget2.h"
|
#include "profile/profilewidget2.h"
|
||||||
#include "pref.h"
|
#include "pref.h"
|
||||||
|
#include "ui_socialnetworksdialog.h"
|
||||||
|
|
||||||
#define GET_TXT(name, field) \
|
#define GET_TXT(name, field) \
|
||||||
v = s.value(QString(name)); \
|
v = s.value(QString(name)); \
|
||||||
|
@ -191,13 +192,12 @@ void FacebookManager::setDesiredAlbumName(const QString& a)
|
||||||
* and send erroniously *all* of them to facebook. */
|
* and send erroniously *all* of them to facebook. */
|
||||||
void FacebookManager::sendDive()
|
void FacebookManager::sendDive()
|
||||||
{
|
{
|
||||||
bool ok;
|
SocialNetworkDialog dialog(qApp->activeWindow());
|
||||||
albumName = QInputDialog::getText(qApp->activeWindow(), tr("Enter Facebook Album"),
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
tr("Facebook Album:"), QLineEdit::Normal,
|
|
||||||
"Subsurface", &ok);
|
|
||||||
if (!ok)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
setDesiredAlbumName(dialog.album());
|
||||||
requestAlbumId();
|
requestAlbumId();
|
||||||
|
|
||||||
ProfileWidget2 *profile = MainWindow::instance()->graphics();
|
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?" +
|
QUrl url("https://graph.facebook.com/v2.2/" + QString(prefs.facebook.album_id) + "/photos?" +
|
||||||
"&access_token=" + QString(prefs.facebook.access_token) +
|
"&access_token=" + QString(prefs.facebook.access_token) +
|
||||||
"&source=image" +
|
"&source=image" +
|
||||||
"&message=" + QString(d->notes).toHtmlEscaped());
|
"&message=" + dialog.text());
|
||||||
|
|
||||||
|
|
||||||
QNetworkAccessManager *am = new QNetworkAccessManager(this);
|
QNetworkAccessManager *am = new QNetworkAccessManager(this);
|
||||||
|
@ -237,11 +237,60 @@ void FacebookManager::sendDive()
|
||||||
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll());
|
QByteArray response = reply->readAll();
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(response);
|
||||||
QJsonObject obj = jsonDoc.object();
|
QJsonObject obj = jsonDoc.object();
|
||||||
if (obj.keys().contains("id")){
|
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 {
|
} 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();
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
class FacebookManager : public QObject
|
class FacebookManager : public QObject
|
||||||
{
|
{
|
||||||
|
@ -29,4 +30,19 @@ private:
|
||||||
QString albumName;
|
QString albumName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class SocialnetworksDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SocialNetworkDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SocialNetworkDialog(QWidget *parent);
|
||||||
|
QString text() const;
|
||||||
|
QString album() const;
|
||||||
|
public slots:
|
||||||
|
void selectionChanged();
|
||||||
|
private:
|
||||||
|
Ui::SocialnetworksDialog *ui;
|
||||||
|
};
|
||||||
#endif // FACEBOOKMANAGER_H
|
#endif // FACEBOOKMANAGER_H
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Dialog</class>
|
<class>SocialnetworksDialog</class>
|
||||||
<widget class="QDialog" name="Dialog">
|
<widget class="QDialog" name="SocialnetworksDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -14,61 +14,61 @@
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="1" rowspan="7">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLineEdit" name="album"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Folder</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" rowspan="9">
|
||||||
<widget class="QPlainTextEdit" name="text"/>
|
<widget class="QPlainTextEdit" name="text"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="time">
|
<widget class="QCheckBox" name="time">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Time</string>
|
<string>Time</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QCheckBox" name="Location">
|
<widget class="QCheckBox" name="Location">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Location</string>
|
<string>Location</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QCheckBox" name="Divemaster">
|
<widget class="QCheckBox" name="Divemaster">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Divemaster</string>
|
<string>Divemaster</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QCheckBox" name="Buddy">
|
<widget class="QCheckBox" name="Buddy">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Buddy</string>
|
<string>Buddy</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="Notes">
|
|
||||||
<property name="text">
|
|
||||||
<string>Notes</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="2">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QCheckBox" name="date">
|
<widget class="QCheckBox" name="date">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>date</string>
|
<string>date</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QCheckBox" name="Notes">
|
||||||
|
<property name="text">
|
||||||
|
<string>Notes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -76,6 +76,23 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="10" column="0" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Include</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -83,7 +100,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>Dialog</receiver>
|
<receiver>SocialnetworksDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
@ -99,7 +116,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>Dialog</receiver>
|
<receiver>SocialnetworksDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
|
@ -237,7 +237,8 @@ FORMS = \
|
||||||
qt-ui/configuredivecomputerdialog.ui \
|
qt-ui/configuredivecomputerdialog.ui \
|
||||||
qt-ui/listfilter.ui \
|
qt-ui/listfilter.ui \
|
||||||
qt-ui/diveshareexportdialog.ui \
|
qt-ui/diveshareexportdialog.ui \
|
||||||
qt-ui/filterwidget.ui
|
qt-ui/filterwidget.ui \
|
||||||
|
qt-ui/socialnetworksdialog.ui
|
||||||
|
|
||||||
# Nether usermanual or printing is supported on android right now
|
# Nether usermanual or printing is supported on android right now
|
||||||
android: FORMS -= qt-ui/printoptions.ui
|
android: FORMS -= qt-ui/printoptions.ui
|
||||||
|
|
Loading…
Reference in a new issue