add preferences dialog
[presencevnc] / src / preferences.cpp
1 /*
2     Presence VNC
3     Copyright (C) 2010 Christian Pulvermacher
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #include <QtGui>
20 #include <QMaemo5ValueButton>
21 #include <QMaemo5ListPickSelector>
22
23 #include "preferences.h"
24
25 Preferences::Preferences(QWidget *parent):
26         QDialog(parent)
27 {
28         setWindowTitle("Preferences");
29
30         QHBoxLayout *layout1 = new QHBoxLayout();
31         QVBoxLayout *layout2 = new QVBoxLayout();
32
33         QMaemo5ValueButton *rotation = new QMaemo5ValueButton(tr("Screen Rotation"), this);
34         //rotation->setValueText(settings.value("sound_filename", SOUND_FILE).toString());
35         rotation_selector = new QMaemo5ListPickSelector(this);
36         QStandardItemModel *model = new QStandardItemModel(0, 1, this);
37         model->appendRow(new QStandardItem(tr("Automatic")));
38         model->appendRow(new QStandardItem(tr("Landscape")));
39         model->appendRow(new QStandardItem(tr("Portrait")));
40         rotation_selector->setModel(model);
41         rotation_selector->setCurrentIndex(settings.value("screen_rotation", 0).toInt());
42         rotation->setPickSelector(rotation_selector);
43         rotation->setValueLayout(QMaemo5ValueButton::ValueBesideText);
44         layout2->addWidget(rotation);
45
46         QPushButton *ok = new QPushButton("OK");
47
48         layout1->addLayout(layout2);
49         layout1->addWidget(ok);
50
51         setLayout(layout1);
52
53         connect(ok, SIGNAL(clicked()),
54                 this, SLOT(accept()));
55         connect(this, SIGNAL(accepted()),
56                 this, SLOT(save()));
57 }
58
59 Preferences::~Preferences()
60 {
61
62 }
63
64
65 void Preferences::save()
66 {
67         settings.setValue("screen_rotation", rotation_selector->currentIndex());
68
69         settings.sync();
70 }