QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
- m_ui->setGPS(gpsEnabled.toBool());
- m_ui->setAutoCentering(autoCenteringEnabled.toBool());
+ // 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_mapEngine->init();
settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
}
+void SituareEngine::changeAutoCenteringSetting(bool enabled)
+{
+ m_autoCenteringEnabled = enabled;
+ enableAutoCentering(enabled);
+}
+
+void SituareEngine::disableAutoCentering()
+{
+ changeAutoCenteringSetting(false);
+ m_ui->showMaemoInformationBox(tr("Auto centering disabled"));
+}
+
+void SituareEngine::enableAutoCentering(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->setAutoCenteringButtonEnabled(enabled);
+ m_mapEngine->setAutoCentering(enabled);
+
+ if (enabled)
+ m_gps->requestLastPosition();
+}
+
+void SituareEngine::enableGPS(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->setGPSButtonEnabled(enabled);
+ m_mapEngine->setGPSEnabled(enabled);
+
+ if (enabled) {
+ m_gps->start();
+ enableAutoCentering(m_autoCenteringEnabled);
+ m_gps->requestLastPosition();
+ }
+ else {
+ m_gps->stop();
+ enableAutoCentering(false);
+ }
+}
+
+void SituareEngine::error(const QString &error)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << error;
+ // ToDo: signal UI?
+}
+
+void SituareEngine::loginOk()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->show();
+ m_situareService->fetchLocations(); // request user locations
+}
+
+void SituareEngine::loginProcessCancelled()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->toggleProgressIndicator(false);
+ //ToDo: do something
+}
+
+void SituareEngine::refreshUserData()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->toggleProgressIndicator(true);
+
+ m_situareService->fetchLocations();
+}
+
+void SituareEngine::requestAddress()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_gps->isRunning()) {
+ m_latestLocation = m_gps->lastPosition();
+ m_situareService->reverseGeo(m_latestLocation);
+ }
+ else {
+ m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
+ }
+}
+
+void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_ui->toggleProgressIndicator(true);
+
+ if (m_gps->isRunning()) {
+ m_latestLocation = m_gps->lastPosition();
+ m_situareService->updateLocation(m_latestLocation, status, publish);
+ }
+ else {
+ m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
+ }
+}
+
void SituareEngine::signalsFromGPS()
{
connect(m_gps, SIGNAL(position(QPointF,qreal)),
// signals from menu buttons
- connect(m_ui, SIGNAL(autoCenteringToggled(bool)),
- m_mapEngine, SLOT(setAutoCentering(bool)));
-
- connect(m_ui, SIGNAL(autoCenteringToggled(bool)),
- this, SLOT(enableAutoCentering(bool)));
+ connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
+ this, SLOT(changeAutoCenteringSetting(bool)));
- connect(m_ui, SIGNAL(gpsToggled(bool)),
- m_mapEngine, SLOT(gpsEnabled(bool)));
-
- connect(m_ui, SIGNAL(gpsToggled(bool)),
+ connect(m_ui, SIGNAL(gpsTriggered(bool)),
this, SLOT(enableGPS(bool)));
//signals from dialogs
m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
}
-void SituareEngine::disableAutoCentering()
-{
- m_ui->setAutoCentering(false);
-}
-
-void SituareEngine::loginProcessCancelled()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->toggleProgressIndicator(false);
- //ToDo: do something
-}
-
-void SituareEngine::error(const QString &error)
-{
- qDebug() << __PRETTY_FUNCTION__;
- qDebug() << error;
- // ToDo: signal UI?
-}
-
-void SituareEngine::loginOk()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->show();
- m_situareService->fetchLocations(); // request user locations
-}
-
-void SituareEngine::requestAddress()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if (m_gps->isRunning()) {
- m_latestLocation = m_gps->lastPosition();
- m_situareService->reverseGeo(m_latestLocation);
- }
- else {
- m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
- }
-}
-
-void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->toggleProgressIndicator(true);
-
- if (m_gps->isRunning()) {
- m_latestLocation = m_gps->lastPosition();
- m_situareService->updateLocation(m_latestLocation, status, publish);
- }
- else {
- m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
- }
-}
-
void SituareEngine::updateWasSuccessful()
{
qDebug() << __PRETTY_FUNCTION__;
m_situareService->fetchLocations();
}
-void SituareEngine::refreshUserData()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->toggleProgressIndicator(true);
-
- m_situareService->fetchLocations();
-}
-
void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
{
qDebug() << __PRETTY_FUNCTION__;
emit userLocationReady(user);
emit friendsLocationsReady(friendsList);
}
-
-void SituareEngine::enableGPS(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if (enabled) {
- /// @todo is this required?
- // m_gps->requestLastPosition();
- m_gps->start();
- }
- else {
- m_gps->stop();
- }
-}
-
-void SituareEngine::enableAutoCentering(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_autoCenteringEnabled = enabled;
-
- if (enabled)
- m_gps->requestLastPosition();
-}
delete m_webView;
}
-void MainWindow::autoCenteringToggledActions(bool enabled)
-{
- if (enabled)
- showMaemoInformationBox(tr("Auto centering enabled"));
- else
- showMaemoInformationBox(tr("Auto centering disabled"));
-}
-
void MainWindow::buildFriendListPanel()
{
m_friendsListPanel = new FriendListPanel(this);
m_gpsToggleAct = new QAction(tr("GPS"), this);
m_gpsToggleAct->setCheckable(true);
- connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
- this, SIGNAL(gpsToggled(bool)));
- connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
- this, SLOT(gpsToggledActions(bool)));
+ connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
+ this, SIGNAL(gpsTriggered(bool)));
// automatic centering
m_autoCenteringAct = new QAction(tr("Auto centering"), this);
m_autoCenteringAct->setCheckable(true);
- connect(m_autoCenteringAct, SIGNAL(toggled(bool)),
- this, SIGNAL(autoCenteringToggled(bool)));
- connect(m_autoCenteringAct, SIGNAL(toggled(bool)),
- this, SLOT(autoCenteringToggledActions(bool)));
+ connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
+ this, SIGNAL(autoCenteringTriggered(bool)));
// build the actual menu
m_viewMenu = menuBar()->addMenu(tr("Main"));
showMaemoInformationBox(tr("GPS timeout"));
}
-void MainWindow::gpsToggledActions(bool enabled)
-{
- if (enabled) {
- showMaemoInformationBox(tr("GPS enabled"));
- setOwnLocationCrosshairVisibility(false);
- }
- else {
- showMaemoInformationBox(tr("GPS disabled"));
- setOwnLocationCrosshairVisibility(true);
- }
-
- m_autoCenteringAct->setVisible(enabled);
-}
-
void MainWindow::grabZoomKeys(bool grab)
{
qDebug() << __PRETTY_FUNCTION__;
dialog->show();
}
-void MainWindow::setAutoCentering(bool enabled)
+void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
m_autoCenteringAct->setChecked(enabled);
}
-void MainWindow::setGPS(bool enabled)
+void MainWindow::setGPSButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
m_gpsToggleAct->setChecked(enabled);
+
+ if (enabled)
+ setOwnLocationCrosshairVisibility(false);
+ else
+ setOwnLocationCrosshairVisibility(true);
+
+ m_autoCenteringAct->setVisible(enabled);
}
void MainWindow::setMapViewScene(QGraphicsScene *scene)
*
* @param enabled true if shoud be enabled, false otherwise
*/
- void setAutoCentering(bool enabled);
+ void setAutoCenteringButtonEnabled(bool enabled);
/**
* @brief Enable / disable GPS.
*
* @param enabled true if enabled, false otherwise
*/
- void setGPS(bool enabled);
+ void setGPSButtonEnabled(bool enabled);
/**
* @brief Set scene for MapView
*/
void setMapViewScene(QGraphicsScene *scene);
+ /**
+ * @brief Show Maemo information box with message.
+ *
+ * @brief message information message
+ */
+ void showMaemoInformationBox(const QString &message);
+
public slots:
/**
* @brief Slot to intercept signal when user has pressed connect button from loginDialog
*/
void setOwnLocationCrosshairVisibility(bool visible);
- /**
- * @brief Show Maemo information box with message.
- *
- * @brief message information message
- */
- void showMaemoInformationBox(const QString &message);
-
private slots:
- void autoCenteringToggledActions(bool enabled);
+// void autoCenteringToggledActions(bool enabled);
/**
* @brief Slot for drawing the Open Street Map license text
*/
void gpsTimeout();
- void gpsToggledActions(bool enabled);
+// void gpsToggledActions(bool enabled);
/**
* @brief Slot to intercept signal when webview has finished loading webpage
void autoCenteringToggled(bool enabled);
/**
+ * @brief Automatic centering setting changed by user
+ *
+ * @param enabled True if automatic centering is enabled, otherwise false
+ */
+ void autoCenteringTriggered(bool enabled);
+
+ /**
* @brief View should be centered to new location
*
* @param sceneCoordinate Scene coordinates of the new center point
*
* @param enabled True if GPS is enabled, otherwise false
*/
- void gpsToggled(bool enabled);
+ void gpsTriggered(bool enabled);
// /**
// * @brief Signal for auto centering enabling.