Changelog fixed.
[jspeed] / src / themescreen.cpp
index d4dcaa0..060e771 100644 (file)
@@ -16,7 +16,9 @@
  *
  */
 
+#include <QtGui/QApplication>
 #include <QtGui/QWidget>
+#include <QtGui/QGraphicsItem>
 #include <QtCore/QString>
 #include <QtCore/QDebug>
 #include <QtXml/QDomNode>
@@ -24,6 +26,7 @@
 #include "themescreen.h"
 #include "graphicselement.h"
 #include "reader.h"
+#include "graphicsscene.h"
 
 ThemeScreen::ThemeScreen(QWidget* parent): GraphicsScreen(parent)
 {
@@ -55,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();
+                }
             }
         }
 
@@ -65,9 +105,29 @@ bool ThemeScreen::load(QDomNode const& data, Reader* reader)
 
     }
 
+    forceRepaint();
+
     return true;
 }
 
+void ThemeScreen::removeElements()
+{
+    for(int i = 0; i < elements_.size(); i++)
+    {
+        QGraphicsItem* item = elements_.at(i)->getElement();
+
+        if(item)
+        {
+            getScene()->removeItem(item);
+            delete item;
+        }
+
+        delete elements_.at(i);
+    }
+
+    elements_.clear();
+}
+
 void ThemeScreen::update()
 {
     for(int i = 0; i < elements_.size(); i++)
@@ -75,3 +135,8 @@ void ThemeScreen::update()
         elements_.at(i)->update();
     }
 }
+
+void ThemeScreen::setColor(QString const& color)
+{
+    Q_UNUSED(color);
+}