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
332b5f8a
Commit
332b5f8a
authored
Jul 13, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-743
Now text size in TextItem is the same on separate platforms.
parent
92809645
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
7 deletions
+41
-7
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+20
-0
UBSettings.cpp
src/core/UBSettings.cpp
+2
-0
UBSettings.h
src/core/UBSettings.h
+1
-0
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+10
-6
UBGraphicsTextItemDelegate.h
src/domain/UBGraphicsTextItemDelegate.h
+8
-1
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
332b5f8a
...
...
@@ -26,6 +26,7 @@
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.h"
...
...
@@ -454,6 +455,13 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
}
QStringRef
pageDpi
=
mXmlReader
.
attributes
().
value
(
"pageDpi"
);
if
(
!
pageDpi
.
isNull
())
{
UBSettings
::
settings
()
->
pageDpi
->
set
(
pageDpi
.
toString
());
}
bool
darkBackground
=
false
;
bool
crossedBackground
=
false
;
...
...
@@ -883,6 +891,15 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
UBGraphicsTextItem
*
textItem
=
textItemFromSvg
();
UBGraphicsTextItemDelegate
*
textDelegate
=
dynamic_cast
<
UBGraphicsTextItemDelegate
*>
(
textItem
->
Delegate
());
if
(
textDelegate
)
{
QDesktopWidget
*
desktop
=
UBApplication
::
desktop
();
qreal
currentDpi
=
(
desktop
->
physicalDpiX
()
+
desktop
->
physicalDpiY
())
/
2
;
qreal
textSizeMultiplier
=
UBSettings
::
settings
()
->
pageDpi
->
get
().
toReal
()
/
currentDpi
;
textDelegate
->
scaleTextSize
(
textSizeMultiplier
);
}
if
(
textItem
)
{
textItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
...
...
@@ -1104,6 +1121,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"dark-background"
,
mScene
->
isDarkBackground
()
?
xmlTrue
:
xmlFalse
);
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"crossed-background"
,
mScene
->
isCrossedBackground
()
?
xmlTrue
:
xmlFalse
);
QDesktopWidget
*
desktop
=
UBApplication
::
desktop
();
mXmlWriter
.
writeAttribute
(
"pageDpi"
,
QString
(
"%1"
).
arg
((
desktop
->
physicalDpiX
()
+
desktop
->
physicalDpiY
())
/
2
));
mXmlWriter
.
writeStartElement
(
"rect"
);
mXmlWriter
.
writeAttribute
(
"fill"
,
mScene
->
isDarkBackground
()
?
"black"
:
"white"
);
mXmlWriter
.
writeAttribute
(
"x"
,
QString
::
number
(
normalized
.
x
()));
...
...
src/core/UBSettings.cpp
View file @
332b5f8a
...
...
@@ -241,6 +241,8 @@ void UBSettings::init()
ValidateKeyboardPaletteKeyBtnSize
();
pageSize
=
new
UBSetting
(
this
,
"Board"
,
"DefaultPageSize"
,
documentSizes
.
value
(
DocumentSizeRatio
::
Ratio4_3
));
pageDpi
=
new
UBSetting
(
this
,
"Board"
,
"pageDpi"
,
0
);
QStringList
penLightBackgroundColors
;
penLightBackgroundColors
<<
"#000000"
<<
"#FF0000"
<<
"#004080"
<<
"#008000"
<<
"#C87400"
<<
"#800040"
<<
"#008080"
<<
"#5F2D0A"
;
...
...
src/core/UBSettings.h
View file @
332b5f8a
...
...
@@ -337,6 +337,7 @@ class UBSettings : public QObject
UBSetting
*
communityPsw
;
UBSetting
*
pageSize
;
UBSetting
*
pageDpi
;
UBSetting
*
KeyboardLocale
;
UBSetting
*
swapControlAndDisplayScreens
;
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
332b5f8a
...
...
@@ -237,12 +237,12 @@ void UBGraphicsTextItemDelegate::pickColor()
void
UBGraphicsTextItemDelegate
::
decreaseSize
()
{
ChangeTextSize
(
-
delta
);
ChangeTextSize
(
-
delta
,
changeSize
);
}
void
UBGraphicsTextItemDelegate
::
increaseSize
()
{
ChangeTextSize
(
delta
);
ChangeTextSize
(
delta
,
changeSize
);
}
UBGraphicsTextItem
*
UBGraphicsTextItemDelegate
::
delegated
()
...
...
@@ -322,9 +322,9 @@ void UBGraphicsTextItemDelegate::positionHandles()
setEditable
(
isEditable
());
}
void
UBGraphicsTextItemDelegate
::
ChangeTextSize
(
int
delta
)
void
UBGraphicsTextItemDelegate
::
ChangeTextSize
(
qreal
factor
,
textChangeMode
changeMode
)
{
if
(
0
==
delta
)
if
(
0
==
factor
)
return
;
QTextCursor
cursor
=
delegated
()
->
textCursor
();
...
...
@@ -378,7 +378,7 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
//setting new parameners
int
iNewPointSize
=
iPointSize
+
delta
;
int
iNewPointSize
=
(
changeSize
==
changeMode
)
?
(
iPointSize
+
factor
)
:
(
iPointSize
*
factor
)
;
curFont
.
setPointSize
(
(
iNewPointSize
>
0
)
?
iNewPointSize
:
1
);
textFormat
.
setFont
(
curFont
);
cursor
.
mergeCharFormat
(
textFormat
);
...
...
@@ -387,7 +387,6 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
cursor
.
setPosition
(
iCursorPos
,
QTextCursor
::
MoveAnchor
);
}
//delegated()->document()->adjustSize();
delegated
()
->
setFont
(
curFont
);
UBSettings
::
settings
()
->
setFontPointSize
(
iPointSize
);
//returning initial selection
...
...
@@ -396,3 +395,8 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
delegated
()
->
setTextCursor
(
cursor
);
}
void
UBGraphicsTextItemDelegate
::
scaleTextSize
(
qreal
multiplyer
)
{
ChangeTextSize
(
multiplyer
,
scaleSize
);
}
\ No newline at end of file
src/domain/UBGraphicsTextItemDelegate.h
View file @
332b5f8a
...
...
@@ -29,10 +29,17 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
{
Q_OBJECT
enum
textChangeMode
{
changeSize
=
0
,
scaleSize
};
public
:
UBGraphicsTextItemDelegate
(
UBGraphicsTextItem
*
pDelegated
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsTextItemDelegate
();
bool
isEditable
();
void
scaleTextSize
(
qreal
multiplyer
);
public
slots
:
void
contentsChanged
();
...
...
@@ -61,7 +68,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private
:
void
customize
(
QFontDialog
&
fontDialog
);
void
ChangeTextSize
(
int
delta
);
void
ChangeTextSize
(
qreal
factor
,
textChangeMode
changeMode
);
QFont
createDefaultFont
();
QAction
*
mEditableAction
;
...
...
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