settingsdialog.
m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
m_facebookAuthenticator->start();
+
+ m_automaticUpdateIntervalTimer = new QTimer(this);
+ connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
+ this, SLOT(automaticUpdateIntervalTimerTimeout()));
}
SituareEngine::~SituareEngine()
settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
}
+void SituareEngine::automaticLocationUpdateIntervalSet(int updateIntervalMsecs)
+{
+ qDebug() << __PRETTY_FUNCTION__ <<;
+
+ if (m_automaticUpdateIntervalTimer) {
+
+ m_automaticUpdateIntervalTimer->stop();
+
+ if ((updateIntervalMsecs > 0) && m_gps->isRunning()) {
+ m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
+ m_automaticUpdateIntervalTimer->start();
+ }
+ }
+}
+
+void SituareEngine::automaticUpdateIntervalTimerTimeout()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_gps->isRunning());
+ //requestUpdateLocation();
+}
+
void SituareEngine::changeAutoCenteringSetting(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
else {
m_gps->stop();
enableAutoCentering(false);
+ automaticLocationUpdateIntervalSet(-1);
}
}
connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
this, SLOT(requestUpdateLocation(QString,bool)));
+ connect(m_ui, SIGNAL(automaticLocationUpdateIntervalSet(int)),
+ this, SLOT(automaticLocationUpdateIntervalSet(int)));
+
// signals from user info tab
connect(m_ui, SIGNAL(refreshUserData()),
this, SLOT(refreshUserData()));
#define ENGINE_H
#include <QObject>
+#include <QTime>
class QMainWindow;
class SituareService;
class User;
+class QTimer;
+
/**
* @brief Engine class for Situare Application
*
* @param status Status message
* @param publish Publish on Facebook
*/
- void requestUpdateLocation(const QString &status, bool publish);
+ void requestUpdateLocation(const QString &status = QString(), bool publish = false);
/**
* @brief Slot to refresh user data
void signalsFromSituareService();
private slots:
+
+ void automaticLocationUpdateIntervalSet(int updateIntervalMsecs);
+
+ void automaticUpdateIntervalTimerTimeout();
+
/**
* @brief Set auto centering feature enabled / disabled
*/
MapEngine *m_mapEngine; ///< MapEngine
SituareService *m_situareService; ///< Instance of the situare server communication service
+ QTimer *m_automaticUpdateIntervalTimer;
+
};
#endif // ENGINE_H
buildFriendListPanel();
buildUserInfoPanel();
+ m_settingsDialog = new SettingsDialog(this);
+ m_settingsDialog->hide();
+ connect(m_settingsDialog, SIGNAL(automaticLocationUpdateIntervalSet(int)),
+ this, SIGNAL(automaticLocationUpdateIntervalSet(int)));
+
createMenus();
setWindowTitle(tr("Situare"));
{
qDebug() << __PRETTY_FUNCTION__;
- SettingsDialog *dialog = new SettingsDialog(this);
- if(!m_loggedIn) {
- dialog->disableSituareSettings();
- }
- dialog->show();
+ m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
+
+ m_settingsDialog->show();
}
void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
class User;
class UserInfoPanel;
class ZoomButtonPanel;
+class SettingsDialog;
/**
* @brief Main Window Class
*/
void autoCenteringTriggered(bool enabled);
+ void automaticLocationUpdateIntervalSet(int updateIntervalMsecs);
+
/**
* @brief Signal that indicates when user has cancelled login process
*
PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
UserInfoPanel *m_userPanel; ///< Instance of the user information panel
ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
+
+ SettingsDialog *m_settingsDialog; ///< Settings dialog
};
#endif // MAINWINDOW_H
#include <QtGui>
#include <QDebug>
+#include <QTime>
#include "common.h"
#include "settingsdialog.h"
-const QString AUTOMATIC_LOCATION_UPDATE("Automatic_location_update");
-
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
{
QScrollArea *scrollArea = new QScrollArea(this);
QGridLayout *gridLayout = new QGridLayout(this);
QGroupBox *groupBox = new QGroupBox(scrollArea);
- QSettings settings(DIRECTORY_NAME, FILE_NAME);
m_automaticLocationUpdate = new QCheckBox(tr("Use automatic location update"));
- m_automaticLocationUpdate->setChecked(settings.value(AUTOMATIC_LOCATION_UPDATE).toBool());
+
+ m_automaticLocationUpdateInterval = new QTimeEdit();
+ m_automaticLocationUpdateInterval->setTimeRange(QTime(0, 0, 5), QTime(1, 0));
+ m_automaticLocationUpdateInterval->setDisplayFormat("mm:ss");
+ m_automaticLocationUpdateInterval->setDisabled(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
QPushButton *saveButton = buttonBox->addButton(QDialogButtonBox::Save);
QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
+
+ connect(m_automaticLocationUpdate, SIGNAL(toggled(bool)),
+ this, SLOT(toggleAutomaticLocationUpdate(bool)));
connect(saveButton, SIGNAL(clicked()), this, SLOT(saveValues()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
-
QFormLayout *form = new QFormLayout();
form->addWidget(m_automaticLocationUpdate);
+ form->addRow("Update interval", m_automaticLocationUpdateInterval);
groupBox->setLayout(form);
scrollArea->setWidget(groupBox);
scrollArea->show();
}
-SettingsDialog::~SettingsDialog()
+void SettingsDialog::saveValues()
{
qDebug() << __PRETTY_FUNCTION__;
- delete m_automaticLocationUpdate;
-}
-void SettingsDialog::dialogFinished(int /* reason */)
-{
- qDebug() << __PRETTY_FUNCTION__;
- deleteLater();
+ if (m_automaticLocationUpdate->isChecked()) {
+ QTime time = QTime();
+ emit automaticLocationUpdateIntervalSet(time.msecsTo(
+ m_automaticLocationUpdateInterval->time()));
+ }
+ else {
+ emit automaticLocationUpdateIntervalSet(-1);
+ }
+ accept();
}
-void SettingsDialog::saveValues()
+void SettingsDialog::enableSituareSettings(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
- QSettings settings(DIRECTORY_NAME, FILE_NAME);
- settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
- accept();
+ m_automaticLocationUpdate->setEnabled(enabled);
}
-void SettingsDialog::disableSituareSettings()
+void SettingsDialog::toggleAutomaticLocationUpdate(bool value)
{
qDebug() << __PRETTY_FUNCTION__;
-
- m_automaticLocationUpdate->setDisabled(true);
+ m_automaticLocationUpdateInterval->setEnabled(value);
}
#include <QDialog>
class QCheckBox;
+class QTimeEdit;
/**
* @brief Settings Dialog NOTE: dialog deletes itself after saving or closing settings
SettingsDialog(QWidget *parent = 0);
/**
- * @brief Destructor
- */
- ~SettingsDialog();
-
- /**
* @brief Disables Situare related settings from settings dialog
*
*/
- void disableSituareSettings();
+ void enableSituareSettings(bool enabled);
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
private slots:
/**
- * @brief is called when dialog is closed
- *
- * @param reason why dialog was closed
- */
- void dialogFinished(int reason);
-
- /**
* @brief Saves settings to file
*/
void saveValues();
+ void toggleAutomaticLocationUpdate(bool value);
+
+signals:
+ void automaticLocationUpdateIntervalSet(int updateIntervalMsecs);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
QCheckBox *m_automaticLocationUpdate; ///< Pointer to CheckBox
+ QTimeEdit *m_automaticLocationUpdateInterval; ///< Pointer to QTimeEdit
};
#endif // SETTINGSDIALOG_H