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/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()));

@ -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";

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

@ -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);
}

@ -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;

Loading…
Cancel
Save