From b958396e9dcff299ef5b36bf4deb5f7074be788a Mon Sep 17 00:00:00 2001 From: eshe Date: Mon, 19 Jul 2010 20:03:22 +0100 Subject: [PATCH] Fixed some problems with effect-enabled texts from not being displayed. Default theme updated a bit. --- src/graphicsscreen.cpp | 8 ++++++ src/graphicsscreen.h | 1 + src/resources/themes/default/theme.xml | 15 +++++++++++ src/textelement.cpp | 43 +++++++++++++++++++++++++++++--- src/textelement.h | 4 ++- src/theme.cpp | 4 ++- src/themescreen.cpp | 7 ------ src/themescreen.h | 1 - 8 files changed, 70 insertions(+), 13 deletions(-) diff --git a/src/graphicsscreen.cpp b/src/graphicsscreen.cpp index 8520c8c..51b5033 100644 --- a/src/graphicsscreen.cpp +++ b/src/graphicsscreen.cpp @@ -16,6 +16,7 @@ * */ +#include #include #include #include "graphicsscreen.h" @@ -92,3 +93,10 @@ GraphicsScene* GraphicsScreen::getScene() const { return scene_; } + +void GraphicsScreen::forceRepaint() +{ + QApplication::processEvents(); + update(); + QApplication::processEvents(); +} diff --git a/src/graphicsscreen.h b/src/graphicsscreen.h index 7bc8ed8..bed1afc 100644 --- a/src/graphicsscreen.h +++ b/src/graphicsscreen.h @@ -44,6 +44,7 @@ public slots: virtual void update() = 0; virtual void reArrange(); void flip(); + void forceRepaint(); protected: GraphicsScene* getScene() const; diff --git a/src/resources/themes/default/theme.xml b/src/resources/themes/default/theme.xml index 6068249..066d2b5 100644 --- a/src/resources/themes/default/theme.xml +++ b/src/resources/themes/default/theme.xml @@ -39,6 +39,21 @@ #a5efff + + {SPEEDUNIT} + 520 + 402 + Nokia Sans Bold + 24 + #fff + true + + 0 + 0 + 35 + #a5efff + + diff --git a/src/textelement.cpp b/src/textelement.cpp index 0187866..1c49b7c 100644 --- a/src/textelement.cpp +++ b/src/textelement.cpp @@ -38,7 +38,9 @@ namespace {"align", false}, {"color", false}, {"size", true}, - {"font", false} + {"font", false}, + {"bold", false}, + {"italic", false} }; const QString FIELDS[TextElement::FIELD_COUNT] = {"TRIP", "TOTAL", "SPEED", @@ -47,7 +49,7 @@ namespace } 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(); } @@ -94,6 +96,20 @@ bool TextElement::setAttribute(QString const& name, QString const& value) 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; @@ -108,6 +124,15 @@ bool TextElement::setAttribute(QString const& name, QString const& value) if(getFont(fontFile_, font)) { font.setPointSize(fontSize_); + + if(bold_) + { + font.setBold(true); + } + if(italic_) + { + font.setItalic(true); + } element_->setFont(font); } else @@ -117,7 +142,19 @@ bool TextElement::setAttribute(QString const& name, QString const& value) } 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); } } diff --git a/src/textelement.h b/src/textelement.h index 19116c1..ddd289c 100644 --- a/src/textelement.h +++ b/src/textelement.h @@ -30,7 +30,7 @@ class GraphicsScene; 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); @@ -48,6 +48,8 @@ private: QString format_; QString align_; int fontSize_; + bool bold_; + bool italic_; QString fontFile_; QList specialFields_; }; diff --git a/src/theme.cpp b/src/theme.cpp index c7d97d4..c44196a 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -303,7 +304,8 @@ void Theme::reArrange() else { setCurrentIndex(landscapeId_); - landscape_->reArrange(); + landscape_->forceRepaint(); + //QTimer::singleShot(5000, landscape_, SLOT(forceRepaint())); } } } diff --git a/src/themescreen.cpp b/src/themescreen.cpp index b9ef61c..90c3269 100644 --- a/src/themescreen.cpp +++ b/src/themescreen.cpp @@ -135,10 +135,3 @@ void ThemeScreen::update() elements_.at(i)->update(); } } - -void ThemeScreen::forceRepaint() -{ - rotate(0.0001); - QApplication::processEvents(); - rotate(-0.0001); -} diff --git a/src/themescreen.h b/src/themescreen.h index 14a8239..33fc14a 100644 --- a/src/themescreen.h +++ b/src/themescreen.h @@ -34,7 +34,6 @@ public: bool load(QDomNode const& data, Reader* reader); virtual void update(); void removeElements(); - void forceRepaint(); private: QList elements_; -- 1.7.9.5