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
8787a51d
Commit
8787a51d
authored
Dec 02, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increasing Decreasing full textItem backward capability now available
parent
8063c989
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
47 deletions
+73
-47
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+17
-11
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+5
-2
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+50
-34
UBGraphicsTextItemDelegate.h
src/domain/UBGraphicsTextItemDelegate.h
+1
-0
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
8787a51d
...
...
@@ -2304,11 +2304,18 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
//for new documents from version 4.5.0
if
(
mFileVersion
>=
40500
)
{
if
(
mXmlReader
.
name
()
==
"itemTextContent"
)
{
QString
text
=
mXmlReader
.
readElementText
();
text
=
mXmlReader
.
readElementText
();
textItem
->
setHtml
(
text
);
break
;
textItem
->
resize
(
width
,
height
);
if
(
textItem
->
toPlainText
().
isEmpty
())
{
delete
textItem
;
textItem
=
0
;
}
return
textItem
;
}
//tracking for back capability with older versions
//tracking for backward capability with older versions
}
else
if
(
mXmlReader
.
name
()
==
"font"
)
{
QFont
font
=
textItem
->
font
();
...
...
@@ -2382,15 +2389,14 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
}
}
if
(
false
)
{
if
(
text
.
isEmpty
())
{
delete
textItem
;
textItem
=
0
;
}
else
{
textItem
->
setPlainText
(
text
);
textItem
->
resize
(
width
,
height
);
}
if
(
text
.
isEmpty
())
{
delete
textItem
;
textItem
=
0
;
}
else
{
textItem
->
setPlainText
(
text
);
textItem
->
resize
(
width
,
height
);
}
textItem
->
resize
(
width
,
height
);
return
textItem
;
...
...
src/domain/UBGraphicsScene.cpp
View file @
8787a51d
...
...
@@ -150,6 +150,9 @@ UBGraphicsScene::~UBGraphicsScene()
void
UBGraphicsScene
::
selectionChangedProcessing
()
{
if
(
selectedItems
().
count
())
UBApplication
::
showMessage
(
"ZValue is "
+
QString
::
number
(
selectedItems
().
first
()
->
zValue
(),
'f'
));
QList
<
QGraphicsItem
*>
allItemsList
=
items
();
for
(
int
i
=
0
;
i
<
allItemsList
.
size
();
i
++
)
{
...
...
@@ -1263,7 +1266,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
textItem
->
setPlainText
(
pString
);
textItem
->
setZValue
(
getNextObjectZIndex
());
QFont
font
;
QFont
font
=
textItem
->
font
()
;
if
(
fontFamily
==
""
)
{
...
...
@@ -1280,7 +1283,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
}
else
{
font
.
setP
ixel
Size
(
pointSize
);
font
.
setP
oint
Size
(
pointSize
);
}
font
.
setBold
(
bold
);
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
8787a51d
...
...
@@ -30,6 +30,7 @@
#include "board/UBBoardController.h"
const
int
UBGraphicsTextItemDelegate
::
sMinPixelSize
=
8
;
const
int
UBGraphicsTextItemDelegate
::
sMinPointSize
=
8
;
UBGraphicsTextItemDelegate
::
UBGraphicsTextItemDelegate
(
UBGraphicsTextItem
*
pDelegated
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
0
,
parent
,
true
)
...
...
@@ -46,23 +47,11 @@ UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDele
format
.
setFont
(
font
);
curCursor
.
mergeCharFormat
(
format
);
delegated
()
->
setTextCursor
(
curCursor
);
delegated
()
->
setFont
(
font
);
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
}
...
...
@@ -71,7 +60,6 @@ UBGraphicsTextItemDelegate::~UBGraphicsTextItemDelegate()
// NOOP
}
QFont
UBGraphicsTextItemDelegate
::
createDefaultFont
()
{
QTextCharFormat
textFormat
;
...
...
@@ -89,10 +77,15 @@ QFont UBGraphicsTextItemDelegate::createDefaultFont()
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
);
// int pixSize = UBSettings::settings()->fontPixelSize();
// if (pixSize > 0) {
// mLastFontPixelSize = pixSize;
// font.setPixelSize(pixSize);
// }
int
pointSize
=
UBSettings
::
settings
()
->
fontPointSize
();
if
(
pointSize
>
0
)
{
// mLastFontPixelSize = pointSize;
font
.
setPointSize
(
pointSize
);
}
return
font
;
...
...
@@ -115,7 +108,6 @@ void UBGraphicsTextItemDelegate::buildButtons()
mButtons
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
}
void
UBGraphicsTextItemDelegate
::
contentsChanged
()
{
positionHandles
();
...
...
@@ -128,8 +120,7 @@ void UBGraphicsTextItemDelegate::customize(QFontDialog &fontDialog)
{
fontDialog
.
setOption
(
QFontDialog
::
DontUseNativeDialog
);
if
(
UBSettings
::
settings
()
->
isDarkBackground
())
{
if
(
UBSettings
::
settings
()
->
isDarkBackground
())
{
fontDialog
.
setStyleSheet
(
"background-color: white;"
);
}
...
...
@@ -171,7 +162,6 @@ void UBGraphicsTextItemDelegate::customize(QFontDialog &fontDialog)
}
}
}
QList
<
QComboBox
*>
comboBoxes
=
fontDialog
.
findChildren
<
QComboBox
*>
();
if
(
comboBoxes
.
count
()
>
0
)
comboBoxes
.
at
(
0
)
->
setEnabled
(
false
);
...
...
@@ -189,9 +179,6 @@ void UBGraphicsTextItemDelegate::pickFont()
{
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
());
UBSettings
::
settings
()
->
setFontPointSize
(
selectedFont
.
pointSize
());
...
...
@@ -201,8 +188,9 @@ void UBGraphicsTextItemDelegate::pickFont()
QTextCharFormat
format
;
format
.
setFont
(
selectedFont
);
curCursor
.
mergeCharFormat
(
format
);
delegated
()
->
setTextCursor
(
curCursor
);
delegated
()
->
setTextCursor
(
curCursor
);
delegated
()
->
setFont
(
selectedFont
);
delegated
()
->
setSelected
(
true
);
delegated
()
->
document
()
->
adjustSize
();
delegated
()
->
contentsChanged
();
...
...
@@ -243,6 +231,15 @@ void UBGraphicsTextItemDelegate::pickColor()
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
{
QTextCursor
cursor
=
delegated
()
->
textCursor
();
QTextCharFormat
textFormat
;
QFont
curFont
=
cursor
.
charFormat
().
font
();
int
pointSize
=
curFont
.
pointSize
();
pointSize
-=
5
;
// QFontInfo fi(delegated()->font());
// int pixelSize = fi.pixelSize();
// if (-1 == mLastFontPixelSize)
...
...
@@ -265,11 +262,28 @@ void UBGraphicsTextItemDelegate::decreaseSize()
// delegated()->document()->adjustSize();
// delegated()->contentsChanged();dddd
// }
curFont
.
setPointSize
(
pointSize
);
textFormat
.
setFont
(
curFont
);
cursor
.
mergeCharFormat
(
textFormat
);
delegated
()
->
setTextCursor
(
cursor
);
UBSettings
::
settings
()
->
setFontPixelSize
(
curFont
.
pixelSize
());
UBSettings
::
settings
()
->
setFontPointSize
(
pointSize
);
delegated
()
->
document
()
->
adjustSize
();
delegated
()
->
setFont
(
curFont
);
}
void
UBGraphicsTextItemDelegate
::
increaseSize
()
{
// QFontInfo fi(delegated()->font());
QTextCursor
cursor
=
delegated
()
->
textCursor
();
QTextCharFormat
textFormat
;
QFont
curFont
=
cursor
.
charFormat
().
font
();
int
pointSize
=
curFont
.
pointSize
();
pointSize
+=
5
;
// QFontInfo fi(cursor.charFormat().font());
// int pixelSize = fi.pixelSize();
// if (-1 == mLastFontPixelSize)
// mLastFontPixelSize = pixelSize;
...
...
@@ -281,16 +295,18 @@ void UBGraphicsTextItemDelegate::increaseSize()
// if (pixelSize < mLastFontPixelSize && mLastFontPixelSize < newPixelSize)
// newPixelSize = mLastFontPixelSize;
// QFont font = delegated()->font();
// font.setPixelSize(newPixelSize);
// delegated()->setFont(font);
// UBSettings::settings()->setFontPixelSize(newPixelSize);
// delegated()->document()->adjustSize();
// delegated()->contentsChanged();
curFont
.
setPointSize
(
pointSize
);
textFormat
.
setFont
(
curFont
);
cursor
.
mergeCharFormat
(
textFormat
);
delegated
()
->
setTextCursor
(
cursor
);
// UBSettings::settings()->setFontPixelSize(curFont.pixelSize());
UBSettings
::
settings
()
->
setFontPointSize
(
pointSize
);
// qDebug() << newPixelSize;
delegated
()
->
document
()
->
adjustSize
();
delegated
()
->
setFont
(
curFont
);
// delegated()->contentsChanged();
}
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
...
...
src/domain/UBGraphicsTextItemDelegate.h
View file @
8787a51d
...
...
@@ -57,6 +57,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
int
mLastFontPixelSize
;
static
const
int
sMinPixelSize
;
static
const
int
sMinPointSize
;
private
:
void
customize
(
QFontDialog
&
fontDialog
);
...
...
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