X-Git-Url: http://git.maemo.org/git/?p=jspeed;a=blobdiff_plain;f=src%2Funitselector.cpp;h=9bd3824c6b78d90b1a86a9772f4e789d37cf4e19;hp=e4b0e16cc7175cc87524163ac817bc868fadd6b9;hb=36d7905fbbcc49571fef5b7769707441f344d179;hpb=5cc39ab8c690baf4e2b189ec189890834e63badc diff --git a/src/unitselector.cpp b/src/unitselector.cpp index e4b0e16..9bd3824 100644 --- a/src/unitselector.cpp +++ b/src/unitselector.cpp @@ -27,11 +27,13 @@ UnitSelector::UnitSelector(QWidget* parent): QDialog(parent) { - setWindowTitle(tr("Set unit")); + setWindowTitle(tr("Options")); unit_ = Settings::instance().value("unit", "km").toString(); - QHBoxLayout* layout = new QHBoxLayout; + QHBoxLayout* mainLayout = new QHBoxLayout; + + QVBoxLayout* layout = new QVBoxLayout; selector_ = new ButtonSelector(tr("Unit")); @@ -43,29 +45,55 @@ UnitSelector::UnitSelector(QWidget* parent): QDialog(parent) selector_->setCurrentIndex(1); } - layout->addWidget(selector_, Qt::AlignLeft); + layout->addWidget(selector_); + + orientation_ = Settings::instance().value("orientation", "auto").toString(); + + orientationSelector_ = new ButtonSelector(tr("Screen orientation")); + + orientationSelector_->addItem(tr("Automatic"), "auto"); + orientationSelector_->addItem(tr("Landscape"), "landscape"); + orientationSelector_->addItem(tr("Portrait"), "portrait"); + + if(orientation_ == "landscape") + { + orientationSelector_->setCurrentIndex(1); + } + else if(orientation_ == "portrait") + { + orientationSelector_->setCurrentIndex(2); + } + + layout->addWidget(orientationSelector_); ButtonBox* buttons = new ButtonBox; buttons->setOrientation(Qt::Horizontal); connect(buttons->addButton(tr("Save"), QDialogButtonBox::AcceptRole), SIGNAL(clicked(bool)), this, SLOT(saveUnit())); - layout->addWidget(buttons); + mainLayout->addLayout(layout, Qt::AlignLeft); + mainLayout->addWidget(buttons); - setLayout(layout); + setLayout(mainLayout); } void UnitSelector::saveUnit() { - QString value = selector_->value().toString(); + QString unitValue = selector_->value().toString(); + QString orientationValue = orientationSelector_->value().toString(); + + if(unitValue != unit_) + { + Settings::instance().setValue("unit", unitValue); + unit_ = unitValue; + emit unitChanged(); + } - if(value == unit_) + if(orientationValue != orientation_) { - hide(); - return; + Settings::instance().setValue("orientation", orientationValue); + orientation_ = orientationValue; + emit orientationChanged(); } - Settings::instance().setValue("unit", value); - unit_ = value; hide(); - emit unitChanged(); }