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 Clears cookie jar
86 void clearCookieJar();
93 void loggedIn(bool logged);
96 * @brief Enable / disable auto centering button.
98 * @param enabled true if shoud be enabled, false otherwise
100 void setAutoCenteringButtonEnabled(bool enabled);
103 * @brief Enable / disable GPS button.
105 * Does set visibilities for manual location cursor and auto centering menu button.
107 * @param enabled true if enabled, false otherwise
109 void setGPSButtonEnabled(bool enabled);
112 * @brief Set scene for MapView
114 * @param scene Scene to be set
116 void setMapViewScene(QGraphicsScene *scene);
119 * @brief Show Maemo information box with message.
121 * @param message Information message
122 * @param modal Modal = true, non-modal false
124 void showMaemoInformationBox(const QString &message, bool modal=false);
127 * @brief Gets the username from member variable for saving purposes
129 * @return QString Username
131 const QString username();
135 * @brief Slot to intercept signal when login has failed (loginFailure signal)
141 * @brief Slot to intercept signal when login with cookies is requested
144 void loginUsingCookies();
147 * @brief Public slot, which open settings dialog
149 void openSettingsDialog();
152 * @brief Sets username to member variable for login dialog
154 * @param username Username to be set
156 void setUsername(const QString &username);
159 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
162 * @param url Login page url
164 void startLoginProcess(const QUrl &url);
167 * @brief Toggle progress indicator.
169 * @param state true if progress indicator should be shown, false otherwise
171 void toggleProgressIndicator(bool state);
174 * @brief Shows / hides Situare related UI items
178 void updateItemVisibility(bool show);
182 * @brief Build fullscreen toggle button and connect slots
184 void buildFullScreenButton();
187 * @brief Build friend list panel and connect slots
189 void buildFriendListPanel();
192 * @brief Build manual location setting cross hair and connect slots
194 void buildManualLocationCrosshair();
197 * @brief Build map and connect slots
202 * @brief Build OSM license and connect slots
204 void buildOsmLicense();
207 * @brief Build user info panel and connect slots
209 void buildUserInfoPanel();
212 * @brief Build webview and connect slots
218 * @brief Build zoom button panel and connect slots
220 void buildZoomButtonPanel();
223 * @brief Private method to create the Menu items
228 * @brief Grab or release HW increase and decrease buttons.
230 * @param grab Use true for grabbing and false for releasing the keys
232 void grabZoomKeys(bool grab);
235 * @brief Set own location crosshair visibility
239 void setOwnLocationCrosshairVisibility(bool visible);
243 * @brief Slot for drawing the fullscreen toggle button
245 * @param size Size of the screen
247 void drawFullScreenButton(const QSize &size);
250 * @brief Slot for drawing the Open Street Map license text
252 * @param size Size of the screen
254 void drawOsmLicense(const QSize &size);
257 * @brief Slot for drawing the own location crosshair
259 * @param width Width of the viewport
260 * @param height Height of the viewport
262 void drawOwnLocationCrosshair(int width, int height);
265 * @brief Slot for gps error.
267 * @param message error message
269 void gpsError(const QString &message);
272 * @brief Slot for gps timeout.
274 * Called when request timeout occurs.
279 * @brief Slot to load cookies from settings
285 * @brief Slot to intercept signal when webview has finished loading webpage
287 * @param done Status of the loading
289 void loadDone(bool done);
292 * @brief Slot to save cookies to settings
298 * @brief Set correnct view port size to datamembers
300 * @param width Width of the viewport
301 * @param height Height of the viewport
303 void setViewPortSize(const int width, const int height);
306 * @brief Toggle between fullscreen and normal window mode
308 void toggleFullScreen();
310 /*******************************************************************************
312 ******************************************************************************/
315 * @brief Automatic centering setting changed by user
317 * @param enabled True if automatic centering is enabled, otherwise false
319 void autoCenteringTriggered(bool enabled);
322 * @brief Signal that indicates when user has cancelled login process
325 void cancelLoginProcess();
328 * @brief View should be centered to new location
330 * @param sceneCoordinate Scene coordinates of the new center point
332 void centerToSceneCoordinates(QPoint sceneCoordinate);
335 * @brief Signal for enabling automatic location update.
337 * @param enabled true if enabled, false otherwise
338 * @param updateIntervalMsecs update interval in milliseconds
340 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
343 * @brief Signal for requesting username from settings
346 void fetchUsernameFromSettings();
349 * @brief Signal for finding user.
351 * @param coordinates user geo coordinates
353 void findUser(const QPointF &coordinates);
356 * @brief GPS setting changed
358 * @param enabled True if GPS is enabled, otherwise false
360 void gpsTriggered(bool enabled);
363 * @brief Signal for finding friend.
365 * @param coordinates friend's geo coordinates
367 void findFriend(const QPointF &coordinates);
370 * @brief Signal for friend location ready.
374 void friendsLocationsReady(QList<User *> &friendsList);
377 * @brief Signal is emitted when location item is clicked.
379 * @param userIDs list of friends user IDs in the group
381 void locationItemClicked(const QList<QString> &userIDs);
384 * @brief Signals when Login/Logout action is pressed
387 void loginActionPressed();
390 * @brief MapView has been resized
392 * @param size view size
394 void mapViewResized(const QSize &size);
397 * @brief Forwarding signal from MapView to MapEngine
399 * @param sceneCoordinate
401 void mapViewScrolled(QPoint sceneCoordinate);
404 * @brief Forwarding signal from MapEngine to MapView
406 void maxZoomLevelReached();
409 * @brief Forwarding signal from MapEngine to MapView
411 void minZoomLevelReached();
414 * @brief Signal for refreshing user data.
417 void refreshUserData();
420 * @brief Signal for requesting reverseGeo from SituareEngine
423 void requestReverseGeo();
426 * @brief Signals, when address data is ready
428 * @param address Street address
430 void reverseGeoReady(const QString &address);
433 * @brief Signal to save username to settings
435 * @param username Username
437 void saveUsername(const QString &username);
440 * @brief Signal for requestLocationUpdate from SituareEngine
442 * @param status Status message
443 * @param publish Publish on Facebook
445 void statusUpdate(const QString &status, const bool &publish);
448 * @brief Signals when webview's urlChanged signal is emitted
452 void updateCredentials(const QUrl &url);
455 * @brief MapView has finished zooming
457 void viewZoomFinished();
460 * @brief Signal for use location ready.
462 * @param user User object
464 void userLocationReady(User *user);
467 * @brief Map zoom in request
472 * @brief Forwarding signal from MapEngine to MapView
474 void zoomLevelChanged(int zoomLevel);
477 * @brief Map zoom out request
481 /*******************************************************************************
483 ******************************************************************************/
485 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
486 bool m_loggedIn; ///< Indicates login state
487 bool m_refresh; ///< Indicates when webpage is refreshed
489 int m_viewPortHeight; ///< Height of view port
490 int m_viewPortWidth; ///< Width of view port
492 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
493 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
494 QAction *m_loginAct; ///< Action to Login/Logout
495 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
497 QLabel *m_osmLicense; ///< Label for Open Street Map license
498 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
500 QMenu *m_viewMenu; ///< Object that hold the view menu items
502 QString m_email; ///< Placeholder for email
503 QString m_password; ///< Placeholder for password
505 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
507 QWebView *m_webView; ///< Shows facebook login page
509 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
510 MapView *m_mapView; ///< Instance of the map view
511 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
512 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
513 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
514 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
515 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
517 SettingsDialog *m_settingsDialog; ///< Settings dialog
520 #endif // MAINWINDOW_H