3 Copyright (C) 2010 Christian Pulvermacher
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.
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.
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.
20 #include <QMaemo5ValueButton>
21 #include <QMaemo5ListPickSelector>
23 #include "preferences.h"
25 Preferences::Preferences(QWidget *parent):
28 setWindowTitle("Preferences");
30 QHBoxLayout *layout1 = new QHBoxLayout();
31 QVBoxLayout *layout2 = new QVBoxLayout();
33 QMaemo5ValueButton *rotation = new QMaemo5ValueButton(tr("Screen Rotation"), this);
34 rotation_selector = new QMaemo5ListPickSelector(this);
35 QStandardItemModel *model = new QStandardItemModel(0, 1, this);
36 model->appendRow(new QStandardItem(tr("Automatic")));
37 model->appendRow(new QStandardItem(tr("Landscape")));
38 model->appendRow(new QStandardItem(tr("Portrait")));
39 rotation_selector->setModel(model);
40 rotation_selector->setCurrentIndex(settings.value("screen_rotation", 0).toInt());
41 rotation->setPickSelector(rotation_selector);
42 rotation->setValueLayout(QMaemo5ValueButton::ValueBesideText);
43 layout2->addWidget(rotation);
45 QMaemo5ValueButton *leftzoom = new QMaemo5ValueButton(tr("Left Zoom Button"), this);
46 leftzoom_selector = new QMaemo5ListPickSelector(this);
47 QStandardItemModel *key_model = new QStandardItemModel(0, 1, this);
48 key_model->appendRow(new QStandardItem(tr("Left Click"))); //0
49 key_model->appendRow(new QStandardItem(tr("Right Click")));//1
50 key_model->appendRow(new QStandardItem(tr("Wheel Up")));//2
51 key_model->appendRow(new QStandardItem(tr("Wheel Down")));//3
52 key_model->appendRow(new QStandardItem(tr("Page Up")));//4
53 key_model->appendRow(new QStandardItem(tr("Page Down")));//5
54 leftzoom_selector->setModel(key_model);
55 leftzoom_selector->setCurrentIndex(settings.value("left_zoom", 0).toInt());
56 leftzoom->setPickSelector(leftzoom_selector);
57 leftzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText);
58 layout2->addWidget(leftzoom);
60 QMaemo5ValueButton *rightzoom = new QMaemo5ValueButton(tr("Right Zoom Button"), this);
61 rightzoom_selector = new QMaemo5ListPickSelector(this);
62 rightzoom_selector->setModel(key_model);
63 rightzoom_selector->setCurrentIndex(settings.value("right_zoom", 1).toInt());
64 rightzoom->setPickSelector(rightzoom_selector);
65 rightzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText);
66 layout2->addWidget(rightzoom);
68 QPushButton *ok = new QPushButton("OK");
69 ok->setMaximumWidth(100);
71 layout1->addLayout(layout2);
72 layout1->addWidget(ok);
76 connect(ok, SIGNAL(clicked()),
77 this, SLOT(accept()));
78 connect(this, SIGNAL(accepted()),
82 Preferences::~Preferences() { }
84 void Preferences::save()
86 settings.setValue("screen_rotation", rotation_selector->currentIndex());
87 settings.setValue("left_zoom", leftzoom_selector->currentIndex());
88 settings.setValue("right_zoom", rightzoom_selector->currentIndex());