From d59e89e569b732661633424fcf19f09e95b936fe Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 16 Sep 2015 16:43:01 -0300 Subject: Make Facebook more user friendly The current way that facebook works is terrible: it's scattered around tons of files ( at least 4 different files and classes ) this moves things around a bit, add a disconnect button that was missing, cleans tons of code and fix inconsistencies. I will also redo this part for 5.0, but it's too late for 4.5 Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 15 --- qt-ui/maintab.ui | 177 ++++------------------------------ qt-ui/mainwindow.cpp | 14 +++ qt-ui/mainwindow.ui | 26 ++--- qt-ui/preferences.cpp | 19 ++-- qt-ui/preferences.ui | 241 ++++++++++------------------------------------- qt-ui/socialnetworks.cpp | 4 +- qt-ui/socialnetworks.h | 4 +- 8 files changed, 110 insertions(+), 390 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index fb1a64c38..2e4d3fc9f 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -25,10 +25,6 @@ #include "locationinformation.h" #include "divesite.h" -#if defined(FBSUPPORT) -#include "socialnetworks.h" -#endif - #include #include #include @@ -201,17 +197,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.photosView->setSelectionMode(QAbstractItemView::SingleSelection); connect(deletePhoto, SIGNAL(triggered(bool)), this, SLOT(removeSelectedPhotos())); -#if defined(FBSUPPORT) - FacebookManager *fb = FacebookManager::instance(); - connect(fb, &FacebookManager::justLoggedIn, ui.facebookPublish, &QPushButton::show); - connect(fb, &FacebookManager::justLoggedOut, ui.facebookPublish, &QPushButton::hide); - connect(ui.facebookPublish, &QPushButton::clicked, fb, &FacebookManager::sendDive); - ui.facebookPublish->setVisible(fb->loggedIn()); -#else - ui.facebookPublish->setVisible(false); - ui.socialNetworks->setVisible(false); -#endif - ui.waitingSpinner->setRoundness(70.0); ui.waitingSpinner->setMinimumTrailOpacity(15.0); ui.waitingSpinner->setTrailFadePercentage(70.0); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 7ea895863..23bacbf85 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -21,16 +21,7 @@ General notes about the current selection - - 5 - - - 5 - - - 5 - - + 5 @@ -55,21 +46,12 @@ 0 0 - 445 - 760 + 449 + 772 - - 0 - - - 0 - - - 0 - - + 0 @@ -458,51 +440,9 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - :/facebook:/facebook - - - - 32 - 32 - - - - true - - - @@ -524,16 +464,7 @@ Used equipment in the current selection - - 5 - - - 5 - - - 5 - - + 5 @@ -560,16 +491,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -581,16 +503,7 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 @@ -619,16 +532,7 @@ Dive information - - 5 - - - 5 - - - 5 - - + 5 @@ -650,21 +554,12 @@ 0 0 - 287 - 320 + 211 + 250 - - 0 - - - 0 - - - 0 - - + 0 @@ -963,16 +858,7 @@ Simple statistics about the selection - - 5 - - - 5 - - - 5 - - + 5 @@ -991,21 +877,12 @@ 0 0 - 297 - 187 + 225 + 166 - - 0 - - - 0 - - - 0 - - + 0 @@ -1181,16 +1058,7 @@ All photos from the current selection - - 5 - - - 5 - - - 5 - - + 5 @@ -1213,16 +1081,7 @@ 0 - - 5 - - - 5 - - - 5 - - + 5 diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index d26ad2a3b..43bc4d3fb 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -51,6 +51,10 @@ #include #include +#if defined(FBSUPPORT) +#include "socialnetworks.h" +#endif + QProgressDialog *progressDialog = NULL; bool progressDialogCanceled = false; @@ -235,6 +239,16 @@ MainWindow::MainWindow() : QMainWindow(), find_all_templates(); #endif +#if defined(FBSUPPORT) + FacebookManager *fb = FacebookManager::instance(); + connect(fb, SIGNAL(justLoggedIn(bool)), ui.actionFacebook, SLOT(setEnabled(bool))); + connect(fb, SIGNAL(justLoggedOut(bool)), ui.actionFacebook, SLOT(setEnabled(bool))); + connect(ui.actionFacebook, SIGNAL(triggered(bool)), fb, SLOT(sendDive())); + ui.actionFacebook->setEnabled(fb->loggedIn()); +#else + ui.actionFacebook->setEnabled(false); +#endif + ui.menubar->show(); set_git_update_cb(&updateProgress); } diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 8ecdc13ac..5e3200cfc 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -15,16 +15,7 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 @@ -62,7 +53,7 @@ 0 0 861 - 29 + 23 @@ -146,11 +137,19 @@ &Edit + + + Share on + + + + + @@ -735,6 +734,11 @@ Dive Site &Edit + + + Facebook + + diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 73d9c7024..fcddb618c 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -52,6 +52,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) FacebookManager *fb = FacebookManager::instance(); facebookWebView = new QWebView(this); + ui.fbWebviewContainer->layout()->addWidget(facebookWebView); if (fb->loggedIn()) { facebookLoggedIn(); } else { @@ -59,7 +60,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial } connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin); connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn); - connect(ui.btnDisconnectFacebook, &QPushButton::clicked, fb, &FacebookManager::logout); + connect(ui.fbDisconnect, &QPushButton::clicked, fb, &FacebookManager::logout); connect(fb, &FacebookManager::justLoggedOut, this, &PreferencesDialog::facebookDisconnect); #endif connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int))); @@ -79,13 +80,10 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial void PreferencesDialog::facebookLoggedIn() { #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - // remove the login view and add the disconnect button - ui.fbLayout->removeItem(ui.fbLayout->itemAt(1)); - ui.fbLayout->insertWidget(1, ui.fbConnected, 0); - ui.fbConnected->show(); + ui.fbDisconnect->show(); + ui.fbWebviewContainer->hide(); + ui.fbWebviewContainer->setEnabled(false); ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below")); - if (facebookWebView) - facebookWebView->hide(); #endif } @@ -94,14 +92,13 @@ void PreferencesDialog::facebookDisconnect() #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) // remove the connect/disconnect button // and instead add the login view - ui.fbLayout->removeItem(ui.fbLayout->itemAt(1)); - ui.fbLayout->insertWidget(1, facebookWebView, 1); - ui.fbConnected->hide(); + ui.fbDisconnect->hide(); + ui.fbWebviewContainer->show(); + ui.fbWebviewContainer->setEnabled(true); ui.FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline")); if (facebookWebView) { 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 dc0d04a5a..a45734d01 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -19,16 +19,7 @@ - - 5 - - - 5 - - - 5 - - + 5 @@ -168,7 +159,7 @@ - 0 + 5 @@ -181,16 +172,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -199,16 +181,7 @@ Lists and tables - - 5 - - - 5 - - - 5 - - + 5 @@ -246,16 +219,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -359,16 +323,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -394,16 +349,7 @@ Animations - - 5 - - - 5 - - - 5 - - + 5 @@ -442,16 +388,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -490,16 +427,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -800,16 +728,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -1103,16 +1022,7 @@ QLayout::SetNoConstraint - - 5 - - - 5 - - - 5 - - + 5 @@ -1196,16 +1106,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -1399,8 +1300,7 @@ - - + @@ -1428,16 +1328,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -1482,65 +1373,44 @@ 0 - + 5 - - 5 - - - 5 - - - 5 - - + 5 - - - - 0 - 0 - - - - true - - - - - - - - - 0 - 0 - 229 - 28 - - - - Disconnect from Facebook - - + + + + + + + 0 + 0 + + + + Connect to facebook text placeholder + + + + + + + + + + + + Disconnect + + + + - - - - Qt::Vertical - - - - 0 - 0 - - - - @@ -1554,16 +1424,7 @@ 5 - - 5 - - - 5 - - - 5 - - + 5 @@ -2026,14 +1887,14 @@ - - - - - - + + + + + + diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp index c165043b6..6e191267a 100644 --- a/qt-ui/socialnetworks.cpp +++ b/qt-ui/socialnetworks.cpp @@ -94,7 +94,7 @@ void FacebookManager::tryLogin(const QUrl& loginResponse) #endif requestUserId(); sync(); - emit justLoggedIn(); + emit justLoggedIn(true); } void FacebookManager::logout() @@ -115,7 +115,7 @@ void FacebookManager::logout() prefs.facebook.album_id = NULL; prefs.facebook.user_id = NULL; #endif - emit justLoggedOut(); + emit justLoggedOut(true); } void FacebookManager::requestAlbumId() diff --git a/qt-ui/socialnetworks.h b/qt-ui/socialnetworks.h index 04d1996b5..2f63915ca 100644 --- a/qt-ui/socialnetworks.h +++ b/qt-ui/socialnetworks.h @@ -16,8 +16,8 @@ public: QUrl connectUrl(); bool loggedIn(); signals: - void justLoggedIn(); - void justLoggedOut(); + void justLoggedIn(bool triggererd); + void justLoggedOut(bool triggered); public slots: void tryLogin(const QUrl& loginResponse); -- cgit v1.2.3-70-g09d2