mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
13e2be5889
commit
39e68c795c
2 changed files with 52 additions and 53 deletions
|
@ -32,12 +32,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
|
||||||
if (ui.listWidget->item(i)->text() == "Facebook")
|
if (ui.listWidget->item(i)->text() == "Facebook")
|
||||||
delete ui.listWidget->item(i);
|
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
|
#endif
|
||||||
|
|
||||||
ui.proxyType->clear();
|
ui.proxyType->clear();
|
||||||
|
@ -50,10 +44,11 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
|
||||||
// Facebook stuff:
|
// Facebook stuff:
|
||||||
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
|
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
|
||||||
FacebookManager *fb = FacebookManager::instance();
|
FacebookManager *fb = FacebookManager::instance();
|
||||||
if(fb->loggedIn()){
|
facebookWebView = new QWebView(this);
|
||||||
facebookWebView->setHtml("You are connected on Facebook, yey.");
|
if (fb->loggedIn()) {
|
||||||
|
facebookLoggedIn();
|
||||||
} else {
|
} else {
|
||||||
facebookWebView->setUrl(fb->connectUrl());
|
facebookDisconnect();
|
||||||
}
|
}
|
||||||
connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin);
|
connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin);
|
||||||
connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn);
|
connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn);
|
||||||
|
@ -78,17 +73,31 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
|
||||||
void PreferencesDialog::facebookLoggedIn()
|
void PreferencesDialog::facebookLoggedIn()
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_ANDROID
|
#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.fbConnected->show();
|
||||||
|
ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below"));
|
||||||
|
if (facebookWebView)
|
||||||
|
facebookWebView->hide();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::facebookDisconnect()
|
void PreferencesDialog::facebookDisconnect()
|
||||||
{
|
{
|
||||||
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
|
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
|
||||||
facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
|
// remove the disconnect button
|
||||||
facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
|
// and instead add the login view
|
||||||
|
ui.fbLayout->removeItem(ui.fbLayout->itemAt(1));
|
||||||
|
ui.fbLayout->addWidget(facebookWebView);
|
||||||
ui.fbConnected->hide();
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="defaults_page">
|
<widget class="QWidget" name="defaults_page">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
@ -788,7 +788,7 @@
|
||||||
<string>GFLow at max depth</string>
|
<string>GFLow at max depth</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="show_ccr_setpoint">
|
<widget class="QCheckBox" name="show_ccr_setpoint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -796,7 +796,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QCheckBox" name="show_ccr_sensors">
|
<widget class="QCheckBox" name="show_ccr_sensors">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>CCR: show individual O₂ sensor values when viewing pO₂</string>
|
<string>CCR: show individual O₂ sensor values when viewing pO₂</string>
|
||||||
|
@ -1048,42 +1048,32 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="facebook_page">
|
<widget class="QWidget" name="facebook_page">
|
||||||
<widget class="QWidget" name="fbConnected" native="true">
|
<layout class="QVBoxLayout" name="fbLayout">
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
<widget class="QLabel" name="FBLabel">
|
||||||
<x>9</x>
|
<property name="wordWrap">
|
||||||
<y>355</y>
|
<bool>true</bool>
|
||||||
<width>265</width>
|
</property>
|
||||||
<height>47</height>
|
</widget>
|
||||||
</rect>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<widget class="QWidget" name="fbConnected" native="true">
|
||||||
<item>
|
<widget class="QPushButton" name="btnDisconnectFacebook">
|
||||||
<layout class="QHBoxLayout" name="connectedLayout">
|
<property name="geometry">
|
||||||
<item>
|
<rect>
|
||||||
<spacer name="horizontalSpacer_2">
|
<x>0</x>
|
||||||
<property name="orientation">
|
<y>0</y>
|
||||||
<enum>Qt::Horizontal</enum>
|
<width>229</width>
|
||||||
</property>
|
<height>28</height>
|
||||||
<property name="sizeHint" stdset="0">
|
</rect>
|
||||||
<size>
|
</property>
|
||||||
<width>40</width>
|
<property name="text">
|
||||||
<height>20</height>
|
<string>Disconnect from Facebook</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<widget class="QPushButton" name="btnDisconnectFacebook">
|
|
||||||
<property name="text">
|
|
||||||
<string>Disconnect from Facebook</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1441,12 +1431,12 @@
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="verticalSpeed"/>
|
<buttongroup name="buttonGroup"/>
|
||||||
<buttongroup name="buttonGroup_2"/>
|
<buttongroup name="buttonGroup_2"/>
|
||||||
<buttongroup name="buttonGroup_3"/>
|
<buttongroup name="buttonGroup_3"/>
|
||||||
<buttongroup name="buttonGroup"/>
|
|
||||||
<buttongroup name="buttonGroup_4"/>
|
<buttongroup name="buttonGroup_4"/>
|
||||||
<buttongroup name="buttonGroup_5"/>
|
<buttongroup name="buttonGroup_5"/>
|
||||||
<buttongroup name="buttonGroup_6"/>
|
<buttongroup name="buttonGroup_6"/>
|
||||||
|
<buttongroup name="verticalSpeed"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue