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
5458a273
Commit
5458a273
authored
Nov 22, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Sankore/Sankore-3.1
parents
61b6decd
5fbb43d4
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 @
5458a273
<?xml version="1.0" encoding="UTF-8"?>
<widget
xmlns=
"http://www.w3.org/ns/widgets"
xmlns:ub=
"http://uniboard.mnemis.com/widgets"
id=
"http://www.example.net/widgets/helloworld"
<widget
xmlns=
"http://www.w3.org/ns/widgets"
xmlns:ub=
"http://uniboard.mnemis.com/widgets"
id=
"http://www.example.net/widgets/helloworld"
version=
"1.0"
width=
"550"
height=
"325"
ub:resizable=
"false"
>
<name>
Rich Note
</name>
<description>
Allows the teacher to attach a rich note to the page.
</description>
<content
src=
"index.html"
/>
ub:resizable=
"false"
>
<name>
Rich Note
</name>
<description>
Allows the teacher to attach a rich note to the page.
</description>
<content
src=
"index.html"
/>
</widget>
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
5458a273
...
...
@@ -27,6 +27,7 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBW3CWidget.h"
#include "frameworks/UBFileSystemUtils.h"
...
...
@@ -440,6 +441,49 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElemen
if
(
!
element
.
attribute
(
aTransform
).
isNull
())
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
)
{
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
...
...
@@ -538,53 +582,70 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgTextarea
(
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
();
qreal
fontSize
=
12
;
QColor
fontColor
(
qApp
->
palette
().
foreground
().
color
());
QString
fontFamily
=
"Arial"
;
QString
fontStretch
=
"normal"
;
bool
italic
=
false
;
int
fontWeight
=
QFont
::
Normal
;
int
textAlign
=
Qt
::
AlignLeft
;
// qreal fontSize = 12;
// QColor fontColor(qApp->palette().foreground().color());
// 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
);
//
parseTextAttributes(element, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
QPainter
painter
;
painter
.
begin
(
generator
);
//
QSvgGenerator *generator = createSvgGenerator(width, height);
//
QPainter painter;
//
painter.begin(generator);
painter
.
setFont
(
QFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
));
//
painter.setFont(QFont(fontFamily, fontSize, fontWeight, italic));
qreal
curY
=
0.0
;
qreal
curX
=
0.0
;
qreal
linespacing
=
QFontMetricsF
(
painter
.
font
()).
leading
();
//
qreal curY = 0.0;
//
qreal curX = 0.0;
//
qreal linespacing = QFontMetricsF(painter.font()).leading();
// remember if text area has transform
// QString transformString;
//
//
remember if text area has transform
//
//
QString transformString;
QTransform
transform
=
fontTransform
;
bool
hasTransform
=
!
fontTransform
.
isIdentity
();
bool
hasTransform
=
false
;
//
!fontTransform.isIdentity();
QRectF
lastDrawnTextBoundingRect
;
//parse text area tags
//
QRectF lastDrawnTextBoundingRect;
//
//parse text area tags
//recursive call any tspan in text svg element
parseTSpan
(
element
,
painter
,
curX
,
curY
,
width
,
height
,
linespacing
,
lastDrawnTextBoundingRect
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
//
//recursive call any tspan in text svg element
//
parseTSpan(element, painter
//
, curX, curY, width, height, linespacing, lastDrawnTextBoundingRect
//
, fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
painter
.
end
();
//
painter.end();
//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
);
hashSceneItem
(
element
,
svgItem
);
//
hashSceneItem(element, svgItem);
delete
generator
;
//
delete generator;
return
true
;
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgImage
(
const
QDomElement
&
element
)
...
...
src/adaptors/UBCFFSubsetAdaptor.h
View file @
5458a273
...
...
@@ -32,6 +32,8 @@ class QTransform;
class
QPainter
;
class
UBGraphicsItem
;
class
QGraphicsItem
;
class
QTextBlockFormat
;
class
QTextCharFormat
;
class
UBCFFSubsetAdaptor
...
...
@@ -104,6 +106,9 @@ private:
inline
void
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
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
bool
parseDoc
();
...
...
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
5458a273
...
...
@@ -76,7 +76,6 @@ QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix)
.
arg
(
matrix
.
m22
(),
0
,
'g'
)
.
arg
(
matrix
.
dx
(),
0
,
'g'
)
.
arg
(
matrix
.
dy
(),
0
,
'g'
);
}
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
5458a273
...
...
@@ -46,8 +46,8 @@ class UBSvgSubsetAdaptor
{
private
:
UBSvgSubsetAdaptor
()
{
};
virtual
~
UBSvgSubsetAdaptor
()
{
};
UBSvgSubsetAdaptor
()
{
;}
virtual
~
UBSvgSubsetAdaptor
()
{
;}
public
:
...
...
src/core/UB.h
View file @
5458a273
...
...
@@ -75,7 +75,9 @@ struct UBGraphicsItemData
{
enum
Enum
{
ItemLayerType
,
ItemLocked
ItemLayerType
,
ItemLocked
,
ItemEditable
//for text only
};
};
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
5458a273
...
...
@@ -165,12 +165,11 @@ class UBGraphicsItemDelegate : public QObject
QList
<
DelegateButton
*>
mButtons
;
protected
slots
:
protected
slots
:
virtual
void
gotoContentSource
(
bool
checked
);
private
:
private
:
QPointF
mOffset
;
QTransform
mPreviousTransform
;
...
...
src/domain/UBGraphicsScene.cpp
View file @
5458a273
...
...
@@ -1311,7 +1311,27 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
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
)
{
...
...
src/domain/UBGraphicsScene.h
View file @
5458a273
...
...
@@ -91,6 +91,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsTextItem
*
addTextWithFont
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
=
QPointF
(
0
,
0
)
,
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
));
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
5458a273
...
...
@@ -56,8 +56,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
}
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
...
...
@@ -65,11 +67,11 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
connect
(
document
(),
SIGNAL
(
contentsChanged
()),
mDelegate
,
SLOT
(
contentsChanged
()));
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
()
{
if
(
mDelegate
)
...
...
@@ -78,7 +80,6 @@ UBGraphicsTextItem::~UBGraphicsTextItem()
}
}
QVariant
UBGraphicsTextItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
if
(
QGraphicsItem
::
ItemSelectedChange
==
change
)
...
...
@@ -106,9 +107,14 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
return
QGraphicsTextItem
::
itemChange
(
change
,
newValue
);
}
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mDelegate
)
mDelegate
->
mousePressEvent
(
event
);
if
(
!
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
())
return
;
int
elapsed
=
mLastMousePressTime
.
msecsTo
(
QTime
::
currentTime
());
if
(
elapsed
<
UBApplication
::
app
()
->
doubleClickInterval
())
...
...
@@ -126,12 +132,8 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if
(
mMultiClickState
==
1
)
{
if
(
mDelegate
)
mDelegate
->
mousePressEvent
(
event
);
// setTextInteractionFlags(Qt::TextEditorInteraction);
QGraphicsTextItem
::
mousePressEvent
(
event
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
setFocus
();
}
else
if
(
mMultiClickState
==
2
)
...
...
@@ -152,7 +154,6 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
void
UBGraphicsTextItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
!
mDelegate
||
!
mDelegate
->
mouseMoveEvent
(
event
))
...
...
@@ -161,7 +162,6 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mMultiClickState
==
1
)
...
...
@@ -177,7 +177,6 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
void
UBGraphicsTextItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
QColor
color
=
UBSettings
::
settings
()
->
isDarkBackground
()
?
mColorOnDarkBackground
:
mColorOnLightBackground
;
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
5458a273
...
...
@@ -27,6 +27,7 @@
#include "core/UBDisplayManager.h" // TODO UB 4.x clean that dependency
#include "core/memcheck.h"
#include "board/UBBoardController.h"
const
int
UBGraphicsTextItemDelegate
::
sMinPixelSize
=
8
;
...
...
@@ -139,16 +140,21 @@ void UBGraphicsTextItemDelegate::pickFont()
UBSettings
::
settings
()
->
setFontPixelSize
(
mLastFontPixelSize
);
UBSettings
::
settings
()
->
setBoldFont
(
selectedFont
.
bold
());
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
()
->
contentsChanged
();
}
}
}
void
UBGraphicsTextItemDelegate
::
pickColor
()
{
if
(
mDelegated
&&
mDelegated
->
scene
()
&&
mDelegated
->
scene
()
->
views
().
size
()
>
0
)
...
...
@@ -164,8 +170,17 @@ void UBGraphicsTextItemDelegate::pickColor()
{
QColor
selectedColor
=
colorDialog
.
selectedColor
();
delegated
()
->
setDefaultTextColor
(
selectedColor
);
delegated
()
->
setColorOnDarkBackground
(
selectedColor
);
delegated
()
->
setColorOnLightBackground
(
selectedColor
);
// delegated()->setColorOnDarkBackground(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
;
...
...
@@ -175,7 +190,6 @@ void UBGraphicsTextItemDelegate::pickColor()
}
}
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
{
QFontInfo
fi
(
delegated
()
->
font
());
...
...
@@ -203,7 +217,6 @@ void UBGraphicsTextItemDelegate::decreaseSize()
}
void
UBGraphicsTextItemDelegate
::
increaseSize
()
{
QFontInfo
fi
(
delegated
()
->
font
());
...
...
@@ -229,8 +242,38 @@ void UBGraphicsTextItemDelegate::increaseSize()
qDebug
()
<<
newPixelSize
;
}
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
{
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 @
5458a273
...
...
@@ -27,17 +27,21 @@ class UBGraphicsTextItem;
class
UBGraphicsTextItemDelegate
:
public
UBGraphicsItemDelegate
{
Q_OBJECT
;
Q_OBJECT
public
:
UBGraphicsTextItemDelegate
(
UBGraphicsTextItem
*
pDelegated
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsTextItemDelegate
();
bool
isEditable
();
public
slots
:
void
contentsChanged
();
virtual
void
setEditable
(
bool
);
protected
:
virtual
void
buildButtons
();
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
private
:
...
...
@@ -54,6 +58,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private
:
void
customize
(
QFontDialog
&
fontDialog
);
QAction
*
mEditableAction
;
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