#include <QtGui/QGraphicsTextItem>
#include <QtGui/QGraphicsLineItem>
-#include <QtGui/QGraphicsView>
-#include <QtGui/QApplication>
-#include <QtGui/QDesktopWidget>
+#include <QtGui/QGraphicsPixmapItem>
+#include <QtGui/QPixmap>
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <math.h>
namespace
{
QString const FONT = "Tahoma";
- QString const BACKGROUND = ":/resources/themes/default/background.png";
+ QString const DEFAULT_BACKGROUND_COLOR = "#000";
+ QString const DEFAULT_COLOR = "#fff";
int const FONT_SIZE = 20;
- int const PADDING_LEFT = 40;
int const START_HEIGHT = 80;
int const ITEM_WIDTH = 130;
+
}
-DetailScreen::DetailScreen(QWidget* parent): GraphicsScreen(parent)
+DetailScreen::DetailScreen(QWidget* parent): ThemeScreen(parent)
{
QString unit = Odometer::getUnit();
QString speedUnit = Odometer::getSpeedUnit();
- QGraphicsPixmapItem* background = new QGraphicsPixmapItem(QPixmap(BACKGROUND));
- getScene()->addItem(background);
+ getScene()->setBackgroundBrush(QBrush(QColor(DEFAULT_BACKGROUND_COLOR)));
tripLabel_ = createItem(tr("Trip"));
trip_ = createItem(roundDouble(Odometer::instance().getTrip()));
line1_ = createLine();
line2_ = createLine();
+ strength_ = new QGraphicsPixmapItem;
+ currentStrength_ = getStrength();
+ strength_->setPixmap(QPixmap(":/resources/signal_" + QString::number(currentStrength_) + ".png"));
+ strength_->setZValue(999);
+ getScene()->addItem(strength_);
+
connect(&(Odometer::instance()), SIGNAL(timeUpdated()), this, SLOT(updateTime()));
connect(&(Odometer::instance()), SIGNAL(unitChanged()), this, SLOT(updateUnits()));
void DetailScreen::update()
{
+ ThemeScreen::update();
+
speed_->setPlainText(roundDouble(Odometer::instance().getLatestFix().speed));
trip_->setPlainText(roundDouble(Odometer::instance().getTrip()));
total_->setPlainText(roundDouble(Odometer::instance().getTotal()));
avgSpeed_->setPlainText(roundDouble(Odometer::instance().getAverageSpeed()));
maxSpeed_->setPlainText(roundDouble(Odometer::instance().getMaxSpeed()));
+
+ int strength = getStrength();
+
+ if(strength != currentStrength_)
+ {
+ currentStrength_ = strength;
+ strength_->setPixmap(QPixmap(":/resources/signal_" + QString::number(strength) + ".png"));
+ }
}
void DetailScreen::updateTime()
void DetailScreen::reArrange()
{
- GraphicsScreen::reArrange();
+ ThemeScreen::reArrange();
+
+ int width = getScene()->width();
+ int height = getScene()->height();
- int lineHeight = getScene()->height() / 9;
+ int lineHeight = height / 9;
- int area1 = (getScene()->width() / 3) + ITEM_WIDTH / 2 + 20;
+ int padding = width / 22;
+ int area1 = (width / 3) + ITEM_WIDTH / 2 + 20;
int area2 = area1 + ITEM_WIDTH;
- tripLabel_->setPos(PADDING_LEFT, START_HEIGHT);
+ tripLabel_->setPos(padding, START_HEIGHT);
trip_->setPos(area1, START_HEIGHT);
tripUnit_->setPos(area2, START_HEIGHT);
- totalLabel_->setPos(PADDING_LEFT, START_HEIGHT + lineHeight);
+ totalLabel_->setPos(padding, START_HEIGHT + lineHeight);
total_->setPos(area1, START_HEIGHT + lineHeight);
totalUnit_->setPos(area2, START_HEIGHT + lineHeight);
- speedLabel_->setPos(PADDING_LEFT, START_HEIGHT + 2 * lineHeight);
+ speedLabel_->setPos(padding, START_HEIGHT + 2 * lineHeight);
speed_->setPos(area1, START_HEIGHT + 2 * lineHeight);
speedUnit_->setPos(area2, START_HEIGHT + 2 * lineHeight);
- avgSpeedLabel_->setPos(PADDING_LEFT, 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);
- maxSpeedLabel_->setPos(PADDING_LEFT, 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);
- tripTimeLabel_->setPos(PADDING_LEFT, START_HEIGHT + 5 * lineHeight);
+ tripTimeLabel_->setPos(padding, START_HEIGHT + 5 * lineHeight);
tripTime_->setPos(area1, START_HEIGHT + 5 * lineHeight);
- totalTimeLabel_->setPos(PADDING_LEFT, START_HEIGHT + 6 * lineHeight);
+ totalTimeLabel_->setPos(padding, START_HEIGHT + 6 * lineHeight);
totalTime_->setPos(area1, START_HEIGHT + 6 * lineHeight);
int y1 = START_HEIGHT + 2 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
int y2 = START_HEIGHT + 5 * lineHeight - lineHeight / 2 + FONT_SIZE + 2;
- int x = getScene()->width() - PADDING_LEFT;
- line1_->setLine(PADDING_LEFT + 2, y1, x, y1);
- line2_->setLine(PADDING_LEFT + 2, y2, x, y2);
+ int x = width - padding;
+ line1_->setLine(padding + 2, y1, x, y1);
+ line2_->setLine(padding + 2, y2, x, y2);
+
+ strength_->setPos(width - padding - 64, height - padding - 41);
}
QGraphicsTextItem* DetailScreen::createItem(QString const& text)
QFont font(FONT, FONT_SIZE);
font.setBold(true);
item->setFont(font);
- item->setDefaultTextColor(QColor("#fff"));
+ item->setDefaultTextColor(QColor(DEFAULT_COLOR));
+ item->setZValue(999);
getScene()->addItem(item);
return item;
}
QGraphicsLineItem* DetailScreen::createLine()
{
QGraphicsLineItem* item = new QGraphicsLineItem;
- QPen pen(QColor("#ddd"));
- pen.setWidth(1);
- item->setPen(pen);
+ QColor pColor(DEFAULT_COLOR);
+ QPen p(pColor);
+ p.setWidth(1);
+ item->setPen(p);
+ item->setZValue(999);
getScene()->addItem(item);
return item;
}
QString().sprintf(format, mins) + ":" +
QString().sprintf(format, secs);
}
+
+int DetailScreen::getStrength()
+{
+ double strength = round(Odometer::instance().getSignalStrength() / 25.0);
+ return static_cast<int>(strength);
+}
+
+void DetailScreen::setColor(QString const& color)
+{
+ QColor c(color);
+
+ tripLabel_->setDefaultTextColor(c);
+ trip_->setDefaultTextColor(c);
+ tripUnit_->setDefaultTextColor(c);
+ totalLabel_->setDefaultTextColor(c);
+ total_->setDefaultTextColor(c);
+ totalUnit_->setDefaultTextColor(c);
+ speedLabel_->setDefaultTextColor(c);
+ speed_->setDefaultTextColor(c);
+ speedUnit_->setDefaultTextColor(c);
+ avgSpeedLabel_->setDefaultTextColor(c);
+ avgSpeed_->setDefaultTextColor(c);
+ avgSpeedUnit_->setDefaultTextColor(c);
+ maxSpeedLabel_->setDefaultTextColor(c);
+ maxSpeed_->setDefaultTextColor(c);
+ maxSpeedUnit_->setDefaultTextColor(c);
+ tripTimeLabel_->setDefaultTextColor(c);
+ tripTime_->setDefaultTextColor(c);
+ totalTimeLabel_->setDefaultTextColor(c);
+ totalTime_->setDefaultTextColor(c);
+
+ QPen p(c);
+ p.setWidth(1);
+
+ line1_->setPen(p);
+ line2_->setPen(p);
+}