void SituareEngine::changeAutoCenteringSetting(bool enabled)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__ << enabled;
m_autoCenteringEnabled = enabled;
- enableAutoCentering(enabled);
+ setAutoCentering(enabled);
}
void SituareEngine::disableAutoCentering()
changeAutoCenteringSetting(false);
}
-void SituareEngine::enableAutoCentering(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->setIndicatorButtonEnabled(enabled);
- m_mapEngine->setAutoCentering(enabled);
-
- if (enabled)
- m_gps->requestLastPosition();
-}
-
-void SituareEngine::enableGPS(bool enabled)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_ui->setOwnLocationCrosshairVisibility(!enabled);
-
- if (m_gps->isInitialized()) {
- m_ui->setGPSButtonEnabled(enabled);
- m_mapEngine->setGPSEnabled(enabled);
-
- if (enabled && !m_gps->isRunning()) {
- m_gps->start();
- enableAutoCentering(m_autoCenteringEnabled);
- m_gps->requestLastPosition();
-
- if(m_ui->loginState())
- m_ui->readAutomaticLocationUpdateSettings();
- }
- else if (!enabled && m_gps->isRunning()) {
- m_gps->stop();
- enableAutoCentering(false);
- enableAutomaticLocationUpdate(false);
- }
- }
- else {
- if (enabled)
- m_ui->buildInformationBox(tr("Unable to start GPS"));
- m_ui->setGPSButtonEnabled(false);
- m_mapEngine->setGPSEnabled(false);
- }
-}
-
void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
{
qDebug() << __PRETTY_FUNCTION__;
void SituareEngine::enablePowerSave(bool enabled)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__ << enabled;
m_gps->enablePowerSave(enabled);
m_ui->buildInformationBox(tr("Map image download failed"), true);
break;
case SituareError::GPS_INITIALIZATION_FAILED:
- enableGPS(false);
+ setGPS(false);
m_ui->buildInformationBox(tr("GPS initialization failed"), true);
break;
case SituareError::INVALID_JSON:
this, SLOT(setFirstStartZoomLevel()));
changeAutoCenteringSetting(true);
- enableGPS(true);
+ setGPS(true);
m_ui->buildInformationBox(tr("GPS enabled"));
} else { // Normal start
changeAutoCenteringSetting(autoCenteringEnabled.toBool());
- enableGPS(gpsEnabled.toBool());
+ setGPS(gpsEnabled.toBool());
if (gpsEnabled.toBool())
m_ui->buildInformationBox(tr("GPS enabled"));
}
} else {
- enableGPS(false);
+ setGPS(false);
}
}
}
}
+void SituareEngine::setAutoCentering(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+ m_ui->setIndicatorButtonEnabled(enabled);
+ m_mapEngine->setAutoCentering(enabled);
+ m_ui->setOwnLocationCrosshairVisibility(!enabled);
+
+ if (enabled) {
+ setGPS(true);
+ m_gps->requestLastPosition();
+ }
+}
+
void SituareEngine::setFirstStartZoomLevel()
{
qDebug() << __PRETTY_FUNCTION__;
this, SLOT(setFirstStartZoomLevel()));
}
+void SituareEngine::setGPS(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+ if (m_gps->isInitialized()) {
+ m_ui->setGPSButtonEnabled(enabled);
+ m_mapEngine->setGPSEnabled(enabled);
+
+ if (enabled && !m_gps->isRunning()) {
+ m_gps->start();
+ m_gps->requestLastPosition();
+
+ if(m_ui->loginState())
+ m_ui->readAutomaticLocationUpdateSettings();
+ }
+ else if (!enabled && m_gps->isRunning()) {
+ m_gps->stop();
+ changeAutoCenteringSetting(false);
+ enableAutomaticLocationUpdate(false);
+ }
+ }
+ else {
+ if (enabled)
+ m_ui->buildInformationBox(tr("Unable to start GPS"));
+ m_ui->setGPSButtonEnabled(false);
+ m_mapEngine->setGPSEnabled(false);
+ }
+}
+
void SituareEngine::signalsFromFacebookAuthenticator()
{
qDebug() << __PRETTY_FUNCTION__;
// signals from menu buttons
connect(m_ui, SIGNAL(gpsTriggered(bool)),
- this, SLOT(enableGPS(bool)));
+ this, SLOT(setGPS(bool)));
//signals from dialogs
connect(m_ui, SIGNAL(cancelLoginProcess()),
void disableAutoCentering();
/**
- * @brief Slot for auto centering enabling.
- *
- * Calls gps to send last known position
- *
- * @param enabled true if auto centering was enabled, false otherwise
- */
- void enableAutoCentering(bool enabled);
-
- /**
- * @brief Slot for gps enabling.
- *
- * @param enabled true if gps should be enabled, false otherwise
- */
- void enableGPS(bool enabled);
-
- /**
* @brief Enables automatic location update.
*
* @param enabled true if enabled, false otherwise
void requestAutomaticUpdateIfMoved(GeoCoordinate position);
/**
+ * @brief Slot for setting auto centering state.
+ *
+ * Calls gps to send last known position
+ *
+ * @param enabled true if auto centering was enabled, false otherwise
+ */
+ void setAutoCentering(bool enabled);
+
+ /**
* @brief Sets zoom level to default when first GPS location is received if autocentering
* is enabled.
*/
void setFirstStartZoomLevel();
/**
+ * @brief Slot for setting GPS state.
+ *
+ * @param enabled true if gps should be enabled, false otherwise
+ */
+ void setGPS(bool enabled);
+
+ /**
* @brief Automatic update interval timer timeout.
*
* Requests update location if user has moved.
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
- m_drawOwnLocationCrosshair(false),
m_errorShown(false),
m_loggedIn(false),
m_refresh(false),
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
+ if (m_ownLocationCrosshair != 0) {
m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
}
qDebug() << __PRETTY_FUNCTION__;
m_gpsToggleAct->setChecked(enabled);
-
- setOwnLocationCrosshairVisibility(!enabled);
}
void MainWindow::setIndicatorButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
- if (visibility && m_loggedIn) {
+ if (visibility) {
m_ownLocationCrosshair->show();
- m_drawOwnLocationCrosshair = true;
drawOwnLocationCrosshair(m_viewPortSize);
} else {
m_ownLocationCrosshair->hide();
- m_drawOwnLocationCrosshair = false;
}
}
{
qDebug() << __PRETTY_FUNCTION__;
- if(m_loggedIn) {
-
- if(!m_gpsToggleAct->isChecked())
- setOwnLocationCrosshairVisibility(true);
- } else {
+ if(!m_loggedIn) {
m_friendsListPanel->closePanel();
m_friendsListPanel->hide();
m_friendsListPanelSidebar->hide();
m_userPanel->closePanel();
m_userPanel->hide();
m_userPanelSidebar->hide();
- setOwnLocationCrosshairVisibility(false);
}
}
*/
void readAutomaticLocationUpdateSettings();
-// /**
-// * @brief Enable / disable auto centering button.
-// *
-// * @param enabled true if shoud be enabled, false otherwise
-// */
-// void setAutoCenteringButtonEnabled(bool enabled);
-
/**
* @brief Enable / disable GPS button.
*
* DATA MEMBERS
******************************************************************************/
private:
- bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
bool m_errorShown; ///< Indicates if error dialog/note is shown
bool m_loggedIn; ///< Indicates login state
bool m_refresh; ///< Indicates when webpage is refreshed
int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
- QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
QAction *m_loginAct; ///< Action to Login/Logout
QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog