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"
37 class FacebookAuthentication;
38 class FriendListPanel;
44 class ZoomButtonPanel;
49 * @brief Main Window Class
51 class MainWindow : public QMainWindow
59 * @param parent Parent
61 MainWindow(QWidget *parent = 0);
69 /*******************************************************************************
70 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
71 ******************************************************************************/
74 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
76 void keyPressEvent(QKeyEvent* event);
78 /*******************************************************************************
79 * MEMBER FUNCTIONS AND SLOTS
80 ******************************************************************************/
83 * @brief Sets automatic location update enabled from settings dialog.
85 * @param enabled true if enabled, false otherwise
87 void automaticLocationUpdateEnabled(bool enabled);
90 * @brief Clears cookie jar
93 void clearCookieJar();
100 void loggedIn(bool logged);
103 * @brief Enable / disable auto centering button.
105 * @param enabled true if shoud be enabled, false otherwise
107 void setAutoCenteringButtonEnabled(bool enabled);
110 * @brief Enable / disable GPS button.
112 * Does set visibilities for manual location cursor and auto centering menu button.
114 * @param enabled true if enabled, false otherwise
116 void setGPSButtonEnabled(bool enabled);
119 * @brief Set scene for MapView
121 * @param scene Scene to be set
123 void setMapViewScene(QGraphicsScene *scene);
126 * Shows dialog with enable automatic location update question.
128 * @return true if accepted, false otherwise
130 bool showEnableAutomaticUpdateLocationDialog();
133 * @brief Show Maemo information box with message.
135 * @param message Information message
136 * @param modal Modal = true, non-modal false
138 void showMaemoInformationBox(const QString &message, bool modal=false);
141 * @brief Gets the username from member variable for saving purposes
143 * @return QString Username
145 const QString username();
149 * @brief Slot to intercept signal when login has failed (loginFailure signal)
155 * @brief Slot to intercept signal when login with cookies is requested
158 void loginUsingCookies();
161 * @brief Public slot, which open settings dialog
163 void openSettingsDialog();
166 * @brief Sets username to member variable for login dialog
168 * @param username Username to be set
170 void setUsername(const QString &username);
173 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
176 * @param url Login page url
178 void startLoginProcess(const QUrl &url);
181 * @brief Toggle progress indicator.
183 * @param state true if progress indicator should be shown, false otherwise
185 void toggleProgressIndicator(bool state);
188 * @brief Shows / hides Situare related UI items
192 void updateItemVisibility(bool show);
196 * @brief Build fullscreen toggle button and connect slots
198 void buildFullScreenButton();
201 * @brief Build friend list panel and connect slots
203 void buildFriendListPanel();
206 * @brief Build manual location setting cross hair and connect slots
208 void buildManualLocationCrosshair();
211 * @brief Build map and connect slots
216 * @brief Build OSM license and connect slots
218 void buildOsmLicense();
221 * @brief Build user info panel and connect slots
223 void buildUserInfoPanel();
226 * @brief Build webview and connect slots
232 * @brief Build zoom button panel and connect slots
234 void buildZoomButtonPanel();
237 * @brief Private method to create the Menu items
242 * @brief Grab or release HW increase and decrease buttons.
244 * @param grab Use true for grabbing and false for releasing the keys
246 void grabZoomKeys(bool grab);
249 * @brief Set own location crosshair visibility
253 void setOwnLocationCrosshairVisibility(bool visible);
257 * @brief Slot for drawing the fullscreen toggle button
259 * @param size Size of the screen
261 void drawFullScreenButton(const QSize &size);
264 * @brief Slot for drawing the Open Street Map license text
266 * @param size Size of the screen
268 void drawOsmLicense(const QSize &size);
271 * @brief Slot for drawing the own location crosshair
273 * @param width Width of the viewport
274 * @param height Height of the viewport
276 void drawOwnLocationCrosshair(int width, int height);
279 * @brief Slot for gps timeout.
281 * Called when request timeout occurs.
286 * @brief Slot to load cookies from settings
292 * @brief Slot to intercept signal when webview has finished loading webpage
294 * @param done Status of the loading
296 void loadDone(bool done);
299 * @brief Slot to save cookies to settings
305 * @brief Set correnct view port size to datamembers
307 * @param width Width of the viewport
308 * @param height Height of the viewport
310 void setViewPortSize(const int width, const int height);
313 * @brief Toggle between fullscreen and normal window mode
315 void toggleFullScreen();
317 /*******************************************************************************
319 ******************************************************************************/
322 * @brief Automatic centering setting changed by user
324 * @param enabled True if automatic centering is enabled, otherwise false
326 void autoCenteringTriggered(bool enabled);
329 * @brief Signal that indicates when user has cancelled login process
332 void cancelLoginProcess();
335 * @brief View should be centered to new location
337 * @param sceneCoordinate Scene coordinates of the new center point
339 void centerToSceneCoordinates(QPoint sceneCoordinate);
342 * @brief Signal for enabling automatic location update.
344 * @param enabled true if enabled, false otherwise
345 * @param updateIntervalMsecs update interval in milliseconds
347 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
350 * @brief Signal for requesting username from settings
353 void fetchUsernameFromSettings();
356 * @brief Signal for finding user.
358 * @param coordinates user geo coordinates
360 void findUser(const QPointF &coordinates);
363 * @brief GPS setting changed
365 * @param enabled True if GPS is enabled, otherwise false
367 void gpsTriggered(bool enabled);
370 * @brief Signal for finding friend.
372 * @param coordinates friend's geo coordinates
374 void findFriend(const QPointF &coordinates);
377 * @brief Signal for friend location ready.
381 void friendsLocationsReady(QList<User *> &friendsList);
384 * @brief Signal is emitted when location item is clicked.
386 * @param userIDs list of friends user IDs in the group
388 void locationItemClicked(const QList<QString> &userIDs);
391 * @brief Signals when Login/Logout action is pressed
394 void loginActionPressed();
397 * @brief MapView has been resized
399 * @param size view size
401 void mapViewResized(const QSize &size);
404 * @brief Forwarding signal from MapView to MapEngine
406 * @param sceneCoordinate
408 void mapViewScrolled(QPoint sceneCoordinate);
411 * @brief Forwarding signal from MapEngine to MapView
413 void maxZoomLevelReached();
416 * @brief Forwarding signal from MapEngine to MapView
418 void minZoomLevelReached();
421 * @brief Signal for refreshing user data.
424 void refreshUserData();
427 * @brief Signal for requesting reverseGeo from SituareEngine
430 void requestReverseGeo();
433 * @brief Signals, when address data is ready
435 * @param address Street address
437 void reverseGeoReady(const QString &address);
440 * @brief Signal to save username to settings
442 * @param username Username
444 void saveUsername(const QString &username);
447 * @brief Signal for requestLocationUpdate from SituareEngine
449 * @param status Status message
450 * @param publish Publish on Facebook
452 void statusUpdate(const QString &status, const bool &publish);
455 * @brief Signals when webview's urlChanged signal is emitted
459 void updateCredentials(const QUrl &url);
462 * @brief MapView has finished zooming
464 void viewZoomFinished();
467 * @brief Signal for use location ready.
469 * @param user User object
471 void userLocationReady(User *user);
474 * @brief Map zoom in request
479 * @brief Forwarding signal from MapEngine to MapView
481 void zoomLevelChanged(int zoomLevel);
484 * @brief Map zoom out request
488 /*******************************************************************************
490 ******************************************************************************/
492 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
493 bool m_loggedIn; ///< Indicates login state
494 bool m_refresh; ///< Indicates when webpage is refreshed
496 int m_viewPortHeight; ///< Height of view port
497 int m_viewPortWidth; ///< Width of view port
499 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
500 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
501 QAction *m_loginAct; ///< Action to Login/Logout
502 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
504 QLabel *m_osmLicense; ///< Label for Open Street Map license
505 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
507 QMenu *m_viewMenu; ///< Object that hold the view menu items
509 QString m_email; ///< Placeholder for email
510 QString m_password; ///< Placeholder for password
512 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
514 QWebView *m_webView; ///< Shows facebook login page
516 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
517 MapView *m_mapView; ///< Instance of the map view
518 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
519 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
520 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
521 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
522 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
524 SettingsDialog *m_settingsDialog; ///< Settings dialog
527 #endif // MAINWINDOW_H