USA.
*/
+#include <QMessageBox>
#include "common.h"
#include "facebookservice/facebookauthentication.h"
SituareEngine::SituareEngine(QMainWindow *parent)
: QObject(parent),
m_autoCenteringEnabled(false),
+ m_automaticUpdateFirstStart(true),
m_loggedIn(false),
m_automaticUpdateIntervalTimer(0),
m_lastUpdatedGPSPosition(QPointF()),
void SituareEngine::automaticUpdateIntervalTimerTimeout()
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
if (m_gps->isRunning() && m_userMoved) {
- requestUpdateLocation();
+// requestUpdateLocation();
+ qWarning() << __PRETTY_FUNCTION__ << "requestUpdateLocation()";
m_userMoved = false;
}
}
void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__ << enabled;
+
+ bool accepted = false;
+
+ if (m_automaticUpdateFirstStart && enabled) {
+ accepted = m_ui->showEnableAutomaticUpdateLocationDialog();
+ m_automaticUpdateFirstStart = false;
+ m_ui->automaticLocationUpdateEnabled(accepted);
+ }
+ else {
+ accepted = true;
+ }
+
+ qWarning() << __PRETTY_FUNCTION__ << accepted;
- if (m_automaticUpdateIntervalTimer) {
+ if (accepted) {
+ if (m_automaticUpdateIntervalTimer) {
- if (enabled && m_gps->isRunning()) {
- m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
- m_automaticUpdateIntervalTimer->start();
+ if (enabled && m_gps->isRunning()) {
+ m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
+ m_automaticUpdateIntervalTimer->start();
+ }
+ else
+ m_automaticUpdateIntervalTimer->stop();
}
- else
- m_automaticUpdateIntervalTimer->stop();
}
}
******************************************************************************/
signals:
/**
+ * @brief Signals when automatic location update was enabled.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
+ void automaticLocationUpdateEnabled(bool enabled);
+
+ /**
* @brief Signals when new friends data is ready
*
* @param friendList List of User instances (friends)
* DATA MEMBERS
******************************************************************************/
private:
- bool m_autoCenteringEnabled; ///< Auto centering enabled
- bool m_loggedIn; ///< Login state
-
+ bool m_autoCenteringEnabled; ///< Auto centering flag
+ bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
+ bool m_loggedIn; ///< Login state
FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
GPSPosition *m_gps; ///< Instance of the gps position
MainWindow *m_ui; ///< Instance of the MainWindow UI
delete m_webView;
}
+void MainWindow::automaticLocationUpdateEnabled(bool enabled)
+{
+ m_settingsDialog->setAutomaticLocationUpdateSettings(enabled);
+}
+
void MainWindow::buildFullScreenButton()
{
qDebug() << __PRETTY_FUNCTION__;
m_viewPortHeight = height;
}
+bool MainWindow::showEnableAutomaticUpdateLocationDialog()
+{
+ QMessageBox msgBox(QMessageBox::Warning, tr("Automatic location update"),
+ tr("Are you sure you want to enable automatic location update?"),
+ QMessageBox::Ok | QMessageBox::Cancel, 0);
+ msgBox.button(QMessageBox::Ok)->setText(tr("Ok"));
+ int ret = msgBox.exec();
+
+ if (ret == QMessageBox::Ok)
+ return true;
+ else
+ return false;
+}
+
void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
{
qDebug() << __PRETTY_FUNCTION__;
******************************************************************************/
public:
/**
+ * @brief Sets automatic location update enabled from settings dialog.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
+ void automaticLocationUpdateEnabled(bool enabled);
+
+ /**
* @brief Clears cookie jar
*
*/
void setMapViewScene(QGraphicsScene *scene);
/**
+ * Shows dialog with enable automatic location update question.
+ *
+ * @return true if accepted, false otherwise
+ */
+ bool showEnableAutomaticUpdateLocationDialog();
+
+ /**
* @brief Show Maemo information box with message.
*
* @param message Information message
#include "common.h"
#include "settingsdialog.h"
+const QString SETTINGS_AUTOMATIC_UPDATE_ENABLED = "SETTINGS_AUTOMATIC_UPDATE_ENABLED";
const QString SETTINGS_AUTOMATIC_UPDATE_INTERVAL = "SETTINGS_AUTOMATIC_UPDATE_INTERVAL";
const int LIST_MINUTES_STEP = 5;
const int LIST_MINUTES_MAX = 60;
QStandardItemModel *updateIntervalListModel = new QStandardItemModel(0, 1, this);
populateUpdateIntervalList(updateIntervalListModel);
m_timePick->setModel(updateIntervalListModel);
-
+ m_automaticLocationUpdateIntervalButton->setValueText(
+ updateIntervalListModel->item(0, 0)->text());
Q_UNUSED(cancelButton);
#else
m_automaticLocationUpdateInterval = new QTimeEdit();
qDebug() << __PRETTY_FUNCTION__;
QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, m_automaticLocationUpdate->isChecked());
settings.setValue(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, time());
}
+void SettingsDialog::setAutomaticLocationUpdateSettings(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_automaticLocationUpdate->setChecked(checked);
+}
+
void SettingsDialog::enableSituareSettings(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
m_automaticLocationUpdate->setEnabled(enabled);
- toggleAutomaticLocationUpdate(enabled);
}
void SettingsDialog::readSettings()
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
QString automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, "")
.toString();
+
+ m_automaticLocationUpdate->setChecked(automaticUpdateEnabled);
+
if (!automaticUpdateInterval.isEmpty()) {
- setTime(QTime::fromString(automaticUpdateInterval));
- m_automaticLocationUpdateIntervalOldValue = time();
+ qWarning() << automaticUpdateInterval;
+ setTime(QTime::fromString(automaticUpdateInterval, "hh:mm:ss"));
+ qWarning() << time().toString("hh:mm:ss");
}
+
+ if (automaticUpdateEnabled)
+ QTimer::singleShot(0, this, SLOT(saveValues()));
}
void SettingsDialog::populateUpdateIntervalList(QStandardItemModel *model)
******************************************************************************/
public:
/**
+ * @brief Sets automatic location update settings from settings dialog.
+ */
+ void setAutomaticLocationUpdateSettings(bool enabled);
+
+ /**
* @brief Enables Situare related settings from settings dialog.
*
*/
void enableSituareSettings(bool enabled);
-
private slots:
/**
* @brief Saves settings to file.
* DATA MEMBERS
******************************************************************************/
private:
- QCheckBox *m_automaticLocationUpdate; ///< Pointer to CheckBox
+ QCheckBox *m_automaticLocationUpdate; ///< Pointer to CheckBox
bool m_automaticLocationUpdateOldValue; ///< Automatic location update state
QTime m_automaticLocationUpdateIntervalOldValue;///< Automatic location update interval value
#ifdef Q_WS_MAEMO_5
- QMaemo5ValueButton *m_automaticLocationUpdateIntervalButton;
- QMaemo5ListPickSelector *m_timePick;
+ QMaemo5ValueButton *m_automaticLocationUpdateIntervalButton; ///< Maemo 5 value button
+ QMaemo5ListPickSelector *m_timePick; ///< Maemo 5 time pick selector
#else
QTimeEdit *m_automaticLocationUpdateInterval; ///< Pointer to QTimeEdit
#endif