Added some effects to graphics elements and changed default theme a bit.
[jspeed] / src / themescreen.cpp
index 6458836..b9ef61c 100644 (file)
@@ -16,6 +16,7 @@
  *
  */
 
+#include <QtGui/QApplication>
 #include <QtGui/QWidget>
 #include <QtGui/QGraphicsItem>
 #include <QtCore/QString>
@@ -57,9 +58,46 @@ bool ThemeScreen::load(QDomNode const& data, Reader* reader)
 
         for(int i = 0; i < options.size(); i++)
         {
-            if(!element->setAttribute(options.at(i).nodeName(), options.at(i).toElement().text()))
+            QString nodeName = options.at(i).nodeName();
+
+
+
+            if(nodeName == "effect")
+            {
+                QDomNode effectName = options.at(i).attributes().namedItem("name");
+
+                if(effectName.isNull())
+                {
+                    qDebug() << "Missing name for effect";
+                }
+                else
+                {
+                    if(!element->setEffect(effectName.toAttr().value()))
+                    {
+                        qDebug() << "Invalid effect: " << effectName.toAttr().value();
+                    }
+                    else
+                    {
+                        QDomNodeList themeOptions = options.at(i).childNodes();
+
+                        for(int i = 0; i < themeOptions.size(); i++)
+                        {
+                            if(!element->setEffectAttribute(themeOptions.at(i).nodeName(), themeOptions.at(i).toElement().text()))
+                            {
+                                qDebug() << "Warning: invalid effect option: " << themeOptions.at(i).nodeName();
+                            }
+                        }
+
+                        element->applyEffect();
+                    }
+                }
+            }
+            else
             {
-                qDebug() << "Warning: invalid option: " << options.at(i).nodeName();
+                if(!element->setAttribute(nodeName, options.at(i).toElement().text()))
+                {
+                    qDebug() << "Warning: invalid option: " << options.at(i).nodeName();
+                }
             }
         }
 
@@ -67,6 +105,8 @@ bool ThemeScreen::load(QDomNode const& data, Reader* reader)
 
     }
 
+    forceRepaint();
+
     return true;
 }
 
@@ -95,3 +135,10 @@ void ThemeScreen::update()
         elements_.at(i)->update();
     }
 }
+
+void ThemeScreen::forceRepaint()
+{
+    rotate(0.0001);
+    QApplication::processEvents();
+    rotate(-0.0001);
+}