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
476fc3fe
Commit
476fc3fe
authored
Nov 21, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some new UBGraphicsTextItem properties
parent
d79f36eb
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
198 additions
and
64 deletions
+198
-64
config.xml
resources/library/interactive/Barre_prof.wgt/config.xml
+8
-8
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+89
-28
UBCFFSubsetAdaptor.h
src/adaptors/UBCFFSubsetAdaptor.h
+5
-0
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+0
-1
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+2
-2
UB.h
src/core/UB.h
+3
-1
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+2
-3
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+20
-0
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-0
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+11
-12
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+51
-8
UBGraphicsTextItemDelegate.h
src/domain/UBGraphicsTextItemDelegate.h
+6
-1
No files found.
resources/library/interactive/Barre_prof.wgt/config.xml
View file @
476fc3fe
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<widget
xmlns=
"http://www.w3.org/ns/widgets"
<widget
xmlns=
"http://www.w3.org/ns/widgets"
xmlns:ub=
"http://uniboard.mnemis.com/widgets"
xmlns:ub=
"http://uniboard.mnemis.com/widgets"
id=
"http://www.example.net/widgets/helloworld"
id=
"http://www.example.net/widgets/helloworld"
version=
"1.0"
version=
"1.0"
width=
"550"
width=
"550"
height=
"325"
height=
"325"
ub:resizable=
"false"
>
ub:resizable=
"false"
>
<name>
Rich Note
</name>
<name>
Rich Note
</name>
<description>
Allows the teacher to attach a rich note to the page.
</description>
<description>
Allows the teacher to attach a rich note to the page.
</description>
<content
src=
"index.html"
/>
<content
src=
"index.html"
/>
</widget>
</widget>
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
476fc3fe
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBW3CWidget.h"
#include "domain/UBW3CWidget.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBFileSystemUtils.h"
...
@@ -440,6 +441,49 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElemen
...
@@ -440,6 +441,49 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElemen
if
(
!
element
.
attribute
(
aTransform
).
isNull
())
if
(
!
element
.
attribute
(
aTransform
).
isNull
())
fontTransform
=
transformFromString
(
element
.
attribute
(
aTransform
));
fontTransform
=
transformFromString
(
element
.
attribute
(
aTransform
));
}
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
readTextBlockAttr
(
const
QDomElement
&
element
,
QTextBlockFormat
&
format
)
{
QString
fontStretchText
=
element
.
attribute
(
aFontstretch
);
if
(
!
fontStretchText
.
isNull
())
format
.
setAlignment
(
Qt
::
AlignJustify
);
QString
align
=
element
.
attribute
(
aTextalign
);
if
(
!
align
.
isNull
())
{
if
(
align
==
"middle"
||
align
==
"center"
)
format
.
setAlignment
(
Qt
::
AlignHCenter
);
else
if
(
align
==
"start"
)
format
.
setAlignment
(
Qt
::
AlignLeft
);
else
if
(
align
==
"end"
)
format
.
setAlignment
(
Qt
::
AlignRight
);
else
if
(
align
==
"justify"
)
format
.
setAlignment
(
Qt
::
AlignJustify
);
}
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
readTextCharAttr
(
const
QDomElement
&
element
,
QTextCharFormat
&
format
)
{
QString
fontSz
=
element
.
attribute
(
aFontSize
);
if
(
!
fontSz
.
isNull
())
{
qreal
fontSize
=
fontSz
.
toDouble
()
*
72
/
QApplication
::
desktop
()
->
physicalDpiY
();
format
.
setFontPointSize
(
fontSize
);
}
QString
fontColorText
=
element
.
attribute
(
aFill
);
if
(
!
fontColorText
.
isNull
())
{
QColor
fontColor
=
colorFromString
(
fontColorText
);
if
(
fontColor
.
isValid
())
format
.
setForeground
(
fontColor
);
}
QString
fontFamilyText
=
element
.
attribute
(
aFontfamily
);
if
(
!
fontFamilyText
.
isNull
())
{
format
.
setFontFamily
(
fontFamilyText
);
}
if
(
!
element
.
attribute
(
aFontstyle
).
isNull
())
{
bool
italic
=
(
element
.
attribute
(
aFontstyle
)
==
"italic"
);
format
.
setFontItalic
(
italic
);
}
QString
weight
=
element
.
attribute
(
aFontweight
);
if
(
!
weight
.
isNull
())
{
if
(
weight
==
"normal"
)
format
.
setFontWeight
(
QFont
::
Normal
);
else
if
(
weight
==
"light"
)
format
.
setFontWeight
(
QFont
::
Light
);
else
if
(
weight
==
"demibold"
)
format
.
setFontWeight
(
QFont
::
DemiBold
);
else
if
(
weight
==
"bold"
)
format
.
setFontWeight
(
QFont
::
Bold
);
else
if
(
weight
==
"black"
)
format
.
setFontWeight
(
QFont
::
Black
);
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgText
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgText
(
const
QDomElement
&
element
)
{
{
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
...
@@ -538,53 +582,70 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
...
@@ -538,53 +582,70 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
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
();
qreal
fontSize
=
12
;
QColor
fontColor
(
qApp
->
palette
().
foreground
().
color
());
QString
fontFamily
=
"Arial"
;
// qreal fontSize = 12;
QString
fontStretch
=
"normal"
;
// QColor fontColor(qApp->palette().foreground().color());
bool
italic
=
false
;
// QString fontFamily = "Arial";
int
fontWeight
=
QFont
::
Normal
;
// QString fontStretch = "normal";
int
textAlign
=
Qt
::
AlignLeft
;
// bool italic = false;
// int fontWeight = QFont::Normal;
// int textAlign = Qt::AlignLeft;
QTransform
fontTransform
;
QTransform
fontTransform
;
parseTextAttributes
(
element
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
//
parseTextAttributes(element, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
//
QSvgGenerator *generator = createSvgGenerator(width, height);
QPainter
painter
;
//
QPainter painter;
painter
.
begin
(
generator
);
//
painter.begin(generator);
painter
.
setFont
(
QFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
));
//
painter.setFont(QFont(fontFamily, fontSize, fontWeight, italic));
qreal
curY
=
0.0
;
//
qreal curY = 0.0;
qreal
curX
=
0.0
;
//
qreal curX = 0.0;
qreal
linespacing
=
QFontMetricsF
(
painter
.
font
()).
leading
();
//
qreal linespacing = QFontMetricsF(painter.font()).leading();
// remember if text area has transform
//
//
remember if text area has transform
// QString transformString;
//
//
QString transformString;
QTransform
transform
=
fontTransform
;
QTransform
transform
=
fontTransform
;
bool
hasTransform
=
!
fontTransform
.
isIdentity
();
bool
hasTransform
=
false
;
//
!fontTransform.isIdentity();
QRectF
lastDrawnTextBoundingRect
;
//
QRectF lastDrawnTextBoundingRect;
//parse text area tags
//
//parse text area tags
//recursive call any tspan in text svg element
//
//recursive call any tspan in text svg element
parseTSpan
(
element
,
painter
//
parseTSpan(element, painter
,
curX
,
curY
,
width
,
height
,
linespacing
,
lastDrawnTextBoundingRect
//
, curX, curY, width, height, linespacing, lastDrawnTextBoundingRect
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
//
, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
painter
.
end
();
//
painter.end();
//add resulting svg file to scene
//add resulting svg file to scene
UBGraphicsSvgItem
*
svgItem
=
mCurrentScene
->
addSvg
(
QUrl
::
fromLocalFile
(
generator
->
fileName
()));
//
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
QFile
file
(
"/home/ilia/Documents/tmp/1/index.html"
);
file
.
open
(
QIODevice
::
ReadOnly
);
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
);
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
//
hashSceneItem(element, svgItem);
delete
generator
;
//
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 @
476fc3fe
...
@@ -32,6 +32,8 @@ class QTransform;
...
@@ -32,6 +32,8 @@ class QTransform;
class
QPainter
;
class
QPainter
;
class
UBGraphicsItem
;
class
UBGraphicsItem
;
class
QGraphicsItem
;
class
QGraphicsItem
;
class
QTextBlockFormat
;
class
QTextCharFormat
;
class
UBCFFSubsetAdaptor
class
UBCFFSubsetAdaptor
...
@@ -104,6 +106,9 @@ private:
...
@@ -104,6 +106,9 @@ private:
inline
void
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
inline
void
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
inline
void
parseTextAttributes
(
const
QDomElement
&
element
,
QFont
&
font
,
QColor
);
inline
void
readTextBlockAttr
(
const
QDomElement
&
element
,
QTextBlockFormat
&
format
);
inline
void
readTextCharAttr
(
const
QDomElement
&
element
,
QTextCharFormat
&
format
);
//elements parsing methods
//elements parsing methods
bool
parseDoc
();
bool
parseDoc
();
...
...
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
476fc3fe
...
@@ -76,7 +76,6 @@ QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix)
...
@@ -76,7 +76,6 @@ QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix)
.
arg
(
matrix
.
m22
(),
0
,
'g'
)
.
arg
(
matrix
.
m22
(),
0
,
'g'
)
.
arg
(
matrix
.
dx
(),
0
,
'g'
)
.
arg
(
matrix
.
dx
(),
0
,
'g'
)
.
arg
(
matrix
.
dy
(),
0
,
'g'
);
.
arg
(
matrix
.
dy
(),
0
,
'g'
);
}
}
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
476fc3fe
...
@@ -46,8 +46,8 @@ class UBSvgSubsetAdaptor
...
@@ -46,8 +46,8 @@ class UBSvgSubsetAdaptor
{
{
private
:
private
:
UBSvgSubsetAdaptor
()
{
};
UBSvgSubsetAdaptor
()
{
;}
virtual
~
UBSvgSubsetAdaptor
()
{
};
virtual
~
UBSvgSubsetAdaptor
()
{
;}
public
:
public
:
...
...
src/core/UB.h
View file @
476fc3fe
...
@@ -75,7 +75,9 @@ struct UBGraphicsItemData
...
@@ -75,7 +75,9 @@ struct UBGraphicsItemData
{
{
enum
Enum
enum
Enum
{
{
ItemLayerType
,
ItemLocked
ItemLayerType
,
ItemLocked
,
ItemEditable
//for text only
};
};
};
};
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
476fc3fe
...
@@ -165,12 +165,11 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -165,12 +165,11 @@ class UBGraphicsItemDelegate : public QObject
QList
<
DelegateButton
*>
mButtons
;
QList
<
DelegateButton
*>
mButtons
;
protected
slots
:
protected
slots
:
virtual
void
gotoContentSource
(
bool
checked
);
virtual
void
gotoContentSource
(
bool
checked
);
private
:
private
:
QPointF
mOffset
;
QPointF
mOffset
;
QTransform
mPreviousTransform
;
QTransform
mPreviousTransform
;
...
...
src/domain/UBGraphicsScene.cpp
View file @
476fc3fe
...
@@ -1311,7 +1311,27 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
...
@@ -1311,7 +1311,27 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
return
textItem
;
return
textItem
;
}
}
UBGraphicsTextItem
*
UBGraphicsScene
::
addTextHtml
(
const
QString
&
pString
)
{
UBGraphicsTextItem
*
textItem
=
new
UBGraphicsTextItem
();
textItem
->
setPlainText
(
""
);
textItem
->
setHtml
(
pString
);
addItem
(
textItem
);
textItem
->
show
();
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
textItem
);
UBApplication
::
undoStack
->
push
(
uc
);
connect
(
textItem
,
SIGNAL
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)),
this
,
SLOT
(
textUndoCommandAdded
(
UBGraphicsTextItem
*
)));
textItem
->
setSelected
(
true
);
textItem
->
setFocus
();
setDocumentUpdated
();
return
textItem
;
}
void
UBGraphicsScene
::
addItem
(
QGraphicsItem
*
item
)
void
UBGraphicsScene
::
addItem
(
QGraphicsItem
*
item
)
{
{
...
...
src/domain/UBGraphicsScene.h
View file @
476fc3fe
...
@@ -91,6 +91,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -91,6 +91,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsTextItem
*
addTextWithFont
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
=
QPointF
(
0
,
0
)
UBGraphicsTextItem
*
addTextWithFont
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
=
QPointF
(
0
,
0
)
,
int
pointSize
=
-
1
,
const
QString
&
fontFamily
=
""
,
bool
bold
=
false
,
bool
italic
=
false
);
,
int
pointSize
=
-
1
,
const
QString
&
fontFamily
=
""
,
bool
bold
=
false
,
bool
italic
=
false
);
UBGraphicsTextItem
*
addTextHtml
(
const
QString
&
pString
=
QString
());
UBGraphicsW3CWidgetItem
*
addOEmbed
(
const
QUrl
&
pContentUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsW3CWidgetItem
*
addOEmbed
(
const
QUrl
&
pContentUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
476fc3fe
...
@@ -56,8 +56,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
...
@@ -56,8 +56,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
}
}
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
...
@@ -65,11 +67,11 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
...
@@ -65,11 +67,11 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
connect
(
document
(),
SIGNAL
(
contentsChanged
()),
mDelegate
,
SLOT
(
contentsChanged
()));
connect
(
document
(),
SIGNAL
(
contentsChanged
()),
mDelegate
,
SLOT
(
contentsChanged
()));
connect
(
document
(),
SIGNAL
(
undoCommandAdded
()),
this
,
SLOT
(
undoCommandAdded
()));
connect
(
document
(),
SIGNAL
(
undoCommandAdded
()),
this
,
SLOT
(
undoCommandAdded
()));
connect
(
document
()
->
documentLayout
(),
SIGNAL
(
documentSizeChanged
(
const
QSizeF
&
)),
this
,
SLOT
(
documentSizeChanged
(
const
QSizeF
&
)));
connect
(
document
()
->
documentLayout
(),
SIGNAL
(
documentSizeChanged
(
const
QSizeF
&
)),
this
,
SLOT
(
documentSizeChanged
(
const
QSizeF
&
)));
}
}
UBGraphicsTextItem
::~
UBGraphicsTextItem
()
UBGraphicsTextItem
::~
UBGraphicsTextItem
()
{
{
if
(
mDelegate
)
if
(
mDelegate
)
...
@@ -78,7 +80,6 @@ UBGraphicsTextItem::~UBGraphicsTextItem()
...
@@ -78,7 +80,6 @@ UBGraphicsTextItem::~UBGraphicsTextItem()
}
}
}
}
QVariant
UBGraphicsTextItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
QVariant
UBGraphicsTextItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
{
if
(
QGraphicsItem
::
ItemSelectedChange
==
change
)
if
(
QGraphicsItem
::
ItemSelectedChange
==
change
)
...
@@ -106,9 +107,14 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
...
@@ -106,9 +107,14 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
return
QGraphicsTextItem
::
itemChange
(
change
,
newValue
);
return
QGraphicsTextItem
::
itemChange
(
change
,
newValue
);
}
}
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mDelegate
)
mDelegate
->
mousePressEvent
(
event
);
if
(
!
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
())
return
;
int
elapsed
=
mLastMousePressTime
.
msecsTo
(
QTime
::
currentTime
());
int
elapsed
=
mLastMousePressTime
.
msecsTo
(
QTime
::
currentTime
());
if
(
elapsed
<
UBApplication
::
app
()
->
doubleClickInterval
())
if
(
elapsed
<
UBApplication
::
app
()
->
doubleClickInterval
())
...
@@ -126,12 +132,8 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -126,12 +132,8 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if
(
mMultiClickState
==
1
)
if
(
mMultiClickState
==
1
)
{
{
if
(
mDelegate
)
// setTextInteractionFlags(Qt::TextEditorInteraction);
mDelegate
->
mousePressEvent
(
event
);
QGraphicsTextItem
::
mousePressEvent
(
event
);
QGraphicsTextItem
::
mousePressEvent
(
event
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
setFocus
();
setFocus
();
}
}
else
if
(
mMultiClickState
==
2
)
else
if
(
mMultiClickState
==
2
)
...
@@ -152,7 +154,6 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -152,7 +154,6 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
}
}
void
UBGraphicsTextItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
!
mDelegate
||
!
mDelegate
->
mouseMoveEvent
(
event
))
if
(
!
mDelegate
||
!
mDelegate
->
mouseMoveEvent
(
event
))
...
@@ -161,7 +162,6 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -161,7 +162,6 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
}
}
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mMultiClickState
==
1
)
if
(
mMultiClickState
==
1
)
...
@@ -177,7 +177,6 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
...
@@ -177,7 +177,6 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
}
}
void
UBGraphicsTextItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
UBGraphicsTextItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
{
QColor
color
=
UBSettings
::
settings
()
->
isDarkBackground
()
?
mColorOnDarkBackground
:
mColorOnLightBackground
;
QColor
color
=
UBSettings
::
settings
()
->
isDarkBackground
()
?
mColorOnDarkBackground
:
mColorOnLightBackground
;
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
476fc3fe
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "core/UBDisplayManager.h" // TODO UB 4.x clean that dependency
#include "core/UBDisplayManager.h" // TODO UB 4.x clean that dependency
#include "core/memcheck.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h"
const
int
UBGraphicsTextItemDelegate
::
sMinPixelSize
=
8
;
const
int
UBGraphicsTextItemDelegate
::
sMinPixelSize
=
8
;
...
@@ -139,16 +140,21 @@ void UBGraphicsTextItemDelegate::pickFont()
...
@@ -139,16 +140,21 @@ 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
());
delegated
()
->
setFont
(
selectedFont
);
delegated
()
->
setSelected
(
true
);
//setting format for selected item
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCharFormat
format
;
format
.
setFont
(
selectedFont
);
curCursor
.
mergeCharFormat
(
format
);
delegated
()
->
setTextCursor
(
curCursor
);
delegated
()
->
setSelected
(
true
);
delegated
()
->
document
()
->
adjustSize
();
delegated
()
->
document
()
->
adjustSize
();
delegated
()
->
contentsChanged
();
delegated
()
->
contentsChanged
();
}
}
}
}
}
}
void
UBGraphicsTextItemDelegate
::
pickColor
()
void
UBGraphicsTextItemDelegate
::
pickColor
()
{
{
if
(
mDelegated
&&
mDelegated
->
scene
()
&&
mDelegated
->
scene
()
->
views
().
size
()
>
0
)
if
(
mDelegated
&&
mDelegated
->
scene
()
&&
mDelegated
->
scene
()
->
views
().
size
()
>
0
)
...
@@ -164,8 +170,17 @@ void UBGraphicsTextItemDelegate::pickColor()
...
@@ -164,8 +170,17 @@ void UBGraphicsTextItemDelegate::pickColor()
{
{
QColor
selectedColor
=
colorDialog
.
selectedColor
();
QColor
selectedColor
=
colorDialog
.
selectedColor
();
delegated
()
->
setDefaultTextColor
(
selectedColor
);
delegated
()
->
setDefaultTextColor
(
selectedColor
);
delegated
()
->
setColorOnDarkBackground
(
selectedColor
);
// delegated()->setColorOnDarkBackground(selectedColor);
delegated
()
->
setColorOnLightBackground
(
selectedColor
);
// delegated()->setColorOnLightBackground(selectedColor);
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCharFormat
format
;
format
.
setForeground
(
QBrush
(
selectedColor
));
// format.setBackground(Qt::yellow);
curCursor
.
mergeCharFormat
(
format
);
QTextBlockFormat
blFormat
;
blFormat
.
setAlignment
(
Qt
::
AlignCenter
);
curCursor
.
setBlockFormat
(
blFormat
);
delegated
()
->
setTextCursor
(
curCursor
);
UBGraphicsTextItem
::
lastUsedTextColor
=
selectedColor
;
UBGraphicsTextItem
::
lastUsedTextColor
=
selectedColor
;
...
@@ -175,7 +190,6 @@ void UBGraphicsTextItemDelegate::pickColor()
...
@@ -175,7 +190,6 @@ void UBGraphicsTextItemDelegate::pickColor()
}
}
}
}
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
{
{
QFontInfo
fi
(
delegated
()
->
font
());
QFontInfo
fi
(
delegated
()
->
font
());
...
@@ -203,7 +217,6 @@ void UBGraphicsTextItemDelegate::decreaseSize()
...
@@ -203,7 +217,6 @@ void UBGraphicsTextItemDelegate::decreaseSize()
}
}
void
UBGraphicsTextItemDelegate
::
increaseSize
()
void
UBGraphicsTextItemDelegate
::
increaseSize
()
{
{
QFontInfo
fi
(
delegated
()
->
font
());
QFontInfo
fi
(
delegated
()
->
font
());
...
@@ -229,8 +242,38 @@ void UBGraphicsTextItemDelegate::increaseSize()
...
@@ -229,8 +242,38 @@ void UBGraphicsTextItemDelegate::increaseSize()
qDebug
()
<<
newPixelSize
;
qDebug
()
<<
newPixelSize
;
}
}
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
{
{
return
static_cast
<
UBGraphicsTextItem
*>
(
mDelegated
);
return
static_cast
<
UBGraphicsTextItem
*>
(
mDelegated
);
}
}
void
UBGraphicsTextItemDelegate
::
setEditable
(
bool
editable
)
{
if
(
editable
)
{
delegated
()
->
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
mDelegated
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
true
));
}
else
{
QTextCursor
cursor
(
delegated
()
->
document
());
cursor
.
clearSelection
();
delegated
()
->
setTextCursor
(
cursor
);
delegated
()
->
setTextInteractionFlags
(
Qt
::
NoTextInteraction
);
mDelegated
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
false
));
}
}
bool
UBGraphicsTextItemDelegate
::
isEditable
()
{
return
mDelegated
->
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
();
}
void
UBGraphicsTextItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
UBGraphicsItemDelegate
::
decorateMenu
(
menu
);
mEditableAction
=
menu
->
addAction
(
tr
(
"Editable"
),
this
,
SLOT
(
setEditable
(
bool
)));
mEditableAction
->
setCheckable
(
true
);
mEditableAction
->
setChecked
(
true
);
}
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
{
UBGraphicsItemDelegate
::
updateMenuActionState
();
}
src/domain/UBGraphicsTextItemDelegate.h
View file @
476fc3fe
...
@@ -27,17 +27,21 @@ class UBGraphicsTextItem;
...
@@ -27,17 +27,21 @@ class UBGraphicsTextItem;
class
UBGraphicsTextItemDelegate
:
public
UBGraphicsItemDelegate
class
UBGraphicsTextItemDelegate
:
public
UBGraphicsItemDelegate
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBGraphicsTextItemDelegate
(
UBGraphicsTextItem
*
pDelegated
,
QObject
*
parent
=
0
);
UBGraphicsTextItemDelegate
(
UBGraphicsTextItem
*
pDelegated
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsTextItemDelegate
();
virtual
~
UBGraphicsTextItemDelegate
();
bool
isEditable
();
public
slots
:
public
slots
:
void
contentsChanged
();
void
contentsChanged
();
virtual
void
setEditable
(
bool
);
protected
:
protected
:
virtual
void
buildButtons
();
virtual
void
buildButtons
();
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
private
:
private
:
...
@@ -54,6 +58,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
...
@@ -54,6 +58,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private
:
private
:
void
customize
(
QFontDialog
&
fontDialog
);
void
customize
(
QFontDialog
&
fontDialog
);
QAction
*
mEditableAction
;
private
slots
:
private
slots
:
...
...
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