*
*/
+#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include "graphicsscreen.h"
{
return scene_;
}
+
+void GraphicsScreen::forceRepaint()
+{
+ QApplication::processEvents();
+ update();
+ QApplication::processEvents();
+}
virtual void update() = 0;
virtual void reArrange();
void flip();
+ void forceRepaint();
protected:
GraphicsScene* getScene() const;
<color>#a5efff</color>
</effect>
</text>
+ <text>
+ <data>{SPEEDUNIT}</data>
+ <xpos>520</xpos>
+ <ypos>402</ypos>
+ <font>Nokia Sans Bold</font>
+ <size>24</size>
+ <color>#fff</color>
+ <bold>true</bold>
+ <effect name="dropshadow">
+ <xoffset>0</xoffset>
+ <yoffset>0</yoffset>
+ <radius>35</radius>
+ <color>#a5efff</color>
+ </effect>
+ </text>
</orientation>
<orientation name="portrait">
<image>
{"align", false},
{"color", false},
{"size", true},
- {"font", false}
+ {"font", false},
+ {"bold", false},
+ {"italic", false}
};
const QString FIELDS[TextElement::FIELD_COUNT] = {"TRIP", "TOTAL", "SPEED",
}
TextElement::TextElement(Reader* reader): GraphicsElement(reader),
-data_(""), format_(""), align_("left"), fontSize_(16)
+data_(""), format_(""), align_("left"), fontSize_(16), bold_(false), italic_(false)
{
element_ = new QGraphicsTextItem();
}
fontFile_ = value;
fontChanged = true;
break;
+ case BOLD:
+ if(value != "false" && value != "0")
+ {
+ bold_ = true;
+ fontChanged = true;
+ }
+ break;
+ case ITALIC:
+ if(value != "false" && value != "0")
+ {
+ italic_ = true;
+ fontChanged = true;
+ }
+ break;
default:
qDebug() << "Unknown attribute: " << attr;
return false;
if(getFont(fontFile_, font))
{
font.setPointSize(fontSize_);
+
+ if(bold_)
+ {
+ font.setBold(true);
+ }
+ if(italic_)
+ {
+ font.setItalic(true);
+ }
element_->setFont(font);
}
else
}
else
{
- element_->setFont(QFont("Default", fontSize_));
+ QFont font("Default");
+
+ if(bold_)
+ {
+ font.setBold(true);
+ }
+ if(italic_)
+ {
+ font.setItalic(true);
+ }
+
+ font.setPointSize(fontSize_);
+ element_->setFont(font);
}
}
class TextElement : public GraphicsElement
{
public:
- enum Attribute {XPOS, YPOS, DATA, FORMAT, WIDTH, ALIGN, COLOR, SIZE, FONT, ATTRIBUTE_COUNT};
+ enum Attribute {XPOS, YPOS, DATA, FORMAT, WIDTH, ALIGN, COLOR, SIZE, FONT, BOLD, ITALIC, ATTRIBUTE_COUNT};
enum Field {TRIP, TOTAL, SPEED, MAXSPEED, AVGSPEED, UNIT, SPEEDUNIT, TIME, FIELD_COUNT};
TextElement(Reader* reader);
virtual bool setAttribute(QString const& name, QString const& value);
QString format_;
QString align_;
int fontSize_;
+ bool bold_;
+ bool italic_;
QString fontFile_;
QList<Field> specialFields_;
};
#include <QtCore/QDir>
#include <QtCore/QString>
#include <QtCore/QDebug>
+#include <QtCore/QTimer>
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include <QtGui/QStackedWidget>
else
{
setCurrentIndex(landscapeId_);
- landscape_->reArrange();
+ landscape_->forceRepaint();
+ //QTimer::singleShot(5000, landscape_, SLOT(forceRepaint()));
}
}
}
elements_.at(i)->update();
}
}
-
-void ThemeScreen::forceRepaint()
-{
- rotate(0.0001);
- QApplication::processEvents();
- rotate(-0.0001);
-}
bool load(QDomNode const& data, Reader* reader);
virtual void update();
void removeElements();
- void forceRepaint();
private:
QList<GraphicsElement*> elements_;