SANKORE-743

Now text size in TextItem is the same on separate platforms.
preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 928096459c
commit 332b5f8a88
  1. 20
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/core/UBSettings.cpp
  3. 1
      src/core/UBSettings.h
  4. 16
      src/domain/UBGraphicsTextItemDelegate.cpp
  5. 9
      src/domain/UBGraphicsTextItemDelegate.h

@ -26,6 +26,7 @@
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBAbstractWidget.h" #include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsStroke.h" #include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.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 darkBackground = false;
bool crossedBackground = false; bool crossedBackground = false;
@ -883,6 +891,15 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
UBGraphicsTextItem* textItem = textItemFromSvg(); 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) if (textItem)
{ {
textItem->setFlag(QGraphicsItem::ItemIsMovable, true); 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, "dark-background", mScene->isDarkBackground() ? xmlTrue : xmlFalse);
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "crossed-background", mScene->isCrossedBackground() ? 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.writeStartElement("rect");
mXmlWriter.writeAttribute("fill", mScene->isDarkBackground() ? "black" : "white"); mXmlWriter.writeAttribute("fill", mScene->isDarkBackground() ? "black" : "white");
mXmlWriter.writeAttribute("x", QString::number(normalized.x())); mXmlWriter.writeAttribute("x", QString::number(normalized.x()));

@ -242,6 +242,8 @@ void UBSettings::init()
pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3)); pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3));
pageDpi = new UBSetting(this, "Board", "pageDpi", 0);
QStringList penLightBackgroundColors; QStringList penLightBackgroundColors;
penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#C87400" << "#800040" << "#008080" << "#5F2D0A"; penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#C87400" << "#800040" << "#008080" << "#5F2D0A";
boardPenLightBackgroundColors = new UBColorListSetting(this, "Board", "PenLightBackgroundColors", penLightBackgroundColors, 1.0); boardPenLightBackgroundColors = new UBColorListSetting(this, "Board", "PenLightBackgroundColors", penLightBackgroundColors, 1.0);

@ -337,6 +337,7 @@ class UBSettings : public QObject
UBSetting* communityPsw; UBSetting* communityPsw;
UBSetting* pageSize; UBSetting* pageSize;
UBSetting* pageDpi;
UBSetting* KeyboardLocale; UBSetting* KeyboardLocale;
UBSetting* swapControlAndDisplayScreens; UBSetting* swapControlAndDisplayScreens;

@ -237,12 +237,12 @@ void UBGraphicsTextItemDelegate::pickColor()
void UBGraphicsTextItemDelegate::decreaseSize() void UBGraphicsTextItemDelegate::decreaseSize()
{ {
ChangeTextSize(-delta); ChangeTextSize(-delta, changeSize);
} }
void UBGraphicsTextItemDelegate::increaseSize() void UBGraphicsTextItemDelegate::increaseSize()
{ {
ChangeTextSize(delta); ChangeTextSize(delta, changeSize);
} }
UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated() UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
@ -322,9 +322,9 @@ void UBGraphicsTextItemDelegate::positionHandles()
setEditable(isEditable()); setEditable(isEditable());
} }
void UBGraphicsTextItemDelegate::ChangeTextSize(int delta) void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode changeMode)
{ {
if (0 == delta) if (0 == factor)
return; return;
QTextCursor cursor = delegated()->textCursor(); QTextCursor cursor = delegated()->textCursor();
@ -378,7 +378,7 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
//setting new parameners //setting new parameners
int iNewPointSize = iPointSize + delta; int iNewPointSize = (changeSize == changeMode) ? (iPointSize + factor) : (iPointSize * factor);
curFont.setPointSize( (iNewPointSize > 0)?iNewPointSize:1); curFont.setPointSize( (iNewPointSize > 0)?iNewPointSize:1);
textFormat.setFont(curFont); textFormat.setFont(curFont);
cursor.mergeCharFormat(textFormat); cursor.mergeCharFormat(textFormat);
@ -387,7 +387,6 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
cursor.setPosition (iCursorPos, QTextCursor::MoveAnchor); cursor.setPosition (iCursorPos, QTextCursor::MoveAnchor);
} }
//delegated()->document()->adjustSize();
delegated()->setFont(curFont); delegated()->setFont(curFont);
UBSettings::settings()->setFontPointSize(iPointSize); UBSettings::settings()->setFontPointSize(iPointSize);
//returning initial selection //returning initial selection
@ -396,3 +395,8 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
delegated()->setTextCursor(cursor); delegated()->setTextCursor(cursor);
} }
void UBGraphicsTextItemDelegate::scaleTextSize(qreal multiplyer)
{
ChangeTextSize(multiplyer, scaleSize);
}

@ -29,10 +29,17 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
{ {
Q_OBJECT Q_OBJECT
enum textChangeMode
{
changeSize = 0,
scaleSize
};
public: public:
UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent = 0); UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent = 0);
virtual ~UBGraphicsTextItemDelegate(); virtual ~UBGraphicsTextItemDelegate();
bool isEditable(); bool isEditable();
void scaleTextSize(qreal multiplyer);
public slots: public slots:
void contentsChanged(); void contentsChanged();
@ -61,7 +68,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private: private:
void customize(QFontDialog &fontDialog); void customize(QFontDialog &fontDialog);
void ChangeTextSize(int delta); void ChangeTextSize(qreal factor, textChangeMode changeMode);
QFont createDefaultFont(); QFont createDefaultFont();
QAction *mEditableAction; QAction *mEditableAction;

Loading…
Cancel
Save