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 FullScreenButton;
40 class FriendListPanel;
47 class ZoomButtonPanel;
53 * @brief Main Window Class
55 class MainWindow : public QMainWindow
63 * @param parent Parent
65 MainWindow(QWidget *parent = 0);
73 /*******************************************************************************
74 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
75 ******************************************************************************/
78 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
80 void keyPressEvent(QKeyEvent* event);
82 /*******************************************************************************
83 * MEMBER FUNCTIONS AND SLOTS
84 ******************************************************************************/
87 * @brief Clears cookie jar
90 void clearCookieJar();
97 void loggedIn(bool logged);
100 * @brief Gets the login state (logged in/logged out)
102 * @return bool Login state
107 * @brief Reads automatic location update settings.
109 void readAutomaticLocationUpdateSettings();
112 * @brief Enable / disable auto centering button.
114 * @param enabled true if shoud be enabled, false otherwise
116 void setAutoCenteringButtonEnabled(bool enabled);
119 * @brief Enable / disable GPS button.
121 * Does set visibilities for manual location cursor and auto centering menu button.
123 * @param enabled true if enabled, false otherwise
125 void setGPSButtonEnabled(bool enabled);
128 * @brief Set scene for MapView
130 * @param scene Scene to be set
132 void setMapViewScene(QGraphicsScene *scene);
135 * Shows dialog with enable automatic location update question.
137 * @param text text to show in dialog
139 void showEnableAutomaticUpdateLocationDialog(const QString &text);
142 * @brief Gets the username from member variable for saving purposes
144 * @return QString Username
146 const QString username();
150 * @brief Builds information box with message.
152 * @param message Information message
153 * @param modal Modal = true, non-modal false
155 void buildInformationBox(const QString &message, bool modal=false);
158 * @brief Slot for failed login
164 * @brief Slot to intercept signal when login with cookies is requested
167 void loginUsingCookies();
170 * @brief Public slot, which open settings dialog
172 void openSettingsDialog();
175 * @brief Set own location crosshair visibility
179 void setOwnLocationCrosshairVisibility(bool visible);
182 * @brief Sets username to member variable for login dialog
184 * @param username Username to be set
186 void setUsername(const QString &username);
189 * @brief Method to show panels
195 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
199 void startLoginProcess();
202 * @brief Toggle progress indicator.
204 * @param state true if progress indicator should be shown, false otherwise
206 void toggleProgressIndicator(bool state);
209 * @brief Shows / hides Situare related UI items
212 void updateItemVisibility();
216 * @brief Build fullscreen toggle button and connect slots
218 void buildFullScreenButton();
221 * @brief Build friend list panel and connect slots
223 void buildFriendListPanel();
226 * @brief Build manual location setting cross hair and connect slots
228 void buildManualLocationCrosshair();
231 * @brief Build map and connect slots
236 * @brief Build map scale and connect slots
238 void buildMapScale();
241 * @brief Build OSM license and connect slots
243 void buildOsmLicense();
246 * @brief Build user info panel and connect slots
248 void buildUserInfoPanel();
251 * @brief Build webview and connect slots
257 * @brief Build zoom button panel and connect slots
259 void buildZoomButtonPanel();
262 * @brief Private method to create the Menu items
267 * @brief Grab or release HW increase and decrease buttons.
269 * @param grab Use true for grabbing and false for releasing the keys
271 void grabZoomKeys(bool grab);
274 * @brief Queues dialog/information box
276 * @param dialog Dialog to be added into queue
278 void queueDialog(QDialog *dialog);
281 * @brief Shows queued error information box
284 void showErrorInformationBox();
287 * @brief Shows queued information box
289 * @fn showInformationBox
291 void showInformationBox();
295 * @brief Slot for automatic update dialog finished.
297 * @result result code
299 void automaticUpdateDialogFinished(int result);
302 * @brief Slot to intercept signal when dialog/information note is processed
304 * @param status Status of the dialog
306 void dialogFinished(int status);
309 * @brief Slot for drawing the fullscreen toggle button
311 * @param size Size of the screen
313 void drawFullScreenButton(const QSize &size);
316 * @brief Slot for drawing the map distance scale
318 * @param size Size of the screen
320 void drawMapScale(const QSize &size);
323 * @brief Slot for drawing the Open Street Map license text
325 * @param size Size of the screen
327 void drawOsmLicense(const QSize &size);
330 * @brief Slot for drawing the own location crosshair
332 * @param size Size of the screen
334 void drawOwnLocationCrosshair(const QSize &size);
337 * @brief Slot to intercept signal when error dialog/information note is processed
339 * @param status Status of the dialog
341 void errorDialogFinished(int status);
344 * @brief Slot for gps timeout.
346 * Called when request timeout occurs.
351 * @brief Slot to load cookies from settings
357 * @brief Slot to intercept signal when webview has finished loading webpage
359 * @param done Status of the loading
361 void loadDone(bool done);
364 * @brief Slot to save cookies to settings
370 * @brief Slot for settings dialog accepted.
372 void settingsDialogAccepted();
375 * @brief Set correnct view port size to datamembers
377 * @param size Size of the screen
379 void setViewPortSize(const QSize &size);
382 * @brief Toggle between fullscreen and normal window mode
384 void toggleFullScreen();
387 * @brief Slot to intercept signal from webview's networkaccessmanager
389 * @param reply Network reply (contains errors)
391 void webViewRequestFinished(QNetworkReply* reply);
393 /*******************************************************************************
395 ******************************************************************************/
398 * @brief Automatic centering setting changed by user
400 * @param enabled True if automatic centering is enabled, otherwise false
402 void autoCenteringTriggered(bool enabled);
405 * @brief Signal that indicates when user has cancelled login process
408 void cancelLoginProcess();
411 * @brief View should be centered to new location
413 * @param sceneCoordinate Scene coordinates of the new center point
415 void centerToSceneCoordinates(QPoint sceneCoordinate);
418 * @brief Signal for enabling automatic location update.
420 * @param enabled true if enabled, false otherwise
421 * @param updateIntervalMsecs update interval in milliseconds
423 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
426 * @brief Signals error
428 * @param context error context
429 * @param error error code
431 void error(const int context, const int error);
434 * @brief Signal for requesting username from settings
437 void fetchUsernameFromSettings();
440 * @brief Signal for finding user.
442 * @param coordinates user geo coordinates
444 void findUser(const QPointF &coordinates);
447 * @brief GPS setting changed
449 * @param enabled True if GPS is enabled, otherwise false
451 void gpsTriggered(bool enabled);
454 * @brief Signal for finding friend.
456 * @param coordinates friend's geo coordinates
458 void findFriend(const QPointF &coordinates);
461 * @brief Signal for friend location ready.
465 void friendsLocationsReady(QList<User *> &friendsList);
468 * @brief Signal is emitted when location item is clicked.
470 * @param userIDs list of friends user IDs in the group
472 void locationItemClicked(const QList<QString> &userIDs);
475 * @brief Signals when Login/Logout action is pressed
478 void loginActionPressed();
481 * @brief MapView has been resized
483 * @param size view size
485 void mapViewResized(const QSize &size);
488 * @brief Forwarding signal from MapView to MapEngine
490 * @param sceneCoordinate
492 void mapViewScrolled(QPoint sceneCoordinate);
495 * @brief Forwarding signal from MapEngine to MapView
497 void maxZoomLevelReached();
500 * @brief Forwarding signal from MapEngine to MapView
502 void minZoomLevelReached();
505 * @brief Forwarding signal from MapEngine to MapScale
507 void newMapResolution(qreal scale);
510 * @brief Signal for refreshing user data.
513 void refreshUserData();
516 * @brief Signal for requesting reverseGeo from SituareEngine
519 void requestReverseGeo();
522 * @brief Signals, when address data is ready
524 * @param address Street address
526 void reverseGeoReady(const QString &address);
529 * @brief Signal to save username to settings
531 * @param username Username
533 void saveUsername(const QString &username);
536 * @brief Signal for requestLocationUpdate from SituareEngine
538 * @param status Status message
539 * @param publish Publish on Facebook
541 void statusUpdate(const QString &status, const bool &publish);
544 * @brief Signals when webview's urlChanged signal is emitted
548 void updateCredentials(const QUrl &url);
551 * @brief Signals when updateLocationDialog's data must be cleared
554 void clearUpdateLocationDialogData();
557 * @brief MapView has finished zooming
559 void viewZoomFinished();
562 * @brief Signal for use location ready.
564 * @param user User object
566 void userLocationReady(User *user);
569 * @brief Map zoom in request
574 * @brief Forwarding signal from MapEngine to MapView
576 void zoomLevelChanged(int zoomLevel);
579 * @brief Map zoom out request
583 /*******************************************************************************
585 ******************************************************************************/
587 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
588 bool m_errorShown; ///< Indicates if error dialog/note is shown
589 bool m_loggedIn; ///< Indicates login state
590 bool m_refresh; ///< Indicates when webpage is refreshed
592 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
594 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
595 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
596 QAction *m_loginAct; ///< Action to Login/Logout
597 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
599 QLabel *m_osmLicense; ///< Label for Open Street Map license
600 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
602 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
603 QList<QDialog *> m_queue; ///< QList type dialog queue
605 QMenu *m_viewMenu; ///< Object that hold the view menu items
607 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
609 QSize m_viewPortSize; ///< Size of the viewport
611 QString m_email; ///< Placeholder for email
612 QString m_password; ///< Placeholder for password
614 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
616 QWebView *m_webView; ///< Shows facebook login page
618 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
619 MapScale *m_mapScale; ///< Instance of the map scale
620 MapView *m_mapView; ///< Instance of the map view
621 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
622 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
623 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
624 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
625 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
628 #endif // MAINWINDOW_H