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 Requests automatic location update settings.
105 void requestAutomaticLocationUpdateSettings();
109 * @brief Enable / disable auto centering button.
111 * @param enabled true if shoud be enabled, false otherwise
113 void setAutoCenteringButtonEnabled(bool enabled);
116 * @brief Enable / disable GPS button.
118 * Does set visibilities for manual location cursor and auto centering menu button.
120 * @param enabled true if enabled, false otherwise
122 void setGPSButtonEnabled(bool enabled);
125 * @brief Set scene for MapView
127 * @param scene Scene to be set
129 void setMapViewScene(QGraphicsScene *scene);
132 * Shows dialog with enable automatic location update question.
134 * @return true if accepted, false otherwise
136 bool showEnableAutomaticUpdateLocationDialog();
139 * @brief Show Maemo information box with message.
141 * @param message Information message
142 * @param modal Modal = true, non-modal false
144 void showMaemoInformationBox(const QString &message, bool modal=false);
147 * @brief Gets the username from member variable for saving purposes
149 * @return QString Username
151 const QString username();
155 * @brief Slot to intercept signal when login has failed (loginFailure signal)
161 * @brief Slot to intercept signal when login with cookies is requested
164 void loginUsingCookies();
167 * @brief Public slot, which open settings dialog
169 void openSettingsDialog();
172 * @brief Sets username to member variable for login dialog
174 * @param username Username to be set
176 void setUsername(const QString &username);
179 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
182 * @param url Login page url
184 void startLoginProcess(const QUrl &url);
187 * @brief Toggle progress indicator.
189 * @param state true if progress indicator should be shown, false otherwise
191 void toggleProgressIndicator(bool state);
194 * @brief Shows / hides Situare related UI items
198 void updateItemVisibility(bool show);
202 * @brief Build fullscreen toggle button and connect slots
204 void buildFullScreenButton();
207 * @brief Build friend list panel and connect slots
209 void buildFriendListPanel();
212 * @brief Build manual location setting cross hair and connect slots
214 void buildManualLocationCrosshair();
217 * @brief Build map and connect slots
222 * @brief Build OSM license and connect slots
224 void buildOsmLicense();
227 * @brief Build user info panel and connect slots
229 void buildUserInfoPanel();
232 * @brief Build webview and connect slots
238 * @brief Build zoom button panel and connect slots
240 void buildZoomButtonPanel();
243 * @brief Private method to create the Menu items
248 * @brief Grab or release HW increase and decrease buttons.
250 * @param grab Use true for grabbing and false for releasing the keys
252 void grabZoomKeys(bool grab);
255 * @brief Set own location crosshair visibility
259 void setOwnLocationCrosshairVisibility(bool visible);
263 * @brief Slot for drawing the fullscreen toggle button
265 * @param size Size of the screen
267 void drawFullScreenButton(const QSize &size);
270 * @brief Slot for drawing the Open Street Map license text
272 * @param size Size of the screen
274 void drawOsmLicense(const QSize &size);
277 * @brief Slot for drawing the own location crosshair
279 * @param width Width of the viewport
280 * @param height Height of the viewport
282 void drawOwnLocationCrosshair(int width, int height);
285 * @brief Slot for gps timeout.
287 * Called when request timeout occurs.
292 * @brief Slot to load cookies from settings
298 * @brief Slot to intercept signal when webview has finished loading webpage
300 * @param done Status of the loading
302 void loadDone(bool done);
305 * @brief Slot to save cookies to settings
311 * @brief Set correnct view port size to datamembers
313 * @param width Width of the viewport
314 * @param height Height of the viewport
316 void setViewPortSize(const int width, const int height);
319 * @brief Toggle between fullscreen and normal window mode
321 void toggleFullScreen();
323 /*******************************************************************************
325 ******************************************************************************/
328 * @brief Automatic centering setting changed by user
330 * @param enabled True if automatic centering is enabled, otherwise false
332 void autoCenteringTriggered(bool enabled);
335 * @brief Signal that indicates when user has cancelled login process
338 void cancelLoginProcess();
341 * @brief View should be centered to new location
343 * @param sceneCoordinate Scene coordinates of the new center point
345 void centerToSceneCoordinates(QPoint sceneCoordinate);
348 * @brief Signal for enabling automatic location update.
350 * @param enabled true if enabled, false otherwise
351 * @param updateIntervalMsecs update interval in milliseconds
353 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
356 * @brief Signal for requesting username from settings
359 void fetchUsernameFromSettings();
362 * @brief Signal for finding user.
364 * @param coordinates user geo coordinates
366 void findUser(const QPointF &coordinates);
369 * @brief GPS setting changed
371 * @param enabled True if GPS is enabled, otherwise false
373 void gpsTriggered(bool enabled);
376 * @brief Signal for finding friend.
378 * @param coordinates friend's geo coordinates
380 void findFriend(const QPointF &coordinates);
383 * @brief Signal for friend location ready.
387 void friendsLocationsReady(QList<User *> &friendsList);
390 * @brief Signal is emitted when location item is clicked.
392 * @param userIDs list of friends user IDs in the group
394 void locationItemClicked(const QList<QString> &userIDs);
397 * @brief Signals when Login/Logout action is pressed
400 void loginActionPressed();
403 * @brief MapView has been resized
405 * @param size view size
407 void mapViewResized(const QSize &size);
410 * @brief Forwarding signal from MapView to MapEngine
412 * @param sceneCoordinate
414 void mapViewScrolled(QPoint sceneCoordinate);
417 * @brief Forwarding signal from MapEngine to MapView
419 void maxZoomLevelReached();
422 * @brief Forwarding signal from MapEngine to MapView
424 void minZoomLevelReached();
427 * @brief Signal for refreshing user data.
430 void refreshUserData();
433 * @brief Signal for requesting reverseGeo from SituareEngine
436 void requestReverseGeo();
439 * @brief Signals, when address data is ready
441 * @param address Street address
443 void reverseGeoReady(const QString &address);
446 * @brief Signal to save username to settings
448 * @param username Username
450 void saveUsername(const QString &username);
453 * @brief Signal for requestLocationUpdate from SituareEngine
455 * @param status Status message
456 * @param publish Publish on Facebook
458 void statusUpdate(const QString &status, const bool &publish);
461 * @brief Signals when webview's urlChanged signal is emitted
465 void updateCredentials(const QUrl &url);
468 * @brief MapView has finished zooming
470 void viewZoomFinished();
473 * @brief Signal for use location ready.
475 * @param user User object
477 void userLocationReady(User *user);
480 * @brief Map zoom in request
485 * @brief Forwarding signal from MapEngine to MapView
487 void zoomLevelChanged(int zoomLevel);
490 * @brief Map zoom out request
494 /*******************************************************************************
496 ******************************************************************************/
498 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
499 bool m_loggedIn; ///< Indicates login state
500 bool m_refresh; ///< Indicates when webpage is refreshed
502 int m_viewPortHeight; ///< Height of view port
503 int m_viewPortWidth; ///< Width of view port
505 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
506 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
507 QAction *m_loginAct; ///< Action to Login/Logout
508 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
510 QLabel *m_osmLicense; ///< Label for Open Street Map license
511 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
513 QMenu *m_viewMenu; ///< Object that hold the view menu items
515 QString m_email; ///< Placeholder for email
516 QString m_password; ///< Placeholder for password
518 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
520 QWebView *m_webView; ///< Shows facebook login page
522 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
523 MapView *m_mapView; ///< Instance of the map view
524 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
525 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
526 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
527 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
528 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
530 SettingsDialog *m_settingsDialog; ///< Settings dialog
533 #endif // MAINWINDOW_H