2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Jussi Laitinen jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
9 Ville Tiensuu - ville.tiensuu@ixonos.com
11 Situare is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 version 2 as published by the Free Software Foundation.
15 Situare is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with Situare; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include <QtAlgorithms>
31 #include "facebookservice/facebookauthentication.h"
32 #include "friendlistpanel.h"
33 #include "logindialog.h"
34 #include "map/mapview.h"
35 #include "settingsdialog.h"
36 #include "userinfopanel.h"
37 #include "zoombuttonpanel.h"
40 #include "mainwindow.h"
42 // These MUST BE HERE, compiling for Maemo fails if moved
44 #include <QtMaemo5/QMaemo5InformationBox>
45 #include <QtGui/QX11Info>
46 #include <X11/Xatom.h>
48 #endif // Q_WS_MAEMO_5
50 // values for setting screen size in desktop matching N900 screen size
51 const int N900_APP_WIDTH = 800;
52 const int N900_APP_HEIGHT = 449;
54 MainWindow::MainWindow(QWidget *parent)
55 : QMainWindow(parent),
56 m_drawOwnLocationCrosshair(false),
60 m_ownLocationCrosshair(0),
63 m_fullScreenButton(0),
68 qDebug() << __PRETTY_FUNCTION__;
73 QHBoxLayout *layout = new QHBoxLayout;
74 layout->addWidget(m_mapView);
76 setCentralWidget(new QWidget());
77 centralWidget()->setLayout(layout);
79 buildFriendListPanel();
82 m_settingsDialog = new SettingsDialog(this);
83 m_settingsDialog->hide();
84 connect(m_settingsDialog, SIGNAL(enableAutomaticLocationUpdate(bool,int)),
85 this, SIGNAL(enableAutomaticLocationUpdate(bool,int)));
86 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
87 tr("Automatic location update"), "",
88 QMessageBox::Yes | QMessageBox::No |
89 QMessageBox::Cancel, this);
90 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
91 this, SLOT(automaticUpdateDialogFinished(int)));
94 setWindowTitle(tr("Situare"));
96 // set stacking order of widgets
97 m_zoomButtonPanel->stackUnder(m_userPanel);
98 if(m_fullScreenButton) {
99 m_fullScreenButton->stackUnder(m_zoomButtonPanel);
100 m_osmLicense->stackUnder(m_fullScreenButton);
102 m_osmLicense->stackUnder(m_zoomButtonPanel);
104 m_ownLocationCrosshair->stackUnder(m_osmLicense);
105 m_mapScale->stackUnder(m_ownLocationCrosshair);
106 m_mapView->stackUnder(m_mapScale);
108 this->toggleProgressIndicator(true);
112 // set screen size in desktop matching N900 screen size
113 resize(N900_APP_WIDTH, N900_APP_HEIGHT);
115 setAttribute(Qt::WA_Maemo5StackedWindow);
119 MainWindow::~MainWindow()
121 qDebug() << __PRETTY_FUNCTION__;
128 qDeleteAll(m_queue.begin(), m_queue.end());
131 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
132 m_error_queue.clear();
135 void MainWindow::automaticUpdateDialogFinished(int result)
137 qDebug() << __PRETTY_FUNCTION__;
139 if (result == QMessageBox::Yes) {
140 m_settingsDialog->setAutomaticLocationUpdateSettings(true);
141 m_settingsDialog->emitAutomaticLocationUpdateSettings();
144 m_settingsDialog->setAutomaticLocationUpdateSettings(false);
145 m_settingsDialog->emitAutomaticLocationUpdateSettings();
149 void MainWindow::buildFullScreenButton()
151 qDebug() << __PRETTY_FUNCTION__;
153 m_fullScreenButton = new QToolButton(this);
154 m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
155 m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
156 connect(m_fullScreenButton, SIGNAL(clicked()),
157 this, SLOT(toggleFullScreen()));
158 #endif // Q_WS_MAEMO_5
162 void MainWindow::buildFriendListPanel()
164 qDebug() << __PRETTY_FUNCTION__;
166 m_friendsListPanel = new FriendListPanel(this);
167 m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
169 m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
171 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
172 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
174 connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
175 this, SIGNAL(findFriend(QPointF)));
177 connect(m_mapView, SIGNAL(viewResized(QSize)),
178 m_friendsListPanel, SLOT(screenResized(QSize)));
180 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
181 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
183 connect(m_mapView, SIGNAL(viewResized(QSize)),
184 m_friendsListPanelSidebar, SLOT(reDrawSidebar(QSize)));
187 void MainWindow::buildInformationBox(const QString &message, bool modal)
189 qDebug() << __PRETTY_FUNCTION__;
191 QString errorMessage = message;
195 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
198 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
199 // extra line changes are needed to make error notes broader
200 errorMessage.prepend("\n");
201 errorMessage.append("\n");
203 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
205 QLabel *label = new QLabel(msgBox);
206 label->setAlignment(Qt::AlignCenter);
207 label->setText(errorMessage);
208 msgBox->setWidget(label);
210 QMessageBox *msgBox = new QMessageBox(this);
211 msgBox->button(QMessageBox::Ok);
212 msgBox->setText(errorMessage);
213 msgBox->setModal(modal);
219 void MainWindow::buildManualLocationCrosshair()
221 qDebug() << __PRETTY_FUNCTION__;
223 m_ownLocationCrosshair = new QLabel(this);
224 QPixmap crosshairImage(":/res/images/sight.png");
225 m_ownLocationCrosshair->setPixmap(crosshairImage);
226 m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
227 m_ownLocationCrosshair->hide();
228 m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
230 connect(m_mapView, SIGNAL(viewResized(QSize)),
231 this, SLOT(drawOwnLocationCrosshair(QSize)));
234 void MainWindow::buildMap()
236 qDebug() << __PRETTY_FUNCTION__;
238 m_mapView = new MapView(this);
240 buildZoomButtonPanel();
242 buildManualLocationCrosshair();
243 buildFullScreenButton();
246 connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
247 this, SIGNAL(mapViewScrolled(QPoint)));
249 connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
250 m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
252 connect(m_mapView, SIGNAL(viewResized(QSize)),
253 this, SIGNAL(mapViewResized(QSize)));
255 connect(m_mapView, SIGNAL(viewResized(QSize)),
256 this, SLOT(drawFullScreenButton(QSize)));
258 connect(m_mapView, SIGNAL(viewResized(QSize)),
259 this, SLOT(drawMapScale(QSize)));
261 connect(m_mapView, SIGNAL(viewResized(QSize)),
262 this, SLOT(setViewPortSize(QSize)));
264 connect(this, SIGNAL(zoomLevelChanged(int)),
265 m_mapView, SLOT(setZoomLevel(int)));
267 connect(m_mapView, SIGNAL(viewZoomFinished()),
268 this, SIGNAL(viewZoomFinished()));
271 void MainWindow::buildMapScale()
273 m_mapScale = new MapScale(this);
274 connect(this, SIGNAL(newMapResolution(qreal)),
275 m_mapScale, SLOT(updateMapResolution(qreal)));
278 void MainWindow::buildOsmLicense()
280 qDebug() << __PRETTY_FUNCTION__;
282 m_osmLicense = new QLabel(this);
283 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
284 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
285 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
286 m_osmLicense->setFont(QFont("Nokia Sans", 9));
287 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
288 m_osmLicense->fontMetrics().height());
290 connect(m_mapView, SIGNAL(viewResized(QSize)),
291 this, SLOT(drawOsmLicense(QSize)));
294 void MainWindow::buildUserInfoPanel()
296 qDebug() << __PRETTY_FUNCTION__;
298 m_userPanel = new UserInfoPanel(this);
299 m_userPanelSidebar = new PanelSideBar(this, LEFT);
301 m_userPanelSidebar->stackUnder(m_friendsListPanel);
302 m_userPanel->stackUnder(m_userPanelSidebar);
304 connect(m_userPanel, SIGNAL(findUser(QPointF)),
305 this, SIGNAL(findUser(QPointF)));
307 connect(this, SIGNAL(userLocationReady(User*)),
308 m_userPanel, SLOT(userDataReceived(User*)));
310 connect(m_userPanel, SIGNAL(requestReverseGeo()),
311 this, SIGNAL(requestReverseGeo()));
313 connect(this, SIGNAL(reverseGeoReady(QString)),
314 m_userPanel, SIGNAL(reverseGeoReady(QString)));
316 connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
317 this, SIGNAL(statusUpdate(QString,bool)));
319 connect(m_userPanel, SIGNAL(refreshUserData()),
320 this, SIGNAL(refreshUserData()));
322 connect(m_mapView, SIGNAL(viewResized(QSize)),
323 m_userPanel, SLOT(screenResized(QSize)));
325 connect(this, SIGNAL(clearUpdateLocationDialogData()),
326 m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
328 connect(this, SIGNAL(messageSendingFailed(int)),
329 m_userPanel, SIGNAL(messageSendingFailed(int)));
331 connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
332 this, SLOT(buildInformationBox(QString, bool)));
335 void MainWindow::buildWebView()
337 qDebug() << __PRETTY_FUNCTION__;
340 m_webView = new QWebView;
343 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
345 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
347 connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
348 this, SLOT(webViewRequestFinished(QNetworkReply*)));
349 connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
350 this, SIGNAL(updateCredentials(QUrl)));
351 connect(m_webView, SIGNAL(loadFinished(bool)),
352 this, SLOT(loadDone(bool)));
358 void MainWindow::buildZoomButtonPanel()
360 qDebug() << __PRETTY_FUNCTION__;
362 m_zoomButtonPanel = new ZoomButtonPanel(this);
364 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
365 this, SIGNAL(zoomIn()));
367 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
368 this, SIGNAL(zoomOut()));
370 connect(this, SIGNAL(zoomLevelChanged(int)),
371 m_zoomButtonPanel, SLOT(resetButtons()));
373 connect(this, SIGNAL(maxZoomLevelReached()),
374 m_zoomButtonPanel, SLOT(disableZoomInButton()));
376 connect(this, SIGNAL(minZoomLevelReached()),
377 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
379 connect(m_mapView, SIGNAL(viewResized(QSize)),
380 m_zoomButtonPanel, SLOT(screenResized(QSize)));
383 void MainWindow::clearCookieJar()
385 qDebug() << __PRETTY_FUNCTION__;
392 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
394 QList<QNetworkCookie> emptyList;
397 m_cookieJar->setAllCookies(emptyList);
398 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
401 void MainWindow::createMenus()
403 qDebug() << __PRETTY_FUNCTION__;
406 m_loginAct = new QAction(tr("Login"), this);
407 connect(m_loginAct, SIGNAL(triggered()),
408 this, SIGNAL(loginActionPressed()));
411 m_toSettingsAct = new QAction(tr("Settings"), this);
412 connect(m_toSettingsAct, SIGNAL(triggered()),
413 this, SLOT(openSettingsDialog()));
416 m_gpsToggleAct = new QAction(tr("GPS"), this);
417 m_gpsToggleAct->setCheckable(true);
419 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
420 this, SIGNAL(gpsTriggered(bool)));
422 // automatic centering
423 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
424 m_autoCenteringAct->setCheckable(true);
425 connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
426 this, SIGNAL(autoCenteringTriggered(bool)));
428 // build the actual menu
429 m_viewMenu = menuBar()->addMenu(tr("Main"));
430 m_viewMenu->addAction(m_loginAct);
431 m_viewMenu->addAction(m_toSettingsAct);
432 m_viewMenu->addAction(m_gpsToggleAct);
433 m_viewMenu->addAction(m_autoCenteringAct);
434 m_viewMenu->setObjectName(tr("Menu"));
437 void MainWindow::dialogFinished(int status)
439 qDebug() << __PRETTY_FUNCTION__;
441 QDialog *dialog = m_queue.takeFirst();
442 LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
446 loginDialog->userInput(m_email, m_password);
448 QStringList urlParts;
449 urlParts.append(FACEBOOK_LOGINBASE);
450 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
451 urlParts.append(INTERVAL1);
452 urlParts.append(SITUARE_LOGIN_SUCCESS);
453 urlParts.append(INTERVAL2);
454 urlParts.append(SITUARE_LOGIN_FAILURE);
455 urlParts.append(FACEBOOK_LOGIN_ENDING);
457 emit saveUsername(m_email);
459 m_webView->load(QUrl(urlParts.join(EMPTY)));
460 toggleProgressIndicator(true);
462 emit cancelLoginProcess();
466 dialog->deleteLater();
468 if(!m_error_queue.isEmpty() && m_errorShown == false) {
469 showErrorInformationBox();
471 if(!m_queue.isEmpty()) {
472 showInformationBox();
477 void MainWindow::drawFullScreenButton(const QSize &size)
479 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
481 if(m_fullScreenButton) {
482 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
484 size.height() - m_fullScreenButton->size().height());
488 void MainWindow::drawMapScale(const QSize &size)
490 const int LEFT_SCALE_MARGIN = 10;
491 const int BOTTOM_SCALE_MARGIN = 2;
492 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
494 m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
495 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
498 void MainWindow::drawOsmLicense(const QSize &size)
500 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
502 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
504 size.height() - m_osmLicense->fontMetrics().height());
507 void MainWindow::drawOwnLocationCrosshair(const QSize &size)
509 qDebug() << __PRETTY_FUNCTION__;
511 if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
512 m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
513 size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
517 void MainWindow::errorDialogFinished(int status)
519 qDebug() << __PRETTY_FUNCTION__;
522 QDialog *dialog = m_error_queue.takeFirst();
524 dialog->deleteLater();
525 m_errorShown = false;
527 if(!m_error_queue.isEmpty())
528 showErrorInformationBox();
529 else if(!m_queue.isEmpty())
530 showInformationBox();
533 void MainWindow::gpsTimeout()
535 qDebug() << __PRETTY_FUNCTION__;
537 buildInformationBox(tr("GPS timeout"));
540 void MainWindow::grabZoomKeys(bool grab)
542 qDebug() << __PRETTY_FUNCTION__;
545 // Can't grab keys unless we have a window id
549 unsigned long val = (grab) ? 1 : 0;
550 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
554 XChangeProperty (QX11Info::display(),
560 reinterpret_cast<unsigned char *>(&val),
564 #endif // Q_WS_MAEMO_5
567 void MainWindow::keyPressEvent(QKeyEvent* event)
569 qDebug() << __PRETTY_FUNCTION__;
571 switch (event->key()) {
582 QWidget::keyPressEvent(event);
585 void MainWindow::loadCookies()
587 qDebug() << __PRETTY_FUNCTION__;
589 QSettings settings(DIRECTORY_NAME, FILE_NAME);
591 QStringList list = settings.value(COOKIES, EMPTY).toStringList();
593 if(!list.isEmpty()) {
594 QList<QNetworkCookie> cookieList;
595 for(int i=0;i<list.count();i++) {
596 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
600 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
602 m_cookieJar->setAllCookies(cookieList);
603 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
608 void MainWindow::loadDone(bool done)
610 qDebug() << __PRETTY_FUNCTION__;
612 // for the first time the login page is opened, we need to refresh it to get cookies working
620 QWebFrame* frame = m_webView->page()->currentFrame();
624 QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
626 foreach (QWebElement element, emailCollection) {
627 element.setAttribute("value", m_email.toAscii());
630 QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
631 foreach (QWebElement element, passwordCollection) {
632 element.setAttribute("value", m_password.toAscii());
634 // find connect button
635 QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
636 foreach (QWebElement element, buttonCollection)
638 QPoint pos(element.geometry().center());
640 // send a mouse click event to the web page
641 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
643 QApplication::sendEvent(m_webView->page(), &event0);
644 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
646 QApplication::sendEvent(m_webView->page(), &event1);
652 void MainWindow::loggedIn(bool logged)
654 qDebug() << __PRETTY_FUNCTION__;
659 m_loginAct->setText(tr("Logout"));
665 m_loginAct->setText(tr("Login"));
667 updateItemVisibility(m_loggedIn);
670 void MainWindow::loginFailed()
672 qDebug() << __PRETTY_FUNCTION__;
676 toggleProgressIndicator(false);
681 void MainWindow::loginUsingCookies()
683 qDebug() << __PRETTY_FUNCTION__;
688 QStringList urlParts;
689 urlParts.append(FACEBOOK_LOGINBASE);
690 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
691 urlParts.append(INTERVAL1);
692 urlParts.append(SITUARE_LOGIN_SUCCESS);
693 urlParts.append(INTERVAL2);
694 urlParts.append(SITUARE_LOGIN_FAILURE);
695 urlParts.append(FACEBOOK_LOGIN_ENDING);
697 m_webView->load(QUrl(urlParts.join(EMPTY)));
701 void MainWindow::openSettingsDialog()
703 qDebug() << __PRETTY_FUNCTION__;
705 m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
706 m_settingsDialog->readSettings();
707 m_settingsDialog->show();
710 void MainWindow::requestAutomaticLocationUpdateSettings()
712 qDebug() << __PRETTY_FUNCTION__;
714 m_settingsDialog->readSettings();
715 m_settingsDialog->emitAutomaticLocationUpdateSettings();
718 void MainWindow::queueDialog(QDialog *dialog)
720 qDebug() << __PRETTY_FUNCTION__;
722 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
723 if(dialog->isModal()) {
724 m_error_queue.append(dialog);
726 m_queue.append(dialog);
729 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
730 if(m_error_queue.count() == 1 && m_errorShown == false)
731 showErrorInformationBox();
732 else if(m_queue.count() == 1 && m_errorShown == false)
733 showInformationBox();
736 void MainWindow::saveCookies()
738 qDebug() << __PRETTY_FUNCTION__;
741 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
743 QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
746 for(int i=0;i<cookieList.count();i++) {
747 QNetworkCookie cookie = cookieList.at(i);
748 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
749 list.append(QString(byteArray));
751 list.removeDuplicates();
753 QSettings settings(DIRECTORY_NAME, FILE_NAME);
754 settings.setValue(COOKIES, list);
757 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
759 qDebug() << __PRETTY_FUNCTION__;
761 m_autoCenteringAct->setChecked(enabled);
764 void MainWindow::setGPSButtonEnabled(bool enabled)
766 qDebug() << __PRETTY_FUNCTION__;
768 m_gpsToggleAct->setChecked(enabled);
770 setOwnLocationCrosshairVisibility(!enabled);
772 m_autoCenteringAct->setVisible(enabled);
775 void MainWindow::setMapViewScene(QGraphicsScene *scene)
777 qDebug() << __PRETTY_FUNCTION__;
779 m_mapView->setScene(scene);
782 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
784 qDebug() << __PRETTY_FUNCTION__;
786 if (visibility && m_loggedIn) {
787 m_ownLocationCrosshair->show();
788 m_drawOwnLocationCrosshair = true;
789 drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
791 m_ownLocationCrosshair->hide();
792 m_drawOwnLocationCrosshair = false;
796 void MainWindow::setUsername(const QString &username)
798 qDebug() << __PRETTY_FUNCTION__;
803 void MainWindow::setViewPortSize(const QSize &size)
805 qDebug() << __PRETTY_FUNCTION__;
807 m_viewPortWidth = size.width();
808 m_viewPortHeight = size.height();
811 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
813 qDebug() << __PRETTY_FUNCTION__;
815 m_automaticUpdateLocationDialog->setText(text);
816 m_automaticUpdateLocationDialog->show();
819 void MainWindow::toggleFullScreen()
821 qDebug() << __PRETTY_FUNCTION__;
823 if(windowState() == Qt::WindowNoState)
829 void MainWindow::showErrorInformationBox()
831 qDebug() << __PRETTY_FUNCTION__;
833 if(m_error_queue.count()) {
835 QDialog *dialog = m_error_queue.first();
836 connect(dialog, SIGNAL(finished(int)),
837 this, SLOT(errorDialogFinished(int)));
842 void MainWindow::showInformationBox()
844 qDebug() << __PRETTY_FUNCTION__;
846 if(m_queue.count()) {
847 QDialog *dialog = m_queue.first();
848 connect(dialog, SIGNAL(finished(int)),
849 this, SLOT(dialogFinished(int)));
854 void MainWindow::startLoginProcess()
856 qDebug() << __PRETTY_FUNCTION__;
858 LoginDialog *loginDialog = new LoginDialog();
860 emit fetchUsernameFromSettings();
862 loginDialog->clearTextFields();
864 if(!m_email.isEmpty())
865 loginDialog->setEmailField(m_email);
867 queueDialog(loginDialog);
870 void MainWindow::toggleProgressIndicator(bool value)
872 qDebug() << __PRETTY_FUNCTION__;
875 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
878 #endif // Q_WS_MAEMO_5
881 void MainWindow::updateItemVisibility(bool show)
883 qDebug() << __PRETTY_FUNCTION__;
886 m_friendsListPanel->show();
887 m_friendsListPanelSidebar->show();
889 m_userPanelSidebar->show();
890 if(!m_gpsToggleAct->isChecked())
891 setOwnLocationCrosshairVisibility(show);
894 m_friendsListPanel->closePanel();
895 m_friendsListPanel->hide();
896 m_friendsListPanelSidebar->hide();
897 m_userPanel->closePanel();
899 m_userPanelSidebar->hide();
900 setOwnLocationCrosshairVisibility(false);
904 const QString MainWindow::username()
906 qDebug() << __PRETTY_FUNCTION__;
911 void MainWindow::webViewRequestFinished(QNetworkReply *reply)
913 qDebug() << __PRETTY_FUNCTION__;
915 // omit QNetworkReply::OperationCanceledError due to it's nature to be called when ever
916 // qwebview starts to load a new page while the current page loading is not finished
917 if(reply->error() != QNetworkReply::OperationCanceledError &&
918 reply->error() != QNetworkReply::NoError) {
919 emit error(reply->error());
920 toggleProgressIndicator(false);