2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Katri Kaikkonen - katri.kaikkonen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include "settingsdialog.h"
28 SettingsDialog::SettingsDialog(QWidget *parent)
31 qDebug() << __PRETTY_FUNCTION__;
32 setWindowTitle(tr("Settings"));
34 QScrollArea *scrollArea = new QScrollArea(this);
35 QGridLayout *gridLayout = new QGridLayout(this);
36 QGroupBox *groupBox = new QGroupBox(scrollArea);
38 m_automaticLocationUpdate = new QCheckBox(tr("Use automatic location update"));
40 m_automaticLocationUpdateInterval = new QTimeEdit();
41 m_automaticLocationUpdateInterval->setTimeRange(QTime(0, 0, 5), QTime(1, 0));
42 m_automaticLocationUpdateInterval->setDisplayFormat("mm:ss");
43 m_automaticLocationUpdateInterval->setDisabled(true);
45 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
46 QPushButton *saveButton = buttonBox->addButton(QDialogButtonBox::Save);
47 QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
49 connect(m_automaticLocationUpdate, SIGNAL(toggled(bool)),
50 this, SLOT(toggleAutomaticLocationUpdate(bool)));
51 connect(saveButton, SIGNAL(clicked()), this, SLOT(saveValues()));
52 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
54 QFormLayout *form = new QFormLayout();
55 form->setRowWrapPolicy(QFormLayout::WrapAllRows);
56 form->addWidget(m_automaticLocationUpdate);
57 form->addRow("Update interval", m_automaticLocationUpdateInterval);
59 groupBox->setLayout(form);
60 scrollArea->setWidget(groupBox);
61 scrollArea->setWidgetResizable(true);
62 gridLayout->addWidget(scrollArea, 0, 0, 2, 1);
63 gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
64 setLayout(gridLayout);
69 void SettingsDialog::saveValues()
71 qDebug() << __PRETTY_FUNCTION__;
73 if (m_automaticLocationUpdate->isChecked()) {
75 emit automaticLocationUpdateIntervalSet(time.msecsTo(
76 m_automaticLocationUpdateInterval->time()));
79 emit automaticLocationUpdateIntervalSet(-1);
84 void SettingsDialog::enableSituareSettings(bool enabled)
86 qDebug() << __PRETTY_FUNCTION__;
88 m_automaticLocationUpdate->setEnabled(enabled);
91 void SettingsDialog::toggleAutomaticLocationUpdate(bool value)
93 qDebug() << __PRETTY_FUNCTION__;
94 m_automaticLocationUpdateInterval->setEnabled(value);