Added altitude display to detail screen. Added option to disable auto rotation.
[jspeed] / src / detailscreen.cpp
index 4599e4c..ee2da40 100644 (file)
@@ -33,7 +33,7 @@ namespace
     QString const DEFAULT_BACKGROUND_COLOR = "#000";
     QString const DEFAULT_COLOR = "#fff";
     int const FONT_SIZE = 20;
     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;
 
 }
     int const ITEM_WIDTH = 130;
 
 }
@@ -42,6 +42,7 @@ DetailScreen::DetailScreen(QWidget* parent): ThemeScreen(parent)
 {
     QString unit = Odometer::getUnit();
     QString speedUnit = Odometer::getSpeedUnit();
 {
     QString unit = Odometer::getUnit();
     QString speedUnit = Odometer::getSpeedUnit();
+    QString meterUnit = Odometer::getMeterUnit();
 
     getScene()->setBackgroundBrush(QBrush(QColor(DEFAULT_BACKGROUND_COLOR)));
 
 
     getScene()->setBackgroundBrush(QBrush(QColor(DEFAULT_BACKGROUND_COLOR)));
 
@@ -53,6 +54,10 @@ DetailScreen::DetailScreen(QWidget* parent): ThemeScreen(parent)
     total_ = createItem(roundDouble(Odometer::instance().getTotal()));
     totalUnit_ = createItem(unit);
 
     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);
     speedLabel_ = createItem(tr("Speed"));
     speed_ = createItem(roundDouble(0.0));
     speedUnit_ = createItem(speedUnit);
@@ -92,6 +97,7 @@ void DetailScreen::update()
 
     speed_->setPlainText(roundDouble(Odometer::instance().getLatestFix().speed));
     trip_->setPlainText(roundDouble(Odometer::instance().getTrip()));
 
     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()));
     total_->setPlainText(roundDouble(Odometer::instance().getTotal()));
     avgSpeed_->setPlainText(roundDouble(Odometer::instance().getAverageSpeed()));
     maxSpeed_->setPlainText(roundDouble(Odometer::instance().getMaxSpeed()));
@@ -115,9 +121,11 @@ void DetailScreen::updateUnits()
 {
     QString unit = Odometer::getUnit();
     QString speedUnit = Odometer::getSpeedUnit();
 {
     QString unit = Odometer::getUnit();
     QString speedUnit = Odometer::getSpeedUnit();
+    QString meterUnit = Odometer::getMeterUnit();
 
     tripUnit_->setPlainText(unit);
     totalUnit_->setPlainText(unit);
 
     tripUnit_->setPlainText(unit);
     totalUnit_->setPlainText(unit);
+    altitudeUnit_->setPlainText(meterUnit);
     speedUnit_->setPlainText(speedUnit);
     avgSpeedUnit_->setPlainText(speedUnit);
     maxSpeedUnit_->setPlainText(speedUnit);
     speedUnit_->setPlainText(speedUnit);
     avgSpeedUnit_->setPlainText(speedUnit);
     maxSpeedUnit_->setPlainText(speedUnit);
@@ -132,7 +140,7 @@ void DetailScreen::reArrange()
     int width = getScene()->width();
     int height = getScene()->height();
 
     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;
 
     int padding = width / 22;
     int area1 = (width / 3) + ITEM_WIDTH / 2 + 20;
@@ -146,26 +154,30 @@ void DetailScreen::reArrange()
     total_->setPos(area1, START_HEIGHT + lineHeight);
     totalUnit_->setPos(area2, START_HEIGHT + lineHeight);
 
     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);
     int x = width - padding;
     line1_->setLine(padding + 2, y1, x, y1);
     line2_->setLine(padding + 2, y2, x, y2);