Make Facebook support a config option

By default it is turned off, turn on by calling qmake with
CONFIG+=FBSUPPORT.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-01-17 08:43:49 +13:00
parent 0d619d569b
commit abddb3ecb9
3 changed files with 23 additions and 9 deletions

View file

@ -16,7 +16,10 @@
#include "qthelper.h" #include "qthelper.h"
#include "display.h" #include "display.h"
#include "divepicturewidget.h" #include "divepicturewidget.h"
#if defined(FBSUPPORT)
#include "socialnetworks.h" #include "socialnetworks.h"
#endif
#include <QLabel> #include <QLabel>
#include <QCompleter> #include <QCompleter>
@ -190,11 +193,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.photosView->setSelectionMode(QAbstractItemView::SingleSelection); ui.photosView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(deletePhoto, SIGNAL(triggered(bool)), this, SLOT(removeSelectedPhotos())); connect(deletePhoto, SIGNAL(triggered(bool)), this, SLOT(removeSelectedPhotos()));
#if defined(FBSUPPORT)
FacebookManager *fb = FacebookManager::instance(); FacebookManager *fb = FacebookManager::instance();
connect(fb, &FacebookManager::justLoggedIn, ui.facebookPublish, &QPushButton::show); connect(fb, &FacebookManager::justLoggedIn, ui.facebookPublish, &QPushButton::show);
connect(fb, &FacebookManager::justLoggedOut, ui.facebookPublish, &QPushButton::hide); connect(fb, &FacebookManager::justLoggedOut, ui.facebookPublish, &QPushButton::hide);
connect(ui.facebookPublish, &QPushButton::clicked, fb, &FacebookManager::sendDive); connect(ui.facebookPublish, &QPushButton::clicked, fb, &FacebookManager::sendDive);
ui.facebookPublish->setVisible(fb->loggedIn()); ui.facebookPublish->setVisible(fb->loggedIn());
#else
ui.facebookPublish->setVisible(false);
#endif
acceptingEdit = false; acceptingEdit = false;
} }

View file

@ -7,7 +7,10 @@
#include <QShortcut> #include <QShortcut>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QNetworkCookieJar> #include <QNetworkCookieJar>
#if defined(FBSUPPORT)
#include "socialnetworks.h" #include "socialnetworks.h"
#endif
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
#include <QWebView> #include <QWebView>
@ -25,7 +28,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
{ {
ui.setupUi(this); ui.setupUi(this);
#ifdef Q_OS_ANDROID #if defined(Q_OS_ANDROID) || !defined(FBSUPPORT)
for (int i = 0; i < ui.listWidget->count(); i++) { for (int i = 0; i < ui.listWidget->count(); i++) {
if (ui.listWidget->item(i)->text() == "Facebook") if (ui.listWidget->item(i)->text() == "Facebook")
delete ui.listWidget->item(i); delete ui.listWidget->item(i);
@ -46,7 +49,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
ui.proxyType->setCurrentIndex(-1); ui.proxyType->setCurrentIndex(-1);
// Facebook stuff: // Facebook stuff:
#ifndef Q_OS_ANDROID #if !defined(Q_OS_ANDROID) && defined(FBSUPPRORT)
FacebookManager *fb = FacebookManager::instance(); FacebookManager *fb = FacebookManager::instance();
if(fb->loggedIn()){ if(fb->loggedIn()){
facebookWebView->setHtml("You are connected on Facebook, yey."); facebookWebView->setHtml("You are connected on Facebook, yey.");
@ -83,7 +86,7 @@ void PreferencesDialog::facebookLoggedIn()
void PreferencesDialog::facebookDisconnect() void PreferencesDialog::facebookDisconnect()
{ {
#ifndef Q_OS_ANDROID #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar()); facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
facebookWebView->setUrl(FacebookManager::instance()->connectUrl()); facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
ui.fbConnected->hide(); ui.fbConnected->hide();

View file

@ -104,8 +104,7 @@ HEADERS = \
qt-ui/statistics/statisticsbar.h \ qt-ui/statistics/statisticsbar.h \
qt-ui/statistics/yearstatistics.h \ qt-ui/statistics/yearstatistics.h \
qt-ui/diveshareexportdialog.h \ qt-ui/diveshareexportdialog.h \
qt-ui/filtermodels.h \ qt-ui/filtermodels.h
qt-ui/socialnetworks.h
android: HEADERS -= \ android: HEADERS -= \
qt-ui/usermanual.h \ qt-ui/usermanual.h \
@ -199,8 +198,7 @@ SOURCES = \
qt-ui/statistics/statisticsbar.cpp \ qt-ui/statistics/statisticsbar.cpp \
qt-ui/statistics/monthstatistics.cpp \ qt-ui/statistics/monthstatistics.cpp \
qt-ui/diveshareexportdialog.cpp \ qt-ui/diveshareexportdialog.cpp \
qt-ui/filtermodels.cpp \ qt-ui/filtermodels.cpp
qt-ui/socialnetworks.cpp
android: SOURCES += android.cpp android: SOURCES += android.cpp
else: win32: SOURCES += windows.c else: win32: SOURCES += windows.c
@ -237,12 +235,18 @@ 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
FBSUPPORT: {
FORMS += qt-ui/socialnetworksdialog.ui
SOURCES += qt-ui/socialnetworks.cpp
HEADERS += qt-ui/socialnetworks.h
DEFINES += FBSUPPORT
}
RESOURCES = subsurface.qrc RESOURCES = subsurface.qrc
TRANSLATIONS = \ TRANSLATIONS = \