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 Sami Rämö - sami.ramo@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include <QtGui/QMainWindow>
30 #include "network/networkcookiejar.h"
31 #include "panelsidebar.h"
38 class FacebookAuthentication;
39 class FriendListPanel;
45 class ZoomButtonPanel;
50 * @brief Main Window Class
52 class MainWindow : public QMainWindow
60 * @param parent Parent
62 MainWindow(QWidget *parent = 0);
70 /*******************************************************************************
71 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
72 ******************************************************************************/
75 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
77 void keyPressEvent(QKeyEvent* event);
79 /*******************************************************************************
80 * MEMBER FUNCTIONS AND SLOTS
81 ******************************************************************************/
84 * @brief Sets automatic location update enabled from settings dialog.
86 * @param enabled true if enabled, false otherwise
88 void automaticLocationUpdateEnabled(bool enabled);
91 * @brief Builds information box with message.
93 * @param message Information message
94 * @param modal Modal = true, non-modal false
96 void buildInformationBox(const QString &message, bool modal=false);
99 * @brief Clears cookie jar
102 void clearCookieJar();
109 void loggedIn(bool logged);
112 * @brief Requests automatic location update settings.
114 void requestAutomaticLocationUpdateSettings();
118 * @brief Enable / disable auto centering button.
120 * @param enabled true if shoud be enabled, false otherwise
122 void setAutoCenteringButtonEnabled(bool enabled);
125 * @brief Enable / disable GPS button.
127 * Does set visibilities for manual location cursor and auto centering menu button.
129 * @param enabled true if enabled, false otherwise
131 void setGPSButtonEnabled(bool enabled);
134 * @brief Set scene for MapView
136 * @param scene Scene to be set
138 void setMapViewScene(QGraphicsScene *scene);
141 * Shows dialog with enable automatic location update question.
143 * @param text text to show in dialog
144 * @return true if accepted, false otherwise
146 bool showEnableAutomaticUpdateLocationDialog(const QString &text);
149 * @brief Gets the username from member variable for saving purposes
151 * @return QString Username
153 const QString username();
157 * @brief Slot to intercept signal when login has failed (loginFailure signal)
163 * @brief Slot to intercept signal when login with cookies is requested
166 void loginUsingCookies();
169 * @brief Public slot, which open settings dialog
171 void openSettingsDialog();
174 * @brief Sets username to member variable for login dialog
176 * @param username Username to be set
178 void setUsername(const QString &username);
181 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
185 void startLoginProcess();
188 * @brief Toggle progress indicator.
190 * @param state true if progress indicator should be shown, false otherwise
192 void toggleProgressIndicator(bool state);
195 * @brief Shows / hides Situare related UI items
199 void updateItemVisibility(bool show);
203 * @brief Build fullscreen toggle button and connect slots
205 void buildFullScreenButton();
208 * @brief Build friend list panel and connect slots
210 void buildFriendListPanel();
213 * @brief Build manual location setting cross hair and connect slots
215 void buildManualLocationCrosshair();
218 * @brief Build map and connect slots
223 * @brief Build OSM license and connect slots
225 void buildOsmLicense();
228 * @brief Build user info panel and connect slots
230 void buildUserInfoPanel();
233 * @brief Build webview and connect slots
239 * @brief Build zoom button panel and connect slots
241 void buildZoomButtonPanel();
244 * @brief Private method to create the Menu items
249 * @brief Grab or release HW increase and decrease buttons.
251 * @param grab Use true for grabbing and false for releasing the keys
253 void grabZoomKeys(bool grab);
256 * @brief Queues dialog/information box
258 * @param dialog Dialog to be added into queue
260 void queueDialog(QDialog *dialog);
263 * @brief Set own location crosshair visibility
267 void setOwnLocationCrosshairVisibility(bool visible);
270 * @brief Shows queued error information box
273 void showErrorInformationBox();
276 * @brief Shows queued information box
278 * @fn showInformationBox
280 void showInformationBox();
284 * @brief Slot to intercept signal when dialog/information note is processed
286 * @param status Status of the dialog
288 void dialogFinished(int status);
291 * @brief Slot for drawing the fullscreen toggle button
293 * @param size Size of the screen
295 void drawFullScreenButton(const QSize &size);
298 * @brief Slot for drawing the Open Street Map license text
300 * @param size Size of the screen
302 void drawOsmLicense(const QSize &size);
305 * @brief Slot for drawing the own location crosshair
307 * @param width Width of the viewport
308 * @param height Height of the viewport
310 void drawOwnLocationCrosshair(int width, int height);
313 * @brief Slot to intercept signal when error dialog/information note is processed
315 * @param status Status of the dialog
317 void errorDialogFinished(int status);
320 * @brief Slot for gps timeout.
322 * Called when request timeout occurs.
327 * @brief Slot to load cookies from settings
333 * @brief Slot to intercept signal when webview has finished loading webpage
335 * @param done Status of the loading
337 void loadDone(bool done);
340 * @brief Slot to save cookies to settings
346 * @brief Set correnct view port size to datamembers
348 * @param width Width of the viewport
349 * @param height Height of the viewport
351 void setViewPortSize(const int width, const int height);
354 * @brief Toggle between fullscreen and normal window mode
356 void toggleFullScreen();
359 * @brief Slot to intercept signal from webview's networkaccessmanager
361 * @param reply Network reply (contains errors)
363 void webViewRequestFinished(QNetworkReply* reply);
365 /*******************************************************************************
367 ******************************************************************************/
370 * @brief Automatic centering setting changed by user
372 * @param enabled True if automatic centering is enabled, otherwise false
374 void autoCenteringTriggered(bool enabled);
377 * @brief Signal that indicates when user has cancelled login process
380 void cancelLoginProcess();
383 * @brief View should be centered to new location
385 * @param sceneCoordinate Scene coordinates of the new center point
387 void centerToSceneCoordinates(QPoint sceneCoordinate);
390 * @brief Signal for enabling automatic location update.
392 * @param enabled true if enabled, false otherwise
393 * @param updateIntervalMsecs update interval in milliseconds
395 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
398 * @brief Signal for requesting username from settings
401 void fetchUsernameFromSettings();
404 * @brief Signal for finding user.
406 * @param coordinates user geo coordinates
408 void findUser(const QPointF &coordinates);
411 * @brief GPS setting changed
413 * @param enabled True if GPS is enabled, otherwise false
415 void gpsTriggered(bool enabled);
418 * @brief Signal for finding friend.
420 * @param coordinates friend's geo coordinates
422 void findFriend(const QPointF &coordinates);
425 * @brief Signal for friend location ready.
429 void friendsLocationsReady(QList<User *> &friendsList);
432 * @brief Signal is emitted when location item is clicked.
434 * @param userIDs list of friends user IDs in the group
436 void locationItemClicked(const QList<QString> &userIDs);
439 * @brief Signals when Login/Logout action is pressed
442 void loginActionPressed();
445 * @brief MapView has been resized
447 * @param size view size
449 void mapViewResized(const QSize &size);
452 * @brief Forwarding signal from MapView to MapEngine
454 * @param sceneCoordinate
456 void mapViewScrolled(QPoint sceneCoordinate);
459 * @brief Forwarding signal from MapEngine to MapView
461 void maxZoomLevelReached();
464 * @brief Signal that informs that user's message/location failed to update on Situare server
465 * This signal is originally sended from SituareService with name error
466 * Signal is renamed on MainWindow
468 void messageSendingFailed(const QString &error);
471 * @brief Forwarding signal from MapEngine to MapView
473 void minZoomLevelReached();
476 * @brief Signal that used to inform user that his message/location update tp Situare server
478 * This signal is originally sended from UserInfo
480 void notificateUpdateFailing(const QString &message);
483 * @brief Signal for refreshing user data.
486 void refreshUserData();
489 * @brief Signal for requesting reverseGeo from SituareEngine
492 void requestReverseGeo();
495 * @brief Signals, when address data is ready
497 * @param address Street address
499 void reverseGeoReady(const QString &address);
502 * @brief Signal to save username to settings
504 * @param username Username
506 void saveUsername(const QString &username);
509 * @brief Signal for requestLocationUpdate from SituareEngine
511 * @param status Status message
512 * @param publish Publish on Facebook
514 void statusUpdate(const QString &status, const bool &publish);
517 * @brief Signals when webview's urlChanged signal is emitted
521 void updateCredentials(const QUrl &url);
524 * @brief Signals when updateLocation request finished successfully
527 void updateWasSuccessful();
530 * @brief MapView has finished zooming
532 void viewZoomFinished();
535 * @brief Signal for use location ready.
537 * @param user User object
539 void userLocationReady(User *user);
542 * @brief Map zoom in request
547 * @brief Forwarding signal from MapEngine to MapView
549 void zoomLevelChanged(int zoomLevel);
552 * @brief Map zoom out request
556 /*******************************************************************************
558 ******************************************************************************/
560 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
561 bool m_errorShown; ///< Indicates if error dialog/note is shown
562 bool m_loggedIn; ///< Indicates login state
563 bool m_refresh; ///< Indicates when webpage is refreshed
565 int m_viewPortHeight; ///< Height of view port
566 int m_viewPortWidth; ///< Width of view port
568 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
569 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
570 QAction *m_loginAct; ///< Action to Login/Logout
571 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
573 QLabel *m_osmLicense; ///< Label for Open Street Map license
574 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
576 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
577 QList<QDialog *> m_queue; ///< QList type dialog queue
579 QMenu *m_viewMenu; ///< Object that hold the view menu items
581 QString m_email; ///< Placeholder for email
582 QString m_password; ///< Placeholder for password
584 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
586 QWebView *m_webView; ///< Shows facebook login page
588 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
589 MapView *m_mapView; ///< Instance of the map view
590 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
591 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
592 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
593 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
594 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
596 SettingsDialog *m_settingsDialog; ///< Settings dialog
600 #endif // MAINWINDOW_H