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();
83 setWindowTitle(tr("Situare"));
85 // set stacking order of widgets
86 m_zoomButtonPanel->stackUnder(m_userPanel);
87 if(m_fullScreenButton) {
88 m_fullScreenButton->stackUnder(m_zoomButtonPanel);
89 m_osmLicense->stackUnder(m_fullScreenButton);
91 m_osmLicense->stackUnder(m_zoomButtonPanel);
93 m_ownLocationCrosshair->stackUnder(m_osmLicense);
94 m_mapScale->stackUnder(m_ownLocationCrosshair);
95 m_mapView->stackUnder(m_mapScale);
97 this->toggleProgressIndicator(true);
101 // set screen size in desktop matching N900 screen size
102 resize(N900_APP_WIDTH, N900_APP_HEIGHT);
104 setAttribute(Qt::WA_Maemo5StackedWindow);
108 MainWindow::~MainWindow()
110 qDebug() << __PRETTY_FUNCTION__;
117 qDeleteAll(m_queue.begin(), m_queue.end());
120 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
121 m_error_queue.clear();
124 void MainWindow::automaticUpdateDialogFinished(int result)
126 qDebug() << __PRETTY_FUNCTION__;
128 if (result == QMessageBox::Yes) {
129 readAutomaticLocationUpdateSettings();
130 } else if (result == QMessageBox::No) {
131 QSettings settings(DIRECTORY_NAME, FILE_NAME);
132 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
133 readAutomaticLocationUpdateSettings();
136 m_automaticUpdateLocationDialog->deleteLater();
139 void MainWindow::buildFullScreenButton()
141 qDebug() << __PRETTY_FUNCTION__;
143 m_fullScreenButton = new QToolButton(this);
144 m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
145 m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
146 connect(m_fullScreenButton, SIGNAL(clicked()),
147 this, SLOT(toggleFullScreen()));
148 #endif // Q_WS_MAEMO_5
152 void MainWindow::buildFriendListPanel()
154 qDebug() << __PRETTY_FUNCTION__;
156 m_friendsListPanel = new FriendListPanel(this);
157 m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
159 m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
161 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
162 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
164 connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
165 this, SIGNAL(findFriend(QPointF)));
167 connect(m_mapView, SIGNAL(viewResized(QSize)),
168 m_friendsListPanel, SLOT(screenResized(QSize)));
170 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
171 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
173 connect(m_mapView, SIGNAL(viewResized(QSize)),
174 m_friendsListPanelSidebar, SLOT(reDrawSidebar(QSize)));
177 void MainWindow::buildInformationBox(const QString &message, bool modal)
179 qDebug() << __PRETTY_FUNCTION__;
181 QString errorMessage = message;
185 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
188 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
189 // extra line changes are needed to make error notes broader
190 errorMessage.prepend("\n");
191 errorMessage.append("\n");
193 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
195 QLabel *label = new QLabel(msgBox);
196 label->setAlignment(Qt::AlignCenter);
197 label->setText(errorMessage);
198 msgBox->setWidget(label);
200 QMessageBox *msgBox = new QMessageBox(this);
201 msgBox->button(QMessageBox::Ok);
202 msgBox->setText(errorMessage);
203 msgBox->setModal(modal);
209 void MainWindow::buildManualLocationCrosshair()
211 qDebug() << __PRETTY_FUNCTION__;
213 m_ownLocationCrosshair = new QLabel(this);
214 QPixmap crosshairImage(":/res/images/sight.png");
215 m_ownLocationCrosshair->setPixmap(crosshairImage);
216 m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
217 m_ownLocationCrosshair->hide();
218 m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
220 connect(m_mapView, SIGNAL(viewResized(QSize)),
221 this, SLOT(drawOwnLocationCrosshair(QSize)));
224 void MainWindow::buildMap()
226 qDebug() << __PRETTY_FUNCTION__;
228 m_mapView = new MapView(this);
230 buildZoomButtonPanel();
232 buildManualLocationCrosshair();
233 buildFullScreenButton();
236 connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
237 this, SIGNAL(mapViewScrolled(QPoint)));
239 connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
240 m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
242 connect(m_mapView, SIGNAL(viewResized(QSize)),
243 this, SIGNAL(mapViewResized(QSize)));
245 connect(m_mapView, SIGNAL(viewResized(QSize)),
246 this, SLOT(drawFullScreenButton(QSize)));
248 connect(m_mapView, SIGNAL(viewResized(QSize)),
249 this, SLOT(drawMapScale(QSize)));
251 connect(m_mapView, SIGNAL(viewResized(QSize)),
252 this, SLOT(setViewPortSize(QSize)));
254 connect(this, SIGNAL(zoomLevelChanged(int)),
255 m_mapView, SLOT(setZoomLevel(int)));
257 connect(m_mapView, SIGNAL(viewZoomFinished()),
258 this, SIGNAL(viewZoomFinished()));
261 void MainWindow::buildMapScale()
263 m_mapScale = new MapScale(this);
264 connect(this, SIGNAL(newMapResolution(qreal)),
265 m_mapScale, SLOT(updateMapResolution(qreal)));
268 void MainWindow::buildOsmLicense()
270 qDebug() << __PRETTY_FUNCTION__;
272 m_osmLicense = new QLabel(this);
273 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
274 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
275 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
276 m_osmLicense->setFont(QFont("Nokia Sans", 9));
277 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
278 m_osmLicense->fontMetrics().height());
280 connect(m_mapView, SIGNAL(viewResized(QSize)),
281 this, SLOT(drawOsmLicense(QSize)));
284 void MainWindow::buildUserInfoPanel()
286 qDebug() << __PRETTY_FUNCTION__;
288 m_userPanel = new UserInfoPanel(this);
289 m_userPanelSidebar = new PanelSideBar(this, LEFT);
291 m_userPanelSidebar->stackUnder(m_friendsListPanel);
292 m_userPanel->stackUnder(m_userPanelSidebar);
294 connect(m_userPanel, SIGNAL(findUser(QPointF)),
295 this, SIGNAL(findUser(QPointF)));
297 connect(this, SIGNAL(userLocationReady(User*)),
298 m_userPanel, SLOT(userDataReceived(User*)));
300 connect(m_userPanel, SIGNAL(requestReverseGeo()),
301 this, SIGNAL(requestReverseGeo()));
303 connect(this, SIGNAL(reverseGeoReady(QString)),
304 m_userPanel, SIGNAL(reverseGeoReady(QString)));
306 connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
307 this, SIGNAL(statusUpdate(QString,bool)));
309 connect(m_userPanel, SIGNAL(refreshUserData()),
310 this, SIGNAL(refreshUserData()));
312 connect(m_mapView, SIGNAL(viewResized(QSize)),
313 m_userPanel, SLOT(screenResized(QSize)));
315 connect(this, SIGNAL(clearUpdateLocationDialogData()),
316 m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
318 connect(this, SIGNAL(messageSendingFailed(int)),
319 m_userPanel, SIGNAL(messageSendingFailed(int)));
321 connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
322 this, SLOT(buildInformationBox(QString, bool)));
325 void MainWindow::buildWebView()
327 qDebug() << __PRETTY_FUNCTION__;
330 m_webView = new QWebView;
333 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
335 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
337 connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
338 this, SLOT(webViewRequestFinished(QNetworkReply*)));
339 connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
340 this, SIGNAL(updateCredentials(QUrl)));
341 connect(m_webView, SIGNAL(loadFinished(bool)),
342 this, SLOT(loadDone(bool)));
348 void MainWindow::buildZoomButtonPanel()
350 qDebug() << __PRETTY_FUNCTION__;
352 m_zoomButtonPanel = new ZoomButtonPanel(this);
354 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
355 this, SIGNAL(zoomIn()));
357 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
358 this, SIGNAL(zoomOut()));
360 connect(this, SIGNAL(zoomLevelChanged(int)),
361 m_zoomButtonPanel, SLOT(resetButtons()));
363 connect(this, SIGNAL(maxZoomLevelReached()),
364 m_zoomButtonPanel, SLOT(disableZoomInButton()));
366 connect(this, SIGNAL(minZoomLevelReached()),
367 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
369 connect(m_mapView, SIGNAL(viewResized(QSize)),
370 m_zoomButtonPanel, SLOT(screenResized(QSize)));
373 void MainWindow::clearCookieJar()
375 qDebug() << __PRETTY_FUNCTION__;
382 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
384 QList<QNetworkCookie> emptyList;
387 m_cookieJar->setAllCookies(emptyList);
388 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
391 void MainWindow::createMenus()
393 qDebug() << __PRETTY_FUNCTION__;
396 m_loginAct = new QAction(tr("Login"), this);
397 connect(m_loginAct, SIGNAL(triggered()),
398 this, SIGNAL(loginActionPressed()));
401 m_toSettingsAct = new QAction(tr("Settings"), this);
402 connect(m_toSettingsAct, SIGNAL(triggered()),
403 this, SLOT(openSettingsDialog()));
406 m_gpsToggleAct = new QAction(tr("GPS"), this);
407 m_gpsToggleAct->setCheckable(true);
409 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
410 this, SIGNAL(gpsTriggered(bool)));
412 // automatic centering
413 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
414 m_autoCenteringAct->setCheckable(true);
415 connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
416 this, SIGNAL(autoCenteringTriggered(bool)));
418 // build the actual menu
419 m_viewMenu = menuBar()->addMenu(tr("Main"));
420 m_viewMenu->addAction(m_loginAct);
421 m_viewMenu->addAction(m_toSettingsAct);
422 m_viewMenu->addAction(m_gpsToggleAct);
423 m_viewMenu->addAction(m_autoCenteringAct);
424 m_viewMenu->setObjectName(tr("Menu"));
427 void MainWindow::dialogFinished(int status)
429 qDebug() << __PRETTY_FUNCTION__;
431 QDialog *dialog = m_queue.takeFirst();
432 LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
436 loginDialog->userInput(m_email, m_password);
438 QStringList urlParts;
439 urlParts.append(FACEBOOK_LOGINBASE);
440 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
441 urlParts.append(INTERVAL1);
442 urlParts.append(SITUARE_LOGIN_SUCCESS);
443 urlParts.append(INTERVAL2);
444 urlParts.append(SITUARE_LOGIN_FAILURE);
445 urlParts.append(FACEBOOK_LOGIN_ENDING);
447 emit saveUsername(m_email);
449 m_webView->load(QUrl(urlParts.join(EMPTY)));
450 toggleProgressIndicator(true);
452 emit cancelLoginProcess();
456 dialog->deleteLater();
458 if(!m_error_queue.isEmpty() && m_errorShown == false) {
459 showErrorInformationBox();
461 if(!m_queue.isEmpty()) {
462 showInformationBox();
467 void MainWindow::drawFullScreenButton(const QSize &size)
469 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
471 if(m_fullScreenButton) {
472 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
474 size.height() - m_fullScreenButton->size().height());
478 void MainWindow::drawMapScale(const QSize &size)
480 const int LEFT_SCALE_MARGIN = 10;
481 const int BOTTOM_SCALE_MARGIN = 2;
482 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
484 m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
485 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
488 void MainWindow::drawOsmLicense(const QSize &size)
490 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
492 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
494 size.height() - m_osmLicense->fontMetrics().height());
497 void MainWindow::drawOwnLocationCrosshair(const QSize &size)
499 qDebug() << __PRETTY_FUNCTION__;
501 if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
502 m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
503 size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
507 void MainWindow::errorDialogFinished(int status)
509 qDebug() << __PRETTY_FUNCTION__;
512 QDialog *dialog = m_error_queue.takeFirst();
514 dialog->deleteLater();
515 m_errorShown = false;
517 if(!m_error_queue.isEmpty())
518 showErrorInformationBox();
519 else if(!m_queue.isEmpty())
520 showInformationBox();
523 void MainWindow::gpsTimeout()
525 qDebug() << __PRETTY_FUNCTION__;
527 buildInformationBox(tr("GPS timeout"));
530 void MainWindow::grabZoomKeys(bool grab)
532 qDebug() << __PRETTY_FUNCTION__;
535 // Can't grab keys unless we have a window id
539 unsigned long val = (grab) ? 1 : 0;
540 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
544 XChangeProperty (QX11Info::display(),
550 reinterpret_cast<unsigned char *>(&val),
554 #endif // Q_WS_MAEMO_5
557 void MainWindow::keyPressEvent(QKeyEvent* event)
559 qDebug() << __PRETTY_FUNCTION__;
561 switch (event->key()) {
572 QWidget::keyPressEvent(event);
575 void MainWindow::loadCookies()
577 qDebug() << __PRETTY_FUNCTION__;
579 QSettings settings(DIRECTORY_NAME, FILE_NAME);
581 QStringList list = settings.value(COOKIES, EMPTY).toStringList();
583 if(!list.isEmpty()) {
584 QList<QNetworkCookie> cookieList;
585 for(int i=0;i<list.count();i++) {
586 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
590 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
592 m_cookieJar->setAllCookies(cookieList);
593 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
598 void MainWindow::loadDone(bool done)
600 qDebug() << __PRETTY_FUNCTION__;
602 // for the first time the login page is opened, we need to refresh it to get cookies working
610 QWebFrame* frame = m_webView->page()->currentFrame();
614 QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
616 foreach (QWebElement element, emailCollection) {
617 element.setAttribute("value", m_email.toAscii());
620 QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
621 foreach (QWebElement element, passwordCollection) {
622 element.setAttribute("value", m_password.toAscii());
624 // find connect button
625 QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
626 foreach (QWebElement element, buttonCollection)
628 QPoint pos(element.geometry().center());
630 // send a mouse click event to the web page
631 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
633 QApplication::sendEvent(m_webView->page(), &event0);
634 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
636 QApplication::sendEvent(m_webView->page(), &event1);
642 void MainWindow::loggedIn(bool logged)
644 qDebug() << __PRETTY_FUNCTION__;
649 m_loginAct->setText(tr("Logout"));
655 m_loginAct->setText(tr("Login"));
657 updateItemVisibility();
660 void MainWindow::loginFailed()
662 qDebug() << __PRETTY_FUNCTION__;
666 toggleProgressIndicator(false);
671 bool MainWindow::loginState()
673 qDebug() << __PRETTY_FUNCTION__;
678 void MainWindow::loginUsingCookies()
680 qDebug() << __PRETTY_FUNCTION__;
685 QStringList urlParts;
686 urlParts.append(FACEBOOK_LOGINBASE);
687 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
688 urlParts.append(INTERVAL1);
689 urlParts.append(SITUARE_LOGIN_SUCCESS);
690 urlParts.append(INTERVAL2);
691 urlParts.append(SITUARE_LOGIN_FAILURE);
692 urlParts.append(FACEBOOK_LOGIN_ENDING);
694 m_webView->load(QUrl(urlParts.join(EMPTY)));
698 void MainWindow::openSettingsDialog()
700 qDebug() << __PRETTY_FUNCTION__;
702 SettingsDialog *settingsDialog = new SettingsDialog(this);
703 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
704 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
706 settingsDialog->show();
709 void MainWindow::readAutomaticLocationUpdateSettings()
711 qDebug() << __PRETTY_FUNCTION__;
713 QSettings settings(DIRECTORY_NAME, FILE_NAME);
714 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
715 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
718 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
720 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
722 emit enableAutomaticLocationUpdate(false);
726 void MainWindow::queueDialog(QDialog *dialog)
728 qDebug() << __PRETTY_FUNCTION__;
730 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
731 if(dialog->isModal()) {
732 m_error_queue.append(dialog);
734 m_queue.append(dialog);
737 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
738 if(m_error_queue.count() == 1 && m_errorShown == false)
739 showErrorInformationBox();
740 else if(m_queue.count() == 1 && m_errorShown == false)
741 showInformationBox();
744 void MainWindow::saveCookies()
746 qDebug() << __PRETTY_FUNCTION__;
749 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
751 QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
754 for(int i=0;i<cookieList.count();i++) {
755 QNetworkCookie cookie = cookieList.at(i);
756 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
757 list.append(QString(byteArray));
759 list.removeDuplicates();
761 QSettings settings(DIRECTORY_NAME, FILE_NAME);
762 settings.setValue(COOKIES, list);
765 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
767 qDebug() << __PRETTY_FUNCTION__;
769 m_autoCenteringAct->setChecked(enabled);
772 void MainWindow::setGPSButtonEnabled(bool enabled)
774 qDebug() << __PRETTY_FUNCTION__;
776 m_gpsToggleAct->setChecked(enabled);
778 setOwnLocationCrosshairVisibility(!enabled);
780 m_autoCenteringAct->setVisible(enabled);
783 void MainWindow::setMapViewScene(QGraphicsScene *scene)
785 qDebug() << __PRETTY_FUNCTION__;
787 m_mapView->setScene(scene);
790 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
792 qDebug() << __PRETTY_FUNCTION__;
794 if (visibility && m_loggedIn) {
795 m_ownLocationCrosshair->show();
796 m_drawOwnLocationCrosshair = true;
797 drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
799 m_ownLocationCrosshair->hide();
800 m_drawOwnLocationCrosshair = false;
804 void MainWindow::settingsDialogAccepted()
806 qDebug() << __PRETTY_FUNCTION__;
808 readAutomaticLocationUpdateSettings();
811 void MainWindow::setUsername(const QString &username)
813 qDebug() << __PRETTY_FUNCTION__;
818 void MainWindow::setViewPortSize(const QSize &size)
820 qDebug() << __PRETTY_FUNCTION__;
822 m_viewPortWidth = size.width();
823 m_viewPortHeight = size.height();
826 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
828 qDebug() << __PRETTY_FUNCTION__;
830 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
831 tr("Automatic location update"), text,
832 QMessageBox::Yes | QMessageBox::No |
833 QMessageBox::Cancel, this);
834 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
835 this, SLOT(automaticUpdateDialogFinished(int)));
837 m_automaticUpdateLocationDialog->show();
840 void MainWindow::toggleFullScreen()
842 qDebug() << __PRETTY_FUNCTION__;
844 if(windowState() == Qt::WindowNoState)
850 void MainWindow::showErrorInformationBox()
852 qDebug() << __PRETTY_FUNCTION__;
854 if(m_error_queue.count()) {
856 QDialog *dialog = m_error_queue.first();
857 connect(dialog, SIGNAL(finished(int)),
858 this, SLOT(errorDialogFinished(int)));
863 void MainWindow::showInformationBox()
865 qDebug() << __PRETTY_FUNCTION__;
867 if(m_queue.count()) {
868 QDialog *dialog = m_queue.first();
869 connect(dialog, SIGNAL(finished(int)),
870 this, SLOT(dialogFinished(int)));
875 void MainWindow::startLoginProcess()
877 qDebug() << __PRETTY_FUNCTION__;
879 LoginDialog *loginDialog = new LoginDialog();
881 emit fetchUsernameFromSettings();
883 loginDialog->clearTextFields();
885 if(!m_email.isEmpty())
886 loginDialog->setEmailField(m_email);
888 queueDialog(loginDialog);
891 void MainWindow::toggleProgressIndicator(bool value)
893 qDebug() << __PRETTY_FUNCTION__;
896 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
899 #endif // Q_WS_MAEMO_5
902 void MainWindow::updateItemVisibility()
904 qDebug() << __PRETTY_FUNCTION__;
907 m_friendsListPanel->show();
908 m_friendsListPanelSidebar->show();
910 m_userPanelSidebar->show();
912 if(!m_gpsToggleAct->isChecked())
913 setOwnLocationCrosshairVisibility(true);
915 m_friendsListPanel->closePanel();
916 m_friendsListPanel->hide();
917 m_friendsListPanelSidebar->hide();
918 m_userPanel->closePanel();
920 m_userPanelSidebar->hide();
921 setOwnLocationCrosshairVisibility(false);
925 const QString MainWindow::username()
927 qDebug() << __PRETTY_FUNCTION__;
932 void MainWindow::webViewRequestFinished(QNetworkReply *reply)
934 qDebug() << __PRETTY_FUNCTION__;
936 // omit QNetworkReply::OperationCanceledError due to it's nature to be called when ever
937 // qwebview starts to load a new page while the current page loading is not finished
938 if(reply->error() != QNetworkReply::OperationCanceledError &&
939 reply->error() != QNetworkReply::NoError) {
940 emit error(reply->error());
941 toggleProgressIndicator(false);