+jspeed (0.1-7) unstable; urgency=low
+
+ * Added altitude display to detail screen.
+ * Added option to disable automatic screen rotation.
+
+ -- Jesse Hakanen <jessehakanen@gmail.com> Fri, 15 Oct 2010 20:30:24 +0100
+
jspeed (0.1-6) unstable; urgency=low
* Added speed camera warning images to default themes.
QString const DEFAULT_BACKGROUND_COLOR = "#000";
QString const DEFAULT_COLOR = "#fff";
int const FONT_SIZE = 20;
- int const START_HEIGHT = 80;
+ int const START_HEIGHT = 61;
int const ITEM_WIDTH = 130;
}
{
QString unit = Odometer::getUnit();
QString speedUnit = Odometer::getSpeedUnit();
+ QString meterUnit = Odometer::getMeterUnit();
getScene()->setBackgroundBrush(QBrush(QColor(DEFAULT_BACKGROUND_COLOR)));
total_ = createItem(roundDouble(Odometer::instance().getTotal()));
totalUnit_ = createItem(unit);
+ altitudeLabel_ = createItem(tr("Altitude"));
+ altitude_ = createItem(roundDouble(Odometer::instance().getLatestFix().altitude));
+ altitudeUnit_ = createItem(meterUnit);
+
speedLabel_ = createItem(tr("Speed"));
speed_ = createItem(roundDouble(0.0));
speedUnit_ = createItem(speedUnit);
speed_->setPlainText(roundDouble(Odometer::instance().getLatestFix().speed));
trip_->setPlainText(roundDouble(Odometer::instance().getTrip()));
+ altitude_->setPlainText(roundDouble(Odometer::instance().getLatestFix().altitude));
total_->setPlainText(roundDouble(Odometer::instance().getTotal()));
avgSpeed_->setPlainText(roundDouble(Odometer::instance().getAverageSpeed()));
maxSpeed_->setPlainText(roundDouble(Odometer::instance().getMaxSpeed()));
{
QString unit = Odometer::getUnit();
QString speedUnit = Odometer::getSpeedUnit();
+ QString meterUnit = Odometer::getMeterUnit();
tripUnit_->setPlainText(unit);
totalUnit_->setPlainText(unit);
+ altitudeUnit_->setPlainText(meterUnit);
speedUnit_->setPlainText(speedUnit);
avgSpeedUnit_->setPlainText(speedUnit);
maxSpeedUnit_->setPlainText(speedUnit);
int width = getScene()->width();
int height = getScene()->height();
- int lineHeight = height / 9;
+ int lineHeight = (height - START_HEIGHT) / 8;
int padding = width / 22;
int area1 = (width / 3) + ITEM_WIDTH / 2 + 20;
total_->setPos(area1, START_HEIGHT + lineHeight);
totalUnit_->setPos(area2, START_HEIGHT + lineHeight);
- speedLabel_->setPos(padding, START_HEIGHT + 2 * lineHeight);
- speed_->setPos(area1, START_HEIGHT + 2 * lineHeight);
- speedUnit_->setPos(area2, START_HEIGHT + 2 * lineHeight);
+ altitudeLabel_->setPos(padding, START_HEIGHT + 2 * lineHeight);
+ altitude_->setPos(area1, START_HEIGHT + 2 * lineHeight);
+ altitudeUnit_->setPos(area2, START_HEIGHT + 2 * lineHeight);
+
+ speedLabel_->setPos(padding, START_HEIGHT + 3 * lineHeight);
+ speed_->setPos(area1, START_HEIGHT + 3 * lineHeight);
+ speedUnit_->setPos(area2, START_HEIGHT + 3 * lineHeight);
- avgSpeedLabel_->setPos(padding, START_HEIGHT + 3 * lineHeight);
- avgSpeed_->setPos(area1, START_HEIGHT + 3 * lineHeight);
- avgSpeedUnit_->setPos(area2, START_HEIGHT + 3 * lineHeight);
+ avgSpeedLabel_->setPos(padding, START_HEIGHT + 4 * lineHeight);
+ avgSpeed_->setPos(area1, START_HEIGHT + 4 * lineHeight);
+ avgSpeedUnit_->setPos(area2, START_HEIGHT + 4 * lineHeight);
- maxSpeedLabel_->setPos(padding, START_HEIGHT + 4 * lineHeight);
- maxSpeed_->setPos(area1, START_HEIGHT + 4 * lineHeight);
- maxSpeedUnit_->setPos(area2, START_HEIGHT + 4 * lineHeight);
+ maxSpeedLabel_->setPos(padding, START_HEIGHT + 5 * lineHeight);
+ maxSpeed_->setPos(area1, START_HEIGHT + 5 * lineHeight);
+ maxSpeedUnit_->setPos(area2, START_HEIGHT + 5 * lineHeight);
- tripTimeLabel_->setPos(padding, START_HEIGHT + 5 * lineHeight);
- tripTime_->setPos(area1, START_HEIGHT + 5 * lineHeight);
+ tripTimeLabel_->setPos(padding, START_HEIGHT + 6 * lineHeight);
+ tripTime_->setPos(area1, START_HEIGHT + 6 * lineHeight);
- totalTimeLabel_->setPos(padding, START_HEIGHT + 6 * lineHeight);
- totalTime_->setPos(area1, START_HEIGHT + 6 * lineHeight);
+ totalTimeLabel_->setPos(padding, START_HEIGHT + 7 * lineHeight);
+ totalTime_->setPos(area1, START_HEIGHT + 7 * lineHeight);
- int y1 = START_HEIGHT + 2 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
- int y2 = START_HEIGHT + 5 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
+ int y1 = START_HEIGHT + 3 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
+ int y2 = START_HEIGHT + 6 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
int x = width - padding;
line1_->setLine(padding + 2, y1, x, y1);
line2_->setLine(padding + 2, y2, x, y2);
QGraphicsTextItem* totalLabel_;
QGraphicsTextItem* total_;
QGraphicsTextItem* totalUnit_;
+ QGraphicsTextItem* altitudeLabel_;
+ QGraphicsTextItem* altitude_;
+ QGraphicsTextItem* altitudeUnit_;
QGraphicsTextItem* speedLabel_;
QGraphicsTextItem* speed_;
QGraphicsTextItem* speedUnit_;
addAction(tr("Reset trip"), this, SIGNAL(resetTrip()));
addAction(tr("Reset all"), this, SLOT(confirmReset()));
addAction(tr("Theme"), this, SLOT(selectTheme()));
- addAction(tr("Set unit"), this, SLOT(selectUnit()));
+ addAction(tr("Options"), this, SLOT(selectUnit()));
addAction(tr("Speed camera alerts"), this, SLOT(openPoiAlerts()));
addAction(tr("Speed alarm"), this, SLOT(openSpeedAlarm()));
addAction(tr("Flip screen"), this, SIGNAL(flip()));
{
unitSelector_ = new UnitSelector(this);
connect(unitSelector_, SIGNAL(unitChanged()), this, SIGNAL(unitChanged()));
+ connect(unitSelector_, SIGNAL(orientationChanged()), this, SIGNAL(orientationChanged()));
}
unitSelector_->show();
void flip();
void themeChanged();
void unitChanged();
+ void orientationChanged();
private slots:
void selectTheme();
#include "speedalarm.h"
#include "mediaplayer.h"
#include "orientation.h"
+#include "settings.h"
#include <QOrientationSensor>
#include <QSensor>
}
orientation_->setSupportedOrientations(orientations);
+ onOrientationChanged();
orientation_->update();
return true;
connect(menu_, SIGNAL(flip()), stack_, SLOT(flip()));
connect(menu_, SIGNAL(themeChanged()), this, SLOT(loadTheme()));
connect(menu_, SIGNAL(unitChanged()), &(Odometer::instance()), SLOT(updateUnit()));
+ connect(menu_, SIGNAL(orientationChanged()), this, SLOT(onOrientationChanged()));
}
menu_->show();
connection.call(msg);
}
+
+void MainWindow::onOrientationChanged()
+{
+ QString value = Settings::instance().value("orientation").toString();
+
+ if(value == "auto")
+ {
+ orientation_->setOrientationType(Orientation::TYPE_AUTO);
+ }
+ else if(value == "landscape")
+ {
+ orientation_->setOrientationType(Orientation::TYPE_LANDSCAPE);
+ }
+ else if(value == "portrait")
+ {
+ orientation_->setOrientationType(Orientation::TYPE_PORTRAIT);
+ }
+}
void openMenu();
void keepBacklightOn();
bool loadTheme();
+ void onOrientationChanged();
private:
void addScreens();
#include "orientation.h"
Orientation::Orientation(QMainWindow* window): QtMobility::QOrientationSensor(window),
-current_(QtMobility::QOrientationReading::TopUp), orientations_(0), window_(window)
+current_(QtMobility::QOrientationReading::TopUp), orientations_(0), window_(window),
+type_(TYPE_AUTO)
{
connect(this, SIGNAL(readingChanged()), this, SLOT(onReadingChanged()));
}
orientations_ = orientations;
}
+void Orientation::setOrientationType(OrientationType type)
+{
+ type_ = type;
+
+ handleManualOrientation();
+}
+
void Orientation::update()
{
+ if(type_ != TYPE_AUTO)
+ {
+ handleManualOrientation();
+ return;
+ }
+
using QtMobility::QOrientationReading;
OrientationName orientation = LANDSCAPE;
void Orientation::onReadingChanged()
{
+ if(type_ != TYPE_AUTO)
+ {
+ return;
+ }
+
if(reading()->orientation() != current_)
{
update();
emit changed();
}
}
+
+void Orientation::handleManualOrientation()
+{
+ switch(type_)
+ {
+ case TYPE_LANDSCAPE:
+ if(orientations_ & LANDSCAPE)
+ {
+ window_->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ }
+ else if(orientations_ & PORTRAIT)
+ {
+ window_->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ }
+ break;
+ case TYPE_PORTRAIT:
+ if(orientations_ & PORTRAIT)
+ {
+ window_->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ }
+ else if(orientations_ & LANDSCAPE)
+ {
+ window_->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ }
+ break;
+ default:
+ break;
+ }
+}
public:
enum OrientationName {LANDSCAPE = 0x01, PORTRAIT = 0x02};
+ enum OrientationType {TYPE_AUTO, TYPE_LANDSCAPE, TYPE_PORTRAIT};
Orientation(QMainWindow* window);
void setSupportedOrientations(int orientations);
+ void setOrientationType(OrientationType type);
public slots:
void update();
private slots:
void onReadingChanged();
+ void handleManualOrientation();
private:
QtMobility::QOrientationReading::Orientation current_;
int orientations_;
QMainWindow* window_;
+ OrientationType type_;
};
#endif
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"));
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();
}
signals:
void unitChanged();
+ void orientationChanged();
private slots:
void saveUnit();
private:
ButtonSelector* selector_;
QString unit_;
+ ButtonSelector* orientationSelector_;
+ QString orientation_;
};
#endif