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
8 Katri Kaikkonen - katri.kaikkonen@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include <QtGui/QMainWindow>
31 #include "network/networkcookiejar.h"
32 #include "panelsidebar.h"
41 class FacebookAuthentication;
42 class FullScreenButton;
43 class FriendListPanel;
44 class IndicatorButton;
50 class SceneCoordinate;
54 class ZoomButtonPanel;
58 * @brief Main Window Class
60 class MainWindow : public QMainWindow
68 * @param parent Parent
70 MainWindow(QWidget *parent = 0);
78 /*******************************************************************************
79 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
80 ******************************************************************************/
83 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
85 void keyPressEvent(QKeyEvent* event);
87 /*******************************************************************************
88 * MEMBER FUNCTIONS AND SLOTS
89 ******************************************************************************/
92 * @brief Clears cookie jar
95 void clearCookieJar();
102 void loggedIn(bool logged);
105 * @brief Gets the login state (logged in/logged out)
107 * @return bool Login state
112 * @brief Reads automatic location update settings.
114 void readAutomaticLocationUpdateSettings();
117 * @brief Enable / disable GPS button.
119 * Does set visibilities for manual location cursor and auto centering menu button.
121 * @param enabled true if enabled, false otherwise
123 void setGPSButtonEnabled(bool enabled);
126 * @brief Enable / disable direction indicator button.
128 * @param enabled true if shoud be enabled, false otherwise
130 void setIndicatorButtonEnabled(bool enabled);
133 * @brief Set scene for MapView
135 * @param scene Scene to be set
137 void setMapViewScene(QGraphicsScene *scene);
140 * Shows dialog with enable automatic location update question.
142 * @param text text to show in dialog
144 void showEnableAutomaticUpdateLocationDialog(const QString &text);
147 * @brief Gets the username from member variable for saving purposes
149 * @return QString Username
151 const QString username();
156 * @brief Build direction indicator button and connect slots
158 void buildIndicatorButton();
161 * @brief Builds information box with message.
163 * @param message Information message
164 * @param modal Modal = true, non-modal false
166 void buildInformationBox(const QString &message, bool modal=false);
169 * @brief Slot for failed login
174 * @brief Slot to intercept signal when login with cookies is requested
176 void loginUsingCookies();
179 * @brief Public slot, which open settings dialog
181 void openSettingsDialog();
184 * @brief Set own location crosshair visibility
188 void setOwnLocationCrosshairVisibility(bool visible);
191 * @brief Sets username to member variable for login dialog
193 * @param username Username to be set
195 void setUsername(const QString &username);
198 * @brief Method to show panels
203 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
207 void startLoginProcess();
210 * @brief Toggle progress indicator.
212 * @param state true if progress indicator should be shown, false otherwise
214 void toggleProgressIndicator(bool state);
217 * @brief Shows / hides Situare related UI items
220 void updateItemVisibility();
224 * @brief Build fullscreen toggle button and connect slots
226 void buildFullScreenButton();
229 * @brief Build friend list panel and connect slots
231 void buildFriendListPanel();
234 * @brief Build manual location setting cross hair and connect slots
236 void buildManualLocationCrosshair();
239 * @brief Build map and connect slots
244 * @brief Build map scale and connect slots
246 void buildMapScale();
249 * @brief Build OSM license and connect slots
251 void buildOsmLicense();
254 * @brief Build user info panel and connect slots
256 void buildUserInfoPanel();
259 * @brief Build webview and connect slots
264 * @brief Build zoom button panel and connect slots
266 void buildZoomButtonPanel();
269 * @brief Private method to create the Menu items
274 * @brief Grab or release HW increase and decrease buttons.
276 * @param grab Use true for grabbing and false for releasing the keys
278 void grabZoomKeys(bool grab);
281 * @brief Queues dialog/information box
283 * @param dialog Dialog to be added into queue
285 void queueDialog(QDialog *dialog);
288 * @brief Shows queued error information box
291 void showErrorInformationBox();
294 * @brief Shows queued information box
296 * @fn showInformationBox
298 void showInformationBox();
302 * @brief Slot for automatic update dialog finished.
304 * @result result code
306 void automaticUpdateDialogFinished(int result);
309 * @brief Slot to intercept signal when dialog/information note is processed
311 * @param status Status of the dialog
313 void dialogFinished(int status);
316 * @brief Slot for drawing the fullscreen toggle button
318 * @param size Size of the screen
320 void drawFullScreenButton(const QSize &size);
323 * @brief Slot for drawing the map distance scale
325 * @param size Size of the screen
327 void drawMapScale(const QSize &size);
330 * @brief Slot for drawing the Open Street Map license text
332 * @param size Size of the screen
334 void drawOsmLicense(const QSize &size);
337 * @brief Slot for drawing the own location crosshair
339 * @param size Size of the screen
341 void drawOwnLocationCrosshair(const QSize &size);
344 * @brief Slot to intercept signal when error dialog/information note is processed
346 * @param status Status of the dialog
348 void errorDialogFinished(int status);
351 * @brief Slot for gps timeout.
353 * Called when request timeout occurs.
358 * @brief Slot to load cookies from settings
363 * @brief Slot to intercept signal when webview has finished loading webpage
365 * @param done Status of the loading
367 void loadDone(bool done);
370 * @brief Slot to save cookies to settings
375 * @brief Slot for settings dialog accepted.
377 void settingsDialogAccepted();
380 * @brief Set correnct view port size to datamembers
382 * @param size Size of the screen
384 void setViewPortSize(const QSize &size);
387 * @brief Start location search (open search dialog)
389 void startLocationSearch();
392 * @brief Toggle between fullscreen and normal window mode
394 void toggleFullScreen();
397 * @brief Slot to intercept signal from webview's networkaccessmanager
399 * @param reply Network reply (contains errors)
401 void webViewRequestFinished(QNetworkReply* reply);
403 /*******************************************************************************
405 ******************************************************************************/
408 * @brief Automatic centering setting changed by user
410 * @param enabled True if automatic centering is enabled, otherwise false
412 void autoCenteringTriggered(bool enabled);
415 * @brief Signal that indicates when user has cancelled login process
418 void cancelLoginProcess();
421 * @brief View should be centered to new location
423 * @param coordinate Scene coordinates of the new center point
425 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
428 * @brief Signal when direction and distance from current map center point to current GPS
429 * location is changed
431 * @param direction Direction in degrees
432 * @param distance Distance in kilometers
433 * @param draw Should the indicator triangle be drawn or not
435 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
438 * @brief Signal for enabling automatic location update.
440 * @param enabled true if enabled, false otherwise
441 * @param updateIntervalMsecs update interval in milliseconds
443 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
446 * @brief Signals error
448 * @param context error context
449 * @param error error code
451 void error(const int context, const int error);
454 * @brief Signal for requesting username from settings
457 void fetchUsernameFromSettings();
460 * @brief Signal for finding user.
462 * @param coordinates user geo coordinates
464 void findUser(const GeoCoordinate &coordinates);
467 * @brief Signals when friend's profile image is ready
471 void friendImageReady(User *user);
474 * @brief GPS setting changed
476 * @param enabled True if GPS is enabled, otherwise false
478 void gpsTriggered(bool enabled);
481 * @brief Signal for finding friend.
483 * @param coordinates friend's geo coordinates
485 void findFriend(const GeoCoordinate &coordinates);
488 * @brief Signal for friend location ready.
492 void friendsLocationsReady(QList<User *> &friendsList);
495 * @brief Signal is emitted when location item is clicked.
497 * @param userIDs list of friends user IDs in the group
499 void locationItemClicked(const QList<QString> &userIDs);
502 * @brief Signals when Login/Logout action is pressed
505 void loginActionPressed();
508 * @brief MapView has been resized
510 * @param size view size
512 void mapViewResized(const QSize &size);
515 * @brief Forwarding signal from MapView to MapEngine
519 void mapViewScrolled(const SceneCoordinate &coordinate);
522 * @brief Forwarding signal from MapEngine to MapView
524 void maxZoomLevelReached();
527 * @brief Forwarding signal from MapEngine to MapView
529 void minZoomLevelReached();
532 * @brief Forwarding signal from MapEngine to MapScale
534 void newMapResolution(qreal scale);
537 * @brief Signal for refreshing user data.
540 void refreshUserData();
543 * @brief Signal for requesting reverseGeo from SituareEngine
546 void requestReverseGeo();
549 * @brief Signals, when address data is ready
551 * @param address Street address
553 void reverseGeoReady(const QString &address);
556 * @brief Signal to save username to settings
558 * @param username Username
560 void saveUsername(const QString &username);
563 * @brief Signal for location search
565 * @param location QString location
567 void searchForLocation(QString location);
570 * @brief Signal for requestLocationUpdate from SituareEngine
572 * @param status Status message
573 * @param publish Publish on Facebook
575 void statusUpdate(const QString &status, const bool &publish);
578 * @brief Signals when webview's urlChanged signal is emitted
582 void updateCredentials(const QUrl &url);
585 * @brief Signals when updateLocationDialog's data must be cleared
588 void clearUpdateLocationDialogData();
591 * @brief MapView has finished zooming
593 void viewZoomFinished();
596 * @brief Signal for use location ready.
598 * @param user User object
600 void userLocationReady(User *user);
603 * @brief Map zoom in request
608 * @brief Forwarding signal from MapEngine to MapView
610 void zoomLevelChanged(int zoomLevel);
613 * @brief Map zoom out request
617 /*******************************************************************************
619 ******************************************************************************/
621 bool m_errorShown; ///< Indicates if error dialog/note is shown
622 bool m_loggedIn; ///< Indicates login state
623 bool m_refresh; ///< Indicates when webpage is refreshed
625 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
627 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
628 QAction *m_loginAct; ///< Action to Login/Logout
629 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
630 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
632 QLabel *m_osmLicense; ///< Label for Open Street Map license
633 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
635 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
636 QList<QDialog *> m_queue; ///< QList type dialog queue
638 QMenu *m_viewMenu; ///< Object that hold the view menu items
640 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
642 QSize m_viewPortSize; ///< Size of the viewport
644 QString m_email; ///< Placeholder for email
645 QString m_password; ///< Placeholder for password
647 QWebView *m_webView; ///< Shows facebook login page
649 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
650 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
651 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
652 MapScale *m_mapScale; ///< Instance of the map scale
653 MapView *m_mapView; ///< Instance of the map view
654 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
655 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
656 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
657 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
658 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
661 #endif // MAINWINDOW_H