Fixed some problems with effect-enabled texts from not being displayed. Default theme...
authoreshe <jessehakanen@gmail.com>
Mon, 19 Jul 2010 19:03:22 +0000 (20:03 +0100)
committereshe <jessehakanen@gmail.com>
Mon, 19 Jul 2010 19:03:22 +0000 (20:03 +0100)
src/graphicsscreen.cpp
src/graphicsscreen.h
src/resources/themes/default/theme.xml
src/textelement.cpp
src/textelement.h
src/theme.cpp
src/themescreen.cpp
src/themescreen.h

index 8520c8c..51b5033 100644 (file)
@@ -16,6 +16,7 @@
  *
  */
 
  *
  */
 
+#include <QtCore/QDebug>
 #include <QtGui/QApplication>
 #include <QtGui/QDesktopWidget>
 #include "graphicsscreen.h"
 #include <QtGui/QApplication>
 #include <QtGui/QDesktopWidget>
 #include "graphicsscreen.h"
@@ -92,3 +93,10 @@ GraphicsScene* GraphicsScreen::getScene() const
 {
     return scene_;
 }
 {
     return scene_;
 }
+
+void GraphicsScreen::forceRepaint()
+{
+    QApplication::processEvents();
+    update();
+    QApplication::processEvents();
+}
index 7bc8ed8..bed1afc 100644 (file)
@@ -44,6 +44,7 @@ public slots:
     virtual void update() = 0;
     virtual void reArrange();
     void flip();
     virtual void update() = 0;
     virtual void reArrange();
     void flip();
+    void forceRepaint();
 
 protected:
     GraphicsScene* getScene() const;
 
 protected:
     GraphicsScene* getScene() const;
index 6068249..066d2b5 100644 (file)
                        <color>#a5efff</color>
                </effect>
        </text>
                        <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>
 </orientation>
 <orientation name="portrait">
        <image>
index 0187866..1c49b7c 100644 (file)
@@ -38,7 +38,9 @@ namespace
      {"align", false},
      {"color", false},
      {"size", true},
      {"align", false},
      {"color", false},
      {"size", true},
-     {"font", false}
+     {"font", false},
+     {"bold", false},
+     {"italic", false}
     };
 
     const QString FIELDS[TextElement::FIELD_COUNT] =  {"TRIP", "TOTAL", "SPEED",
     };
 
     const QString FIELDS[TextElement::FIELD_COUNT] =  {"TRIP", "TOTAL", "SPEED",
@@ -47,7 +49,7 @@ namespace
 }
 
 TextElement::TextElement(Reader* reader): GraphicsElement(reader),
 }
 
 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();
 }
 {
     element_ = new QGraphicsTextItem();
 }
@@ -94,6 +96,20 @@ bool TextElement::setAttribute(QString const& name, QString const& value)
             fontFile_ = value;
             fontChanged = true;
             break;
             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;
         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(getFont(fontFile_, font))
                 {
                     font.setPointSize(fontSize_);
+
+                    if(bold_)
+                    {
+                        font.setBold(true);
+                    }
+                    if(italic_)
+                    {
+                        font.setItalic(true);
+                    }
                     element_->setFont(font);
                 }
                 else
                     element_->setFont(font);
                 }
                 else
@@ -117,7 +142,19 @@ bool TextElement::setAttribute(QString const& name, QString const& value)
             }
             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);
             }
         }
 
             }
         }
 
index 19116c1..ddd289c 100644 (file)
@@ -30,7 +30,7 @@ class GraphicsScene;
 class TextElement : public GraphicsElement
 {
 public:
 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);
     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_;
     QString format_;
     QString align_;
     int fontSize_;
+    bool bold_;
+    bool italic_;
     QString fontFile_;
     QList<Field> specialFields_;
 };
     QString fontFile_;
     QList<Field> specialFields_;
 };
index c7d97d4..c44196a 100644 (file)
@@ -19,6 +19,7 @@
 #include <QtCore/QDir>
 #include <QtCore/QString>
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
 #include <QtCore/QString>
 #include <QtCore/QDebug>
+#include <QtCore/QTimer>
 #include <QtGui/QApplication>
 #include <QtGui/QDesktopWidget>
 #include <QtGui/QStackedWidget>
 #include <QtGui/QApplication>
 #include <QtGui/QDesktopWidget>
 #include <QtGui/QStackedWidget>
@@ -303,7 +304,8 @@ void Theme::reArrange()
         else
         {
             setCurrentIndex(landscapeId_);
         else
         {
             setCurrentIndex(landscapeId_);
-            landscape_->reArrange();
+            landscape_->forceRepaint();
+            //QTimer::singleShot(5000, landscape_, SLOT(forceRepaint()));
         }
     }
 }
         }
     }
 }
index b9ef61c..90c3269 100644 (file)
@@ -135,10 +135,3 @@ void ThemeScreen::update()
         elements_.at(i)->update();
     }
 }
         elements_.at(i)->update();
     }
 }
-
-void ThemeScreen::forceRepaint()
-{
-    rotate(0.0001);
-    QApplication::processEvents();
-    rotate(-0.0001);
-}
index 14a8239..33fc14a 100644 (file)
@@ -34,7 +34,6 @@ public:
     bool load(QDomNode const& data, Reader* reader);
     virtual void update();
     void removeElements();
     bool load(QDomNode const& data, Reader* reader);
     virtual void update();
     void removeElements();
-    void forceRepaint();
 
 private:
     QList<GraphicsElement*> elements_;
 
 private:
     QList<GraphicsElement*> elements_;