const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
-const QString ZOOMPANEL_POSITION = "ZoomPanelPosition";
+const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
+const QString ZOOMPANEL_POSITION = "ZoomPanelPosition"; ///< Zoom panel position string
#endif // COMMON_H
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
+ initializeGpsAndAutocentering();
+
// signals connected, now it's time to show the main window
// but init the MapEngine before so starting location is set
m_mapEngine->init();
m_ui->show();
- QSettings settings(DIRECTORY_NAME, FILE_NAME);
- QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
- QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
-
- // set features on / off based on settings
- changeAutoCenteringSetting(autoCenteringEnabled.toBool());
- enableGPS(gpsEnabled.toBool());
-
- // show messages at startup if features are enabled automatically
- if (gpsEnabled.toBool())
- m_ui->showMaemoInformationBox(tr("GPS enabled"));
- if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
- m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
-
m_facebookAuthenticator->start();
}
void SituareEngine::fetchUsernameFromSettings()
{
qDebug() << __PRETTY_FUNCTION__;
+
m_ui->setUsername(m_facebookAuthenticator->loadUsername());
}
+void SituareEngine::initializeGpsAndAutocentering()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
+ QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
+
+ if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
+
+ connect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+
+ changeAutoCenteringSetting(true);
+ enableGPS(true);
+
+ m_ui->showMaemoInformationBox(tr("GPS enabled"));
+ m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+ } else { // Normal start
+ changeAutoCenteringSetting(autoCenteringEnabled.toBool());
+ enableGPS(gpsEnabled.toBool());
+
+ if (gpsEnabled.toBool())
+ m_ui->showMaemoInformationBox(tr("GPS enabled"));
+
+ if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
+ m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+ }
+}
+
void SituareEngine::invalidCredentials()
{
qDebug() << __PRETTY_FUNCTION__;
m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
}
+void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ Q_UNUSED(latLonCoordinate);
+ Q_UNUSED(accuracy);
+
+ if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
+ m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
+
+ disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+}
+
void SituareEngine::signalsFromFacebookAuthenticator()
{
qDebug() << __PRETTY_FUNCTION__;
#define ENGINE_H
#include <QObject>
+#include <QPointF>
class QMainWindow;
private:
/**
+ * @brief Read settings and determine whether to use GPS and autocentering.
+ * When values does not found on the settings, GPS and autocentering are enabled as a default.
+ */
+ void initializeGpsAndAutocentering();
+
+ /**
* @brief Connect signals coming from Facdebook authenticator
*/
void signalsFromFacebookAuthenticator();
void enableGPS(bool enabled);
/**
+ * @brief Sets zoom level to default when first GPS location is received if autocentering
+ * is enabled.
+ *
+ * @param latLonCoordinate own location
+ * @param accuracy accuracy of GPS location
+ */
+ void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
+
+ /**
* @brief Slot for intercepting signal when credentials are invalid
*
*/
QPointF startLocation;
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
- ERROR_VALUE_NOT_FOUND_ON_SETTINGS ||
- settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
- ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
+ if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString()
+ == ERROR_VALUE_NOT_FOUND_ON_SETTINGS || settings.value(MAP_LAST_ZOOMLEVEL,
+ ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() == ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
startLocation = QPointF(DEFAULT_LONGITUDE, DEFAULT_LATITUDE);
m_zoomLevel = DEFAULT_START_ZOOM_LEVEL;
- }
-
- else {
+ } else {
m_zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toInt();
startLocation = settings.value(MAP_LAST_POSITION,
ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
}
}
+void MapEngine::setZoomLevel(int newZoomLevel)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomLevel = newZoomLevel;
+ emit zoomLevelChanged(m_zoomLevel);
+}
+
void MapEngine::setViewLocation(QPointF latLonCoordinate)
{
qDebug() << __PRETTY_FUNCTION__;
QGraphicsScene* scene();
/**
+ * @brief Sets new zoom level
+ *
+ * @return newZoomLevel value that is set to new zoom level
+ */
+ void setZoomLevel(const int newZoomLevel);
+
+ /**
* @brief Return tile path created from tile values.
*
* @param zoomLevel tile's zoom level
*
* @param latLonCoordinate Latitude & longitude coordinates for location
*/
- void setViewLocation(QPointF latLonCoordinate);
+ void setViewLocation(QPointF latLonCoordinate);
/**
* @brief Slot for view resizing.
# Automatically generated by qmake (2.01a) Fri Mar 26 15:22:56 2010
# #####################################################################
CONFIG += qtestlib
-QT += opengl
+#QT += opengl
TEMPLATE = app
TARGET =
DEPENDPATH += .
// Check parameters of sended signals
QList<QVariant> parameters = mapEngineSpy.takeFirst();
QVERIFY(parameters.at(0).toInt() == DEFAULT_TEST_ZOOMLEVEL);
-// parameters = mapEngineSpy.takeFirst();
-// QVERIFY(parameters.at(0).toInt() == 0);
+
parameters = mapEngineSpy.takeFirst();
QVERIFY(parameters.at(0).toInt() == DEFAULT_START_ZOOM_LEVEL);
../../../src/map/friendlocationitem.cpp \
../../../src/map/friendgroupitem.cpp \
../../../src/ui/mainwindow.cpp \
- ../../../src/ui/mapviewscreen.cpp \
../../../src/ui/settingsdialog.cpp \
../../../src/ui/logindialog.cpp \
../../../src/map/mapview.cpp \
../../../src/ui/friendlistpanel.cpp \
- ../../../src/ui/userpanel.cpp \
../../../src/ui/panelsidebar.cpp \
../../../src/ui/zoombuttonpanel.cpp \
../../../src/ui/friendlistview.cpp \
../../../src/ui/userinfo.cpp \
../../../src/ui/imagebutton.cpp \
../../../src/ui/updatelocation/updatelocationdialog.cpp \
- ../../../src/ui/updatelocation/texteditautoresizer.cpp
+ ../../../src/ui/updatelocation/texteditautoresizer.cpp \
+ ../../../src/ui/userinfopanel.cpp \
+ ../../../src/ui/sidepanel.cpp \
+ ../../../src/ui/zoombutton.cpp
HEADERS += ../../../src/map/mapengine.h \
../../../src/map/mapscene.h \
../../../src/map/friendlocationitem.h \
../../../src/map/friendgroupitem.h \
../../../src/ui/mainwindow.h \
- ../../../src/ui/mapviewscreen.h \
../../../src/ui/settingsdialog.h \
../../../src/ui/logindialog.h \
../../../src/map/mapview.h \
../../../src/ui/friendlistpanel.h \
- ../../../src/ui/userpanel.h \
../../../src/ui/panelsidebar.h \
../../../src/ui/zoombuttonpanel.h \
../../../src/ui/friendlistview.h \
../../../src/ui/userinfo.h \
../../../src/ui/imagebutton.h \
../../../src/ui/updatelocation/updatelocationdialog.h \
- ../../../src/ui/updatelocation/texteditautoresizer.h
+ ../../../src/ui/updatelocation/texteditautoresizer.h \
+ ../../../src/ui/userinfopanel.h \
+ ../../../src/ui/sidepanel.h \
+ ../../../src/ui/zoombutton.h
map/friendgroupitem \
map/mapscene \
map/friendlocationitem \
+ map/uselastlocation \
user \
ui/friendlist \
ui/zoombuttonpanel