Skip to content

Commit

Permalink
cleanId added
Browse files Browse the repository at this point in the history
  • Loading branch information
Artanidos committed Oct 25, 2017
1 parent 738b3a7 commit ea27ca7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1.7
---
- Rendering text as SVG now
- New plugin technology for export added.
- New plugin technology for export added
- New Plugin -> Export HTML
- Rendering text as SVG now for compability to HTML export
- Selection rectangle added

1.6
Expand Down
21 changes: 12 additions & 9 deletions plugins/Html/htmlexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include <QBuffer>
#include <QDesktopServices>

QString cleanId(QString id)
{
return id.replace(" ", "_").replace("!","_").replace(".", "_");
}

QString getEaseString(int easing)
{
switch(easing)
Expand Down Expand Up @@ -236,7 +241,7 @@ QString HtmlExport::getTweens(QString &tweenArray, AnimationItem *item, int i, Q
if(!tweenArray.isEmpty())
tweenArray += ", ";
tweenArray += obj;
js << "var " + obj + " = TweenLite.to(\"#" + id + "\", ";
js << "var " + obj + " = TweenLite.to(\"#" + cleanId(id) + "\", ";
if(from->prev() && from->prev()->easing() >= 0)
js << QString::number(double(from->time() - from->prev()->time())/1000.0);
else
Expand Down Expand Up @@ -352,7 +357,7 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
if(rect)
{
html << "<rect ";
html << "id=\"" + rect->id() + QString::number(i) + "\" ";
html << "id=\"" + cleanId(rect->id() + QString::number(i)) + "\" ";
html << "x=\"" + QString::number(rect->x()) + "\" ";
html << "y=\"" + QString::number(rect->y()) + "\" ";
html << "width=\"" + QString::number(rect->width()) + "\" ";
Expand All @@ -368,7 +373,7 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
if(ellipse)
{
html << "<ellipse ";
html << "id=\"" + ellipse->id() + QString::number(i) + "\" ";
html << "id=\"" + cleanId(ellipse->id() + QString::number(i)) + "\" ";
html << "cx=\"" + QString::number((qreal)ellipse->x() + ellipse->width() / 2.0) + "\" ";
html << "cy=\"" + QString::number((qreal)ellipse->y() + ellipse->height() / 2.0) + "\" ";
html << "rx=\"" + QString::number((qreal)ellipse->width() / 2.0) + "\" ";
Expand All @@ -383,12 +388,12 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
Text *text = dynamic_cast<Text*>(item);
if(text)
{
html << "<svg id=\"" + text->id() + QString::number(i) + "\" ";
html << "<svg id=\"" + cleanId(text->id() + QString::number(i)) + "\" ";
html << "x=\"" + QString::number(text->x()) + "\" ";
html << "y=\"" + QString::number(text->y()) + "\" ";
html << "opacity=\"" + QString::number((double)text->opacity() / 100.0) + "\" ";
html << ">";
html << text->getTextTag(text->id() + QString::number(i) + "t");
html << text->getTextTag(cleanId(text->id() + QString::number(i)) + "t");
html << "</svg>";
}

Expand All @@ -400,7 +405,7 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
bitmap->getImage().save(&buffer, "PNG");

html << "<image ";
html << "id=\"" + bitmap->id() + QString::number(i) + "\" ";
html << "id=\"" + cleanId(bitmap->id() + QString::number(i)) + "\" ";
html << "x=\"" + QString::number(bitmap->x()) + "\" ";
html << "y=\"" + QString::number(bitmap->y()) + "\" ";
html << "width=\"" + QString::number(bitmap->width()) + "\" ";
Expand All @@ -413,7 +418,7 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
Vectorgraphic *vg = dynamic_cast<Vectorgraphic*>(item);
if(vg)
{
html << "<svg id=\"" + vg->id() + QString::number(i) + "\" ";
html << "<svg id=\"" + cleanId(vg->id() + QString::number(i)) + "\" ";
html << "x=\"" + QString::number(vg->x()) + "\" ";
html << "y=\"" + QString::number(vg->y()) + "\" ";
html << "opacity=\"" + QString::number((double)vg->opacity() / 100.0) + "\" ";
Expand Down Expand Up @@ -449,5 +454,3 @@ void HtmlExport::exportAnimation(AnimationScene *scene, QStatusBar *bar)
bar->showMessage("Animation has been exported to " + dir.absoluteFilePath("index.html"));
QDesktopServices::openUrl(QUrl(dir.absoluteFilePath("index.html")));
}


0 comments on commit ea27ca7

Please sign in to comment.