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(updateWasSuccessful()),
326 m_userPanel, SIGNAL(updateWasSuccessful()));
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__;
390 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
392 QList<QNetworkCookie> emptyList;
395 m_cookieJar->setAllCookies(emptyList);
396 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
399 void MainWindow::createMenus()
401 qDebug() << __PRETTY_FUNCTION__;
404 m_loginAct = new QAction(tr("Login"), this);
405 connect(m_loginAct, SIGNAL(triggered()),
406 this, SIGNAL(loginActionPressed()));
409 m_toSettingsAct = new QAction(tr("Settings"), this);
410 connect(m_toSettingsAct, SIGNAL(triggered()),
411 this, SLOT(openSettingsDialog()));
414 m_gpsToggleAct = new QAction(tr("GPS"), this);
415 m_gpsToggleAct->setCheckable(true);
417 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
418 this, SIGNAL(gpsTriggered(bool)));
420 // automatic centering
421 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
422 m_autoCenteringAct->setCheckable(true);
423 connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
424 this, SIGNAL(autoCenteringTriggered(bool)));
426 // build the actual menu
427 m_viewMenu = menuBar()->addMenu(tr("Main"));
428 m_viewMenu->addAction(m_loginAct);
429 m_viewMenu->addAction(m_toSettingsAct);
430 m_viewMenu->addAction(m_gpsToggleAct);
431 m_viewMenu->addAction(m_autoCenteringAct);
432 m_viewMenu->setObjectName(tr("Menu"));
435 void MainWindow::dialogFinished(int status)
437 qDebug() << __PRETTY_FUNCTION__;
439 QDialog *dialog = m_queue.takeFirst();
440 LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
444 loginDialog->userInput(m_email, m_password);
446 QStringList urlParts;
447 urlParts.append(FACEBOOK_LOGINBASE);
448 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
449 urlParts.append(INTERVAL1);
450 urlParts.append(SITUARE_LOGIN_SUCCESS);
451 urlParts.append(INTERVAL2);
452 urlParts.append(SITUARE_LOGIN_FAILURE);
453 urlParts.append(FACEBOOK_LOGIN_ENDING);
455 emit saveUsername(m_email);
457 m_webView->load(QUrl(urlParts.join(EMPTY)));
458 toggleProgressIndicator(true);
460 emit cancelLoginProcess();
464 dialog->deleteLater();
466 if(!m_error_queue.isEmpty() && m_errorShown == false) {
467 showErrorInformationBox();
469 if(!m_queue.isEmpty()) {
470 showInformationBox();
475 void MainWindow::drawFullScreenButton(const QSize &size)
477 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
479 if(m_fullScreenButton) {
480 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
482 size.height() - m_fullScreenButton->size().height());
486 void MainWindow::drawMapScale(const QSize &size)
488 const int LEFT_SCALE_MARGIN = 10;
489 const int BOTTOM_SCALE_MARGIN = 2;
490 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
492 m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
493 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
496 void MainWindow::drawOsmLicense(const QSize &size)
498 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
500 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
502 size.height() - m_osmLicense->fontMetrics().height());
505 void MainWindow::drawOwnLocationCrosshair(const QSize &size)
507 qDebug() << __PRETTY_FUNCTION__;
509 if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
510 m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
511 size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
515 void MainWindow::errorDialogFinished(int status)
517 qDebug() << __PRETTY_FUNCTION__;
520 QDialog *dialog = m_error_queue.takeFirst();
522 dialog->deleteLater();
523 m_errorShown = false;
525 if(!m_error_queue.isEmpty())
526 showErrorInformationBox();
527 else if(!m_queue.isEmpty())
528 showInformationBox();
531 void MainWindow::gpsTimeout()
533 qDebug() << __PRETTY_FUNCTION__;
535 buildInformationBox(tr("GPS timeout"));
538 void MainWindow::grabZoomKeys(bool grab)
540 qDebug() << __PRETTY_FUNCTION__;
543 // Can't grab keys unless we have a window id
547 unsigned long val = (grab) ? 1 : 0;
548 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
552 XChangeProperty (QX11Info::display(),
558 reinterpret_cast<unsigned char *>(&val),
562 #endif // Q_WS_MAEMO_5
565 void MainWindow::keyPressEvent(QKeyEvent* event)
567 qDebug() << __PRETTY_FUNCTION__;
569 switch (event->key()) {
580 QWidget::keyPressEvent(event);
583 void MainWindow::loadCookies()
585 qDebug() << __PRETTY_FUNCTION__;
587 QSettings settings(DIRECTORY_NAME, FILE_NAME);
589 QStringList list = settings.value(COOKIES, EMPTY).toStringList();
591 if(!list.isEmpty()) {
592 QList<QNetworkCookie> cookieList;
593 for(int i=0;i<list.count();i++) {
594 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
598 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
600 m_cookieJar->setAllCookies(cookieList);
601 m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
606 void MainWindow::loadDone(bool done)
608 qDebug() << __PRETTY_FUNCTION__;
610 // for the first time the login page is opened, we need to refresh it to get cookies working
618 QWebFrame* frame = m_webView->page()->currentFrame();
622 QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
624 foreach (QWebElement element, emailCollection) {
625 element.setAttribute("value", m_email.toAscii());
628 QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
629 foreach (QWebElement element, passwordCollection) {
630 element.setAttribute("value", m_password.toAscii());
632 // find connect button
633 QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
634 foreach (QWebElement element, buttonCollection)
636 QPoint pos(element.geometry().center());
638 // send a mouse click event to the web page
639 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
641 QApplication::sendEvent(m_webView->page(), &event0);
642 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
644 QApplication::sendEvent(m_webView->page(), &event1);
650 void MainWindow::loggedIn(bool logged)
652 qDebug() << __PRETTY_FUNCTION__;
657 m_loginAct->setText(tr("Logout"));
663 m_loginAct->setText(tr("Login"));
665 updateItemVisibility(m_loggedIn);
668 void MainWindow::loginFailed()
670 qDebug() << __PRETTY_FUNCTION__;
674 toggleProgressIndicator(false);
679 void MainWindow::loginUsingCookies()
681 qDebug() << __PRETTY_FUNCTION__;
686 QStringList urlParts;
687 urlParts.append(FACEBOOK_LOGINBASE);
688 urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
689 urlParts.append(INTERVAL1);
690 urlParts.append(SITUARE_LOGIN_SUCCESS);
691 urlParts.append(INTERVAL2);
692 urlParts.append(SITUARE_LOGIN_FAILURE);
693 urlParts.append(FACEBOOK_LOGIN_ENDING);
695 m_webView->load(QUrl(urlParts.join(EMPTY)));
699 void MainWindow::openSettingsDialog()
701 qDebug() << __PRETTY_FUNCTION__;
703 m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
704 m_settingsDialog->readSettings();
705 m_settingsDialog->show();
708 void MainWindow::requestAutomaticLocationUpdateSettings()
710 qDebug() << __PRETTY_FUNCTION__;
712 m_settingsDialog->readSettings();
713 m_settingsDialog->emitAutomaticLocationUpdateSettings();
716 void MainWindow::queueDialog(QDialog *dialog)
718 qDebug() << __PRETTY_FUNCTION__;
720 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
721 if(dialog->isModal()) {
722 m_error_queue.append(dialog);
724 m_queue.append(dialog);
727 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
728 if(m_error_queue.count() == 1 && m_errorShown == false)
729 showErrorInformationBox();
730 else if(m_queue.count() == 1 && m_errorShown == false)
731 showInformationBox();
734 void MainWindow::saveCookies()
736 qDebug() << __PRETTY_FUNCTION__;
739 m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
741 QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
744 for(int i=0;i<cookieList.count();i++) {
745 QNetworkCookie cookie = cookieList.at(i);
746 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
747 list.append(QString(byteArray));
749 list.removeDuplicates();
751 QSettings settings(DIRECTORY_NAME, FILE_NAME);
752 settings.setValue(COOKIES, list);
755 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
757 qDebug() << __PRETTY_FUNCTION__;
759 m_autoCenteringAct->setChecked(enabled);
762 void MainWindow::setGPSButtonEnabled(bool enabled)
764 qDebug() << __PRETTY_FUNCTION__;
766 m_gpsToggleAct->setChecked(enabled);
769 setOwnLocationCrosshairVisibility(!enabled);
771 m_autoCenteringAct->setVisible(enabled);
774 void MainWindow::setMapViewScene(QGraphicsScene *scene)
776 qDebug() << __PRETTY_FUNCTION__;
778 m_mapView->setScene(scene);
781 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
783 qDebug() << __PRETTY_FUNCTION__;
785 if (visibility && m_loggedIn) {
786 m_ownLocationCrosshair->show();
787 m_drawOwnLocationCrosshair = true;
788 drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
790 m_ownLocationCrosshair->hide();
791 m_drawOwnLocationCrosshair = false;
795 void MainWindow::setUsername(const QString &username)
797 qDebug() << __PRETTY_FUNCTION__;
802 void MainWindow::setViewPortSize(const QSize &size)
804 qDebug() << __PRETTY_FUNCTION__;
806 m_viewPortWidth = size.width();
807 m_viewPortHeight = size.height();
810 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
812 qDebug() << __PRETTY_FUNCTION__;
814 m_automaticUpdateLocationDialog->setText(text);
815 m_automaticUpdateLocationDialog->show();
818 void MainWindow::toggleFullScreen()
820 qDebug() << __PRETTY_FUNCTION__;
822 if(windowState() == Qt::WindowNoState)
828 void MainWindow::showErrorInformationBox()
830 qDebug() << __PRETTY_FUNCTION__;
832 if(m_error_queue.count()) {
834 QDialog *dialog = m_error_queue.first();
835 connect(dialog, SIGNAL(finished(int)),
836 this, SLOT(errorDialogFinished(int)));
841 void MainWindow::showInformationBox()
843 qDebug() << __PRETTY_FUNCTION__;
845 if(m_queue.count()) {
846 QDialog *dialog = m_queue.first();
847 connect(dialog, SIGNAL(finished(int)),
848 this, SLOT(dialogFinished(int)));
853 void MainWindow::startLoginProcess()
855 qDebug() << __PRETTY_FUNCTION__;
857 LoginDialog *loginDialog = new LoginDialog();
859 emit fetchUsernameFromSettings();
861 loginDialog->clearTextFields();
863 if(!m_email.isEmpty())
864 loginDialog->setEmailField(m_email);
866 queueDialog(loginDialog);
869 void MainWindow::toggleProgressIndicator(bool value)
871 qDebug() << __PRETTY_FUNCTION__;
874 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
877 #endif // Q_WS_MAEMO_5
880 void MainWindow::updateItemVisibility(bool show)
882 qDebug() << __PRETTY_FUNCTION__;
884 setOwnLocationCrosshairVisibility(show);
887 m_friendsListPanel->show();
888 m_friendsListPanelSidebar->show();
890 m_userPanelSidebar->show();
893 m_friendsListPanel->closePanel();
894 m_friendsListPanel->hide();
895 m_friendsListPanelSidebar->hide();
896 m_userPanel->closePanel();
898 m_userPanelSidebar->hide();
902 const QString MainWindow::username()
904 qDebug() << __PRETTY_FUNCTION__;
909 void MainWindow::webViewRequestFinished(QNetworkReply *reply)
911 qDebug() << __PRETTY_FUNCTION__;
914 emit error(reply->error());
915 toggleProgressIndicator(false);