From a2734e6aaf4c7e10624342a69f127789ea22b5ab Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 2 Oct 2017 12:55:13 +0200 Subject: [PATCH] [Facebook] New method, grabProfilePixmap Just some code organization Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- .../facebook/facebookconnectwidget.cpp | 33 +++++++++++-------- .../plugins/facebook/facebookconnectwidget.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp index f8e2d6b62..721179db6 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp @@ -171,6 +171,25 @@ void FacebookManager::setDesiredAlbumName(const QString& a) albumName = a; } +QPixmap FacebookManager::grabProfilePixmap() +{ + ProfileWidget2 *profile = MainWindow::instance()->graphics(); + + QSize size = fbInfo.profileSize == FacebookInfo::SMALL ? QSize(800,600) : + fbInfo.profileSize == FacebookInfo::MEDIUM ? QSize(1024,760) : + fbInfo.profileSize == FacebookInfo::BIG ? QSize(1280,1024) : QSize(); + + auto currSize = profile->size(); + profile->resize(size); + profile->setToolTipVisibile(false); + QPixmap pix = profile->grab(); + profile->setToolTipVisibile(true); + profile->resize(currSize); + + return pix; +} + + /* to be changed to export the currently selected dive as shown on the profile. * Much much easier, and its also good to people do not select all the dives * and send erroniously *all* of them to facebook. */ @@ -183,19 +202,7 @@ void FacebookManager::sendDive() setDesiredAlbumName(dialog.album()); requestAlbumId(); - ProfileWidget2 *profile = MainWindow::instance()->graphics(); - - QSize size = dialog.profileSize() == FacebookInfo::SMALL ? QSize(800,600) : - dialog.profileSize() == FacebookInfo::MEDIUM ? QSize(1024,760) : - dialog.profileSize() == FacebookInfo::BIG ? QSize(1280,1024) : QSize(); - - auto currSize = profile->size(); - profile->resize(size); - profile->setToolTipVisibile(false); - QPixmap pix = profile->grab(); - profile->setToolTipVisibile(true); - profile->resize(currSize); - + QPixmap pix = grabProfilePixmap(); QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.h b/desktop-widgets/plugins/facebook/facebookconnectwidget.h index 793cf4bee..adc84dda4 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.h +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.h @@ -36,6 +36,7 @@ public: QUrl connectUrl(); QUrl albumListUrl(); bool loggedIn(); + QPixmap grabProfilePixmap(); signals: void justLoggedIn(bool triggererd); void justLoggedOut(bool triggered); @@ -53,6 +54,7 @@ public slots: private: explicit FacebookManager(QObject *parent = 0); QString albumName; + FacebookInfo fbInfo; QNetworkAccessManager *manager; };