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)));
88 setWindowTitle(tr("Situare"));
90 // set stacking order of widgets
91 m_zoomButtonPanel->stackUnder(m_userPanel);
92 if(m_fullScreenButton) {
93 m_fullScreenButton->stackUnder(m_zoomButtonPanel);
94 m_osmLicense->stackUnder(m_fullScreenButton);
96 m_osmLicense->stackUnder(m_zoomButtonPanel);
98 m_ownLocationCrosshair->stackUnder(m_osmLicense);
99 m_mapScale->stackUnder(m_ownLocationCrosshair);
100 m_mapView->stackUnder(m_mapScale);
102 this->toggleProgressIndicator(true);
106 // set screen size in desktop matching N900 screen size
107 resize(N900_APP_WIDTH, N900_APP_HEIGHT);
109 setAttribute(Qt::WA_Maemo5StackedWindow);
113 MainWindow::~MainWindow()
115 qDebug() << __PRETTY_FUNCTION__;
122 qDeleteAll(m_queue.begin(), m_queue.end());
125 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
126 m_error_queue.clear();
129 void MainWindow::automaticUpdateDialogFinished(int result)
131 qDebug() << __PRETTY_FUNCTION__;
133 if (result == QMessageBox::Yes) {
134 m_settingsDialog->setAutomaticLocationUpdateSettings(true);
135 m_settingsDialog->emitAutomaticLocationUpdateSettings();
138 m_settingsDialog->setAutomaticLocationUpdateSettings(false);
139 m_settingsDialog->emitAutomaticLocationUpdateSettings();
143 void MainWindow::buildFullScreenButton()
145 qDebug() << __PRETTY_FUNCTION__;
147 m_fullScreenButton = new QToolButton(this);
148 m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
149 m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
150 connect(m_fullScreenButton, SIGNAL(clicked()),
151 this, SLOT(toggleFullScreen()));
152 #endif // Q_WS_MAEMO_5
156 void MainWindow::buildFriendListPanel()
158 qDebug() << __PRETTY_FUNCTION__;
160 m_friendsListPanel = new FriendListPanel(this);
161 m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
163 m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
165 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
166 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
168 connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
169 this, SIGNAL(findFriend(QPointF)));
171 connect(m_mapView, SIGNAL(viewResized(QSize)),
172 m_friendsListPanel, SLOT(screenResized(QSize)));
174 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
175 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
177 connect(m_mapView, SIGNAL(viewResized(QSize)),
178 m_friendsListPanelSidebar, SLOT(reDrawSidebar(QSize)));
181 void MainWindow::buildInformationBox(const QString &message, bool modal)
183 qDebug() << __PRETTY_FUNCTION__;
186 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
187 QLabel *label = new QLabel(msgBox);
188 label->setAlignment(Qt::AlignCenter);
189 label->setText(message);
190 msgBox->setWidget(label);
193 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
195 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
198 QMessageBox *msgBox = new QMessageBox(this);
199 msgBox->button(QMessageBox::Ok);
200 msgBox->setText(message);
201 msgBox->setModal(modal);
207 void MainWindow::buildManualLocationCrosshair()
209 qDebug() << __PRETTY_FUNCTION__;
211 m_ownLocationCrosshair = new QLabel(this);
212 QPixmap crosshairImage(":/res/images/sight.png");
213 m_ownLocationCrosshair->setPixmap(crosshairImage);
214 m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
215 m_ownLocationCrosshair->hide();
216 m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
218 connect(m_mapView, SIGNAL(viewResized(QSize)),
219 this, SLOT(drawOwnLocationCrosshair(QSize)));
222 void MainWindow::buildMap()
224 qDebug() << __PRETTY_FUNCTION__;
226 m_mapView = new MapView(this);
228 buildZoomButtonPanel();
230 buildManualLocationCrosshair();
231 buildFullScreenButton();
234 connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
235 this, SIGNAL(mapViewScrolled(QPoint)));
237 connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
238 m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
240 connect(m_mapView, SIGNAL(viewResized(QSize)),
241 this, SIGNAL(mapViewResized(QSize)));
243 connect(m_mapView, SIGNAL(viewResized(QSize)),
244 this, SLOT(drawFullScreenButton(QSize)));
246 connect(m_mapView, SIGNAL(viewResized(QSize)),
247 this, SLOT(drawMapScale(QSize)));
249 connect(m_mapView, SIGNAL(viewResized(QSize)),
250 this, SLOT(setViewPortSize(QSize)));
252 connect(this, SIGNAL(zoomLevelChanged(int)),
253 m_mapView, SLOT(setZoomLevel(int)));
255 connect(m_mapView, SIGNAL(viewZoomFinished()),
256 this, SIGNAL(viewZoomFinished()));
259 void MainWindow::buildMapScale()
261 m_mapScale = new MapScale(this);
262 connect(this, SIGNAL(newMapResolution(qreal)),
263 m_mapScale, SLOT(updateMapResolution(qreal)));
266 void MainWindow::buildOsmLicense()
268 qDebug() << __PRETTY_FUNCTION__;
270 m_osmLicense = new QLabel(this);
271 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
272 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
273 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
274 m_osmLicense->setFont(QFont("Nokia Sans", 9));
275 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
276 m_osmLicense->fontMetrics().height());
278 connect(m_mapView, SIGNAL(viewResized(QSize)),
279 this, SLOT(drawOsmLicense(QSize)));
282 void MainWindow::buildUserInfoPanel()
284 qDebug() << __PRETTY_FUNCTION__;
286 m_userPanel = new UserInfoPanel(this);
287 m_userPanelSidebar = new PanelSideBar(this, LEFT);
289 m_userPanelSidebar->stackUnder(m_friendsListPanel);
290 m_userPanel->stackUnder(m_userPanelSidebar);
292 connect(m_userPanel, SIGNAL(findUser(QPointF)),
293 this, SIGNAL(findUser(QPointF)));
295 connect(this, SIGNAL(userLocationReady(User*)),
296 m_userPanel, SLOT(userDataReceived(User*)));
298 connect(m_userPanel, SIGNAL(requestReverseGeo()),
299 this, SIGNAL(requestReverseGeo()));
301 connect(this, SIGNAL(reverseGeoReady(QString)),
302 m_userPanel, SIGNAL(reverseGeoReady(QString)));
304 connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
305 this, SIGNAL(statusUpdate(QString,bool)));
307 connect(m_userPanel, SIGNAL(refreshUserData()),
308 this, SIGNAL(refreshUserData()));
310 connect(m_mapView, SIGNAL(viewResized(QSize)),
311 m_userPanel, SLOT(screenResized(QSize)));
313 connect(this, SIGNAL(updateWasSuccessful()),
314 m_userPanel, SIGNAL(updateWasSuccessful()));
316 connect(this, SIGNAL(messageSendingFailed(QString)),
317 m_userPanel, SIGNAL(messageSendingFailed(QString)));
319 connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString)),
320 this, SIGNAL(notificateUpdateFailing(QString)));
323 void MainWindow::buildWebView()
325 qDebug() << __PRETTY_FUNCTION__;
328 m_webView = new QWebView;
331 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
333 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
335 connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
336 this, SLOT(webViewRequestFinished(QNetworkReply*)));
337 connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
338 this, SIGNAL(updateCredentials(QUrl)));
339 connect(m_webView, SIGNAL(loadFinished(bool)),
340 this, SLOT(loadDone(bool)));
346 void MainWindow::buildZoomButtonPanel()
348 qDebug() << __PRETTY_FUNCTION__;
350 m_zoomButtonPanel = new ZoomButtonPanel(this);
352 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
353 this, SIGNAL(zoomIn()));
355 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
356 this, SIGNAL(zoomOut()));
358 connect(this, SIGNAL(zoomLevelChanged(int)),
359 m_zoomButtonPanel, SLOT(resetButtons()));
361 connect(this, SIGNAL(maxZoomLevelReached()),
362 m_zoomButtonPanel, SLOT(disableZoomInButton()));
364 connect(this, SIGNAL(minZoomLevelReached()),
365 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
367 connect(m_mapView, SIGNAL(viewResized(QSize)),
368 m_zoomButtonPanel, SLOT(screenResized(QSize)));
371 void MainWindow::clearCookieJar()
373 qDebug() << __PRETTY_FUNCTION__;
378 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
380 QList<QNetworkCookie> emptyList;
383 m_cookieJar->setAllCookies(emptyList);
384 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
387 void MainWindow::createMenus()
389 qDebug() << __PRETTY_FUNCTION__;
392 m_loginAct = new QAction(tr("Login"), this);
393 connect(m_loginAct, SIGNAL(triggered()),
394 this, SIGNAL(loginActionPressed()));
397 m_toSettingsAct = new QAction(tr("Settings"), this);
398 connect(m_toSettingsAct, SIGNAL(triggered()),
399 this, SLOT(openSettingsDialog()));
402 m_gpsToggleAct = new QAction(tr("GPS"), this);
403 m_gpsToggleAct->setCheckable(true);
405 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
406 this, SIGNAL(gpsTriggered(bool)));
408 // automatic centering
409 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
410 m_autoCenteringAct->setCheckable(true);
411 connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
412 this, SIGNAL(autoCenteringTriggered(bool)));
414 // build the actual menu
415 m_viewMenu = menuBar()->addMenu(tr("Main"));
416 m_viewMenu->addAction(m_loginAct);
417 m_viewMenu->addAction(m_toSettingsAct);
418 m_viewMenu->addAction(m_gpsToggleAct);
419 m_viewMenu->addAction(m_autoCenteringAct);
420 m_viewMenu->setObjectName(tr("Menu"));
423 void MainWindow::dialogFinished(int status)
425 qDebug() << __PRETTY_FUNCTION__;
427 QDialog *dialog = m_queue.takeFirst();
428 LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
432 loginDialog->userInput(m_email, m_password);
434 QStringList urlParts;
435 urlParts.append(FACEBOOK_LOGINBASE);
436 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
437 urlParts.append(INTERVAL1);
438 urlParts.append(SITUARE_LOGIN_SUCCESS);
439 urlParts.append(INTERVAL2);
440 urlParts.append(SITUARE_LOGIN_FAILURE);
441 urlParts.append(FACEBOOK_LOGIN_ENDING);
443 emit saveUsername(m_email);
445 m_webView->load(QUrl(urlParts.join(EMPTY)));
446 toggleProgressIndicator(true);
448 emit cancelLoginProcess();
452 dialog->deleteLater();
454 if(!m_error_queue.isEmpty() && m_errorShown == false) {
455 showErrorInformationBox();
457 if(!m_queue.isEmpty()) {
458 showInformationBox();
463 void MainWindow::drawFullScreenButton(const QSize &size)
465 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
467 if(m_fullScreenButton) {
468 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
470 size.height() - m_fullScreenButton->size().height());
474 void MainWindow::drawMapScale(const QSize &size)
476 const int LEFT_SCALE_MARGIN = 10;
477 const int BOTTOM_SCALE_MARGIN = 2;
478 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
480 m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
481 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
484 void MainWindow::drawOsmLicense(const QSize &size)
486 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
488 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
490 size.height() - m_osmLicense->fontMetrics().height());
493 void MainWindow::drawOwnLocationCrosshair(const QSize &size)
495 qDebug() << __PRETTY_FUNCTION__;
497 if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
498 m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
499 size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
503 void MainWindow::errorDialogFinished(int status)
505 qDebug() << __PRETTY_FUNCTION__;
508 QDialog *dialog = m_error_queue.takeFirst();
510 dialog->deleteLater();
511 m_errorShown = false;
513 if(!m_error_queue.isEmpty())
514 showErrorInformationBox();
515 else if(!m_queue.isEmpty())
516 showInformationBox();
519 void MainWindow::gpsTimeout()
521 qDebug() << __PRETTY_FUNCTION__;
523 buildInformationBox(tr("GPS timeout"));
526 void MainWindow::grabZoomKeys(bool grab)
528 qDebug() << __PRETTY_FUNCTION__;
531 // Can't grab keys unless we have a window id
535 unsigned long val = (grab) ? 1 : 0;
536 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
540 XChangeProperty (QX11Info::display(),
546 reinterpret_cast<unsigned char *>(&val),
550 #endif // Q_WS_MAEMO_5
553 void MainWindow::keyPressEvent(QKeyEvent* event)
555 qDebug() << __PRETTY_FUNCTION__;
557 switch (event->key()) {
568 QWidget::keyPressEvent(event);
571 void MainWindow::loadCookies()
573 qDebug() << __PRETTY_FUNCTION__;
575 QSettings settings(DIRECTORY_NAME, FILE_NAME);
577 QStringList list = settings.value(COOKIES, EMPTY).toStringList();
579 if(!list.isEmpty()) {
580 QList<QNetworkCookie> cookieList;
581 for(int i=0;i<list.count();i++) {
582 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
586 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
588 m_cookieJar->setAllCookies(cookieList);
589 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
594 void MainWindow::loadDone(bool done)
596 qDebug() << __PRETTY_FUNCTION__;
598 // for the first time the login page is opened, we need to refresh it to get cookies working
606 QWebFrame* frame = m_webView->page()->currentFrame();
610 QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
612 foreach (QWebElement element, emailCollection) {
613 element.setAttribute("value", m_email.toAscii());
616 QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
617 foreach (QWebElement element, passwordCollection) {
618 element.setAttribute("value", m_password.toAscii());
620 // find connect button
621 QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
622 foreach (QWebElement element, buttonCollection)
624 QPoint pos(element.geometry().center());
626 // send a mouse click event to the web page
627 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
629 QApplication::sendEvent(m_webView->page(), &event0);
630 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
632 QApplication::sendEvent(m_webView->page(), &event1);
638 void MainWindow::loggedIn(bool logged)
640 qDebug() << __PRETTY_FUNCTION__;
645 m_loginAct->setText(tr("Logout"));
651 m_loginAct->setText(tr("Login"));
653 updateItemVisibility(m_loggedIn);
656 void MainWindow::loginFailed()
658 qDebug() << __PRETTY_FUNCTION__;
662 toggleProgressIndicator(false);
667 void MainWindow::loginUsingCookies()
669 qDebug() << __PRETTY_FUNCTION__;
674 QStringList urlParts;
675 urlParts.append(FACEBOOK_LOGINBASE);
676 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
677 urlParts.append(INTERVAL1);
678 urlParts.append(SITUARE_LOGIN_SUCCESS);
679 urlParts.append(INTERVAL2);
680 urlParts.append(SITUARE_LOGIN_FAILURE);
681 urlParts.append(FACEBOOK_LOGIN_ENDING);
683 m_webView->load(QUrl(urlParts.join(EMPTY)));
687 void MainWindow::openSettingsDialog()
689 qDebug() << __PRETTY_FUNCTION__;
691 m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
692 m_settingsDialog->readSettings();
693 m_settingsDialog->show();
696 void MainWindow::requestAutomaticLocationUpdateSettings()
698 qDebug() << __PRETTY_FUNCTION__;
700 m_settingsDialog->emitAutomaticLocationUpdateSettings();
703 void MainWindow::queueDialog(QDialog *dialog)
705 qDebug() << __PRETTY_FUNCTION__;
707 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
708 if(dialog->isModal()) {
709 m_error_queue.append(dialog);
711 m_queue.append(dialog);
714 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
715 if(m_error_queue.count() == 1 && m_errorShown == false)
716 showErrorInformationBox();
717 else if(m_queue.count() == 1 && m_errorShown == false)
718 showInformationBox();
721 void MainWindow::saveCookies()
723 qDebug() << __PRETTY_FUNCTION__;
726 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
728 QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
731 for(int i=0;i<cookieList.count();i++) {
732 QNetworkCookie cookie = cookieList.at(i);
733 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
734 list.append(QString(byteArray));
736 list.removeDuplicates();
738 QSettings settings(DIRECTORY_NAME, FILE_NAME);
739 settings.setValue(COOKIES, list);
742 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
744 qDebug() << __PRETTY_FUNCTION__;
746 m_autoCenteringAct->setChecked(enabled);
749 void MainWindow::setGPSButtonEnabled(bool enabled)
751 qDebug() << __PRETTY_FUNCTION__;
753 m_gpsToggleAct->setChecked(enabled);
756 setOwnLocationCrosshairVisibility(!enabled);
758 m_autoCenteringAct->setVisible(enabled);
761 void MainWindow::setMapViewScene(QGraphicsScene *scene)
763 qDebug() << __PRETTY_FUNCTION__;
765 m_mapView->setScene(scene);
768 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
770 qDebug() << __PRETTY_FUNCTION__;
773 m_ownLocationCrosshair->show();
774 m_drawOwnLocationCrosshair = true;
775 drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
777 m_ownLocationCrosshair->hide();
778 m_drawOwnLocationCrosshair = false;
782 void MainWindow::setUsername(const QString &username)
784 qDebug() << __PRETTY_FUNCTION__;
789 void MainWindow::setViewPortSize(const QSize &size)
791 qDebug() << __PRETTY_FUNCTION__;
793 m_viewPortWidth = size.width();
794 m_viewPortHeight = size.height();
797 bool MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
799 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
800 tr("Automatic location update"), text,
801 QMessageBox::Yes | QMessageBox::No |
802 QMessageBox::Cancel, this);
803 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
804 this, SLOT(automaticUpdateDialogFinished(int)));
805 m_automaticUpdateLocationDialog->show();
808 void MainWindow::toggleFullScreen()
810 qDebug() << __PRETTY_FUNCTION__;
812 if(windowState() == Qt::WindowNoState)
818 void MainWindow::showErrorInformationBox()
820 qDebug() << __PRETTY_FUNCTION__;
822 if(m_error_queue.count()) {
824 QDialog *dialog = m_error_queue.first();
825 connect(dialog, SIGNAL(finished(int)),
826 this, SLOT(errorDialogFinished(int)));
831 void MainWindow::showInformationBox()
833 qDebug() << __PRETTY_FUNCTION__;
835 if(m_queue.count()) {
836 QDialog *dialog = m_queue.first();
837 connect(dialog, SIGNAL(finished(int)),
838 this, SLOT(dialogFinished(int)));
843 void MainWindow::startLoginProcess()
845 qDebug() << __PRETTY_FUNCTION__;
847 LoginDialog *loginDialog = new LoginDialog();
849 emit fetchUsernameFromSettings();
851 loginDialog->clearTextFields();
853 if(!m_email.isEmpty())
854 loginDialog->setEmailField(m_email);
856 queueDialog(loginDialog);
859 void MainWindow::toggleProgressIndicator(bool value)
861 qDebug() << __PRETTY_FUNCTION__;
864 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
867 #endif // Q_WS_MAEMO_5
870 void MainWindow::updateItemVisibility(bool show)
872 qDebug() << __PRETTY_FUNCTION__;
875 m_friendsListPanel->show();
876 m_friendsListPanelSidebar->show();
878 m_userPanelSidebar->show();
880 if(m_drawOwnLocationCrosshair) {
881 m_ownLocationCrosshair->show();
882 setGPSButtonEnabled(false);
883 emit gpsTriggered(false);
886 m_friendsListPanel->closePanel();
887 m_friendsListPanel->hide();
888 m_friendsListPanelSidebar->hide();
889 m_userPanel->closePanel();
891 m_userPanelSidebar->hide();
892 m_ownLocationCrosshair->hide();
896 const QString MainWindow::username()
898 qDebug() << __PRETTY_FUNCTION__;
903 void MainWindow::webViewRequestFinished(QNetworkReply *reply)
905 qDebug() << __PRETTY_FUNCTION__;
908 qDebug() << reply->error() << reply->errorString();
909 toggleProgressIndicator(false);