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;
43 class IndicatorButton;
49 class SceneCoordinate;
53 class ZoomButtonPanel;
57 * @brief Main Window Class
59 class MainWindow : public QMainWindow
67 * @param parent Parent
69 MainWindow(QWidget *parent = 0);
77 /*******************************************************************************
78 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
79 ******************************************************************************/
82 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
84 void keyPressEvent(QKeyEvent* event);
86 /*******************************************************************************
87 * MEMBER FUNCTIONS AND SLOTS
88 ******************************************************************************/
91 * @brief Clears cookie jar
94 void clearCookieJar();
101 void loggedIn(bool logged);
104 * @brief Gets the login state (logged in/logged out)
106 * @return bool Login state
111 * @brief Reads automatic location update settings.
113 void readAutomaticLocationUpdateSettings();
116 // * @brief Enable / disable auto centering button.
118 // * @param enabled true if shoud be enabled, false otherwise
120 // void setAutoCenteringButtonEnabled(bool enabled);
123 * @brief Enable / disable GPS button.
125 * Does set visibilities for manual location cursor and auto centering menu button.
127 * @param enabled true if enabled, false otherwise
129 void setGPSButtonEnabled(bool enabled);
132 * @brief Enable / disable direction indicator button.
134 * @param enabled true if shoud be enabled, false otherwise
136 void setIndicatorButtonEnabled(bool enabled);
139 * @brief Set scene for MapView
141 * @param scene Scene to be set
143 void setMapViewScene(QGraphicsScene *scene);
146 * Shows dialog with enable automatic location update question.
148 * @param text text to show in dialog
150 void showEnableAutomaticUpdateLocationDialog(const QString &text);
153 * @brief Gets the username from member variable for saving purposes
155 * @return QString Username
157 const QString username();
162 * @brief Build direction indicator button and connect slots
164 void buildIndicatorButton();
167 * @brief Builds information box with message.
169 * @param message Information message
170 * @param modal Modal = true, non-modal false
172 void buildInformationBox(const QString &message, bool modal=false);
175 * @brief Slot for failed login
181 * @brief Slot to intercept signal when login with cookies is requested
184 void loginUsingCookies();
187 * @brief Public slot, which open settings dialog
189 void openSettingsDialog();
192 * @brief Set own location crosshair visibility
196 void setOwnLocationCrosshairVisibility(bool visible);
199 * @brief Sets username to member variable for login dialog
201 * @param username Username to be set
203 void setUsername(const QString &username);
206 * @brief Method to show panels
212 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
216 void startLoginProcess();
219 * @brief Toggle progress indicator.
221 * @param state true if progress indicator should be shown, false otherwise
223 void toggleProgressIndicator(bool state);
226 * @brief Shows / hides Situare related UI items
229 void updateItemVisibility();
233 * @brief Build fullscreen toggle button and connect slots
235 void buildFullScreenButton();
238 * @brief Build friend list panel and connect slots
240 void buildFriendListPanel();
243 * @brief Build manual location setting cross hair and connect slots
245 void buildManualLocationCrosshair();
248 * @brief Build map and connect slots
253 * @brief Build map scale and connect slots
255 void buildMapScale();
258 * @brief Build OSM license and connect slots
260 void buildOsmLicense();
263 * @brief Build user info panel and connect slots
265 void buildUserInfoPanel();
268 * @brief Build webview and connect slots
274 * @brief Build zoom button panel and connect slots
276 void buildZoomButtonPanel();
279 * @brief Private method to create the Menu items
284 * @brief Grab or release HW increase and decrease buttons.
286 * @param grab Use true for grabbing and false for releasing the keys
288 void grabZoomKeys(bool grab);
291 * @brief Queues dialog/information box
293 * @param dialog Dialog to be added into queue
295 void queueDialog(QDialog *dialog);
298 * @brief Shows queued error information box
301 void showErrorInformationBox();
304 * @brief Shows queued information box
306 * @fn showInformationBox
308 void showInformationBox();
312 * @brief Slot for automatic update dialog finished.
314 * @result result code
316 void automaticUpdateDialogFinished(int result);
319 * @brief Slot to intercept signal when dialog/information note is processed
321 * @param status Status of the dialog
323 void dialogFinished(int status);
326 * @brief Slot for drawing the fullscreen toggle button
328 * @param size Size of the screen
330 void drawFullScreenButton(const QSize &size);
333 * @brief Slot for drawing the map distance scale
335 * @param size Size of the screen
337 void drawMapScale(const QSize &size);
340 * @brief Slot for drawing the Open Street Map license text
342 * @param size Size of the screen
344 void drawOsmLicense(const QSize &size);
347 * @brief Slot for drawing the own location crosshair
349 * @param size Size of the screen
351 void drawOwnLocationCrosshair(const QSize &size);
354 * @brief Slot to intercept signal when error dialog/information note is processed
356 * @param status Status of the dialog
358 void errorDialogFinished(int status);
361 * @brief Slot for gps timeout.
363 * Called when request timeout occurs.
368 * @brief Slot to load cookies from settings
374 * @brief Slot to intercept signal when webview has finished loading webpage
376 * @param done Status of the loading
378 void loadDone(bool done);
381 * @brief Slot to save cookies to settings
387 * @brief Slot for settings dialog accepted.
389 void settingsDialogAccepted();
392 * @brief Set correnct view port size to datamembers
394 * @param size Size of the screen
396 void setViewPortSize(const QSize &size);
399 * @brief Toggle between fullscreen and normal window mode
401 void toggleFullScreen();
404 * @brief Slot to intercept signal from webview's networkaccessmanager
406 * @param reply Network reply (contains errors)
408 void webViewRequestFinished(QNetworkReply* reply);
410 /*******************************************************************************
412 ******************************************************************************/
415 * @brief Automatic centering setting changed by user
417 * @param enabled True if automatic centering is enabled, otherwise false
419 void autoCenteringTriggered(bool enabled);
422 * @brief Signal that indicates when user has cancelled login process
425 void cancelLoginProcess();
428 * @brief View should be centered to new location
430 * @param coordinate Scene coordinates of the new center point
432 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
435 * @brief Signal for enabling automatic location update.
437 * @param enabled true if enabled, false otherwise
438 * @param updateIntervalMsecs update interval in milliseconds
440 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
443 * @brief Signals error
445 * @param context error context
446 * @param error error code
448 void error(const int context, const int error);
451 * @brief Signal for requesting username from settings
454 void fetchUsernameFromSettings();
457 * @brief Signal for finding user.
459 * @param coordinates user geo coordinates
461 void findUser(const GeoCoordinate &coordinates);
464 * @brief Signals when friend's profile image is ready
468 void friendImageReady(User *user);
471 * @brief GPS setting changed
473 * @param enabled True if GPS is enabled, otherwise false
475 void gpsTriggered(bool enabled);
478 * @brief Signal for finding friend.
480 * @param coordinates friend's geo coordinates
482 void findFriend(const GeoCoordinate &coordinates);
485 * @brief Signal for friend location ready.
489 void friendsLocationsReady(QList<User *> &friendsList);
492 * @brief Signal is emitted when location item is clicked.
494 * @param userIDs list of friends user IDs in the group
496 void locationItemClicked(const QList<QString> &userIDs);
499 * @brief Signals when Login/Logout action is pressed
502 void loginActionPressed();
505 * @brief MapView has been resized
507 * @param size view size
509 void mapViewResized(const QSize &size);
512 * @brief Forwarding signal from MapView to MapEngine
516 void mapViewScrolled(const SceneCoordinate &coordinate);
519 * @brief Forwarding signal from MapEngine to MapView
521 void maxZoomLevelReached();
524 * @brief Forwarding signal from MapEngine to MapView
526 void minZoomLevelReached();
529 * @brief Forwarding signal from MapEngine to MapScale
531 void newMapResolution(qreal scale);
534 * @brief Signal for refreshing user data.
537 void refreshUserData();
540 * @brief Signal for requesting reverseGeo from SituareEngine
543 void requestReverseGeo();
546 * @brief Signals, when address data is ready
548 * @param address Street address
550 void reverseGeoReady(const QString &address);
553 * @brief Signal to save username to settings
555 * @param username Username
557 void saveUsername(const QString &username);
560 * @brief Signal for requestLocationUpdate from SituareEngine
562 * @param status Status message
563 * @param publish Publish on Facebook
565 void statusUpdate(const QString &status, const bool &publish);
568 * @brief Signals when webview's urlChanged signal is emitted
572 void updateCredentials(const QUrl &url);
575 * @brief Signals when updateLocationDialog's data must be cleared
578 void clearUpdateLocationDialogData();
581 * @brief MapView has finished zooming
583 void viewZoomFinished();
586 * @brief Signal for use location ready.
588 * @param user User object
590 void userLocationReady(User *user);
593 * @brief Map zoom in request
598 * @brief Forwarding signal from MapEngine to MapView
600 void zoomLevelChanged(int zoomLevel);
603 * @brief Map zoom out request
607 /*******************************************************************************
609 ******************************************************************************/
611 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
612 bool m_errorShown; ///< Indicates if error dialog/note is shown
613 bool m_loggedIn; ///< Indicates login state
614 bool m_refresh; ///< Indicates when webpage is refreshed
616 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
618 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
619 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
620 QAction *m_loginAct; ///< Action to Login/Logout
621 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
623 QLabel *m_osmLicense; ///< Label for Open Street Map license
624 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
626 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
627 QList<QDialog *> m_queue; ///< QList type dialog queue
629 QMenu *m_viewMenu; ///< Object that hold the view menu items
631 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
633 QSize m_viewPortSize; ///< Size of the viewport
635 QString m_email; ///< Placeholder for email
636 QString m_password; ///< Placeholder for password
638 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
639 IndicatorButton * m_indicatorButton; ///< Instance of direction indicator button
641 QWebView *m_webView; ///< Shows facebook login page
643 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
644 MapScale *m_mapScale; ///< Instance of the map scale
645 MapView *m_mapView; ///< Instance of the map view
646 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
647 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
648 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
649 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
650 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
653 #endif // MAINWINDOW_H