|
|
@ -30,6 +30,7 @@ |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
|
|
|
|
|
|
|
|
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8; |
|
|
|
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8; |
|
|
|
|
|
|
|
const int UBGraphicsTextItemDelegate::sMinPointSize = 8; |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent) |
|
|
|
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent) |
|
|
|
: UBGraphicsItemDelegate(pDelegated,0, parent, true) |
|
|
|
: UBGraphicsItemDelegate(pDelegated,0, parent, true) |
|
|
@ -46,23 +47,11 @@ UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDele |
|
|
|
format.setFont(font); |
|
|
|
format.setFont(font); |
|
|
|
curCursor.mergeCharFormat(format); |
|
|
|
curCursor.mergeCharFormat(format); |
|
|
|
delegated()->setTextCursor(curCursor); |
|
|
|
delegated()->setTextCursor(curCursor); |
|
|
|
|
|
|
|
delegated()->setFont(font); |
|
|
|
|
|
|
|
|
|
|
|
delegated()->adjustSize(); |
|
|
|
delegated()->adjustSize(); |
|
|
|
delegated()->contentsChanged(); |
|
|
|
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
|
|
|
|
// NOOP
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -71,7 +60,6 @@ UBGraphicsTextItemDelegate::~UBGraphicsTextItemDelegate() |
|
|
|
// NOOP
|
|
|
|
// NOOP
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFont UBGraphicsTextItemDelegate::createDefaultFont() |
|
|
|
QFont UBGraphicsTextItemDelegate::createDefaultFont() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QTextCharFormat textFormat; |
|
|
|
QTextCharFormat textFormat; |
|
|
@ -89,10 +77,15 @@ QFont UBGraphicsTextItemDelegate::createDefaultFont() |
|
|
|
textFormat.setFontItalic(true); |
|
|
|
textFormat.setFontItalic(true); |
|
|
|
|
|
|
|
|
|
|
|
QFont font(fFamily, -1, bold ? QFont::Bold : -1, italic); |
|
|
|
QFont font(fFamily, -1, bold ? QFont::Bold : -1, italic); |
|
|
|
int pixSize = UBSettings::settings()->fontPixelSize(); |
|
|
|
// int pixSize = UBSettings::settings()->fontPixelSize();
|
|
|
|
if (pixSize > 0) { |
|
|
|
// if (pixSize > 0) {
|
|
|
|
mLastFontPixelSize = pixSize; |
|
|
|
// mLastFontPixelSize = pixSize;
|
|
|
|
font.setPixelSize(pixSize); |
|
|
|
// font.setPixelSize(pixSize);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
int pointSize = UBSettings::settings()->fontPointSize(); |
|
|
|
|
|
|
|
if (pointSize > 0) { |
|
|
|
|
|
|
|
// mLastFontPixelSize = pointSize;
|
|
|
|
|
|
|
|
font.setPointSize(pointSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return font; |
|
|
|
return font; |
|
|
@ -115,7 +108,6 @@ void UBGraphicsTextItemDelegate::buildButtons() |
|
|
|
mButtons << mFontButton << mColorButton << mDecreaseSizeButton << mIncreaseSizeButton; |
|
|
|
mButtons << mFontButton << mColorButton << mDecreaseSizeButton << mIncreaseSizeButton; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsTextItemDelegate::contentsChanged() |
|
|
|
void UBGraphicsTextItemDelegate::contentsChanged() |
|
|
|
{ |
|
|
|
{ |
|
|
|
positionHandles(); |
|
|
|
positionHandles(); |
|
|
@ -128,8 +120,7 @@ void UBGraphicsTextItemDelegate::customize(QFontDialog &fontDialog) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fontDialog.setOption(QFontDialog::DontUseNativeDialog); |
|
|
|
fontDialog.setOption(QFontDialog::DontUseNativeDialog); |
|
|
|
|
|
|
|
|
|
|
|
if (UBSettings::settings()->isDarkBackground()) |
|
|
|
if (UBSettings::settings()->isDarkBackground()) { |
|
|
|
{ |
|
|
|
|
|
|
|
fontDialog.setStyleSheet("background-color: white;"); |
|
|
|
fontDialog.setStyleSheet("background-color: white;"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -171,7 +162,6 @@ void UBGraphicsTextItemDelegate::customize(QFontDialog &fontDialog) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QList<QComboBox*> comboBoxes = fontDialog.findChildren<QComboBox*>(); |
|
|
|
QList<QComboBox*> comboBoxes = fontDialog.findChildren<QComboBox*>(); |
|
|
|
if (comboBoxes.count() > 0) |
|
|
|
if (comboBoxes.count() > 0) |
|
|
|
comboBoxes.at(0)->setEnabled(false); |
|
|
|
comboBoxes.at(0)->setEnabled(false); |
|
|
@ -189,9 +179,6 @@ void UBGraphicsTextItemDelegate::pickFont() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFont selectedFont = fontDialog.selectedFont(); |
|
|
|
QFont selectedFont = fontDialog.selectedFont(); |
|
|
|
UBSettings::settings()->setFontFamily(selectedFont.family()); |
|
|
|
UBSettings::settings()->setFontFamily(selectedFont.family()); |
|
|
|
QFontInfo fi(selectedFont); |
|
|
|
|
|
|
|
mLastFontPixelSize = fi.pixelSize(); |
|
|
|
|
|
|
|
UBSettings::settings()->setFontPixelSize(mLastFontPixelSize); |
|
|
|
|
|
|
|
UBSettings::settings()->setBoldFont(selectedFont.bold()); |
|
|
|
UBSettings::settings()->setBoldFont(selectedFont.bold()); |
|
|
|
UBSettings::settings()->setItalicFont(selectedFont.italic()); |
|
|
|
UBSettings::settings()->setItalicFont(selectedFont.italic()); |
|
|
|
UBSettings::settings()->setFontPointSize(selectedFont.pointSize()); |
|
|
|
UBSettings::settings()->setFontPointSize(selectedFont.pointSize()); |
|
|
@ -201,8 +188,9 @@ void UBGraphicsTextItemDelegate::pickFont() |
|
|
|
QTextCharFormat format; |
|
|
|
QTextCharFormat format; |
|
|
|
format.setFont(selectedFont); |
|
|
|
format.setFont(selectedFont); |
|
|
|
curCursor.mergeCharFormat(format); |
|
|
|
curCursor.mergeCharFormat(format); |
|
|
|
delegated()->setTextCursor(curCursor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delegated()->setTextCursor(curCursor); |
|
|
|
|
|
|
|
delegated()->setFont(selectedFont); |
|
|
|
delegated()->setSelected(true); |
|
|
|
delegated()->setSelected(true); |
|
|
|
delegated()->document()->adjustSize(); |
|
|
|
delegated()->document()->adjustSize(); |
|
|
|
delegated()->contentsChanged(); |
|
|
|
delegated()->contentsChanged(); |
|
|
@ -243,6 +231,15 @@ void UBGraphicsTextItemDelegate::pickColor() |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsTextItemDelegate::decreaseSize() |
|
|
|
void UBGraphicsTextItemDelegate::decreaseSize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QTextCursor cursor = delegated()->textCursor(); |
|
|
|
|
|
|
|
QTextCharFormat textFormat; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFont curFont = cursor.charFormat().font(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int pointSize = curFont.pointSize(); |
|
|
|
|
|
|
|
pointSize -= 5; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QFontInfo fi(delegated()->font());
|
|
|
|
// QFontInfo fi(delegated()->font());
|
|
|
|
// int pixelSize = fi.pixelSize();
|
|
|
|
// int pixelSize = fi.pixelSize();
|
|
|
|
// if (-1 == mLastFontPixelSize)
|
|
|
|
// if (-1 == mLastFontPixelSize)
|
|
|
@ -265,11 +262,28 @@ void UBGraphicsTextItemDelegate::decreaseSize() |
|
|
|
// delegated()->document()->adjustSize();
|
|
|
|
// delegated()->document()->adjustSize();
|
|
|
|
// delegated()->contentsChanged();dddd
|
|
|
|
// 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() |
|
|
|
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();
|
|
|
|
// int pixelSize = fi.pixelSize();
|
|
|
|
// if (-1 == mLastFontPixelSize)
|
|
|
|
// if (-1 == mLastFontPixelSize)
|
|
|
|
// mLastFontPixelSize = pixelSize;
|
|
|
|
// mLastFontPixelSize = pixelSize;
|
|
|
@ -281,16 +295,18 @@ void UBGraphicsTextItemDelegate::increaseSize() |
|
|
|
// if (pixelSize < mLastFontPixelSize && mLastFontPixelSize < newPixelSize)
|
|
|
|
// if (pixelSize < mLastFontPixelSize && mLastFontPixelSize < newPixelSize)
|
|
|
|
// newPixelSize = mLastFontPixelSize;
|
|
|
|
// newPixelSize = mLastFontPixelSize;
|
|
|
|
|
|
|
|
|
|
|
|
// QFont font = delegated()->font();
|
|
|
|
|
|
|
|
// font.setPixelSize(newPixelSize);
|
|
|
|
|
|
|
|
// delegated()->setFont(font);
|
|
|
|
|
|
|
|
// UBSettings::settings()->setFontPixelSize(newPixelSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// delegated()->document()->adjustSize();
|
|
|
|
curFont.setPointSize(pointSize); |
|
|
|
// delegated()->contentsChanged();
|
|
|
|
textFormat.setFont(curFont); |
|
|
|
|
|
|
|
cursor.mergeCharFormat(textFormat); |
|
|
|
|
|
|
|
delegated()->setTextCursor(cursor); |
|
|
|
|
|
|
|
// UBSettings::settings()->setFontPixelSize(curFont.pixelSize());
|
|
|
|
|
|
|
|
UBSettings::settings()->setFontPointSize(pointSize); |
|
|
|
|
|
|
|
|
|
|
|
// qDebug() << newPixelSize;
|
|
|
|
|
|
|
|
delegated()->document()->adjustSize(); |
|
|
|
delegated()->document()->adjustSize(); |
|
|
|
|
|
|
|
delegated()->setFont(curFont); |
|
|
|
|
|
|
|
// delegated()->contentsChanged();
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated() |
|
|
|
UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated() |
|
|
|