From d1d4b4edb11de05294ba2502f1b87506d24c23f1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 10 Nov 2017 10:30:26 +0100 Subject: Initialize Facebook page only when dialog is shown Quick hack to avoid Facebook access on every program start. Move the initialization of the login page from the FacebookConnectWidget constructor to the show event handler. Signed-off-by: Berthold Stoeger --- .../plugins/facebook/facebookconnectwidget.cpp | 15 ++++++++++----- desktop-widgets/plugins/facebook/facebookconnectwidget.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp index b4f306609..37da1c018 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp @@ -300,6 +300,16 @@ void FacebookManager::uploadFinished() emit sendDiveFinished(); } +void FacebookConnectWidget::showEvent(QShowEvent *event) +{ + if (FacebookManager::instance()->loggedIn()) { + facebookLoggedIn(); + } else { + facebookDisconnect(); + } + return QDialog::showEvent(event); +} + FacebookConnectWidget::FacebookConnectWidget(QWidget *parent) : QDialog(parent), ui(new Ui::FacebookConnectWidget) { ui->setupUi(this); FacebookManager *fb = FacebookManager::instance(); @@ -309,11 +319,6 @@ FacebookConnectWidget::FacebookConnectWidget(QWidget *parent) : QDialog(parent), facebookWebView = new QWebView(this); #endif ui->fbWebviewContainer->layout()->addWidget(facebookWebView); - if (fb->loggedIn()) { - facebookLoggedIn(); - } else { - facebookDisconnect(); - } #ifdef USE_WEBENGINE connect(facebookWebView, &QWebEngineView::urlChanged, fb, &FacebookManager::tryLogin); #else diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.h b/desktop-widgets/plugins/facebook/facebookconnectwidget.h index 3a442d4c9..ebaded04b 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.h +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.h @@ -70,6 +70,7 @@ public: explicit FacebookConnectWidget(QWidget* parent = 0); void facebookLoggedIn(); void facebookDisconnect(); + void showEvent(QShowEvent *event); private: Ui::FacebookConnectWidget *ui; #ifdef USE_WEBENGINE -- cgit v1.2.3-70-g09d2