diff --git a/resources/etc/npapi-wrapper.application.x-shockwave-flash.swf.htm b/resources/etc/npapi-wrapper.application.x-shockwave-flash.swf.htm
index a59f0462..7d99bf8c 100644
--- a/resources/etc/npapi-wrapper.application.x-shockwave-flash.swf.htm
+++ b/resources/etc/npapi-wrapper.application.x-shockwave-flash.swf.htm
@@ -7,6 +7,15 @@
html, body, #content { height:100%; }
body { margin:0; padding:0; overflow:hidden; }
+
diff --git a/resources/library/userImage/Backgrounds/2009_calendar_EU.svg b/resources/library/userImage/Backgrounds/2009_calendar_EU.svg
deleted file mode 100644
index 5007696f..00000000
--- a/resources/library/userImage/Backgrounds/2009_calendar_EU.svg
+++ /dev/null
@@ -1,6619 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-]>
-
diff --git a/resources/library/userImage/Backgrounds/2009_calendar_US.svg b/resources/library/userImage/Backgrounds/2009_calendar_US.svg
deleted file mode 100644
index 697691fb..00000000
--- a/resources/library/userImage/Backgrounds/2009_calendar_US.svg
+++ /dev/null
@@ -1,5811 +0,0 @@
-
-
-
-
diff --git a/resources/library/userImage/Backgrounds/calendar_2011.svg b/resources/library/userImage/Backgrounds/calendar_2011.svg
new file mode 100644
index 00000000..2452cec7
--- /dev/null
+++ b/resources/library/userImage/Backgrounds/calendar_2011.svg
@@ -0,0 +1,5576 @@
+
+
diff --git a/resources/library/userImage/Backgrounds/calendar_2012.svg b/resources/library/userImage/Backgrounds/calendar_2012.svg
new file mode 100644
index 00000000..d8e8a619
--- /dev/null
+++ b/resources/library/userImage/Backgrounds/calendar_2012.svg
@@ -0,0 +1,5116 @@
+
+
diff --git a/resources/library/userImage/Backgrounds/calendrier_2011.svg b/resources/library/userImage/Backgrounds/calendrier_2011.svg
new file mode 100644
index 00000000..3a95030b
--- /dev/null
+++ b/resources/library/userImage/Backgrounds/calendrier_2011.svg
@@ -0,0 +1,5114 @@
+
+
diff --git a/resources/library/userImage/Backgrounds/calendrier_2012.svg b/resources/library/userImage/Backgrounds/calendrier_2012.svg
new file mode 100644
index 00000000..c70360ab
--- /dev/null
+++ b/resources/library/userImage/Backgrounds/calendrier_2012.svg
@@ -0,0 +1,5116 @@
+
+
diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp
index a4812096..2661f667 100644
--- a/src/adaptors/UBCFFSubsetAdaptor.cpp
+++ b/src/adaptors/UBCFFSubsetAdaptor.cpp
@@ -25,6 +25,7 @@
#include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsSvgItem.h"
+#include "domain/UBGraphicsPixmapItem.h"
#include "UBCFFSubsetAdaptor.h"
#include "UBMetadataDcSubsetAdaptor.h"
@@ -34,11 +35,14 @@
#include "core/UBApplication.h"
#include "QFile"
+#include "QDomDocument"
+
//enum of xmlparse status
//tag names definition
//use them everiwhere!
static QString tElement = "element";
+static QString tGroup = "group";
static QString tEllipse = "ellipse";
static QString tIwb = "iwb";
static QString tMeta = "meta";
@@ -52,6 +56,7 @@ static QString tText = "text";
static QString tTextarea = "textarea";
static QString tTspan = "tspan";
static QString tBreak = "tbreak";
+static QString tImage = "image";
//attribute names definition
static QString aFill = "fill";
@@ -75,10 +80,126 @@ static QString aFontstyle = "font-style";
static QString aFontweight = "font-weight";
static QString aTextalign = "text-align";
static QString aPoints = "points";
+static QString svgNS = "http://www.w3.org/2000/svg";
+static QString iwbNS = "http://www.becta.org.uk/iwb";
+static QString aId = "id";
+static QString aRef = "ref";
+static QString aHref = "href";
+
+//attributes part names
+static QString apRotate = "rotate";
+static QString apTranslate = "translate";
UBCFFSubsetAdaptor::UBCFFSubsetAdaptor()
{
+
+}
+
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSiblingIwbElements(QDomElement *parent, QDomElement *topGroup) {
+
+ QDomElement curExt = parent->firstChildElement(tElement);
+ while (!curExt.isNull()) {
+ if (curExt.namespaceURI() != iwbNS)
+ continue;
+ QHash
::iterator iSvgElement = iwbExtProperties.find(curExt.attribute(aRef));
+ if (iSvgElement != iwbExtProperties.end()) {
+ IwbExt &svgElement = *iSvgElement;
+ svgElement.extAttr.push_back(curExt);
+ if (topGroup)
+ svgElement.group = *topGroup;
+ }
+ curExt = curExt.nextSiblingElement(tElement);
+ }
+}
+
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::addExtentionsToHash(QDomElement *parent, QDomElement *topGroup)
+{
+ //add top level elements
+ if(*parent == mDOMdoc.documentElement()) {
+ hashSiblingIwbElements(parent);
+ } else
+ hashSiblingIwbElements(parent, topGroup);
+
+ //add iwb groups if needed
+ QDomElement curGroup = parent->firstChildElement(tGroup);
+ while (!curGroup.isNull()) {
+ if (curGroup.namespaceURI() != iwbNS)
+ continue;
+ if(*parent == mDOMdoc.documentElement()) {
+ topGroup = &curGroup;
+ }
+ if (curGroup.hasChildNodes()) {
+ addExtentionsToHash(&curGroup, topGroup);
+ }
+ curGroup = curGroup.nextSiblingElement(tGroup);
+ }
+}
+
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSvg(QDomNode *parent, QString prefix)
+{
+ QDomNode n = parent->firstChild();
+ while (!n.isNull()) {
+ QDomElement e = n.toElement();
+ QString id = e.attribute(aId);
+ if(!id.isNull()) {
+ iwbExtProperties.insert(id, IwbExt(e));
+ qDebug() << prefix + e.prefix() + ":" + e.tagName();
+ }
+ if (n.hasChildNodes()) {
+ hashSvg(&n, QString("| %1").arg(prefix));
+ }
+ n = n.nextSibling();
+ }
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::hashElements()
+{
+ bool result = true;
+
+ QDomElement svgSection = mDOMdoc.elementsByTagNameNS(svgNS, tSvg).at(0).toElement();
+ if (svgSection.isNull()) {
+ qDebug("\"svg:svg\" section not found maybe invalid document");
+ result = false;
+ }
+ hashSvg(&svgSection);
+
+ QDomElement parElement = mDOMdoc.documentElement();
+ if (parElement.isNull()) {
+ qDebug("invalid pass paramentr maybe invalid document");
+ result = false;
+ }
+
+ // Adding iwb extentions to hash table crossing elements and groups using recursive descent
+ addExtentionsToHash(&parElement, 0);
+
+// int i = 0;
+// foreach (IwbExt cur, iwbExtProperties) {
+// QString elem = cur.element.toElement().attribute(aId);
+// QString tagName = cur.element.toElement().tagName();
+// QString gr = !cur.group.isNull()
+// ? i++, " is group\n-------------\n" + QString::number(i)
+// + cur.group.toElement().tagName()
+// + (cur.group.toElement().hasChildNodes() ? "true" : "false")
+// : "";
+//// QString attr = !cur.extAttr.isEmpty() ? cur.extAttr.first().toElement().attribute(aRef) : "";
+//// if (cur.group) {
+//// *(cur.group);
+//// }
+// qDebug() << "element" + elem + "tag" + tagName + gr;
+// if (!gr.isNull()) {
+
+// mDOMdoc.documentElement().removeChild(cur.group);
+// }
+// }
+// QDomNode n = mDOMdoc.documentElement().firstChild();
+// while (!n.isNull()) {
+// qDebug() << "new dom tags"<< n.toElement().tagName();
+// n = n.nextSibling();
+// }
+
+
+ return result;
}
bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentProxy* pDocument)
@@ -95,32 +216,31 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
return false;
}
-// QTextStream out(&file);
-// out.setCodec("UTF-8");
-// QString dta = out.readAll();
- QByteArray data = file.readAll();
- if (data.length() == 0)
- {
- qWarning() << "Either content file " << cffSourceFile << " is empty or failed to read from file";
- file.close();
- return false;
- }
-
- UBCFFSubsetReader cffReader(pDocument, data);
+ UBCFFSubsetReader cffReader(pDocument, &file);
bool result = cffReader.parse();
file.close();
return result;
}
-UBCFFSubsetAdaptor::UBCFFSubsetReader::UBCFFSubsetReader(UBDocumentProxy *proxy, QByteArray &content):
+UBCFFSubsetAdaptor::UBCFFSubsetReader::UBCFFSubsetReader(UBDocumentProxy *proxy, QFile *content):
mReader(content), mProxy(proxy), currentState(NONE)
{
+ int errorLine, errorColumn;
+ QString errorStr;
+ if(!mDOMdoc.setContent(content, true, &errorStr, &errorLine, &errorColumn)){
+ qWarning() << "Error:Parseerroratline" << errorLine << ","
+ << "column" << errorColumn << ":" << errorStr;
+ } else {
+ qDebug() << "well parsed to DOM";
+ pwdContent = QFileInfo(content->fileName()).dir().absolutePath();
+ }
// QFile tfile("/home/ilia/Documents/tmp/2/out.xml");
// tfile.open(QIODevice::ReadWr ite | QIODevice::Text);
// QTextStream out(&tfile);
// out << content;
// tfile.close();
+ qDebug() << "tmp path is" << pwdContent;
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
@@ -131,6 +251,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
if (!getTempFileName())
return false;
+ if (mDOMdoc.isNull())
+ return false;
+
bool result = parseDoc();
if (result)
result = mProxy->pageCount() != 0;
@@ -158,39 +281,677 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::PushState(int state)
currentState = state;
}
-bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseDoc()
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgRect(const QDomElement &element)
{
- while (!mReader.atEnd())
- {
- mReader.readNext();
- if (mReader.isStartElement())
- {
- if (!parseCurrentElementStart())
- return false;
+ qreal x1 = element.attribute(aX).toDouble();
+ qreal y1 = element.attribute(aY).toDouble();
+ //rect dimensions
+ qreal width = element.attribute(aWidth).toDouble();
+ qreal height = element.attribute(aHeight).toDouble();
+
+ QString textFillColor = element.attribute(aFill);
+ QString textStrokeColor = element.attribute(aStroke);
+ QString textStrokeWidth = element.attribute(aStrokewidth);
+
+ QColor fillColor = !textFillColor.isNull() ? colorFromString(textFillColor) : QColor();
+ QColor strokeColor = !textStrokeColor.isNull() ? colorFromString(textStrokeColor) : QColor();
+ int strokeWidth = !textStrokeWidth.isNull() ? textStrokeWidth.toInt() : 0;
+
+ //init svg generator with temp file
+ QSvgGenerator *generator = createSvgGenerator(width + 10, height + 10);
+
+ //init painter to paint to svg
+ QPainter painter;
+
+ painter.begin(generator);
+
+ //fill rect
+ if (fillColor.isValid()) {
+ painter.setBrush(QBrush(fillColor));
+ painter.fillRect(5, 5, width, height, fillColor);
+ }
+ QPen pen;
+ if (strokeColor.isValid()) {
+ pen.setColor(strokeColor);
+ }
+ if (strokeWidth)
+ pen.setWidth(strokeWidth);
+ painter.setPen(pen);
+ painter.drawRect(5, 5, width, height);
+
+ painter.end();
+
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ QString textTransform = element.attribute(aTransform);
+ bool hastransform = false;
+ if (!textTransform.isNull()) {
+ transform = transformFromString(textTransform);
+ hastransform = true;
+ }
+ repositionSvgItem(svgItem, width + 10, height + 10, x1 - 5, y1 - 5, hastransform, transform);
+ delete generator;
+
+ return true;
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgEllipse(const QDomElement &element)
+{
+ //ellipse horisontal and vertical radius
+ qreal rx = element.attribute(aRx).toDouble();
+ qreal ry = element.attribute(aRy).toDouble();
+ QSvgGenerator *generator = createSvgGenerator(rx * 2 + 10, ry * 2 + 10);
+
+ //fill and stroke color
+ QColor fillColor = colorFromString(element.attribute(aFill));
+ QColor strokeColor = colorFromString(element.attribute(aStroke));
+ int strokeWidth = element.attribute(aStrokewidth).toInt();
+
+ //ellipse center coordinates
+ qreal cx = element.attribute(aCx).toDouble();
+ qreal cy = element.attribute(aCy).toDouble();
+
+ //init painter to paint to svg
+ QPainter painter;
+ painter.begin(generator);
+
+ QPen pen(strokeColor);
+ pen.setWidth(strokeWidth);
+ painter.setPen(pen);
+ painter.setBrush(QBrush(fillColor));
+
+ painter.drawEllipse(5, 5, rx * 2, ry * 2);
+
+ painter.end();
+
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ QString textTransform = element.attribute(aTransform);
+ bool hastransform = false;
+ if (!textTransform.isNull()) {
+ transform = transformFromString(textTransform);
+ hastransform = true;
+ }
+ repositionSvgItem(svgItem, rx * 2 + 10, ry * 2 + 10, cx - rx - 5, cy - ry -5, hastransform, transform);
+ delete generator;
+
+ return true;
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &element)
+{
+ QString svgPoints = element.attribute(aPoints);
+ QPolygonF polygon;
+
+ if (!svgPoints.isNull()) {
+ QStringList ts = svgPoints.split(QLatin1Char(' '), QString::SkipEmptyParts);
+
+ foreach(const QString sPoint, ts) {
+ QStringList sCoord = sPoint.split(QLatin1Char(','), QString::SkipEmptyParts);
+ if (sCoord.size() == 2) {
+ QPointF point;
+ point.setX(sCoord.at(0).toFloat());
+ point.setY(sCoord.at(1).toFloat());
+ polygon << point;
+ }
+ else {
+ qWarning() << "cannot make sense of a 'point' value" << sCoord;
+ }
}
- else
- if (mReader.isCharacters())
- {
- if (!parseCurrentElementCharacters())
- return false;
+ }
+
+ //bounding rect lef top corner coordinates
+ qreal x1 = polygon.boundingRect().topLeft().x();
+ qreal y1 = polygon.boundingRect().topLeft().y();
+ //bounding rect dimensions
+ qreal width = polygon.boundingRect().width();
+ qreal height = polygon.boundingRect().height();
+
+ QString strokeColorText = element.attribute(aStroke);
+ QString fillColorText = element.attribute(aFill);
+ QString strokeWidthText = element.attribute(aStrokewidth);
+
+ QColor strokeColor = !strokeColorText.isEmpty() ? colorFromString(strokeColorText) : QColor();
+ QColor fillColor = !fillColorText.isEmpty() ? colorFromString(fillColorText) : QColor();
+ int strokeWidth = strokeWidthText.toInt() > 0 ? strokeWidthText.toInt() : 0;
+
+ QPen pen;
+ pen.setColor(strokeColor);
+ pen.setWidth(strokeWidth);
+
+ QBrush brush;
+ brush.setColor(fillColor);
+ brush.setStyle(Qt::SolidPattern);
+
+ QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
+ QPainter painter;
+
+ painter.begin(generator); //drawing to svg tmp file
+
+ painter.translate(pen.widthF() / 2 - x1, pen.widthF() / 2 - y1);
+ painter.setBrush(brush);
+ painter.setPen(pen);
+ painter.drawPolygon(polygon);
+
+ painter.end();
+
+ //add resulting svg file to scene
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ QString textTransform = element.attribute(aTransform);
+ bool hastransform = false;
+ if (!textTransform.isNull()) {
+ transform = transformFromString(textTransform);
+ hastransform = true;
+ }
+ repositionSvgItem(svgItem, width + 10, height + 10, x1 - 5, y1 - 5, hastransform, transform);
+ delete generator;
+
+ return true;
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &element)
+{
+ QString svgPoints = element.attribute(aPoints);
+ QPolygonF polygon;
+
+ if (!svgPoints.isNull()) {
+ QStringList ts = svgPoints.split(QLatin1Char(' '),
+ QString::SkipEmptyParts);
+
+ foreach(const QString sPoint, ts) {
+ QStringList sCoord = sPoint.split(QLatin1Char(','), QString::SkipEmptyParts);
+ if (sCoord.size() == 2) {
+ QPointF point;
+ point.setX(sCoord.at(0).toFloat());
+ point.setY(sCoord.at(1).toFloat());
+ polygon << point;
}
- else
- if (mReader.isEndElement())
- {
- if (!parseCurrentElementEnd())
- return false;
+ else {
+ qWarning() << "cannot make sense of a 'point' value" << sCoord;
+ }
+ }
+ }
+
+ //bounding rect lef top corner coordinates
+ qreal x1 = polygon.boundingRect().topLeft().x();
+ qreal y1 = polygon.boundingRect().topLeft().y();
+ //bounding rect dimensions
+ qreal width = polygon.boundingRect().width();
+ qreal height = polygon.boundingRect().height();
+
+ QString strokeColorText = element.attribute(aStroke);
+ QString strokeWidthText = element.attribute(aStrokewidth);
+
+ QColor strokeColor = !strokeColorText.isEmpty() ? colorFromString(strokeColorText) : QColor();
+ int strokeWidth = strokeWidthText.toInt() > 0 ? strokeWidthText.toInt() : 0;
+
+ QPen pen;
+ pen.setColor(strokeColor);
+ pen.setWidth(strokeWidth);
+
+ QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
+ QPainter painter;
+
+ painter.begin(generator); //drawing to svg tmp file
+
+ painter.translate(pen.widthF() / 2 - x1, pen.widthF() / 2 - y1);
+ painter.setPen(pen);
+ painter.drawPolyline(polygon);
+
+ painter.end();
+
+ //add resulting svg file to scene
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ QString textTransform = element.attribute(aTransform);
+ bool hastransform = false;
+ if (!textTransform.isNull()) {
+ transform = transformFromString(textTransform);
+ hastransform = true;
+ }
+ repositionSvgItem(svgItem, width + 10, height + 10, x1 - 5, y1 - 5, hastransform, transform);
+ delete generator;
+
+ return true;
+}
+
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElement &element,
+ qreal &fontSize, QColor &fontColor, QString &fontFamily,
+ QString &fontStretch, bool &italic, int &fontWeight,
+ int &textAlign, QTransform &fontTransform)
+{
+ //consider inch has 72 liens
+ //since svg font size is given in pixels, divide it by pixels per line
+ QString fontSz = element.attribute(aFontSize);
+ if (!fontSz.isNull()) fontSize = fontSz.toDouble() * 72 / QApplication::desktop()->physicalDpiY();
+
+ QString fontColorText = element.attribute(aFill);
+ if (!fontColorText.isNull()) fontColor = colorFromString(fontColorText);
+
+ QString fontFamilyText = element.attribute(aFontfamily);
+ if (!fontFamilyText.isNull()) fontFamily = fontFamilyText;
+
+ QString fontStretchText = element.attribute(aFontstretch);
+ if (!fontStretchText.isNull()) fontStretch = fontStretchText;
+
+ if (!element.attribute(aFontstyle).isNull())
+ italic = (element.attribute(aFontstyle) == "italic");
+
+ QString weight = element.attribute(aFontweight);
+ if (!weight.isNull()) {
+ if (weight == "normal") fontWeight = QFont::Normal;
+ else if (weight == "light") fontWeight = QFont::Light;
+ else if (weight == "demibold") fontWeight = QFont::DemiBold;
+ else if (weight == "bold") fontWeight = QFont::Bold;
+ else if (weight == "black") fontWeight = QFont::Black;
+ }
+ QString align = element.attribute(aTextalign);
+ if (!align.isNull()) {
+ if (align == "middle" || align == "center") textAlign = Qt::AlignHCenter;
+ else if (align == "start") textAlign = Qt::AlignLeft;
+ else if (align == "end") textAlign = Qt::AlignRight;
+ }
+
+ if (!element.attribute(aTransform).isNull())
+ fontTransform = transformFromString(element.attribute(aTransform));
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &element)
+{
+// qreal x = element.attribute(aX).toDouble();
+// qreal y = element.attribute(aY).toDouble();;
+
+// qreal width = 0;
+// qreal height = 0;
+
+// QList textRects;
+// QList textFonts;
+// QList textLines;
+// QList textAligns;
+// QList textColors;
+
+// qWarning() << QString().sprintf("Text coordinates : %f,%f. Text size %f,%f", x, y, width, height);
+
+// qreal fontSize = 12.0;
+// QFont textFont;
+// QColor fontColor;
+// QString fontFamily = "Arial";
+// QString fontStretch = "normal";
+
+// bool italic = false;
+// int fontWeight = QFont::Normal;
+// int textAlign = Qt::AlignLeft;
+// QTransform fontTransform;
+// parseTextAttributes(element, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
+// textFont = QFont(fontFamily, fontSize, fontWeight, italic);
+
+// QFontMetricsF metrics = QFontMetricsF(textFont);
+// qreal curHeight = metrics.height();
+
+// qreal curY = 0.0;
+// qreal curX = 0.0;
+
+// qreal linespacing = QFontMetrics(textFont).leading();
+
+// //remember if text area has transform
+// QTransform transform;
+//// bool hasTransform = getCurElementTransorm(transform);
+
+// QRectF lastDrawnTextBoundingRect;
+
+// QStack fontStack;
+// QStack colorStack;
+// QStack alignStack;
+
+// // first extimate desired text area size
+// // to do that, parse text area tags
+// while(true)
+// {
+// mReader.readNext();
+// QStringRef elementName = mReader.name();
+// if (mReader.isEndDocument())
+// break;
+// if (mReader.isEndElement())
+// {
+// if (elementName == tBreak)
+// {
+// //when tbreak appers, move down by the drawn rect height
+// //TODO: line spacing is not calculated yet, probably additional code is required
+// curY += lastDrawnTextBoundingRect.height() + linespacing;
+// curX = 0.0;
+// height += lastDrawnTextBoundingRect.height();
+// lastDrawnTextBoundingRect = QRectF(0,0,0,0);
+// continue;
+// }
+// if (elementName == tTspan)
+// {
+// textFont = fontStack.pop();
+// fontColor = colorStack.pop();
+// textAlign = alignStack.pop();
+// continue;
+// }
+// }
+// if (mReader.isEndElement() && elementName == tText)
+// break;
+// if (mReader.isStartElement() && elementName == tTspan)
+// {
+// fontStack.push(textFont);
+// colorStack.push(fontColor);
+// alignStack.push(textAlign);
+
+// parseTextAttributes(fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
+// textFont = QFont(fontFamily, fontSize, fontWeight, italic);
+// metrics = QFontMetricsF(textFont);
+// curHeight = metrics.height();
+// linespacing = QFontMetricsF(textFont).leading();
+// continue;
+// }
+// if (mReader.isCharacters() || mReader.isCDATA())
+// {
+// QString text = mReader.text().toString();
+
+// //skip empty text
+// if (text.trimmed().length() == 0)
+// continue;
+// //get bounding rect to obtain desired text height
+// lastDrawnTextBoundingRect = metrics.boundingRect(QRectF(), textAlign, text);
+// QString log = QString().sprintf(" at rect %f, %f, %f, %f. Bounding rect is %f, %f, %f, %f", 0.0, curY, width, height - curY, lastDrawnTextBoundingRect.x(), lastDrawnTextBoundingRect.y(), lastDrawnTextBoundingRect.width(), lastDrawnTextBoundingRect.height());
+// qWarning() << "Text " << text << log;
+// textFonts.append(textFont);
+// textRects.append(QRectF(curX, curY, lastDrawnTextBoundingRect.width(), lastDrawnTextBoundingRect.height()));
+// textLines.append(text);
+// textAligns.append(textAlign);
+// textColors.append(fontColor);
+// curX += lastDrawnTextBoundingRect.width();
+// if (width < curX)
+// width = curX;
+// if (height == 0)
+// height = curHeight;
+
+// continue;
+// }
+// }
+
+// QSvgGenerator *generator = createSvgGenerator(width, height);
+// QPainter painter;
+// painter.begin(generator);
+
+// if (textRects.count() != 0)
+// {
+// QListIterator textRectsIter(textRects);
+// QListIterator textFontsIter(textFonts);
+// QListIterator textLinesIter(textLines);
+// QListIterator textAlignsIter(textAligns);
+// QListIterator textColorsIter(textColors);
+
+// while (textRectsIter.hasNext())
+// {
+// QRectF rt = textRectsIter.next();
+// QFont font = textFontsIter.next();
+// QString line = textLinesIter.next();
+// int align = textAlignsIter.next();
+// QColor color = textColorsIter.next();
+// painter.setFont(font);
+// painter.setPen(color);
+// painter.drawText(rt.x(), rt.y(), rt.width(), rt.height(), align, line);
+// }
+// }
+
+// painter.end();
+
+// //add resulting svg file to scene
+// UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+// repositionSvgItem(svgItem, width, height, x, y, hasTransform, transform);
+
+// delete generator;
+
+ return true;
+
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &element)
+{
+ //TODO textarea node
+ qreal x = element.attribute(aX).toDouble();
+ qreal y = element.attribute(aY).toDouble();
+ qreal width = element.attribute(aWidth).toDouble();
+ qreal height = element.attribute(aHeight).toDouble();
+
+ qreal fontSize = 12;
+ QColor fontColor;
+ QString fontFamily = "Arial";
+ QString fontStretch = "normal";
+ bool italic = false;
+ int fontWeight = QFont::Normal;
+ int textAlign = Qt::AlignLeft;
+ QTransform fontTransform;
+ parseTextAttributes(fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
+
+ QSvgGenerator *generator = createSvgGenerator(width, height);
+ QPainter painter;
+ painter.begin(generator);
+ painter.setFont(QFont(fontFamily, fontSize, fontWeight, italic));
+
+ qreal curY = 0.0;
+ qreal curX = 0.0;
+ qreal linespacing = QFontMetricsF(painter.font()).leading();
+
+// remember if text area has transform
+// QString transformString;
+ QTransform transform = fontTransform;
+ bool hasTransform = !fontTransform.isIdentity();
+
+ QRectF lastDrawnTextBoundingRect;
+ //parse text area tags
+
+ QDomElement curTextElement = element.firstChildElement();
+ while (!curTextElement.isNull()) {
+ QString tagName = curTextElement.tagName();
+ if (tagName == tTspan) {
+ parseTextAttributes(curTextElement, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
+ painter.setFont(QFont(fontFamily, fontSize, fontWeight, italic));
+ painter.setPen(fontColor);
+ linespacing = QFontMetricsF(painter.font()).leading();
+
+ QDomNode tspanNode = curTextElement.firstChild();
+ while (!tspanNode.isNull()) {
+ if (tspanNode.nodeType() == QDomNode::CharacterDataNode
+ || tspanNode.nodeType() == QDomNode::CDATASectionNode) {
+ QDomCharacterData textData = tspanNode.toCharacterData();
+ QString text = textData.data().trimmed();
+ //get bounding rect to obtain desired text height
+ lastDrawnTextBoundingRect = painter.boundingRect(QRectF(curX, curY, width, height - curY), textAlign|Qt::TextWordWrap, text);
+ painter.drawText(curX, curY, width, lastDrawnTextBoundingRect.height(), textAlign|Qt::TextWordWrap, text);
+ curX += lastDrawnTextBoundingRect.x() + lastDrawnTextBoundingRect.width();
+ } else if (tspanNode.nodeType() == QDomNode::ElementNode) {
+ //when tbreak appers, move down by the drawn rect height
+ //TODO: line spacing is not calculated yet, additional code is required
+ curY += lastDrawnTextBoundingRect.height() + linespacing;
+ curX = 0.0;
+ lastDrawnTextBoundingRect = QRectF(0,0,0,0);
}
+ tspanNode = tspanNode.nextSibling();
+ }
+ } else if (tagName == tBreak) {
+
+ }
+ curTextElement = curTextElement.nextSiblingElement();
+ }
+
+ painter.end();
+
+ //add resulting svg file to scene
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ repositionSvgItem(svgItem, width, height, x, y, hasTransform, transform);
+ delete generator;
+
+ return true;
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &element)
+{
+ qreal x = element.attribute(aX).toDouble();
+ qreal y = element.attribute(aY).toDouble();
+ qreal width = element.attribute(aWidth).toDouble();
+ qreal height = element.attribute(aHeight).toDouble();
+
+ QString itemRefPath = element.attribute(aHref);
+
+ QPixmap pix;
+ if (!itemRefPath.isNull()) {
+ QString imagePath = pwdContent + "/" + itemRefPath;
+ if (!QFile::exists(imagePath)) {
+ qDebug() << "can't load file" << pwdContent + "/" + itemRefPath << "maybe file corrupted";
+ return false;
+ } else {
+ qDebug() << "size of file" << itemRefPath << QFileInfo(itemRefPath).size();
+ }
+ pix.load(imagePath);
+ if (pix.isNull()) {
+ qDebug() << "can't create pixmap for file" << pwdContent + "/" + itemRefPath << "maybe format does not supported";
+ }
+ }
+
+ UBGraphicsPixmapItem *pixItem = mCurrentScene->addPixmap(pix);
+ QTransform transform;
+ QString textTransform = element.attribute(aTransform);
+ bool hastransform = false;
+ if (!textTransform.isNull()) {
+ transform = transformFromString(textTransform);
+ hastransform = true;
+ }
+// repositionSvgItem(svgItem, rx * 2 + 10, ry * 2 + 10, cx - rx - 5, cy - ry -5, hastransform, transform);
+ repositionPixmapItem(pixItem, width, height, x, y, hastransform, transform);
+// hashSceneItem(element, pixItem->);
+
+ return true;
+}
+
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgSectionAttr(const QDomElement &svgSection)
+{
+ getViewBoxDimenstions(svgSection.attribute(aViewbox));
+ mSize = QSize(svgSection.attribute(aWidth).toInt(),
+ svgSection.attribute(aHeight).toInt());
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGroup(QDomNode *group)
+{
+ QDomElement curGroupPtr = group->firstChildElement();
+
+ while (!curGroupPtr.isNull()) {
+ if (curGroupPtr.namespaceURI() != iwbNS)
+ continue;
+ if (curGroupPtr.hasChildNodes() && curGroupPtr.toElement().tagName() == tGroup) {
+ parseIwbGroup(&curGroupPtr);
+ } else if (curGroupPtr.toElement().tagName() == tElement) {
+ QHash::iterator iSvgElementExt = iwbExtProperties.find(curGroupPtr.attribute(aRef));
+ if (iSvgElementExt != iwbExtProperties.end()) {
+ IwbExt &svgElementExt = *iSvgElementExt;
+ QDomNode &svgElement = svgElementExt.element;
+ svgElement.parentNode().removeChild(svgElement);
+ }
+ }
+ curGroupPtr = curGroupPtr.nextSiblingElement(tElement);
}
- if (!mReader.error() == QXmlStreamReader::NoError)
- UBApplication::showMessage(mReader.errorString());
+ return true;
+}
+
+//void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSceneItem(QDomNode &element, UBGraphicsItemDelegate *item)
+//{
+//// adding element pointer to hash to refer if needed
+// QString key = element.attribute(aId);
+// if (!key.isNull())
+// persistedItems.insert(key, item);
+//}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &parent)
+{
+ QString tagName = parent.tagName();
+ if (parent.namespaceURI() != svgNS) {
+ qDebug() << "Incorrect namespace, error at content file, line number" << parent.lineNumber();
+ return false;
+ }
+
+
+ if (tagName == tRect && !parseSvgRect(parent)) return false;
+ else if (tagName == tEllipse && !parseSvgEllipse(parent)) return false;
+ else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false;
+ else if (tagName == tPolyline && !parseSvgPolyline(parent)) return false;
+ else if (tagName == tText && !parseSvgText(parent)) return false;
+ else if (tagName == tTextarea && !parseSvgTextarea(parent)) return false;
+ else if (tagName == tImage && !parseSvgImage(parent)) return false;
+
+ return true;
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPage(const QDomElement &parent)
+{
+ createNewScene();
+ QDomElement currentSvgElement = parent.firstChildElement();
+ while (!currentSvgElement.isNull()) {
+ if (!parseSvgElement(currentSvgElement))
+ return false;
+
+ currentSvgElement = currentSvgElement.nextSiblingElement();
+ }
+ persistCurrentScene();
+ return true;
+}
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPageset(const QDomElement &parent)
+{
+ QDomElement currentPage = parent.firstChildElement(tPage);
+ while (!currentPage.isNull()) {
+ if (!parseSvgPage(currentPage))
+ return false;
+ currentPage = currentPage.nextSiblingElement(tPage);
+ }
+ return true;
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseDoc()
+{
+ if (!hashElements()) return false; //hashing all elements having id attribute
+
+ QDomElement svgSection = mDOMdoc.elementsByTagNameNS(svgNS, tSvg).at(0).toElement();
+ parseSvgSectionAttr(svgSection);
+
+ QDomElement currentSvg = svgSection.firstChildElement();
+
+ if (currentSvg.tagName() != tPageset) {
+ parseSvgPage(svgSection);
+ } else if (currentSvg.tagName() == tPageset){
+ parseSvgPageset(currentSvg);
+ }
+
+
+// while (!mReader.atEnd())
+// {
+// mReader.readNext();
+// if (mReader.isStartElement())
+// {
+// if (!parseCurrentElementStart())
+// return false;
+// }
+// else
+// if (mReader.isCharacters())
+// {
+// if (!parseCurrentElementCharacters())
+// return false;
+// }
+// else
+// if (mReader.isEndElement())
+// {
+// if (!parseCurrentElementEnd())
+// return false;
+// }
+// }
+// if (!mReader.error() == QXmlStreamReader::NoError)
+// UBApplication::showMessage(mReader.errorString());
+
return true;
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseCurrentElementStart()
{
QStringRef elName = mReader.name();
- QString log = QString("%1<%2>").arg(mIndent).arg(elName.toString());
- qDebug() << log;
+// QString log = QString("%1<%2>").arg(mIndent).arg(elName.toString());
+// qDebug() << log;
mIndent += " ";
if ( elName == tIwb)
{
@@ -351,10 +1112,12 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvg()
return true;
}
-void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(UBGraphicsSvgItem *item, qreal width, qreal height, qreal x, qreal y, bool useTransform, QTransform &transform)
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(UBGraphicsSvgItem *item, qreal width, qreal height,
+ qreal x, qreal y,
+ bool useTransform, QTransform &transform)
{
QTransform curTrans = item->transform();
- qWarning() << QString().sprintf("Item current transform = %f 0 0 %f %f %f, position %f, %f", curTrans.m11(), curTrans.m22(), curTrans.dx(), curTrans.dy(), item->x(), item->y());
+// qWarning() << QString().sprintf("Item current transform = %f 0 0 %f %f %f, position %f, %f", curTrans.m11(), curTrans.m22(), curTrans.dx(), curTrans.dy(), item->x(), item->y());
//check if rect is rotated
//rotate svg item itself
QRectF itemBounds = item->boundingRect();
@@ -379,7 +1142,49 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(UBGraphicsSvgItem
}
QTransform newTrans = item->transform();
- qWarning() << QString("Item new transform = %3 0 0 %4 %1 %2, position %5, %6").arg(newTrans.dx()).arg(newTrans.dy()).arg(newTrans.m11()).arg(newTrans.m22()).arg(item->x()).arg(item->y());
+// qWarning() << QString("Item new transform = %3 0 0 %4 %1 %2, position %5, %6").arg(newTrans.dx()).arg(newTrans.dy()).arg(newTrans.m11()).arg(newTrans.m22()).arg(item->x()).arg(item->y());
+
+}
+void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionPixmapItem(UBGraphicsPixmapItem *item, qreal width, qreal height,
+ qreal x, qreal y,
+ bool useTransform, QTransform &transform)
+{
+ //if element is to transform
+// if (!transform.isIdentity()) {
+// QTransform curTransform = item->transform();
+// qreal hScale = item->boundingRect().width() / width * curTransform.m11();
+// qreal vScale = item->boundingRect().height() / height * curTransform.m22();
+// curTransform = curTransform.translate(x - mViewBoxCenter.x(), y - mViewBoxCenter.y()).scale(hScale, vScale);
+// curTransform = curTransform * transform;
+
+// item->setTransform(curTransform);
+
+
+ QTransform curTrans = item->transform();
+// qWarning() << QString().sprintf("Item current transform = %f 0 0 %f %f %f, position %f, %f", curTrans.m11(), curTrans.m22(), curTrans.dx(), curTrans.dy(), item->x(), item->y());
+ //check if rect is rotated
+ //rotate svg item itself
+ QRectF itemBounds = item->boundingRect();
+ //first, svg is mapped to svg item bound
+ //second, svg item is mapped to scene
+ //so, get svg to svg item scale and multiple by scene scale
+ qreal hScale = itemBounds.width() / width * curTrans.m11();
+ qreal vScale = itemBounds.height() / height * curTrans.m22();
+
+ if (useTransform)
+ {
+ QPointF oldVector((x - transform.dx()), (y - transform.dy()));
+ QTransform rTransform(transform.m11(), transform.m12(), transform.m21(), transform.m22(), 0, 0);
+ QPointF newVector = rTransform.map(oldVector);
+ rTransform.scale(curTrans.m11(), curTrans.m22());
+ item->setTransform(QTransform(rTransform.m11(), rTransform.m12(), rTransform.m21(), rTransform.m22(), 0, 0));
+ item->setPos((x - mViewBoxCenter.x() + (newVector - oldVector).x()) * hScale, (y - mViewBoxCenter.y() + (newVector - oldVector).y()) * vScale );
+ }
+ else
+ {
+ item->setPos((x - mViewBoxCenter.x()) * hScale, (y - mViewBoxCenter.y()) * vScale);
+ }
+
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseRect()
@@ -879,8 +1684,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parsePolyline()
if (mReader.attributes().hasAttribute(aStrokewidth))
pen.setWidth(mReader.attributes().value(aStrokewidth).toString().toInt());
- pen.setColor(Qt::yellow);
-
QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
QPainter painter;
@@ -909,11 +1712,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parsePage()
qWarning() << "iwb content parse error, unexpected page tag at line" << mReader.lineNumber();
return false;
}
-
createNewScene();
-
qWarning() << "Added page number" << mProxy->pageCount();
-
return true;
}
@@ -999,31 +1799,31 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::getCurElementTransorm(QTransform &tr
QTransform UBCFFSubsetAdaptor::UBCFFSubsetReader::transformFromString(const QString trString)
{
+ qreal dx = 0.0;
+ qreal dy = 0.0;
+ qreal angle = 0.0;
+
//check pattern for strings like 'rotate(10)'
QRegExp regexp("rotate\\( *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *\\)");
- if (regexp.exactMatch(trString))
- {
- if (regexp.capturedTexts().count() == 2 && regexp.capturedTexts().at(0).length() == trString.length())
- {
- qreal angle = regexp.capturedTexts().at(1).toDouble();
- return QTransform().rotate(angle);
+ if (regexp.exactMatch(trString)) {
+ angle = regexp.capturedTexts().at(1).toDouble();
+ } else {
+ //check pattern for strings like 'rotate(10,20,20)' or 'rotate(10.1,10.2,34.2)'
+ regexp.setPattern("rotate\\( *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *, *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *, *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *\\)");
+ if (regexp.exactMatch(trString)) {
+ angle = regexp.capturedTexts().at(1).toDouble();
+ dx = regexp.capturedTexts().at(2).toDouble();
+ dy = regexp.capturedTexts().at(3).toDouble();
}
}
-
- //check pattern for strings like 'rotate(10,20,20)' or 'rotate(10.1,10.2,34.2)'
- regexp.setPattern("rotate\\( *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *, *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *, *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *\\)");
- if (regexp.exactMatch(trString))
- {
- if (regexp.capturedTexts().count() == 4 && regexp.capturedTexts().at(0).length() == trString.length())
- {
- qreal angle = regexp.capturedTexts().at(1).toDouble();
- qreal dx = regexp.capturedTexts().at(2).toDouble();
- qreal dy = regexp.capturedTexts().at(3).toDouble();
- return QTransform().translate(dx, dy).rotate(angle);
- }
+ //check pattern for strings like 'translate(11.0, 12.34)'
+ regexp.setPattern("translate\\( *([-+]{0,1}[0-9]*\\.{0,1}[0-9]*) *,*([-+]{0,1}[0-9]*\\.{0,1}[0-9]*)*\\)");
+ if (regexp.exactMatch(trString)) {
+ dx = regexp.capturedTexts().at(1).toDouble();
+ dy = regexp.capturedTexts().at(2).toDouble();
}
- return QTransform();
+ return QTransform().translate(dx, dy).rotate(angle);
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::getViewBoxDimenstions(const QString& viewBox)
diff --git a/src/adaptors/UBCFFSubsetAdaptor.h b/src/adaptors/UBCFFSubsetAdaptor.h
index 2c78f1e4..dcddefdd 100644
--- a/src/adaptors/UBCFFSubsetAdaptor.h
+++ b/src/adaptors/UBCFFSubsetAdaptor.h
@@ -19,12 +19,28 @@
#include
#include
#include
+#include
+#include
class UBDocumentProxy;
class UBGraphicsScene;
class QSvgGenerator;
class UBGraphicsSvgItem;
+class UBGraphicsPixmapItem;
+class UBGraphicsItemDelegate;
class QTransform;
+class QPainter;
+
+struct IwbExt {
+ IwbExt() {;}
+ IwbExt(QDomNode element) : element(element), extAttr(*(new QVector())) {;}
+
+ QDomNode group;
+ QDomNode element;
+ QVector extAttr;
+ QHash textAttributes;
+ operator bool() const {return !group.isNull() || !element.isNull();}
+};
class UBCFFSubsetAdaptor
{
@@ -49,10 +65,11 @@ private:
};
public:
- UBCFFSubsetReader(UBDocumentProxy *proxy, QByteArray &content);
+ UBCFFSubsetReader(UBDocumentProxy *proxy, QFile *content);
QXmlStreamReader mReader;
UBDocumentProxy *mProxy;
+ QString pwdContent;
bool parse();
@@ -65,6 +82,41 @@ private:
QPointF mViewBoxCenter;
QSize mSize;
+ private:
+ // to kill
+ QDomDocument mDOMdoc;
+ QDomNode mCurrentDOMElement;
+ QHash iwbExtProperties;
+ QHash persistedItems;
+
+ bool hashElements();
+ void addExtentionsToHash(QDomElement *parent, QDomElement *topGroup);
+
+ void hashSvg(QDomNode *parent, QString prefix = "");
+ void hashSiblingIwbElements(QDomElement *parent, QDomElement *topGroup = 0);
+
+ inline void parseSvgSectionAttr(const QDomElement &);
+ bool parseSvgPage(const QDomElement &parent);
+ bool parseSvgPageset(const QDomElement &parent);
+ bool parseSvgElement(const QDomElement &parent);
+
+ inline bool parseSvgRect(const QDomElement &element);
+ inline bool parseSvgEllipse(const QDomElement &element);
+ inline bool parseSvgPolygon(const QDomElement &element);
+ inline bool parseSvgPolyline(const QDomElement &element);
+ inline bool parseSvgText(const QDomElement &element);
+ inline bool parseSvgTextarea(const QDomElement &element);
+ inline bool parseSvgImage(const QDomElement &element);
+// inline bool parseSvgTSpan(const QDomElement)
+ bool parseIwbGroup(QDomNode *element);
+ inline void hashSceneItem(QDomNode *element, UBGraphicsItemDelegate *item);
+
+ // to kill
+ void parseTextAttributes(const QDomElement &element, qreal &fontSize, QColor &fontColor,
+ QString &fontFamily, QString &fontStretch, bool &italic,
+ int &fontWeight, int &textAlign, QTransform &fontTransform);
+
+
//methods to store current xml parse state
int PopState();
void PushState(int state);
@@ -92,12 +144,16 @@ private:
bool createNewScene();
bool persistCurrentScene();
+
QStack stateStack;
+
int currentState;
//helper methods
bool getCurElementTransorm(QTransform &transform);
void repositionSvgItem(UBGraphicsSvgItem *item, qreal width, qreal height, qreal x, qreal y, bool useTransform, QTransform &transform);
+ void repositionPixmapItem(UBGraphicsPixmapItem *item, qreal width, qreal height, qreal x, qreal y
+ , bool useTransform, QTransform &transform);
QColor colorFromString(const QString& clrString);
QTransform transformFromString(const QString trString);
bool getViewBoxDimenstions(const QString& viewBox);
diff --git a/src/adaptors/UBImportCFF.cpp b/src/adaptors/UBImportCFF.cpp
index 4ad47896..f6554415 100644
--- a/src/adaptors/UBImportCFF.cpp
+++ b/src/adaptors/UBImportCFF.cpp
@@ -47,8 +47,8 @@ UBImportCFF::~UBImportCFF()
QStringList UBImportCFF::supportedExtentions()
{
-// return QStringList("iwb");
- return QStringList();
+ return QStringList("iwb");
+// return QStringList();
}
diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp
index 059883e0..7db6d551 100644
--- a/src/board/UBBoardController.cpp
+++ b/src/board/UBBoardController.cpp
@@ -1708,7 +1708,7 @@ UBGraphicsAudioItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool st
QUuid uuid = QUuid::createUuid();
QUrl concreteUrl = pSourceUrl;
- concreteUrl = QUrl(UBPersistenceManager::persistenceManager()
+ concreteUrl = QUrl::fromLocalFile(mActiveDocument->persistencePath() + "/" + UBPersistenceManager::persistenceManager()
->addAudioFileToDocument(mActiveDocument, pSourceUrl.toLocalFile(), uuid));
UBGraphicsAudioItem* vi = mActiveScene->addAudio(concreteUrl, startPlay, pos);
diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp
old mode 100755
new mode 100644
index 88693189..314cfd39
--- a/src/board/UBBoardPaletteManager.cpp
+++ b/src/board/UBBoardPaletteManager.cpp
@@ -80,7 +80,6 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mpPageNavigWidget(NULL)
, mpLibWidget(NULL)
, mpCachePropWidget(NULL)
-// , mDesktopRightPalette(NULL)
, mpTeacherBarWidget(NULL)
, mpDesktopLibWidget(NULL)
{
@@ -225,15 +224,38 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
void UBBoardPaletteManager::slot_changeMainMode(UBApplicationController::MainMode mainMode)
{
+// Board = 0, Internet, Document, Tutorial, ParaschoolEditor, WebDocument
+
switch( mainMode )
{
- case UBApplicationController::Board:
- // call changeMode only when switch NOT from desktop mode
- if(!UBApplication::applicationController->isShowingDesktop())
- changeMode(eUBDockPaletteWidget_BOARD);
+ case UBApplicationController::Board:
+ {
+ // call changeMode only when switch NOT from desktop mode
+ if(!UBApplication::applicationController->isShowingDesktop())
+ changeMode(eUBDockPaletteWidget_BOARD);
+ }
+ break;
+
+ case UBApplicationController::Tutorial:
+ {
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ mKeyboardPalette->hide();
+ }
+ break;
+
+ case UBApplicationController::Internet:
+ changeMode(eUBDockPaletteWidget_WEB);
+ break;
+
+ case UBApplicationController::Document:
+ changeMode(eUBDockPaletteWidget_DOCUMENT);
break;
default:
+ {
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ mKeyboardPalette->hide();
+ }
break;
}
}
@@ -260,25 +282,25 @@ void UBBoardPaletteManager::slot_changeDesktopMode(bool isDesktop)
void UBBoardPaletteManager::setupPalettes()
{
- setupDockPaletteWidgets();
-
-
- // Add the other palettes
- mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal);
- connect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int)));
- mStylusPalette->show(); // always show stylus palette at startup
-
if (UBPlatformUtils::hasVirtualKeyboard())
{
- mKeyboardPalette = UBKeyboardPalette::create(0);
+ mKeyboardPalette = new UBKeyboardPalette(0);
#ifndef Q_WS_WIN
connect(mKeyboardPalette, SIGNAL(closed()), mKeyboardPalette, SLOT(onDeactivated()));
#endif
#ifndef Q_WS_MAC
- mKeyboardPalette->setParent(mContainer);
+ // mKeyboardPalette->setParent(mContainer);
#endif
}
+ setupDockPaletteWidgets();
+
+
+ // Add the other palettes
+ mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal);
+ connect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int)));
+ mStylusPalette->show(); // always show stylus palette at startup
+
mZoomPalette = new UBZoomPalette(mContainer);
QList backgroundsActions;
@@ -488,7 +510,7 @@ void UBBoardPaletteManager::connectPalettes()
}
-
+bool isFirstResized = true;
void UBBoardPaletteManager::containerResized()
{
int innerMargin = UBSettings::boardMargin;
@@ -498,25 +520,39 @@ void UBBoardPaletteManager::containerResized()
int userTop = innerMargin;
int userHeight = mContainer->height() - (2 * innerMargin);
- mStylusPalette->move(userLeft, userTop);
- mStylusPalette->adjustSizeAndPosition();
- mStylusPalette->initPosition();
+ if(mStylusPalette)
+ {
+ mStylusPalette->move(userLeft, userTop);
+ mStylusPalette->adjustSizeAndPosition();
+ mStylusPalette->initPosition();
+ }
- mZoomPalette->move(userLeft + userWidth - mZoomPalette->width()
- , userTop + userHeight /*- mPageNumberPalette->height()*/ - innerMargin - mZoomPalette->height());
- mZoomPalette->adjustSizeAndPosition();
+ if(mZoomPalette)
+ {
+ mZoomPalette->move(userLeft + userWidth - mZoomPalette->width()
+ , userTop + userHeight /*- mPageNumberPalette->height()*/ - innerMargin - mZoomPalette->height());
+ mZoomPalette->adjustSizeAndPosition();
+ }
- if (mKeyboardPalette)
+ if (isFirstResized && mKeyboardPalette && mKeyboardPalette->parent() == UBApplication::boardController->controlContainer())
{
- mKeyboardPalette->move(userLeft + (userWidth - mKeyboardPalette->width())/2,
- userTop + userHeight - mKeyboardPalette->height());
- mKeyboardPalette->adjustSizeAndPosition();
+ isFirstResized = false;
+ mKeyboardPalette->move(userLeft + (userWidth - mKeyboardPalette->width())/2,
+ userTop + (userHeight - mKeyboardPalette->height())/2);
+ mKeyboardPalette->adjustSizeAndPosition();
}
- mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height());
- mRightPalette->resize(mRightPalette->width()-1, mContainer->height());
- mLeftPalette->resize(mLeftPalette->width(), mContainer->height());
- mRightPalette->resize(mRightPalette->width(), mContainer->height());
+ if(mLeftPalette)
+ {
+ mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height());
+ mLeftPalette->resize(mLeftPalette->width(), mContainer->height());
+ }
+
+ if(mRightPalette)
+ {
+ mRightPalette->resize(mRightPalette->width()-1, mContainer->height());
+ mRightPalette->resize(mRightPalette->width(), mContainer->height());
+ }
}
@@ -688,6 +724,18 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
{
mLeftPalette->setParent(UBApplication::boardController->controlContainer());
mRightPalette->setParent(UBApplication::boardController->controlContainer());
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ {
+
+ if(mKeyboardPalette->m_isVisible)
+ {
+ mKeyboardPalette->hide();
+ mKeyboardPalette->setParent(UBApplication::boardController->controlContainer());
+ mKeyboardPalette->show();
+ }
+ else
+ mKeyboardPalette->setParent(UBApplication::boardController->controlContainer());
+ }
mLeftPalette->setVisible(true);
mRightPalette->setVisible(true);
@@ -701,6 +749,22 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
{
mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ {
+
+ if(mKeyboardPalette->m_isVisible)
+ {
+ mKeyboardPalette->hide();
+#ifndef Q_WS_X11
+ mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
+#else
+ mKeyboardPalette->setParent(0);
+#endif
+ mKeyboardPalette->show();
+ }
+ else
+ mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
+ }
mLeftPalette->setVisible(false);
mRightPalette->setVisible(true);
@@ -710,12 +774,46 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
}
break;
+ case eUBDockPaletteWidget_WEB:
+ {
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ {
+ WBBrowserWindow* brWnd = UBApplication::webController->GetCurrentWebBrowser();
+
+ if(mKeyboardPalette->m_isVisible)
+ {
+ mKeyboardPalette->hide();
+ mKeyboardPalette->setParent(brWnd);
+ mKeyboardPalette->show();
+ }
+ else
+ mKeyboardPalette->setParent(brWnd);
+ }
+
+ }
+ break;
+
default:
{
mLeftPalette->setVisible(false);
mRightPalette->setVisible(false);
mLeftPalette->setParent(0);
mRightPalette->setParent(0);
+ if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
+ {
+
+ if(mKeyboardPalette->m_isVisible)
+ {
+ mKeyboardPalette->hide();
+ mKeyboardPalette->setParent(0);
+ mKeyboardPalette->show();
+ }
+ else
+ mKeyboardPalette->setParent(0);
+
+// mKeyboardPalette->update();
+
+ }
}
break;
}
diff --git a/src/board/UBLibraryController.cpp b/src/board/UBLibraryController.cpp
index d2d66716..edd4bc2e 100644
--- a/src/board/UBLibraryController.cpp
+++ b/src/board/UBLibraryController.cpp
@@ -353,7 +353,6 @@ QList UBLibraryController::listElementsInPath(const QString& pPat
UBLibElement *element = new UBLibElement(fileType, QUrl::fromLocalFile(fileInfo->absoluteFilePath()), itemName);
if (fileType == eUBLibElementType_Folder) {
-// QImage* directoryImage = new QImage(":images/libpalette/folder.svg");
element->setThumbnail(QImage(":images/libpalette/folder.svg"));
}
else if (fileType == eUBLibElementType_Item) {
diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp
index b239fa25..efece366 100644
--- a/src/core/UBApplicationController.cpp
+++ b/src/core/UBApplicationController.cpp
@@ -368,6 +368,8 @@ void UBApplicationController::showInternet()
if (UBSettings::settings()->webUseExternalBrowser->get().toBool())
{
showDesktop(true);
+ UBApplication::webController->show(UBWebController::WebBrowser);
+ // really no have emit mainModeChanged here ? potential problem with virtual keyboard ?
}
else
{
@@ -382,10 +384,11 @@ void UBApplicationController::showInternet()
mMainWindow->show();
mUninoteController->hideWindow();
+
+ UBApplication::webController->show(UBWebController::WebBrowser);
+
emit mainModeChanged(Internet);
}
-
- UBApplication::webController->show(UBWebController::WebBrowser);
}
diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp
index 5ffd8759..aa4b0504 100644
--- a/src/desktop/UBDesktopAnnotationController.cpp
+++ b/src/desktop/UBDesktopAnnotationController.cpp
@@ -52,7 +52,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mTransparentDrawingView(0)
, mTransparentDrawingScene(0)
, mDesktopPalette(NULL)
- , mKeyboardPalette(0)
+// , mKeyboardPalette(0)
, mDesktopPenPalette(NULL)
, mDesktopMarkerPalette(NULL)
, mDesktopEraserPalette(NULL)
@@ -64,7 +64,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mPendingMarkerButtonPressed(false)
, mPendingEraserButtonPressed(false)
, mbArrowClicked(false)
- , mBoardStylusTool(UBStylusTool::Pen)
+ , mBoardStylusTool(UBStylusTool::Selector /*UBStylusTool::Pen*/)
, mDesktopStylusTool(UBStylusTool::Selector)
{
@@ -97,16 +97,21 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
if (UBPlatformUtils::hasVirtualKeyboard())
{
#ifdef Q_WS_X11
- mKeyboardPalette = UBKeyboardPalette::create(0);
- connect(mTransparentDrawingView, SIGNAL(hidden()), mKeyboardPalette, SLOT(hide()));
- connect(mTransparentDrawingView, SIGNAL(shown()), this, SLOT(showKeyboard()));
+// mKeyboardPalette = UBKeyboardPalette::create(0);
+// connect(mTransparentDrawingView, SIGNAL(hidden()), mKeyboardPalette, SLOT(hide()));
+// connect(mTransparentDrawingView, SIGNAL(shown()), this, SLOT(showKeyboard()));
#else
- mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
- mKeyboardPalette->setParent(mTransparentDrawingView);
+// mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
+// mKeyboardPalette->setParent(mTransparentDrawingView);
#endif
- connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
+ connect( UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(keyboardActivated(bool)),
+ mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
+
+// connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)),
+// mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
+
#ifdef Q_WS_X11
- connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
+ connect(UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
connect(mDesktopPalette,SIGNAL(refreshMask()), this, SLOT(refreshMask()));
#endif
}
@@ -117,7 +122,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture()));
connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize()));
- connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
+// connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized()));
@@ -164,31 +169,32 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
onDesktopPaletteMaximized();
}
-void UBDesktopAnnotationController::showKeyboard(bool show)
-{
- #ifdef Q_WS_X11
- if (!mTransparentDrawingView->isVisible())
- return;
- #endif
-
- if(mKeyboardPalette)
- {
- if(show)
- UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
- mKeyboardPalette->setVisible(show);
-
- #ifdef Q_WS_X11
- updateMask(true);
- #endif
-
- }
-
-}
-void UBDesktopAnnotationController::showKeyboard()
-{
- if (UBApplication::mainWindow->actionVirtualKeyboard->isChecked())
- mKeyboardPalette->show();
-}
+// void UBDesktopAnnotationController::showKeyboard(bool show)
+// {
+// #ifdef Q_WS_X11
+// if (!mTransparentDrawingView->isVisible())
+// return;
+// #endif
+//
+// if(mKeyboardPalette)
+// {
+// if(show)
+// UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
+// mKeyboardPalette->setVisible(show);
+//
+// #ifdef Q_WS_X11
+// updateMask(true);
+// #endif
+//
+// }
+//
+// }
+
+// void UBDesktopAnnotationController::showKeyboard()
+// {
+// if (UBApplication::mainWindow->actionVirtualKeyboard->isChecked())
+// mKeyboardPalette->show();
+// }
UBDesktopAnnotationController::~UBDesktopAnnotationController()
{
@@ -366,12 +372,12 @@ void UBDesktopAnnotationController::close()
void UBDesktopAnnotationController::stylusToolChanged(int tool)
{
- UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
- if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text)
- {
- if(mKeyboardPalette->m_isVisible)
- UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger);
- }
+// UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
+// if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text)
+// {
+// if(mKeyboardPalette->m_isVisible)
+// UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger);
+// }
updateBackground();
}
@@ -910,9 +916,10 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height());
}
- if(mKeyboardPalette->isVisible())
+ if(UBApplication::boardController->paletteManager()->mKeyboardPalette->isVisible())
{
- p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height());
+ p.drawRect(UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().x(), UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().y(),
+ UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height());
}
// UBApplication::boardController->paletteManager()->mDesktopRightPalette
diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h
index b3a9e37f..924156b0 100644
--- a/src/desktop/UBDesktopAnnotationController.h
+++ b/src/desktop/UBDesktopAnnotationController.h
@@ -29,7 +29,7 @@ class UBDesktopPenPalette;
class UBDesktopMarkerPalette;
class UBDesktopEraserPalette;
class UBActionPalette;
-class UBKeyboardPalette;
+//class UBKeyboardPalette;
class UBMainWindow;
#define PROPERTY_PALETTE_TIMER 1000
@@ -72,8 +72,8 @@ class UBDesktopAnnotationController : public QObject
void stylusToolChanged(int tool);
void updateBackground();
- void showKeyboard(bool show);
- void showKeyboard(); //X11 virtual keyboard working only needed
+// void showKeyboard(bool show);
+// void showKeyboard(); //X11 virtual keyboard working only needed
signals:
/**
@@ -118,7 +118,7 @@ class UBDesktopAnnotationController : public QObject
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette;
- UBKeyboardPalette *mKeyboardPalette;
+ //UBKeyboardPalette *mKeyboardPalette;
UBDesktopPenPalette* mDesktopPenPalette;
UBDesktopMarkerPalette* mDesktopMarkerPalette;
UBDesktopEraserPalette* mDesktopEraserPalette;
diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp
index b2cd201b..dd014988 100644
--- a/src/document/UBDocumentController.cpp
+++ b/src/document/UBDocumentController.cpp
@@ -38,7 +38,7 @@
#include "board/UBBoardPaletteManager.h"
#include "board/UBDrawingController.h"
-#include "gui/UBKeyboardPalette.h"
+//#include "gui/UBKeyboardPalette.h"
#include "gui/UBThumbnailView.h"
#include "gui/UBDocumentTreeWidget.h"
@@ -70,7 +70,7 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow)
, mToolsPalette(0)
, mToolsPalettePositionned(false)
, mTrashTi(0)
- , mKeyboardPalette(0)
+// , mKeyboardPalette(0)
{
setupViews();
setupToolbar();
@@ -444,12 +444,12 @@ void UBDocumentController::setupViews()
mMessageWindow = new UBMessageWindow(mDocumentUI->thumbnailWidget);
mMessageWindow->hide();
- if (UBPlatformUtils::hasVirtualKeyboard())
- {
- mKeyboardPalette = UBKeyboardPalette::create(0);
- mKeyboardPalette->setParent(controlView());
- connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
- }
+// if (UBPlatformUtils::hasVirtualKeyboard())
+// {
+// mKeyboardPalette = UBKeyboardPalette::create(0);
+// mKeyboardPalette->setParent(controlView());
+// connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
+// }
}
}
@@ -467,6 +467,7 @@ void UBDocumentController::setupToolbar()
connect(mMainWindow->actionDocumentTools, SIGNAL(triggered()), this, SLOT(toggleDocumentToolsPalette()));
}
+/*
void UBDocumentController::showKeyboard(bool show)
{
if(mKeyboardPalette)
@@ -477,6 +478,7 @@ void UBDocumentController::showKeyboard(bool show)
}
}
+*/
void UBDocumentController::setupPalettes()
{
diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h
index 4e9b3d31..4baf8b36 100644
--- a/src/document/UBDocumentController.h
+++ b/src/document/UBDocumentController.h
@@ -34,7 +34,7 @@ class UBDocumentGroupTreeItem;
class UBDocumentProxyTreeItem;
class UBMainWindow;
class UBDocumentToolsPalette;
-class UBKeyboardPalette;
+//class UBKeyboardPalette;
class UBDocumentController : public QObject
{
@@ -76,7 +76,7 @@ class UBDocumentController : public QObject
void paste();
void focusChanged(QWidget *old, QWidget *current);
- void showKeyboard(bool show);
+// void showKeyboard(bool show);
protected:
virtual void setupViews();
@@ -112,7 +112,7 @@ class UBDocumentController : public QObject
UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument;
- UBKeyboardPalette *mKeyboardPalette;
+// UBKeyboardPalette *mKeyboardPalette;
private slots:
diff --git a/src/domain/UBGraphicsProxyWidget.h b/src/domain/UBGraphicsProxyWidget.h
index a7dc5de7..adf0737f 100644
--- a/src/domain/UBGraphicsProxyWidget.h
+++ b/src/domain/UBGraphicsProxyWidget.h
@@ -41,7 +41,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void remove();
- UBGraphicsItemDelegate* delegate (){ return mDelegate;};
+ UBGraphicsItemDelegate* delegate (){ return mDelegate;}
protected:
diff --git a/src/domain/UBGraphicsWidgetItemDelegate.cpp b/src/domain/UBGraphicsWidgetItemDelegate.cpp
index 8b45eefa..a5f45d3a 100644
--- a/src/domain/UBGraphicsWidgetItemDelegate.cpp
+++ b/src/domain/UBGraphicsWidgetItemDelegate.cpp
@@ -17,8 +17,6 @@
#include
#include "UBGraphicsWidgetItemDelegate.h"
-
-
#include "UBGraphicsScene.h"
#include "core/UBApplication.h"
diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp
index cf4f3b85..9c76cc9b 100644
--- a/src/gui/UBKeyboardPalette.cpp
+++ b/src/gui/UBKeyboardPalette.cpp
@@ -27,6 +27,9 @@
UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
: UBActionPalette(Qt::TopRightCorner, parent)
{
+
+ // setWindowFlags(/*Qt::CustomizeWindowHint|*/Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);
+
setCustomCloseProcessing(true);
setCustomPosition(true);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
@@ -56,57 +59,25 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
setContentsMargins( 22, 22, 22, 22 );
- connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool)));
+ init();
}
-QList UBKeyboardPalette::instances;
-UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent)
+//QList UBKeyboardPalette::instances;
+void UBKeyboardPalette::init()
{
- //------------------------------//
-
- if (!UBPlatformUtils::hasVirtualKeyboard())
- return NULL;
-
- //------------------------------//
-
- UBKeyboardPalette* firstKeyboard = NULL;
- // if we already have keyboards inside, get it position and show/hide status, for new keyboard
- if(instances.size() > 0)
- firstKeyboard = instances.at(0);
-
- //------------------------------//
+ m_isVisible = false;
+ setVisible(false);
- UBKeyboardPalette* instance = new UBKeyboardPalette(parent);
- instance->setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString());
+ setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString());
- instance->m_isVisible = firstKeyboard ? firstKeyboard->m_isVisible : false;
- instance->setVisible(instance->m_isVisible);
-
- if( firstKeyboard )
- instance->move(firstKeyboard->m_pos);
-
- connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteButtonSizeChanged(QVariant)));
- connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), instance, SLOT(showKeyboard(bool)));
-// connect(instance, SIGNAL(moved(const QPoint&)), instance, SLOT(syncPosition(const QPoint&)));
- connect(instance, SIGNAL(closed()), instance, SLOT(hideKeyboard()));
-
- //------------------------------//
-
- instances.append(instance);
- foreach(UBKeyboardPalette* inst, instances)
- {
- connect(inst, SIGNAL(moved(const QPoint&)), instance, SLOT(syncPosition(const QPoint&)));
- connect(instance, SIGNAL(moved(const QPoint&)), inst, SLOT(syncPosition(const QPoint&)));
-
- connect(inst, SIGNAL(localeChanged(int)), instance, SLOT(syncLocale(int)));
- connect(instance, SIGNAL(localeChanged(int)), inst, SLOT(syncLocale(int)));
-
-// connect(instance, SIGNAL(closed()), inst, )
- }
+ connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool)));
+ connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), this, SLOT(keyboardPaletteButtonSizeChanged(QVariant)));
+ connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
+ connect(this, SIGNAL(closed()), this, SLOT(hideKeyboard()));
//------------------------------//
- return instance;
+ UBPlatformUtils::setWindowNonActivableFlag(this, true);
}
void UBKeyboardPalette::showKeyboard(bool show)
diff --git a/src/gui/UBKeyboardPalette.h b/src/gui/UBKeyboardPalette.h
index 68a0a7e9..c7077fe2 100644
--- a/src/gui/UBKeyboardPalette.h
+++ b/src/gui/UBKeyboardPalette.h
@@ -67,6 +67,7 @@ friend class UBCapsLockButton;
friend class UBLocaleButton;
public:
+ UBKeyboardPalette(QWidget *parent);
~UBKeyboardPalette();
BTNImages *currBtnImages;
@@ -77,8 +78,6 @@ public:
QString getKeyButtonSize() const {QString res; res.sprintf("%dx%d", btnWidth, btnHeight); return res;}
void setKeyButtonSize(const QString& strSize);
- static UBKeyboardPalette* create(QWidget *parent);
- static QList instances;
bool m_isVisible;
QPoint m_pos;
@@ -119,10 +118,10 @@ protected:
void setLocale(int nLocale);
const QString* getLocaleName();
-
-private:
- UBKeyboardPalette(QWidget *parent);
+ void init();
+
+private:
QRect originalRect;
diff --git a/src/web/UBTrapFlashController.cpp b/src/web/UBTrapFlashController.cpp
index f88136af..bd2c4c06 100644
--- a/src/web/UBTrapFlashController.cpp
+++ b/src/web/UBTrapFlashController.cpp
@@ -73,49 +73,49 @@ void UBTrapFlashController::showTrapFlash()
, viewHeight);
connect(mTrapFlashUi->flashCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFlash(int)));
- connect(mTrapFlashUi->widgetNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(text_Changed(const QString &)));
- connect(mTrapFlashUi->widgetNameLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(text_Edited(const QString &)));
+ connect(mTrapFlashUi->widgetNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(text_Changed(const QString &)));
+ connect(mTrapFlashUi->widgetNameLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(text_Edited(const QString &)));
connect(mTrapFlashUi->createWidgetButton, SIGNAL(clicked(bool)), this, SLOT(createWidget()));
}
mTrapFlashDialog->show();
}
-void UBTrapFlashController::text_Changed(const QString &newText)
-{
- QString new_text = newText;
-
-#ifdef Q_WS_WIN // Defined on Windows.
- QString illegalCharList(" < > : \" / \\ | ? * ");
- QRegExp regExp("[<>:\"/\\\\|?*]");
-#endif
-
-#ifdef Q_WS_QWS // Defined on Qt for Embedded Linux.
- QString illegalCharList(" < > : \" / \\ | ? * ");
- QRegExp regExp("[<>:\"/\\\\|?*]");
-#endif
-
-#ifdef Q_WS_MAC // Defined on Mac OS X.
- QString illegalCharList(" < > : \" / \\ | ? * ");
- QRegExp regExp("[<>:\"/\\\\|?*]");
-#endif
-
-#ifdef Q_WS_X11 // Defined on X11.
- QString illegalCharList(" < > : \" / \\ | ? * ");
- QRegExp regExp("[<>:\"/\\\\|?*]");
-#endif
-
- if(new_text.indexOf(regExp) > -1)
- {
- new_text.remove(regExp);
- mTrapFlashUi->widgetNameLineEdit->setText(new_text);
- QToolTip::showText(mTrapFlashUi->widgetNameLineEdit->mapToGlobal(QPoint()), "Application name can`t contain any of the following characters:\r\n"+illegalCharList);
- }
+void UBTrapFlashController::text_Changed(const QString &newText)
+{
+ QString new_text = newText;
+
+#ifdef Q_WS_WIN // Defined on Windows.
+ QString illegalCharList(" < > : \" / \\ | ? * ");
+ QRegExp regExp("[<>:\"/\\\\|?*]");
+#endif
+
+#ifdef Q_WS_QWS // Defined on Qt for Embedded Linux.
+ QString illegalCharList(" < > : \" / \\ | ? * ");
+ QRegExp regExp("[<>:\"/\\\\|?*]");
+#endif
+
+#ifdef Q_WS_MAC // Defined on Mac OS X.
+ QString illegalCharList(" < > : \" / \\ | ? * ");
+ QRegExp regExp("[<>:\"/\\\\|?*]");
+#endif
+
+#ifdef Q_WS_X11 // Defined on X11.
+ QString illegalCharList(" < > : \" / \\ | ? * ");
+ QRegExp regExp("[<>:\"/\\\\|?*]");
+#endif
+
+ if(new_text.indexOf(regExp) > -1)
+ {
+ new_text.remove(regExp);
+ mTrapFlashUi->widgetNameLineEdit->setText(new_text);
+ QToolTip::showText(mTrapFlashUi->widgetNameLineEdit->mapToGlobal(QPoint()), "Application name can`t contain any of the following characters:\r\n"+illegalCharList);
+ }
}
-void UBTrapFlashController::text_Edited(const QString &newText)
-{
-
+void UBTrapFlashController::text_Edited(const QString &newText)
+{
+
}
void UBTrapFlashController::hideTrapFlash()
diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp
index 6ae2361b..26ddd181 100644
--- a/src/web/UBWebController.cpp
+++ b/src/web/UBWebController.cpp
@@ -46,6 +46,7 @@
#include "domain/UBGraphicsScene.h"
#include "desktop/UBCustomCaptureWindow.h"
+#include "board/UBBoardPaletteManager.h"
UBWebController::UBWebController(UBMainWindow* mainWindow)
@@ -55,7 +56,7 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
, mBrowserWidget(0)
, mTrapFlashController(0)
, mToolsCurrentPalette(0)
- , mKeyboardCurrentPalette(0)
+// , mKeyboardCurrentPalette(0)
, mToolsPalettePositionned(false)
, mDownloadViewIsVisible(false)
@@ -113,7 +114,7 @@ void UBWebController::webBrowserInstance()
{
mCurrentWebBrowser = &mWebBrowserList[WebBrowser];
mToolsCurrentPalette = &mToolsPaletteList[WebBrowser];
- mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser];
+// mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser];
mToolsPalettePositionned = mToolsPalettePositionnedList[WebBrowser];
if (!(*mCurrentWebBrowser))
{
@@ -191,7 +192,7 @@ void UBWebController::tutorialWebInstance()
{
mCurrentWebBrowser = &mWebBrowserList[Tutorial];
mToolsCurrentPalette = &mToolsPaletteList[Tutorial];
- mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial];
+// mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial];
mToolsPalettePositionned = &mToolsPalettePositionnedList[Tutorial];
if (!(*mCurrentWebBrowser))
{
@@ -249,7 +250,7 @@ void UBWebController::paraschoolWebInstance()
else {
mCurrentWebBrowser = &mWebBrowserList[Paraschool];
mToolsCurrentPalette = &mToolsPaletteList[Paraschool];
- mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool];
+// mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool];
mToolsPalettePositionned = &mToolsPalettePositionnedList[Paraschool];
if (!(*mCurrentWebBrowser)){
(*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow, true);
@@ -391,10 +392,11 @@ void UBWebController::setupPalettes()
{
(*mToolsCurrentPalette) = new UBWebToolsPalette((*mCurrentWebBrowser),false);
- (*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser);
+// (*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser);
#ifndef Q_WS_WIN
- if (*mKeyboardCurrentPalette)
- connect(*mKeyboardCurrentPalette, SIGNAL(closed()), *mKeyboardCurrentPalette, SLOT(onDeactivated()));
+ if (UBPlatformUtils::hasVirtualKeyboard() && UBApplication::boardController->paletteManager()->mKeyboardPalette)
+ connect(UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(closed()),
+ UBApplication::boardController->paletteManager()->mKeyboardPalette, SLOT(onDeactivated()));
#endif
connect(mMainWindow->actionWebTrapFlash, SIGNAL(triggered()), this, SLOT(trapFlash()));
@@ -411,7 +413,7 @@ void UBWebController::setupPalettes()
(*mToolsCurrentPalette)->hide();
(*mToolsCurrentPalette)->adjustSizeAndPosition();
- (*mKeyboardCurrentPalette)->adjustSizeAndPosition();
+// (*mKeyboardCurrentPalette)->adjustSizeAndPosition();
if (controlView()){
int left = controlView()->width() - 20 - (*mToolsCurrentPalette)->width();
@@ -435,15 +437,14 @@ void UBWebController::toggleWebTrap(bool checked)
}
}
-void UBWebController::showKeyboard(bool checked)
-{
- if (mKeyboardCurrentPalette
- && (*mKeyboardCurrentPalette))
- {
- (*mKeyboardCurrentPalette)->setVisible(checked);
- }
-}
-
+// void UBWebController::showKeyboard(bool checked)
+// {
+// if (mKeyboardCurrentPalette
+// && (*mKeyboardCurrentPalette))
+// {
+// (*mKeyboardCurrentPalette)->setVisible(checked);
+// }
+// }
void UBWebController::toggleWebToolsPalette(bool checked)
{
diff --git a/src/web/UBWebController.h b/src/web/UBWebController.h
index 1cb38c4c..29640cbe 100644
--- a/src/web/UBWebController.h
+++ b/src/web/UBWebController.h
@@ -28,7 +28,7 @@ class UBMainWindow;
class UBWebToolsPalette;
class WBWebView;
class UBServerXMLHttpRequest;
-class UBKeyboardPalette;
+//class UBKeyboardPalette;
class UBWebController : public QObject
@@ -58,6 +58,12 @@ class UBWebController : public QObject
void show(WebInstance type = UBWebController::WebBrowser);
+ WBBrowserWindow* GetCurrentWebBrowser()
+ {
+ if( mCurrentWebBrowser != NULL ) return *mCurrentWebBrowser;
+ else return NULL;
+ };
+
protected:
void setupPalettes();
@@ -101,8 +107,8 @@ class UBWebController : public QObject
UBTrapFlashController* mTrapFlashController;
UBWebToolsPalette** mToolsCurrentPalette;
UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances];
- UBKeyboardPalette** mKeyboardCurrentPalette;
- UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances];
+// UBKeyboardPalette** mKeyboardCurrentPalette;
+// UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances];
bool mToolsPalettePositionned;
bool mToolsPalettePositionnedList[TotalNumberOfWebInstances];
@@ -124,7 +130,7 @@ class UBWebController : public QObject
void toggleWebTrap(bool checked);
- void showKeyboard(bool checked);
+// void showKeyboard(bool checked);
signals:
/**