aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-30 22:10:21 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-30 22:36:49 -0800
commit39e68c795c79a02135467f5ebd39c534ab2d43f3 (patch)
tree00d651cad87a3d319536b9f7f9554e0adbcca544
parent13e2be58892c7d6790090892eef9b3dc7408f7da (diff)
downloadsubsurface-39e68c795c79a02135467f5ebd39c534ab2d43f3.tar.gz
Try to make the Facebook interaction be more pleasant
Show either the login screen or the disconnect button, plus some text that explains what the user is expected to do. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/preferences.cpp33
-rw-r--r--qt-ui/preferences.ui72
2 files changed, 52 insertions, 53 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 632251d18..6509975f8 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -32,12 +32,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
if (ui.listWidget->item(i)->text() == "Facebook")
delete ui.listWidget->item(i);
}
-#else
- facebookWebView = new QWebView(this);
- QVBoxLayout fbLayout(ui.facebook_page);
- fbLayout.addWidget(facebookWebView);
- fbLayout.addWidget(ui.fbConnected);
- ui.facebook_page->setLayout(&fbLayout);
#endif
ui.proxyType->clear();
@@ -50,10 +44,11 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
// Facebook stuff:
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
FacebookManager *fb = FacebookManager::instance();
- if(fb->loggedIn()){
- facebookWebView->setHtml("You are connected on Facebook, yey.");
+ facebookWebView = new QWebView(this);
+ if (fb->loggedIn()) {
+ facebookLoggedIn();
} else {
- facebookWebView->setUrl(fb->connectUrl());
+ facebookDisconnect();
}
connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin);
connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn);
@@ -78,17 +73,31 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
void PreferencesDialog::facebookLoggedIn()
{
#ifndef Q_OS_ANDROID
- facebookWebView->setHtml("We need a better 'you re connected' page. but, YEY. ");
+ // remove the login view and add the disconnect button
+ ui.fbLayout->removeItem(ui.fbLayout->itemAt(1));
+ ui.fbLayout->addWidget(ui.fbConnected);
ui.fbConnected->show();
+ ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below"));
+ if (facebookWebView)
+ facebookWebView->hide();
#endif
}
void PreferencesDialog::facebookDisconnect()
{
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
- facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
- facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
+ // remove the disconnect button
+ // and instead add the login view
+ ui.fbLayout->removeItem(ui.fbLayout->itemAt(1));
+ ui.fbLayout->addWidget(facebookWebView);
ui.fbConnected->hide();
+ ui.FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline"));
+ if (facebookWebView) {
+ facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
+ facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
+ facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
+ facebookWebView->show();
+ }
#endif
}
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 2072e4eef..e67925f56 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -151,7 +151,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="defaults_page">
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -788,7 +788,7 @@
<string>GFLow at max depth</string>
</property>
</widget>
- </item>
+ </item>
<item row="5" column="0">
<widget class="QCheckBox" name="show_ccr_setpoint">
<property name="text">
@@ -796,7 +796,7 @@
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="6" column="0">
<widget class="QCheckBox" name="show_ccr_sensors">
<property name="text">
<string>CCR: show individual O₂ sensor values when viewing pO₂</string>
@@ -1048,42 +1048,32 @@
</layout>
</widget>
<widget class="QWidget" name="facebook_page">
- <widget class="QWidget" name="fbConnected" native="true">
- <property name="geometry">
- <rect>
- <x>9</x>
- <y>355</y>
- <width>265</width>
- <height>47</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_9">
- <item>
- <layout class="QHBoxLayout" name="connectedLayout">
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btnDisconnectFacebook">
- <property name="text">
- <string>Disconnect from Facebook</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
+ <layout class="QVBoxLayout" name="fbLayout">
+ <item>
+ <widget class="QLabel" name="FBLabel">
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="fbConnected" native="true">
+ <widget class="QPushButton" name="btnDisconnectFacebook">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>229</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Disconnect from Facebook</string>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
</widget>
</widget>
</item>
@@ -1441,12 +1431,12 @@
</connection>
</connections>
<buttongroups>
- <buttongroup name="verticalSpeed"/>
+ <buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup_3"/>
- <buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_4"/>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup_6"/>
+ <buttongroup name="verticalSpeed"/>
</buttongroups>
</ui>