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"
40 class FacebookAuthentication;
41 class FullScreenButton;
42 class FriendListPanel;
48 class SceneCoordinate;
52 class ZoomButtonPanel;
56 * @brief Main Window Class
58 class MainWindow : public QMainWindow
66 * @param parent Parent
68 MainWindow(QWidget *parent = 0);
76 /*******************************************************************************
77 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
78 ******************************************************************************/
81 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
83 void keyPressEvent(QKeyEvent* event);
85 /*******************************************************************************
86 * MEMBER FUNCTIONS AND SLOTS
87 ******************************************************************************/
90 * @brief Clears cookie jar
93 void clearCookieJar();
100 void loggedIn(bool logged);
103 * @brief Gets the login state (logged in/logged out)
105 * @return bool Login state
110 * @brief Reads automatic location update settings.
112 void readAutomaticLocationUpdateSettings();
115 * @brief Enable / disable auto centering button.
117 * @param enabled true if shoud be enabled, false otherwise
119 void setAutoCenteringButtonEnabled(bool enabled);
122 * @brief Enable / disable GPS button.
124 * Does set visibilities for manual location cursor and auto centering menu button.
126 * @param enabled true if enabled, false otherwise
128 void setGPSButtonEnabled(bool enabled);
131 * @brief Set scene for MapView
133 * @param scene Scene to be set
135 void setMapViewScene(QGraphicsScene *scene);
138 * Shows dialog with enable automatic location update question.
140 * @param text text to show in dialog
142 void showEnableAutomaticUpdateLocationDialog(const QString &text);
145 * @brief Gets the username from member variable for saving purposes
147 * @return QString Username
149 const QString username();
153 * @brief Builds information box with message.
155 * @param message Information message
156 * @param modal Modal = true, non-modal false
158 void buildInformationBox(const QString &message, bool modal=false);
161 * @brief Slot for failed login
167 * @brief Slot to intercept signal when login with cookies is requested
170 void loginUsingCookies();
173 * @brief Public slot, which open settings dialog
175 void openSettingsDialog();
178 * @brief Set own location crosshair visibility
182 void setOwnLocationCrosshairVisibility(bool visible);
185 * @brief Sets username to member variable for login dialog
187 * @param username Username to be set
189 void setUsername(const QString &username);
192 * @brief Method to show panels
198 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
202 void startLoginProcess();
205 * @brief Toggle progress indicator.
207 * @param state true if progress indicator should be shown, false otherwise
209 void toggleProgressIndicator(bool state);
212 * @brief Shows / hides Situare related UI items
215 void updateItemVisibility();
219 * @brief Build fullscreen toggle button and connect slots
221 void buildFullScreenButton();
224 * @brief Build friend list panel and connect slots
226 void buildFriendListPanel();
229 * @brief Build manual location setting cross hair and connect slots
231 void buildManualLocationCrosshair();
234 * @brief Build map and connect slots
239 * @brief Build map scale and connect slots
241 void buildMapScale();
244 * @brief Build OSM license and connect slots
246 void buildOsmLicense();
249 * @brief Build user info panel and connect slots
251 void buildUserInfoPanel();
254 * @brief Build webview and connect slots
260 * @brief Build zoom button panel and connect slots
262 void buildZoomButtonPanel();
265 * @brief Private method to create the Menu items
270 * @brief Grab or release HW increase and decrease buttons.
272 * @param grab Use true for grabbing and false for releasing the keys
274 void grabZoomKeys(bool grab);
277 * @brief Queues dialog/information box
279 * @param dialog Dialog to be added into queue
281 void queueDialog(QDialog *dialog);
284 * @brief Shows queued error information box
287 void showErrorInformationBox();
290 * @brief Shows queued information box
292 * @fn showInformationBox
294 void showInformationBox();
298 * @brief Slot for automatic update dialog finished.
300 * @result result code
302 void automaticUpdateDialogFinished(int result);
305 * @brief Slot to intercept signal when dialog/information note is processed
307 * @param status Status of the dialog
309 void dialogFinished(int status);
312 * @brief Slot for drawing the fullscreen toggle button
314 * @param size Size of the screen
316 void drawFullScreenButton(const QSize &size);
319 * @brief Slot for drawing the map distance scale
321 * @param size Size of the screen
323 void drawMapScale(const QSize &size);
326 * @brief Slot for drawing the Open Street Map license text
328 * @param size Size of the screen
330 void drawOsmLicense(const QSize &size);
333 * @brief Slot for drawing the own location crosshair
335 * @param size Size of the screen
337 void drawOwnLocationCrosshair(const QSize &size);
340 * @brief Slot to intercept signal when error dialog/information note is processed
342 * @param status Status of the dialog
344 void errorDialogFinished(int status);
347 * @brief Slot for gps timeout.
349 * Called when request timeout occurs.
354 * @brief Slot to load cookies from settings
360 * @brief Slot to intercept signal when webview has finished loading webpage
362 * @param done Status of the loading
364 void loadDone(bool done);
367 * @brief Slot to save cookies to settings
373 * @brief Slot for settings dialog accepted.
375 void settingsDialogAccepted();
378 * @brief Set correnct view port size to datamembers
380 * @param size Size of the screen
382 void setViewPortSize(const QSize &size);
385 * @brief Toggle between fullscreen and normal window mode
387 void toggleFullScreen();
390 * @brief Slot to intercept signal from webview's networkaccessmanager
392 * @param reply Network reply (contains errors)
394 void webViewRequestFinished(QNetworkReply* reply);
396 /*******************************************************************************
398 ******************************************************************************/
401 * @brief Automatic centering setting changed by user
403 * @param enabled True if automatic centering is enabled, otherwise false
405 void autoCenteringTriggered(bool enabled);
408 * @brief Signal that indicates when user has cancelled login process
411 void cancelLoginProcess();
414 * @brief View should be centered to new location
416 * @param sceneCoordinate Scene coordinates of the new center point
418 void centerToSceneCoordinates(const SceneCoordinate &sceneCoordinate);
421 * @brief Signal for enabling automatic location update.
423 * @param enabled true if enabled, false otherwise
424 * @param updateIntervalMsecs update interval in milliseconds
426 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
429 * @brief Signals error
431 * @param context error context
432 * @param error error code
434 void error(const int context, const int error);
437 * @brief Signal for requesting username from settings
440 void fetchUsernameFromSettings();
443 * @brief Signal for finding user.
445 * @param coordinates user geo coordinates
447 void findUser(const GeoCoordinate &coordinates);
450 * @brief Signals when friend's profile image is ready
454 void friendImageReady(User *user);
457 * @brief GPS setting changed
459 * @param enabled True if GPS is enabled, otherwise false
461 void gpsTriggered(bool enabled);
464 * @brief Signal for finding friend.
466 * @param coordinates friend's geo coordinates
468 void findFriend(const GeoCoordinate &coordinates);
471 * @brief Signal for friend location ready.
475 void friendsLocationsReady(QList<User *> &friendsList);
478 * @brief Signal is emitted when location item is clicked.
480 * @param userIDs list of friends user IDs in the group
482 void locationItemClicked(const QList<QString> &userIDs);
485 * @brief Signals when Login/Logout action is pressed
488 void loginActionPressed();
491 * @brief MapView has been resized
493 * @param size view size
495 void mapViewResized(const QSize &size);
498 * @brief Forwarding signal from MapView to MapEngine
500 * @param sceneCoordinate
502 void mapViewScrolled(const SceneCoordinate &sceneCoordinate);
505 * @brief Forwarding signal from MapEngine to MapView
507 void maxZoomLevelReached();
510 * @brief Forwarding signal from MapEngine to MapView
512 void minZoomLevelReached();
515 * @brief Forwarding signal from MapEngine to MapScale
517 void newMapResolution(qreal scale);
520 * @brief Signal for refreshing user data.
523 void refreshUserData();
526 * @brief Signal for requesting reverseGeo from SituareEngine
529 void requestReverseGeo();
532 * @brief Signals, when address data is ready
534 * @param address Street address
536 void reverseGeoReady(const QString &address);
539 * @brief Signal to save username to settings
541 * @param username Username
543 void saveUsername(const QString &username);
546 * @brief Signal for requestLocationUpdate from SituareEngine
548 * @param status Status message
549 * @param publish Publish on Facebook
551 void statusUpdate(const QString &status, const bool &publish);
554 * @brief Signals when webview's urlChanged signal is emitted
558 void updateCredentials(const QUrl &url);
561 * @brief Signals when updateLocationDialog's data must be cleared
564 void clearUpdateLocationDialogData();
567 * @brief MapView has finished zooming
569 void viewZoomFinished();
572 * @brief Signal for use location ready.
574 * @param user User object
576 void userLocationReady(User *user);
579 * @brief Map zoom in request
584 * @brief Forwarding signal from MapEngine to MapView
586 void zoomLevelChanged(int zoomLevel);
589 * @brief Map zoom out request
593 /*******************************************************************************
595 ******************************************************************************/
597 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
598 bool m_errorShown; ///< Indicates if error dialog/note is shown
599 bool m_loggedIn; ///< Indicates login state
600 bool m_refresh; ///< Indicates when webpage is refreshed
602 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
604 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
605 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
606 QAction *m_loginAct; ///< Action to Login/Logout
607 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
609 QLabel *m_osmLicense; ///< Label for Open Street Map license
610 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
612 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
613 QList<QDialog *> m_queue; ///< QList type dialog queue
615 QMenu *m_viewMenu; ///< Object that hold the view menu items
617 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
619 QSize m_viewPortSize; ///< Size of the viewport
621 QString m_email; ///< Placeholder for email
622 QString m_password; ///< Placeholder for password
624 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
626 QWebView *m_webView; ///< Shows facebook login page
628 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
629 MapScale *m_mapScale; ///< Instance of the map scale
630 MapView *m_mapView; ///< Instance of the map view
631 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
632 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
633 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
634 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
635 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
638 #endif // MAINWINDOW_H