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>
30 #include "facebookservice/facebookauthentication.h"
31 #include "map/mapcommon.h"
32 #include "map/mapview.h"
34 #include "friendlistpanel.h"
35 #include "logindialog.h"
37 #include "settingsdialog.h"
38 #include "userinfopanel.h"
39 #include "zoombuttonpanel.h"
41 #include "mainwindow.h"
43 // These MUST BE HERE, compiling for Maemo fails if moved
45 #include <QtMaemo5/QMaemo5InformationBox>
46 #include <QtGui/QX11Info>
47 #include <X11/Xatom.h>
49 #endif // Q_WS_MAEMO_5
51 MainWindow::MainWindow(QWidget *parent)
52 : QMainWindow(parent),
53 m_drawOwnLocationCrosshair(false),
57 m_ownLocationCrosshair(0),
60 m_fullScreenButton(0),
65 qDebug() << __PRETTY_FUNCTION__;
70 QHBoxLayout *layout = new QHBoxLayout;
71 layout->addWidget(m_mapView);
73 layout->setSpacing(0);
75 setCentralWidget(new QWidget());
76 centralWidget()->setLayout(layout);
78 buildFriendListPanel();
82 setWindowTitle(tr("Situare"));
84 // set stacking order of widgets
85 m_zoomButtonPanel->stackUnder(m_userPanel);
86 if(m_fullScreenButton) {
87 m_fullScreenButton->stackUnder(m_zoomButtonPanel);
88 m_osmLicense->stackUnder(m_fullScreenButton);
90 m_osmLicense->stackUnder(m_zoomButtonPanel);
92 m_ownLocationCrosshair->stackUnder(m_osmLicense);
93 m_mapScale->stackUnder(m_ownLocationCrosshair);
94 m_mapView->stackUnder(m_mapScale);
96 this->toggleProgressIndicator(true);
100 // Set default screen size
101 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
103 setAttribute(Qt::WA_Maemo5StackedWindow);
107 MainWindow::~MainWindow()
109 qDebug() << __PRETTY_FUNCTION__;
116 qDeleteAll(m_queue.begin(), m_queue.end());
119 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
120 m_error_queue.clear();
123 void MainWindow::automaticUpdateDialogFinished(int result)
125 qDebug() << __PRETTY_FUNCTION__;
127 if (result == QMessageBox::Yes) {
128 readAutomaticLocationUpdateSettings();
130 QSettings settings(DIRECTORY_NAME, FILE_NAME);
131 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
132 readAutomaticLocationUpdateSettings();
135 m_automaticUpdateLocationDialog->deleteLater();
138 void MainWindow::buildFullScreenButton()
140 qDebug() << __PRETTY_FUNCTION__;
142 m_fullScreenButton = new QToolButton(this);
143 m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
144 m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
145 connect(m_fullScreenButton, SIGNAL(clicked()),
146 this, SLOT(toggleFullScreen()));
147 #endif // Q_WS_MAEMO_5
150 void MainWindow::buildFriendListPanel()
152 qDebug() << __PRETTY_FUNCTION__;
154 m_friendsListPanel = new FriendListPanel(this);
156 m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
158 m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
160 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
161 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
163 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
164 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
166 connect(m_mapView, SIGNAL(viewResized(QSize)),
167 m_friendsListPanel, SLOT(resizePanel(QSize)));
169 connect(m_mapView, SIGNAL(viewResized(QSize)),
170 m_friendsListPanelSidebar, SLOT(resizeSideBar(QSize)));
172 connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
173 this, SIGNAL(findFriend(QPointF)));
176 void MainWindow::buildInformationBox(const QString &message, bool modal)
178 qDebug() << __PRETTY_FUNCTION__;
180 QString errorMessage = message;
184 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
187 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
188 // extra line changes are needed to make error notes broader
189 errorMessage.prepend("\n");
190 errorMessage.append("\n");
192 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
194 QLabel *label = new QLabel(msgBox);
195 label->setAlignment(Qt::AlignCenter);
196 label->setText(errorMessage);
197 msgBox->setWidget(label);
199 QMessageBox *msgBox = new QMessageBox(this);
200 msgBox->button(QMessageBox::Ok);
201 msgBox->setText(errorMessage);
202 msgBox->setModal(modal);
208 void MainWindow::buildManualLocationCrosshair()
210 qDebug() << __PRETTY_FUNCTION__;
212 m_ownLocationCrosshair = new QLabel(this);
213 QPixmap crosshairImage(":/res/images/sight.png");
214 m_ownLocationCrosshair->setPixmap(crosshairImage);
215 m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
216 m_ownLocationCrosshair->hide();
217 m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
219 connect(m_mapView, SIGNAL(viewResized(QSize)),
220 this, SLOT(drawOwnLocationCrosshair(QSize)));
223 void MainWindow::buildMap()
225 qDebug() << __PRETTY_FUNCTION__;
227 m_mapView = new MapView(this);
229 buildZoomButtonPanel();
231 buildManualLocationCrosshair();
232 buildFullScreenButton();
235 connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
236 this, SIGNAL(mapViewScrolled(QPoint)));
238 connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
239 m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
241 connect(m_mapView, SIGNAL(viewResized(QSize)),
242 this, SIGNAL(mapViewResized(QSize)));
244 connect(m_mapView, SIGNAL(viewResized(QSize)),
245 this, SLOT(drawFullScreenButton(QSize)));
247 connect(m_mapView, SIGNAL(viewResized(QSize)),
248 this, SLOT(drawMapScale(QSize)));
250 connect(m_mapView, SIGNAL(viewResized(QSize)),
251 this, SLOT(setViewPortSize(QSize)));
253 connect(this, SIGNAL(zoomLevelChanged(int)),
254 m_mapView, SLOT(setZoomLevel(int)));
256 connect(m_mapView, SIGNAL(viewZoomFinished()),
257 this, SIGNAL(viewZoomFinished()));
259 connect(m_mapView, SIGNAL(zoomIn()),
260 this, SIGNAL(zoomIn()));
263 void MainWindow::buildMapScale()
265 m_mapScale = new MapScale(this);
266 connect(this, SIGNAL(newMapResolution(qreal)),
267 m_mapScale, SLOT(updateMapResolution(qreal)));
270 void MainWindow::buildOsmLicense()
272 qDebug() << __PRETTY_FUNCTION__;
274 m_osmLicense = new QLabel(this);
275 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
276 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
277 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
278 m_osmLicense->setFont(QFont("Nokia Sans", 9));
279 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
280 m_osmLicense->fontMetrics().height());
282 connect(m_mapView, SIGNAL(viewResized(QSize)),
283 this, SLOT(drawOsmLicense(QSize)));
286 void MainWindow::buildUserInfoPanel()
288 qDebug() << __PRETTY_FUNCTION__;
290 m_userPanel = new UserInfoPanel(this);
292 m_userPanelSidebar = new PanelSideBar(this, LEFT);
294 m_userPanelSidebar->stackUnder(m_friendsListPanel);
295 m_userPanel->stackUnder(m_userPanelSidebar);
297 connect(this, SIGNAL(userLocationReady(User*)),
298 m_userPanel, SLOT(userDataReceived(User*)));
300 connect(this, SIGNAL(reverseGeoReady(QString)),
301 m_userPanel, SIGNAL(reverseGeoReady(QString)));
303 connect(this, SIGNAL(clearUpdateLocationDialogData()),
304 m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
306 connect(this, SIGNAL(messageSendingFailed(int)),
307 m_userPanel, SIGNAL(messageSendingFailed(int)));
309 connect(m_mapView, SIGNAL(viewResized(QSize)),
310 m_userPanel, SLOT(resizePanel(QSize)));
312 connect(m_mapView, SIGNAL(viewResized(QSize)),
313 m_userPanelSidebar, SLOT(resizeSideBar(QSize)));
315 connect(m_userPanel, SIGNAL(findUser(QPointF)),
316 this, SIGNAL(findUser(QPointF)));
318 connect(m_userPanel, SIGNAL(requestReverseGeo()),
319 this, SIGNAL(requestReverseGeo()));
321 connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
322 this, SIGNAL(statusUpdate(QString,bool)));
324 connect(m_userPanel, SIGNAL(refreshUserData()),
325 this, SIGNAL(refreshUserData()));
327 connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
328 this, SLOT(buildInformationBox(QString, bool)));
331 void MainWindow::buildWebView()
333 qDebug() << __PRETTY_FUNCTION__;
336 m_webView = new QWebView;
339 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
341 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
343 connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
344 this, SLOT(webViewRequestFinished(QNetworkReply*)));
345 connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
346 this, SIGNAL(updateCredentials(QUrl)));
347 connect(m_webView, SIGNAL(loadFinished(bool)),
348 this, SLOT(loadDone(bool)));
354 void MainWindow::buildZoomButtonPanel()
356 qDebug() << __PRETTY_FUNCTION__;
358 m_zoomButtonPanel = new ZoomButtonPanel(this);
360 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
361 this, SIGNAL(zoomIn()));
363 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
364 this, SIGNAL(zoomOut()));
366 connect(this, SIGNAL(zoomLevelChanged(int)),
367 m_zoomButtonPanel, SLOT(resetButtons()));
369 connect(this, SIGNAL(maxZoomLevelReached()),
370 m_zoomButtonPanel, SLOT(disableZoomInButton()));
372 connect(this, SIGNAL(minZoomLevelReached()),
373 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
375 connect(m_mapView, SIGNAL(viewResized(QSize)),
376 m_zoomButtonPanel, SLOT(screenResized(QSize)));
379 void MainWindow::clearCookieJar()
381 qDebug() << __PRETTY_FUNCTION__;
388 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
390 QList<QNetworkCookie> emptyList;
393 m_cookieJar->setAllCookies(emptyList);
394 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
397 void MainWindow::createMenus()
399 qDebug() << __PRETTY_FUNCTION__;
402 m_loginAct = new QAction(tr("Login"), this);
403 connect(m_loginAct, SIGNAL(triggered()),
404 this, SIGNAL(loginActionPressed()));
407 m_toSettingsAct = new QAction(tr("Settings"), this);
408 connect(m_toSettingsAct, SIGNAL(triggered()),
409 this, SLOT(openSettingsDialog()));
412 m_gpsToggleAct = new QAction(tr("GPS"), this);
413 m_gpsToggleAct->setCheckable(true);
415 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
416 this, SIGNAL(gpsTriggered(bool)));
418 // automatic centering
419 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
420 m_autoCenteringAct->setCheckable(true);
421 connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
422 this, SIGNAL(autoCenteringTriggered(bool)));
424 // build the actual menu
425 m_viewMenu = menuBar()->addMenu(tr("Main"));
426 m_viewMenu->addAction(m_loginAct);
427 m_viewMenu->addAction(m_toSettingsAct);
428 m_viewMenu->addAction(m_gpsToggleAct);
429 m_viewMenu->addAction(m_autoCenteringAct);
430 m_viewMenu->setObjectName(tr("Menu"));
433 void MainWindow::dialogFinished(int status)
435 qDebug() << __PRETTY_FUNCTION__;
437 QDialog *dialog = m_queue.takeFirst();
438 LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
442 loginDialog->userInput(m_email, m_password);
444 QStringList urlParts;
445 urlParts.append(FACEBOOK_LOGINBASE);
446 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
447 urlParts.append(INTERVAL1);
448 urlParts.append(SITUARE_LOGIN_SUCCESS);
449 urlParts.append(INTERVAL2);
450 urlParts.append(SITUARE_LOGIN_FAILURE);
451 urlParts.append(FACEBOOK_LOGIN_ENDING);
453 emit saveUsername(m_email);
455 m_webView->load(QUrl(urlParts.join(EMPTY)));
456 toggleProgressIndicator(true);
458 emit cancelLoginProcess();
462 dialog->deleteLater();
464 if(!m_error_queue.isEmpty() && m_errorShown == false) {
465 showErrorInformationBox();
467 if(!m_queue.isEmpty()) {
468 showInformationBox();
473 void MainWindow::drawFullScreenButton(const QSize &size)
475 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
477 if(m_fullScreenButton) {
478 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
480 size.height() - m_fullScreenButton->size().height());
484 void MainWindow::drawMapScale(const QSize &size)
486 const int LEFT_SCALE_MARGIN = 10;
487 const int BOTTOM_SCALE_MARGIN = 2;
488 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
490 m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
491 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
494 void MainWindow::drawOsmLicense(const QSize &size)
496 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
498 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
500 size.height() - m_osmLicense->fontMetrics().height());
503 void MainWindow::drawOwnLocationCrosshair(const QSize &size)
505 qDebug() << __PRETTY_FUNCTION__;
507 if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
508 m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
509 size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
513 void MainWindow::errorDialogFinished(int status)
515 qDebug() << __PRETTY_FUNCTION__;
518 QDialog *dialog = m_error_queue.takeFirst();
520 dialog->deleteLater();
521 m_errorShown = false;
523 if(!m_error_queue.isEmpty())
524 showErrorInformationBox();
525 else if(!m_queue.isEmpty())
526 showInformationBox();
529 void MainWindow::gpsTimeout()
531 qDebug() << __PRETTY_FUNCTION__;
533 buildInformationBox(tr("GPS timeout"));
536 void MainWindow::grabZoomKeys(bool grab)
538 qDebug() << __PRETTY_FUNCTION__;
541 // Can't grab keys unless we have a window id
545 unsigned long val = (grab) ? 1 : 0;
546 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
550 XChangeProperty (QX11Info::display(),
556 reinterpret_cast<unsigned char *>(&val),
560 #endif // Q_WS_MAEMO_5
563 void MainWindow::keyPressEvent(QKeyEvent* event)
565 qDebug() << __PRETTY_FUNCTION__;
567 switch (event->key()) {
578 QWidget::keyPressEvent(event);
581 void MainWindow::loadCookies()
583 qDebug() << __PRETTY_FUNCTION__;
585 QSettings settings(DIRECTORY_NAME, FILE_NAME);
587 QStringList list = settings.value(COOKIES, EMPTY).toStringList();
589 if(!list.isEmpty()) {
590 QList<QNetworkCookie> cookieList;
591 for(int i=0;i<list.count();i++) {
592 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
596 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
598 m_cookieJar->setAllCookies(cookieList);
599 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
604 void MainWindow::loadDone(bool done)
606 qDebug() << __PRETTY_FUNCTION__;
608 // for the first time the login page is opened, we need to refresh it to get cookies working
616 QWebFrame* frame = m_webView->page()->currentFrame();
620 QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
622 foreach (QWebElement element, emailCollection) {
623 element.setAttribute("value", m_email.toAscii());
626 QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
627 foreach (QWebElement element, passwordCollection) {
628 element.setAttribute("value", m_password.toAscii());
630 // find connect button
631 QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
632 foreach (QWebElement element, buttonCollection)
634 QPoint pos(element.geometry().center());
636 // send a mouse click event to the web page
637 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
639 QApplication::sendEvent(m_webView->page(), &event0);
640 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
642 QApplication::sendEvent(m_webView->page(), &event1);
648 void MainWindow::loggedIn(bool logged)
650 qDebug() << __PRETTY_FUNCTION__;
655 m_loginAct->setText(tr("Logout"));
661 m_loginAct->setText(tr("Login"));
663 updateItemVisibility();
666 void MainWindow::loginFailed()
668 qDebug() << __PRETTY_FUNCTION__;
672 toggleProgressIndicator(false);
677 bool MainWindow::loginState()
679 qDebug() << __PRETTY_FUNCTION__;
684 void MainWindow::loginUsingCookies()
686 qDebug() << __PRETTY_FUNCTION__;
691 QStringList urlParts;
692 urlParts.append(FACEBOOK_LOGINBASE);
693 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
694 urlParts.append(INTERVAL1);
695 urlParts.append(SITUARE_LOGIN_SUCCESS);
696 urlParts.append(INTERVAL2);
697 urlParts.append(SITUARE_LOGIN_FAILURE);
698 urlParts.append(FACEBOOK_LOGIN_ENDING);
700 m_webView->load(QUrl(urlParts.join(EMPTY)));
704 void MainWindow::openSettingsDialog()
706 qDebug() << __PRETTY_FUNCTION__;
708 SettingsDialog *settingsDialog = new SettingsDialog(this);
709 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
710 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
712 settingsDialog->show();
715 void MainWindow::readAutomaticLocationUpdateSettings()
717 qDebug() << __PRETTY_FUNCTION__;
719 QSettings settings(DIRECTORY_NAME, FILE_NAME);
720 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
721 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
724 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
726 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
728 emit enableAutomaticLocationUpdate(false);
732 void MainWindow::queueDialog(QDialog *dialog)
734 qDebug() << __PRETTY_FUNCTION__;
736 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
737 if(dialog->isModal()) {
738 m_error_queue.append(dialog);
740 m_queue.append(dialog);
743 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
744 if(m_error_queue.count() == 1 && m_errorShown == false)
745 showErrorInformationBox();
746 else if(m_queue.count() == 1 && m_errorShown == false)
747 showInformationBox();
750 void MainWindow::saveCookies()
752 qDebug() << __PRETTY_FUNCTION__;
755 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
757 QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
760 for(int i=0;i<cookieList.count();i++) {
761 QNetworkCookie cookie = cookieList.at(i);
762 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
763 list.append(QString(byteArray));
765 list.removeDuplicates();
767 QSettings settings(DIRECTORY_NAME, FILE_NAME);
768 settings.setValue(COOKIES, list);
771 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
773 qDebug() << __PRETTY_FUNCTION__;
775 m_autoCenteringAct->setChecked(enabled);
778 void MainWindow::setGPSButtonEnabled(bool enabled)
780 qDebug() << __PRETTY_FUNCTION__;
782 m_gpsToggleAct->setChecked(enabled);
784 setOwnLocationCrosshairVisibility(!enabled);
786 m_autoCenteringAct->setVisible(enabled);
789 void MainWindow::setMapViewScene(QGraphicsScene *scene)
791 qDebug() << __PRETTY_FUNCTION__;
793 m_mapView->setScene(scene);
796 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
798 qDebug() << __PRETTY_FUNCTION__;
800 if (visibility && m_loggedIn) {
801 m_ownLocationCrosshair->show();
802 m_drawOwnLocationCrosshair = true;
803 drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
805 m_ownLocationCrosshair->hide();
806 m_drawOwnLocationCrosshair = false;
810 void MainWindow::settingsDialogAccepted()
812 qDebug() << __PRETTY_FUNCTION__;
814 readAutomaticLocationUpdateSettings();
817 void MainWindow::setUsername(const QString &username)
819 qDebug() << __PRETTY_FUNCTION__;
824 void MainWindow::setViewPortSize(const QSize &size)
826 qDebug() << __PRETTY_FUNCTION__;
828 m_viewPortWidth = size.width();
829 m_viewPortHeight = size.height();
832 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
834 qDebug() << __PRETTY_FUNCTION__;
836 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
837 tr("Automatic location update"), text,
838 QMessageBox::Yes | QMessageBox::No |
839 QMessageBox::Cancel, this);
840 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
841 this, SLOT(automaticUpdateDialogFinished(int)));
843 m_automaticUpdateLocationDialog->show();
846 void MainWindow::toggleFullScreen()
848 qDebug() << __PRETTY_FUNCTION__;
850 if(windowState() == Qt::WindowNoState)
856 void MainWindow::showErrorInformationBox()
858 qDebug() << __PRETTY_FUNCTION__;
860 if(m_error_queue.count()) {
862 QDialog *dialog = m_error_queue.first();
863 connect(dialog, SIGNAL(finished(int)),
864 this, SLOT(errorDialogFinished(int)));
869 void MainWindow::showInformationBox()
871 qDebug() << __PRETTY_FUNCTION__;
873 if(m_queue.count()) {
874 QDialog *dialog = m_queue.first();
875 connect(dialog, SIGNAL(finished(int)),
876 this, SLOT(dialogFinished(int)));
881 void MainWindow::startLoginProcess()
883 qDebug() << __PRETTY_FUNCTION__;
885 LoginDialog *loginDialog = new LoginDialog();
887 emit fetchUsernameFromSettings();
889 loginDialog->clearTextFields();
891 if(!m_email.isEmpty())
892 loginDialog->setEmailField(m_email);
894 queueDialog(loginDialog);
897 void MainWindow::toggleProgressIndicator(bool value)
899 qDebug() << __PRETTY_FUNCTION__;
902 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
905 #endif // Q_WS_MAEMO_5
908 void MainWindow::updateItemVisibility()
910 qDebug() << __PRETTY_FUNCTION__;
913 m_friendsListPanel->show();
914 m_friendsListPanelSidebar->show();
916 m_userPanelSidebar->show();
918 if(!m_gpsToggleAct->isChecked())
919 setOwnLocationCrosshairVisibility(true);
921 m_friendsListPanel->closePanel();
922 m_friendsListPanel->hide();
923 m_friendsListPanelSidebar->hide();
924 m_userPanel->closePanel();
926 m_userPanelSidebar->hide();
927 setOwnLocationCrosshairVisibility(false);
931 const QString MainWindow::username()
933 qDebug() << __PRETTY_FUNCTION__;
938 void MainWindow::webViewRequestFinished(QNetworkReply *reply)
940 qDebug() << __PRETTY_FUNCTION__;
942 // omit QNetworkReply::OperationCanceledError due to it's nature to be called when ever
943 // qwebview starts to load a new page while the current page loading is not finished
944 if(reply->error() != QNetworkReply::OperationCanceledError &&
945 reply->error() != QNetworkReply::NoError) {
946 emit error(reply->error());
947 toggleProgressIndicator(false);