Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
f13cceb4
Commit
f13cceb4
authored
Nov 28, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CFF is about to be done
parent
c7cbce30
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
271 additions
and
180 deletions
+271
-180
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+56
-52
UBCFFSubsetAdaptor.h
src/adaptors/UBCFFSubsetAdaptor.h
+3
-0
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+72
-62
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+2
-2
UBSetting.h
src/core/UBSetting.h
+2
-2
UBSettings.cpp
src/core/UBSettings.cpp
+9
-2
UBSettings.h
src/core/UBSettings.h
+2
-0
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+3
-2
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+4
-2
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+14
-14
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+100
-41
UBGraphicsTextItemDelegate.h
src/domain/UBGraphicsTextItemDelegate.h
+3
-0
UBGraphicsVideoItemDelegate.h
src/domain/UBGraphicsVideoItemDelegate.h
+1
-1
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
f13cceb4
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include <QDomDocument>
#include <QDomDocument>
#include "core/memcheck.h"
#include "core/memcheck.h"
#include "qtlogger.h"
//tag names definition. Use them everiwhere!
//tag names definition. Use them everiwhere!
static
QString
tElement
=
"element"
;
static
QString
tElement
=
"element"
;
...
@@ -548,7 +549,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
...
@@ -548,7 +549,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
QDomNode
curNode
=
parent
.
firstChild
();
QDomNode
curNode
=
parent
.
firstChild
();
while
(
!
curNode
.
isNull
())
{
while
(
!
curNode
.
isNull
())
{
if
(
curNode
.
toElement
().
tagName
()
==
tTspan
)
{
if
(
curNode
.
toElement
().
tagName
()
==
tTspan
)
{
QDomElement
curTSpan
=
curNode
.
toElement
();
QDomElement
curTSpan
=
curNode
.
toElement
();
parseTextAttributes
(
curTSpan
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
parseTextAttributes
(
curTSpan
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
,
fontWeight
,
textAlign
,
fontTransform
);
...
@@ -579,73 +579,77 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
...
@@ -579,73 +579,77 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
curNode
=
curNode
.
nextSibling
();
curNode
=
curNode
.
nextSibling
();
}
}
}
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseTSpan
(
const
QDomElement
&
element
,
QTextCursor
&
cursor
,
QTextBlockFormat
&
blockFormat
,
QTextCharFormat
&
charFormat
)
{
QDomNode
curNode
=
element
.
firstChild
();
while
(
!
curNode
.
isNull
())
{
if
(
curNode
.
toElement
().
tagName
()
==
tTspan
)
{
QDomElement
curTspan
=
curNode
.
toElement
();
readTextBlockAttr
(
curTspan
,
blockFormat
);
readTextCharAttr
(
curTspan
,
charFormat
);
cursor
.
setBlockFormat
(
blockFormat
);
cursor
.
setCharFormat
(
charFormat
);
parseTSpan
(
curTspan
,
cursor
,
blockFormat
,
charFormat
);
}
else
if
(
curNode
.
nodeType
()
==
QDomNode
::
CharacterDataNode
||
curNode
.
nodeType
()
==
QDomNode
::
CDATASectionNode
||
curNode
.
nodeType
()
==
QDomNode
::
TextNode
)
{
QDomCharacterData
textData
=
curNode
.
toCharacterData
();
QString
text
=
textData
.
data
().
trimmed
();
cursor
.
insertText
(
text
,
charFormat
);
}
else
if
(
curNode
.
nodeType
()
==
QDomNode
::
ElementNode
&&
curNode
.
toElement
().
tagName
()
==
tBreak
)
{
cursor
.
insertBlock
();
}
curNode
=
curNode
.
nextSibling
();
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgTextarea
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgTextarea
(
const
QDomElement
&
element
)
{
{
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
qreal
y
=
element
.
attribute
(
aY
).
toDouble
();
qreal
y
=
element
.
attribute
(
aY
).
toDouble
();
qreal
width
=
element
.
attribute
(
aWidth
).
toDouble
();
qreal
width
=
element
.
attribute
(
aWidth
).
toDouble
();
qreal
height
=
element
.
attribute
(
aHeight
).
toDouble
();
qreal
height
=
element
.
attribute
(
aHeight
).
toDouble
();
QTextBlockFormat
blockFormat
;
blockFormat
.
setAlignment
(
Qt
::
AlignLeft
);
QTextCharFormat
textFormat
;
textFormat
.
setFontPointSize
(
12
*
72
/
QApplication
::
desktop
()
->
physicalDpiY
());
textFormat
.
setForeground
(
qApp
->
palette
().
foreground
().
color
());
textFormat
.
setFontFamily
(
"Arial"
);
textFormat
.
setFontItalic
(
false
);
textFormat
.
setFontWeight
(
QFont
::
Normal
);
// qreal fontSize = 12;
readTextBlockAttr
(
element
,
blockFormat
);
// QColor fontColor(qApp->palette().foreground().color());
readTextCharAttr
(
element
,
textFormat
);
// 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);
// QSvgGenerator *generator = createSvgGenerator(width, height);
// QPainter painter;
// painter.begin(generator);
// painter.setFont(QFont(fontFamily, fontSize, fontWeight, italic));
QTextDocument
doc
;
doc
.
setPlainText
(
""
);
QTextCursor
tCursor
(
&
doc
);
tCursor
.
setBlockFormat
(
blockFormat
);
tCursor
.
setCharFormat
(
textFormat
);
// qreal curY = 0.0;
parseTSpan
(
element
,
tCursor
,
blockFormat
,
textFormat
);
// qreal curX = 0.0;
// qreal linespacing = QFontMetricsF(painter.font()).leading();
//// remember if text area has transform
//// QString transformString;
QTransform
transform
=
fontTransform
;
bool
hasTransform
=
false
;
//!fontTransform.isIdentity();
// QRectF lastDrawnTextBoundingRect
;
UBGraphicsTextItem
*
svgItem
=
mCurrentScene
->
addTextHtml
(
doc
.
toHtml
())
;
// //parse text area tags
svgItem
->
resize
(
width
,
height
);
// //recursive call any tspan in text svg element
QTransform
transform
;
// parseTSpan(element, painter
QString
textTransform
=
element
.
attribute
(
aTransform
);
// , curX, curY, width, height, linespacing, lastDrawnTextBoundingRect
bool
hastransform
=
false
;
// , fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
if
(
!
textTransform
.
isNull
())
{
transform
=
transformFromString
(
textTransform
);
// painter.end();
hastransform
=
true
;
}
//add resulting svg file to scene
// UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
QFile
file
(
"/home/ilia/Documents/tmp/1/index.html"
);
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hastransform
,
transform
);
file
.
open
(
QIODevice
::
ReadOnly
);
hashSceneItem
(
element
,
svgItem
);
QByteArray
barr
=
file
.
readAll
();
file
.
close
();
QString
str
(
barr
);
UBGraphicsTextItem
*
svgItem
=
mCurrentScene
->
addTextHtml
(
str
);
svgItem
->
resize
(
width
*
mVBTransFactor
,
height
*
mVBTransFactor
);
// QTextCursor cursor;
// cursor.insertBlock();
// cursor.insertText("way away");
// cursor.insertBlock();
// cursor.insertText("for the right");
// svgItem->setTextCursor(cursor);
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
// hashSceneItem(element, svgItem);
// delete generator;
return
true
;
return
true
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgImage
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgImage
(
const
QDomElement
&
element
)
...
...
src/adaptors/UBCFFSubsetAdaptor.h
View file @
f13cceb4
...
@@ -34,6 +34,7 @@ class UBGraphicsItem;
...
@@ -34,6 +34,7 @@ class UBGraphicsItem;
class
QGraphicsItem
;
class
QGraphicsItem
;
class
QTextBlockFormat
;
class
QTextBlockFormat
;
class
QTextCharFormat
;
class
QTextCharFormat
;
class
QTextCursor
;
class
UBCFFSubsetAdaptor
class
UBCFFSubsetAdaptor
...
@@ -100,6 +101,8 @@ private:
...
@@ -100,6 +101,8 @@ private:
,
qreal
&
curX
,
qreal
&
curY
,
qreal
&
width
,
qreal
&
height
,
qreal
&
linespacing
,
QRectF
&
lastDrawnTextBoundingRect
,
qreal
&
curX
,
qreal
&
curY
,
qreal
&
width
,
qreal
&
height
,
qreal
&
linespacing
,
QRectF
&
lastDrawnTextBoundingRect
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
,
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
inline
void
parseTSpan
(
const
QDomElement
&
element
,
QTextCursor
&
cursor
,
QTextBlockFormat
&
blockFormat
,
QTextCharFormat
&
charFormat
);
inline
void
hashSceneItem
(
const
QDomElement
&
element
,
UBGraphicsItem
*
item
);
inline
void
hashSceneItem
(
const
QDomElement
&
element
,
UBGraphicsItem
*
item
);
// to kill
// to kill
...
...
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
f13cceb4
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
#include "pdf/PDFRenderer.h"
#include "pdf/PDFRenderer.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
#include "qtlogger.h"
const
QString
UBSvgSubsetAdaptor
::
nsSvg
=
"http://www.w3.org/2000/svg"
;
const
QString
UBSvgSubsetAdaptor
::
nsSvg
=
"http://www.w3.org/2000/svg"
;
const
QString
UBSvgSubsetAdaptor
::
nsXHtml
=
"http://www.w3.org/1999/xhtml"
;
const
QString
UBSvgSubsetAdaptor
::
nsXHtml
=
"http://www.w3.org/1999/xhtml"
;
...
@@ -2216,6 +2217,14 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it
...
@@ -2216,6 +2217,14 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"fill-on-light-background"
,
colorLightBg
.
name
());
,
"fill-on-light-background"
,
colorLightBg
.
name
());
//for new documents from version 4.5.0
if
(
true
)
{
mXmlWriter
.
writeStartElement
(
"itemTextContent"
);
mXmlWriter
.
writeCDATA
(
item
->
toHtml
());
mXmlWriter
.
writeEndElement
();
//itemTextContent
//tracking for back capability with older versions
}
else
if
(
false
)
{
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"body"
);
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"body"
);
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"div"
);
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"div"
);
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"font"
);
mXmlWriter
.
writeStartElement
(
nsXHtml
,
"font"
);
...
@@ -2246,8 +2255,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it
...
@@ -2246,8 +2255,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it
mXmlWriter
.
writeEndElement
();
//font
mXmlWriter
.
writeEndElement
();
//font
mXmlWriter
.
writeEndElement
();
//div
mXmlWriter
.
writeEndElement
();
//div
mXmlWriter
.
writeEndElement
();
//body
mXmlWriter
.
writeEndElement
();
//body
}
mXmlWriter
.
writeEndElement
();
//foreignObject
mXmlWriter
.
writeEndElement
();
//foreignObject
QtLogger
::
start
(
"/home/ilia/Documents/tmp/10/log.log"
);
QtLogger
::
appendl
(
item
->
toHtml
());
QtLogger
::
finish
();
}
}
UBGraphicsTextItem
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
textItemFromSvg
()
UBGraphicsTextItem
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
textItemFromSvg
()
...
@@ -2275,39 +2289,41 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2275,39 +2289,41 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
mXmlReader
.
readNext
();
mXmlReader
.
readNext
();
if
(
mXmlReader
.
isStartElement
())
if
(
mXmlReader
.
isStartElement
())
{
{
if
(
mXmlReader
.
name
()
==
"font"
)
//for new documents from version 4.5.0
{
if
(
true
)
{
if
(
mXmlReader
.
name
()
==
"itemTextContent"
)
{
QString
text
=
mXmlReader
.
readElementText
();
// QtLogger::start("/home/ilia/Documents/tmp/10/log.log");
// QtLogger::appendl(text);
// QtLogger::finish();
// textItem->setPlainText("");
textItem
->
setHtml
(
text
);
break
;
}
//tracking for back capability with older versions
}
else
if
(
mXmlReader
.
name
()
==
"font"
)
{
QFont
font
=
textItem
->
font
();
QFont
font
=
textItem
->
font
();
QStringRef
fontFamily
=
mXmlReader
.
attributes
().
value
(
"face"
);
QStringRef
fontFamily
=
mXmlReader
.
attributes
().
value
(
"face"
);
if
(
!
fontFamily
.
isNull
())
if
(
!
fontFamily
.
isNull
())
{
{
font
.
setFamily
(
fontFamily
.
toString
());
font
.
setFamily
(
fontFamily
.
toString
());
}
}
QStringRef
fontStyle
=
mXmlReader
.
attributes
().
value
(
"style"
);
QStringRef
fontStyle
=
mXmlReader
.
attributes
().
value
(
"style"
);
if
(
!
fontStyle
.
isNull
())
if
(
!
fontStyle
.
isNull
())
{
{
foreach
(
QString
styleToken
,
fontStyle
.
toString
().
split
(
";"
))
{
foreach
(
QString
styleToken
,
fontStyle
.
toString
().
split
(
";"
))
{
styleToken
=
styleToken
.
trimmed
();
styleToken
=
styleToken
.
trimmed
();
if
(
styleToken
.
startsWith
(
sFontSizePrefix
)
&&
styleToken
.
endsWith
(
sPixelUnit
))
if
(
styleToken
.
startsWith
(
sFontSizePrefix
)
&&
styleToken
.
endsWith
(
sPixelUnit
))
{
{
int
fontSize
=
styleToken
.
mid
(
int
fontSize
=
styleToken
.
mid
(
sFontSizePrefix
.
length
(),
sFontSizePrefix
.
length
(),
styleToken
.
length
()
-
sFontSizePrefix
.
length
()
-
sPixelUnit
.
length
()).
toInt
();
styleToken
.
length
()
-
sFontSizePrefix
.
length
()
-
sPixelUnit
.
length
()).
toInt
();
font
.
setPixelSize
(
fontSize
);
font
.
setPixelSize
(
fontSize
);
}
}
else
if
(
styleToken
.
startsWith
(
sFontWeightPrefix
))
{
else
if
(
styleToken
.
startsWith
(
sFontWeightPrefix
))
{
QString
fontWeight
=
styleToken
.
mid
(
QString
fontWeight
=
styleToken
.
mid
(
sFontWeightPrefix
.
length
(),
sFontWeightPrefix
.
length
(),
styleToken
.
length
()
-
sFontWeightPrefix
.
length
());
styleToken
.
length
()
-
sFontWeightPrefix
.
length
());
font
.
setBold
(
fontWeight
.
contains
(
"bold"
));
font
.
setBold
(
fontWeight
.
contains
(
"bold"
));
}
}
else
if
(
styleToken
.
startsWith
(
sFontStylePrefix
))
{
else
if
(
styleToken
.
startsWith
(
sFontStylePrefix
))
{
QString
fontStyle
=
styleToken
.
mid
(
QString
fontStyle
=
styleToken
.
mid
(
sFontStylePrefix
.
length
(),
sFontStylePrefix
.
length
(),
styleToken
.
length
()
-
sFontStylePrefix
.
length
());
styleToken
.
length
()
-
sFontStylePrefix
.
length
());
...
@@ -2319,15 +2335,13 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2319,15 +2335,13 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
textItem
->
setFont
(
font
);
textItem
->
setFont
(
font
);
QStringRef
fill
=
mXmlReader
.
attributes
().
value
(
"color"
);
QStringRef
fill
=
mXmlReader
.
attributes
().
value
(
"color"
);
if
(
!
fill
.
isNull
())
if
(
!
fill
.
isNull
())
{
{
QColor
textColor
;
QColor
textColor
;
textColor
.
setNamedColor
(
fill
.
toString
());
textColor
.
setNamedColor
(
fill
.
toString
());
textItem
->
setDefaultTextColor
(
textColor
);
textItem
->
setDefaultTextColor
(
textColor
);
}
}
if
(
!
ubFillOnDarkBackground
.
isNull
())
if
(
!
ubFillOnDarkBackground
.
isNull
())
{
{
QColor
color
;
QColor
color
;
color
.
setNamedColor
(
ubFillOnDarkBackground
.
toString
());
color
.
setNamedColor
(
ubFillOnDarkBackground
.
toString
());
if
(
!
color
.
isValid
())
if
(
!
color
.
isValid
())
...
@@ -2335,8 +2349,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2335,8 +2349,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
textItem
->
setColorOnDarkBackground
(
color
);
textItem
->
setColorOnDarkBackground
(
color
);
}
}
if
(
!
ubFillOnLightBackground
.
isNull
())
if
(
!
ubFillOnLightBackground
.
isNull
())
{
{
QColor
color
;
QColor
color
;
color
.
setNamedColor
(
ubFillOnLightBackground
.
toString
());
color
.
setNamedColor
(
ubFillOnLightBackground
.
toString
());
if
(
!
color
.
isValid
())
if
(
!
color
.
isValid
())
...
@@ -2344,20 +2357,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2344,20 +2357,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
textItem
->
setColorOnLightBackground
(
color
);
textItem
->
setColorOnLightBackground
(
color
);
}
}
while
(
!
(
mXmlReader
.
isEndElement
()
&&
mXmlReader
.
name
()
==
"font"
))
while
(
!
(
mXmlReader
.
isEndElement
()
&&
mXmlReader
.
name
()
==
"font"
))
{
{
if
(
mXmlReader
.
hasError
())
{
if
(
mXmlReader
.
hasError
())
{
break
;
break
;
}
}
QXmlStreamReader
::
TokenType
tt
=
mXmlReader
.
readNext
();
QXmlStreamReader
::
TokenType
tt
=
mXmlReader
.
readNext
();
if
(
tt
==
QXmlStreamReader
::
Characters
)
if
(
tt
==
QXmlStreamReader
::
Characters
)
{
{
text
+=
mXmlReader
.
text
().
toString
();
text
+=
mXmlReader
.
text
().
toString
();
}
}
if
(
mXmlReader
.
isStartElement
()
&&
mXmlReader
.
name
()
==
"br"
)
if
(
mXmlReader
.
isStartElement
()
&&
mXmlReader
.
name
()
==
"br"
)
{
{
text
+=
"
\n
"
;
text
+=
"
\n
"
;
}
}
}
}
...
@@ -2365,16 +2374,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2365,16 +2374,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
}
}
}
}
if
(
text
.
isEmpty
())
if
(
false
)
{
{
if
(
text
.
isEmpty
())
{
delete
textItem
;
delete
textItem
;
textItem
=
0
;
textItem
=
0
;
}
}
else
{
else
{
textItem
->
setPlainText
(
text
);
textItem
->
setPlainText
(
text
);
textItem
->
resize
(
width
,
height
);
textItem
->
resize
(
width
,
height
);
}
}
}
textItem
->
resize
(
width
,
height
);
return
textItem
;
return
textItem
;
}
}
...
@@ -2412,6 +2421,7 @@ UBGraphicsCurtainItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::curtainItemFromSvg
...
@@ -2412,6 +2421,7 @@ UBGraphicsCurtainItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::curtainItemFromSvg
QRectF
rect
=
curtainItem
->
rect
();
QRectF
rect
=
curtainItem
->
rect
();
rect
.
setWidth
(
svgWidth
.
toString
().
toFloat
());
rect
.
setWidth
(
svgWidth
.
toString
().
toFloat
());
rect
.
setHeight
(
svgHeight
.
toString
().
toFloat
());
rect
.
setHeight
(
svgHeight
.
toString
().
toFloat
());
rect
.
translate
(
-
rect
.
center
());
curtainItem
->
setRect
(
rect
);
curtainItem
->
setRect
(
rect
);
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
f13cceb4
...
@@ -92,7 +92,7 @@ class UBSvgSubsetAdaptor
...
@@ -92,7 +92,7 @@ class UBSvgSubsetAdaptor
UBSvgSubsetReader
(
UBDocumentProxy
*
proxy
,
const
QByteArray
&
pXmlData
);
UBSvgSubsetReader
(
UBDocumentProxy
*
proxy
,
const
QByteArray
&
pXmlData
);
virtual
~
UBSvgSubsetReader
(){}
;
virtual
~
UBSvgSubsetReader
(){}
UBGraphicsScene
*
loadScene
();
UBGraphicsScene
*
loadScene
();
...
@@ -155,7 +155,7 @@ class UBSvgSubsetAdaptor
...
@@ -155,7 +155,7 @@ class UBSvgSubsetAdaptor
bool
persistScene
();
bool
persistScene
();
virtual
~
UBSvgSubsetWriter
(){}
;
virtual
~
UBSvgSubsetWriter
(){}
private
:
private
:
...
...
src/core/UBSetting.h
View file @
f13cceb4
...
@@ -22,7 +22,7 @@ class UBSettings;
...
@@ -22,7 +22,7 @@ class UBSettings;
class
UBSetting
:
public
QObject
class
UBSetting
:
public
QObject
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBSetting
(
UBSettings
*
parent
=
0
);
UBSetting
(
UBSettings
*
parent
=
0
);
...
@@ -71,7 +71,7 @@ class UBSetting : public QObject
...
@@ -71,7 +71,7 @@ class UBSetting : public QObject
class
UBColorListSetting
:
public
UBSetting
class
UBColorListSetting
:
public
UBSetting
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBColorListSetting
(
UBSettings
*
parent
=
0
);
UBColorListSetting
(
UBSettings
*
parent
=
0
);
...
...
src/core/UBSettings.cpp
View file @
f13cceb4
...
@@ -112,8 +112,6 @@ void UBSettings::destroy()
...
@@ -112,8 +112,6 @@ void UBSettings::destroy()
}
}
QSettings
*
UBSettings
::
getAppSettings
()
QSettings
*
UBSettings
::
getAppSettings
()
{
{
if
(
!
UBSettings
::
sAppSettings
)
if
(
!
UBSettings
::
sAppSettings
)
...
@@ -689,6 +687,15 @@ void UBSettings::setFontPixelSize(int pixelSize)
...
@@ -689,6 +687,15 @@ void UBSettings::setFontPixelSize(int pixelSize)
setValue
(
"Board/FontPixelSize"
,
pixelSize
);
setValue
(
"Board/FontPixelSize"
,
pixelSize
);
}
}
int
UBSettings
::
fontPointSize
()
{
return
value
(
"Board/FontPointSize"
,
12
).
toInt
();
}
void
UBSettings
::
setFontPointSize
(
int
pointSize
)
{
setValue
(
"Board/FontPointSize"
,
pointSize
);
}
bool
UBSettings
::
isBoldFont
()
bool
UBSettings
::
isBoldFont
()
{
{
...
...
src/core/UBSettings.h
View file @
f13cceb4
...
@@ -75,6 +75,8 @@ class UBSettings : public QObject
...
@@ -75,6 +75,8 @@ class UBSettings : public QObject
void
setFontFamily
(
const
QString
&
family
);
void
setFontFamily
(
const
QString
&
family
);
int
fontPixelSize
();
int
fontPixelSize
();
void
setFontPixelSize
(
int
pixelSize
);
void
setFontPixelSize
(
int
pixelSize
);
int
fontPointSize
();
void
setFontPointSize
(
int
pointSize
);
bool
isBoldFont
();
bool
isBoldFont
();
void
setBoldFont
(
bool
bold
);
void
setBoldFont
(
bool
bold
);
bool
isItalicFont
();
bool
isItalicFont
();
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
f13cceb4
...
@@ -163,8 +163,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -163,8 +163,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
qDebug
()
<<
mDelegated
->
zValue
();
qDebug
()
<<
mDelegated
->
zValue
();
qDebug
()
<<
scene
->
currentObjectZIndex
();
qDebug
()
<<
scene
->
currentObjectZIndex
();
if
(
mDelegated
->
zValue
()
<
scene
->
currentObjectZIndex
()
&&
!
isLocked
())
// To investigate. Z value behavior
mDelegated
->
setZValue
(
scene
->
getNextObjectZIndex
());
// if (mDelegated->zValue() < scene->currentObjectZIndex() && !isLocked())
// mDelegated->setZValue(scene->getNextObjectZIndex());
positionHandles
();
positionHandles
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
f13cceb4
...
@@ -1316,6 +1316,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString)
...
@@ -1316,6 +1316,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString)
UBGraphicsTextItem
*
textItem
=
new
UBGraphicsTextItem
();
UBGraphicsTextItem
*
textItem
=
new
UBGraphicsTextItem
();
textItem
->
setPlainText
(
""
);
textItem
->
setPlainText
(
""
);
textItem
->
setHtml
(
pString
);
textItem
->
setHtml
(
pString
);
textItem
->
setZValue
(
getNextObjectZIndex
());
addItem
(
textItem
);
addItem
(
textItem
);
textItem
->
show
();
textItem
->
show
();
...
@@ -1323,9 +1324,10 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString)
...
@@ -1323,9 +1324,10 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString)
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
textItem
);
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
textItem
);
UBApplication
::
undoStack
->
push
(
uc
);
UBApplication
::
undoStack
->
push
(
uc
);
connect
(
textItem
,
SIGNAL
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)),
this
,
SLOT
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)));
connect
(
textItem
,
SIGNAL
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)),
this
,
SLOT
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)));
textItem
->
setSelected
(
true
);
//
textItem->setSelected(true);
textItem
->
setFocus
();
textItem
->
setFocus
();
setDocumentUpdated
();
setDocumentUpdated
();
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
f13cceb4
...
@@ -40,20 +40,20 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
...
@@ -40,20 +40,20 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
mTypeTextHereLabel
=
tr
(
"<Type Text Here>"
);
mTypeTextHereLabel
=
tr
(
"<Type Text Here>"
);
if
(
lastUsedTextColor
.
isValid
())
//
if (lastUsedTextColor.isValid())
{
//
{
setDefaultTextColor
(
lastUsedTextColor
);
//
setDefaultTextColor(lastUsedTextColor);
setColorOnDarkBackground
(
lastUsedTextColor
);
//
setColorOnDarkBackground(lastUsedTextColor);
setColorOnLightBackground
(
lastUsedTextColor
);
//
setColorOnLightBackground(lastUsedTextColor);
}
//
}
else
//
else
{
//
{
QColor
colorOnDarkBG
=
UBApplication
::
boardController
->
penColorOnDarkBackground
();
//
QColor colorOnDarkBG = UBApplication::boardController->penColorOnDarkBackground();
QColor
colorOnLightBG
=
UBApplication
::
boardController
->
penColorOnLightBackground
();
//
QColor colorOnLightBG = UBApplication::boardController->penColorOnLightBackground();
setColorOnDarkBackground
(
colorOnDarkBG
);
//
setColorOnDarkBackground(colorOnDarkBG);
setColorOnLightBackground
(
colorOnLightBG
);
//
setColorOnLightBackground(colorOnLightBG);
}
//
}
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
f13cceb4
...
@@ -35,6 +35,33 @@ UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDele
...
@@ -35,6 +35,33 @@ UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDele
:
UBGraphicsItemDelegate
(
pDelegated
,
0
,
parent
,
true
)
:
UBGraphicsItemDelegate
(
pDelegated
,
0
,
parent
,
true
)
,
mLastFontPixelSize
(
-
1
)
,
mLastFontPixelSize
(
-
1
)
{
{
delegated
()
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
true
));
delegated
()
->
setPlainText
(
""
);
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCharFormat
format
;
QFont
font
(
createDefaultFont
());
font
.
setPointSize
(
UBSettings
::
settings
()
->
fontPointSize
());
format
.
setFont
(
font
);
curCursor
.
mergeCharFormat
(
format
);
delegated
()
->
setTextCursor
(
curCursor
);
delegated
()
->
adjustSize
();
delegated
()
->
contentsChanged
();
// QTextCursor defcursor(createDefaultCursor());
// defcursor.movePosition(QTextCursor::Start);
// delegated()->setTextCursor(defcursor);
// QFont selectedFont = fontDialog.selectedFont();
// UBSettings::settings()->setFontFamily(selectedFont.family());
// QFontInfo fi(selectedFont);
// mLastFontPixelSize = fi.pixelSize();
// UBSettings::settings()->setFontPixelSize(mLastFontPixelSize);
// UBSettings::settings()->setBoldFont(selectedFont.bold());
// UBSettings::settings()->setItalicFont(selectedFont.italic());
// NOOP
// NOOP
}
}
...
@@ -44,6 +71,32 @@ UBGraphicsTextItemDelegate::~UBGraphicsTextItemDelegate()
...
@@ -44,6 +71,32 @@ UBGraphicsTextItemDelegate::~UBGraphicsTextItemDelegate()
}
}
QFont
UBGraphicsTextItemDelegate
::
createDefaultFont
()
{
QTextCharFormat
textFormat
;
QString
fFamily
=
UBSettings
::
settings
()
->
fontFamily
();
if
(
!
fFamily
.
isEmpty
())
textFormat
.
setFontFamily
(
fFamily
);
bool
bold
=
UBSettings
::
settings
()
->
isBoldFont
();
if
(
bold
)
textFormat
.
setFontWeight
(
QFont
::
Bold
);
bool
italic
=
UBSettings
::
settings
()
->
isItalicFont
();
if
(
italic
)
textFormat
.
setFontItalic
(
true
);
QFont
font
(
fFamily
,
-
1
,
bold
?
QFont
::
Bold
:
-
1
,
italic
);
int
pixSize
=
UBSettings
::
settings
()
->
fontPixelSize
();
if
(
pixSize
>
0
)
{
mLastFontPixelSize
=
pixSize
;
font
.
setPixelSize
(
pixSize
);
}
return
font
;
}
void
UBGraphicsTextItemDelegate
::
buildButtons
()
void
UBGraphicsTextItemDelegate
::
buildButtons
()
{
{
UBGraphicsItemDelegate
::
buildButtons
();
UBGraphicsItemDelegate
::
buildButtons
();
...
@@ -128,7 +181,7 @@ void UBGraphicsTextItemDelegate::pickFont()
...
@@ -128,7 +181,7 @@ void UBGraphicsTextItemDelegate::pickFont()
{
{
if
(
mDelegated
&&
mDelegated
->
scene
()
&&
mDelegated
->
scene
()
->
views
().
size
()
>
0
)
if
(
mDelegated
&&
mDelegated
->
scene
()
&&
mDelegated
->
scene
()
->
views
().
size
()
>
0
)
{
{
QFontDialog
fontDialog
(
delegated
()
->
font
(),
mDelegated
->
scene
()
->
views
().
at
(
0
));
QFontDialog
fontDialog
(
delegated
()
->
textCursor
().
charFormat
().
font
(),
mDelegated
->
scene
()
->
views
().
at
(
0
));
customize
(
fontDialog
);
customize
(
fontDialog
);
if
(
fontDialog
.
exec
())
if
(
fontDialog
.
exec
())
...
@@ -140,6 +193,7 @@ void UBGraphicsTextItemDelegate::pickFont()
...
@@ -140,6 +193,7 @@ void UBGraphicsTextItemDelegate::pickFont()
UBSettings
::
settings
()
->
setFontPixelSize
(
mLastFontPixelSize
);
UBSettings
::
settings
()
->
setFontPixelSize
(
mLastFontPixelSize
);
UBSettings
::
settings
()
->
setBoldFont
(
selectedFont
.
bold
());
UBSettings
::
settings
()
->
setBoldFont
(
selectedFont
.
bold
());
UBSettings
::
settings
()
->
setItalicFont
(
selectedFont
.
italic
());
UBSettings
::
settings
()
->
setItalicFont
(
selectedFont
.
italic
());
UBSettings
::
settings
()
->
setFontPointSize
(
selectedFont
.
pointSize
());
//setting format for selected item
//setting format for selected item
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
...
@@ -192,54 +246,54 @@ void UBGraphicsTextItemDelegate::pickColor()
...
@@ -192,54 +246,54 @@ void UBGraphicsTextItemDelegate::pickColor()
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
{
{
QFontInfo
fi
(
delegated
()
->
font
());
// QFontInfo fi(delegated()->font());
int
pixelSize
=
fi
.
pixelSize
();
// int pixelSize = fi.pixelSize();
if
(
-
1
==
mLastFontPixelSize
)
// if (-1 == mLastFontPixelSize)
mLastFontPixelSize
=
pixelSize
;
// mLastFontPixelSize = pixelSize;
int
newPixelSize
=
sMinPixelSize
;
// int newPixelSize = sMinPixelSize;
while
(
newPixelSize
*
1.5
<
pixelSize
)
// while (newPixelSize * 1.5 < pixelSize)
newPixelSize
*=
1.5
;
// newPixelSize *= 1.5;
if
(
newPixelSize
<
mLastFontPixelSize
&&
mLastFontPixelSize
<
pixelSize
)
// if (newPixelSize < mLastFontPixelSize && mLastFontPixelSize < pixelSize)
newPixelSize
=
mLastFontPixelSize
;
// newPixelSize = mLastFontPixelSize;
if
(
pixelSize
>
newPixelSize
)
// if (pixelSize > newPixelSize)
{
// {
QFont
font
=
delegated
()
->
font
();
// QFont font = delegated()->font();
font
.
setPixelSize
(
newPixelSize
);
// font.setPixelSize(newPixelSize);
delegated
()
->
setFont
(
font
);
// delegated()->setFont(font);
UBSettings
::
settings
()
->
setFontPixelSize
(
newPixelSize
);
// UBSettings::settings()->setFontPixelSize(newPixelSize);
delegated
()
->
document
()
->
adjustSize
();
// delegated()->document()->adjustSize();
delegated
()
->
contentsChanged
();
// delegated()->contentsChanged();dddd
}
// }
}
}
void
UBGraphicsTextItemDelegate
::
increaseSize
()
void
UBGraphicsTextItemDelegate
::
increaseSize
()
{
{
QFontInfo
fi
(
delegated
()
->
font
());
//
QFontInfo fi(delegated()->font());
int
pixelSize
=
fi
.
pixelSize
();
//
int pixelSize = fi.pixelSize();
if
(
-
1
==
mLastFontPixelSize
)
//
if (-1 == mLastFontPixelSize)
mLastFontPixelSize
=
pixelSize
;
//
mLastFontPixelSize = pixelSize;
int
newPixelSize
=
sMinPixelSize
;
//
int newPixelSize = sMinPixelSize;
while
(
newPixelSize
<=
pixelSize
)
//
while (newPixelSize <= pixelSize)
newPixelSize
*=
1.5
;
//
newPixelSize *= 1.5;
if
(
pixelSize
<
mLastFontPixelSize
&&
mLastFontPixelSize
<
newPixelSize
)
//
if (pixelSize < mLastFontPixelSize && mLastFontPixelSize < newPixelSize)
newPixelSize
=
mLastFontPixelSize
;
//
newPixelSize = mLastFontPixelSize;
QFont
font
=
delegated
()
->
font
();
//
QFont font = delegated()->font();
font
.
setPixelSize
(
newPixelSize
);
//
font.setPixelSize(newPixelSize);
delegated
()
->
setFont
(
font
);
//
delegated()->setFont(font);
UBSettings
::
settings
()
->
setFontPixelSize
(
newPixelSize
);
//
UBSettings::settings()->setFontPixelSize(newPixelSize);
delegated
()
->
document
()
->
adjustSize
();
//
delegated()->document()->adjustSize();
delegated
()
->
contentsChanged
();
//
delegated()->contentsChanged();
qDebug
()
<<
newPixelSize
;
// qDebug() << newPixelSize;
delegated
()
->
document
()
->
adjustSize
();
}
}
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
...
@@ -270,10 +324,15 @@ void UBGraphicsTextItemDelegate::decorateMenu(QMenu *menu)
...
@@ -270,10 +324,15 @@ void UBGraphicsTextItemDelegate::decorateMenu(QMenu *menu)
mEditableAction
=
menu
->
addAction
(
tr
(
"Editable"
),
this
,
SLOT
(
setEditable
(
bool
)));
mEditableAction
=
menu
->
addAction
(
tr
(
"Editable"
),
this
,
SLOT
(
setEditable
(
bool
)));
mEditableAction
->
setCheckable
(
true
);
mEditableAction
->
setCheckable
(
true
);
mEditableAction
->
setChecked
(
true
);
mEditableAction
->
setChecked
(
isEditable
()
);
}
}
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
{
{
UBGraphicsItemDelegate
::
updateMenuActionState
();
UBGraphicsItemDelegate
::
updateMenuActionState
();
}
}
void
UBGraphicsTextItemDelegate
::
positionHandles
()
{
UBGraphicsItemDelegate
::
positionHandles
();
setEditable
(
isEditable
());
}
src/domain/UBGraphicsTextItemDelegate.h
View file @
f13cceb4
...
@@ -43,6 +43,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
...
@@ -43,6 +43,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
virtual
void
updateMenuActionState
();
virtual
void
positionHandles
();
private
:
private
:
UBGraphicsTextItem
*
delegated
();
UBGraphicsTextItem
*
delegated
();
...
@@ -58,6 +60,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
...
@@ -58,6 +60,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private
:
private
:
void
customize
(
QFontDialog
&
fontDialog
);
void
customize
(
QFontDialog
&
fontDialog
);
QFont
createDefaultFont
();
QAction
*
mEditableAction
;
QAction
*
mEditableAction
;
private
slots
:
private
slots
:
...
...
src/domain/UBGraphicsVideoItemDelegate.h
View file @
f13cceb4
...
@@ -68,7 +68,7 @@ class DelegateVideoControl: public QGraphicsRectItem
...
@@ -68,7 +68,7 @@ class DelegateVideoControl: public QGraphicsRectItem
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment