Commit 2879bf0a authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Prepare for slightly improved titler:

* improved handling of text box size and alignment
* allow adjusting letter and line spacing

This needs a patched MLT that will also fix the awful crashes
that plagued us since the Qt5 port when using title clips
(patch is currently waiting MLT's approval)
parent b3c9bc59
......@@ -27,11 +27,75 @@
#include <QGraphicsView>
#include <QCursor>
#include <QTextCursor>
#include <QTextDocument>
#include <QList>
#include <QKeyEvent>
#include <QApplication>
#include <QTextBlock>
MyTextItem::MyTextItem(const QString &txt, QGraphicsItem *parent) :
QGraphicsTextItem(txt, parent)
, m_alignment(Qt::AlignLeft)
{
document()->setDocumentMargin(0);
updateGeometry();
connect(document(), SIGNAL(contentsChange(int, int, int)),
this, SLOT(updateGeometry(int, int, int)));
}
Qt::Alignment MyTextItem::alignment() const
{
return m_alignment;
}
void MyTextItem::setAlignment(Qt::Alignment alignment)
{
m_alignment = alignment;
QTextBlockFormat format;
format.setAlignment(alignment);
QTextCursor cursor = textCursor(); // save cursor position
int position = textCursor().position();
cursor.select(QTextCursor::Document);
cursor.mergeBlockFormat(format);
cursor.clearSelection();
cursor.setPosition(position); // restore cursor position
setTextCursor(cursor);
}
void MyTextItem::updateGeometry(int, int, int)
{
updateGeometry();
}
void MyTextItem::updateGeometry()
{
QPointF topRightPrev = boundingRect().topRight();
setTextWidth(-1);
setTextWidth(boundingRect().width());
setAlignment(m_alignment);
QPointF topRight = boundingRect().topRight();
if (m_alignment & Qt::AlignRight)
{
setPos(pos() + (topRightPrev - topRight));
}
}
QRectF MyTextItem::boundingRect() const
{
QRectF base = QGraphicsTextItem::boundingRect();
QTextCursor cur(document());
cur.select(QTextCursor::Document);
QTextBlockFormat format = cur.blockFormat();
int lines = document()->lineCount();
int lineHeight = format.lineHeight();
int lineHeight2 = QFontMetrics(font()).lineSpacing();
if (lines > 1) {
base.setHeight(lines * lineHeight2 + lineHeight * (lines - 1));
}
return base;
}
GraphicsSceneRectMove::GraphicsSceneRectMove(QObject *parent) :
QGraphicsScene(parent),
......@@ -80,7 +144,7 @@ void GraphicsSceneRectMove::keyPressEvent(QKeyEvent * keyEvent)
return;
}
if (m_selectedItem->type() == QGraphicsTextItem::Type) {
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
MyTextItem *t = static_cast<MyTextItem *>(m_selectedItem);
if (t->textInteractionFlags() & Qt::TextEditorInteraction) {
QGraphicsScene::keyPressEvent(keyEvent);
return;
......@@ -135,7 +199,7 @@ void GraphicsSceneRectMove::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e)
QGraphicsItem* g = i.first();
if (g->type() == QGraphicsTextItem::Type) {
m_selectedItem = g;
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(g);
MyTextItem *t = static_cast<MyTextItem *>(g);
t->setTextInteractionFlags(Qt::TextEditorInteraction);
} else emit doubleClickEvent();
QGraphicsScene::mouseDoubleClickEvent(e);
......@@ -169,7 +233,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
if (item == NULL || !(item->flags() & QGraphicsItem::ItemIsSelectable)) {
if (m_selectedItem && m_selectedItem->type() == QGraphicsTextItem::Type) {
// disable text editing
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
MyTextItem *t = static_cast<MyTextItem *>(m_selectedItem);
t->textCursor().setPosition(0);
QTextBlock cur = t->textCursor().block();
t->setTextCursor(QTextCursor(cur));
......@@ -188,7 +252,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
m_selectedItem = item;
//qDebug() << "///////// ITEM TYPE: " << item->type();
if (item->type() == QGraphicsTextItem::Type) {
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(item);
MyTextItem *t = static_cast<MyTextItem *>(item);
if (t->textInteractionFlags() == Qt::TextEditorInteraction) {
QGraphicsScene::mousePressEvent(e);
return;
......@@ -242,10 +306,11 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
m_sceneClickPoint = e->scenePos();
m_selectedItem = NULL;
} else if (m_tool == TITLE_TEXT) {
m_selectedItem = addText(QString());
emit newText((QGraphicsTextItem *) m_selectedItem);
m_selectedItem = new MyTextItem(QString(), NULL);
addItem(m_selectedItem);
emit newText((MyTextItem *) m_selectedItem);
m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
((QGraphicsTextItem *)m_selectedItem)->setTextInteractionFlags(Qt::TextEditorInteraction);
((MyTextItem *)m_selectedItem)->setTextInteractionFlags(Qt::TextEditorInteraction);
m_selectedItem->setPos(e->scenePos() - QPointF(0, (int)(m_fontSize / 2)));
QGraphicsScene::mousePressEvent(e);
}
......@@ -258,7 +323,7 @@ void GraphicsSceneRectMove::clearTextSelection()
{
if (m_selectedItem && m_selectedItem->type() == QGraphicsTextItem::Type) {
// disable text editing
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
MyTextItem *t = static_cast<MyTextItem *>(m_selectedItem);
t->textCursor().setPosition(0);
QTextBlock cur = t->textCursor().block();
t->setTextCursor(QTextCursor(cur));
......@@ -429,7 +494,7 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
return;
}*/
} else if (m_selectedItem->type() == QGraphicsTextItem::Type) {
QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
MyTextItem *t = static_cast<MyTextItem *>(m_selectedItem);
if (t->textInteractionFlags() & Qt::TextEditorInteraction) {
QGraphicsScene::mouseMoveEvent(e);
return;
......
......@@ -22,10 +22,28 @@
#define GRAPHICSSCENERECTMOVE_H
#include <QGraphicsScene>
#include <QGraphicsTextItem>
enum resizeModes {NoResize, TopLeft, BottomLeft, TopRight, BottomRight, Left, Right, Up, Down};
enum TITLETOOL { TITLE_SELECT = 0, TITLE_RECTANGLE = 1, TITLE_TEXT = 2, TITLE_IMAGE = 3 };
class MyTextItem: public QGraphicsTextItem
{
Q_OBJECT
public:
MyTextItem(const QString &, QGraphicsItem *);
void setAlignment(Qt::Alignment alignment);
virtual QRectF boundingRect() const;
Qt::Alignment alignment() const;
private:
Qt::Alignment m_alignment;
public slots:
void updateGeometry(int, int, int);
void updateGeometry();
};
class GraphicsSceneRectMove: public QGraphicsScene
{
Q_OBJECT
......@@ -65,7 +83,7 @@ signals:
void itemMoved();
void sceneZoom(bool);
void newRect(QGraphicsRectItem *);
void newText(QGraphicsTextItem *);
void newText(MyTextItem *);
void actionFinished();
void doubleClickEvent();
};
......
......@@ -19,6 +19,7 @@
#include "kdenlivesettings.h"
#include "timecode.h"
#include "effectstack/graphicsscenerectmove.h"
#include <KLocalizedString>
#include <KMessageBox>
......@@ -33,6 +34,7 @@
#include <QGraphicsItem>
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QTextDocument>
#include <QGraphicsSvgItem>
#include <QCryptographicHash>
#include <QSvgRenderer>
......@@ -137,12 +139,14 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
#endif
main.setAttribute(QStringLiteral("LC_NUMERIC"), locale);
doc.appendChild(main);
QTextCursor cur;
QTextBlockFormat format;
foreach(QGraphicsItem * item, m_scene->items()) {
QDomElement e = doc.createElement(QStringLiteral("item"));
QDomElement content = doc.createElement(QStringLiteral("content"));
QFont font;
QGraphicsTextItem *t;
MyTextItem *t;
switch (item->type()) {
case 7:
......@@ -164,7 +168,7 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
break;
case 8:
e.setAttribute(QStringLiteral("type"), QStringLiteral("QGraphicsTextItem"));
t = static_cast<QGraphicsTextItem *>(item);
t = static_cast<MyTextItem *>(item);
// Don't save empty text nodes
if (t->toPlainText().simplified().isEmpty()) continue;
//content.appendChild(doc.createTextNode(((QGraphicsTextItem*)item)->toHtml()));
......@@ -175,6 +179,13 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
content.setAttribute(QStringLiteral("font-pixel-size"), font.pixelSize());
content.setAttribute(QStringLiteral("font-italic"), font.italic());
content.setAttribute(QStringLiteral("font-underline"), font.underline());
content.setAttribute(QStringLiteral("letter-spacing"), QString::number(font.letterSpacing()));
cur = QTextCursor(t->document());
cur.select(QTextCursor::Document);
format = cur.blockFormat();
content.setAttribute(QStringLiteral("line-spacing"), QString::number(format.lineHeight()));
content.setAttribute(QStringLiteral("box-width"), QString::number(t->boundingRect().width()));
content.setAttribute(QStringLiteral("box-height"), QString::number(t->boundingRect().height()));
{
QTextCursor cursor(t->document());
cursor.select(QTextCursor::Document);
......@@ -202,7 +213,7 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
content.setAttribute(QStringLiteral("kdenlive-axis-y-inverted"), t->data(OriginYTop).toInt());
}
if (t->textWidth() != -1) {
content.setAttribute(QStringLiteral("alignment"), t->textCursor().blockFormat().alignment());
content.setAttribute(QStringLiteral("alignment"), (int) t->alignment());
}
break;
default:
......@@ -381,10 +392,14 @@ int TitleDocument::loadFromXml(const QDomDocument& doc, QGraphicsRectItem* start
QFont f2;
f2.setPointSize(txtProperties.namedItem(QStringLiteral("font-size")).nodeValue().toInt());
font.setPixelSize(QFontInfo(f2).pixelSize());
} else
} else {
font.setPixelSize(txtProperties.namedItem(QStringLiteral("font-pixel-size")).nodeValue().toInt());
}
font.setLetterSpacing(QFont::AbsoluteSpacing, txtProperties.namedItem(QStringLiteral("letter-spacing")).nodeValue().toInt());
QColor col(stringToColor(txtProperties.namedItem(QStringLiteral("font-color")).nodeValue()));
QGraphicsTextItem *txt = m_scene->addText(items.item(i).namedItem(QStringLiteral("content")).firstChild().nodeValue(), font);
MyTextItem *txt = new MyTextItem(items.item(i).namedItem(QStringLiteral("content")).firstChild().nodeValue(), NULL);
txt->setFont(font);
m_scene->addItem(txt);
QTextCursor cursor(txt->document());
cursor.select(QTextCursor::Document);
QTextCharFormat format;
......@@ -398,19 +413,16 @@ int TitleDocument::loadFromXml(const QDomDocument& doc, QGraphicsRectItem* start
);
}
if (txtProperties.namedItem(QStringLiteral("line-spacing")).nodeValue().toInt() != 0.0) {
QTextBlockFormat format = cursor.blockFormat();
format.setLineHeight(txtProperties.namedItem(QStringLiteral("line-spacing")).nodeValue().toInt(), QTextBlockFormat::LineDistanceHeight);
cursor.setBlockFormat(format);
}
format.setForeground(QBrush(col));
cursor.mergeCharFormat(format);
txt->setTextInteractionFlags(Qt::NoTextInteraction);
if (txtProperties.namedItem(QStringLiteral("alignment")).isNull() == false) {
txt->setTextWidth(txt->boundingRect().width());
QTextCursor cur = txt->textCursor();
QTextBlockFormat format = cur.blockFormat();
format.setAlignment((Qt::Alignment) txtProperties.namedItem(QStringLiteral("alignment")).nodeValue().toInt());
cur.select(QTextCursor::Document);
cur.setBlockFormat(format);
txt->setTextCursor(cur);
cur.clearSelection();
txt->setTextCursor(cur);
txt->setAlignment((Qt::Alignment) txtProperties.namedItem(QStringLiteral("alignment")).nodeValue().toInt());
}
if (!txtProperties.namedItem(QStringLiteral("kdenlive-axis-x-inverted")).isNull()) {
......
......@@ -140,7 +140,9 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
connect(fontColorButton, SIGNAL(changed(QColor)), this, SLOT(slotUpdateText())) ;
connect(textOutlineColor, SIGNAL(changed(QColor)), this, SLOT(slotUpdateText())) ;
connect(font_family, SIGNAL(currentFontChanged(QFont)), this, SLOT(slotUpdateText())) ;
connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
connect(letter_spacing, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
connect(line_spacing, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
connect(textOutline, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
connect(font_weight_box, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateText()));
......@@ -432,7 +434,7 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, const QString &pro
connect(m_scene, SIGNAL(sceneZoom(bool)), this , SLOT(slotZoom(bool)));
connect(m_scene, SIGNAL(actionFinished()), this , SLOT(slotSelectTool()));
connect(m_scene, SIGNAL(newRect(QGraphicsRectItem*)), this , SLOT(slotNewRect(QGraphicsRectItem*)));
connect(m_scene, SIGNAL(newText(QGraphicsTextItem*)), this , SLOT(slotNewText(QGraphicsTextItem*)));
connect(m_scene, SIGNAL(newText(MyTextItem*)), this , SLOT(slotNewText(MyTextItem*)));
connect(zoom_slider, SIGNAL(valueChanged(int)), this , SLOT(slotUpdateZoom(int)));
connect(zoom_spin, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateZoom(int)));
......@@ -568,8 +570,7 @@ void TitleWidget::templateIndexChanged(int index)
QList<QGraphicsItem *> list = graphicsView->scene()->items();
foreach(QGraphicsItem * qgItem, list) {
if (qgItem->type() == TEXTITEM) {
QGraphicsTextItem *i;
i = static_cast<QGraphicsTextItem *>(qgItem);
MyTextItem *i = static_cast<MyTextItem *>(qgItem);
i->setProperty("isTemplate", "true");
i->setProperty("templateText", i->toHtml());
}
......@@ -854,10 +855,18 @@ void TitleWidget::slotNewRect(QGraphicsRectItem * rect)
//graphicsView->setFocus();
}
void TitleWidget::slotNewText(QGraphicsTextItem *tt)
void TitleWidget::slotNewText(MyTextItem *tt)
{
updateAxisButtons(tt); // back to default
letter_spacing->blockSignals(true);
line_spacing->blockSignals(true);
letter_spacing->setValue(0);
line_spacing->setValue(0);
letter_spacing->blockSignals(false);
line_spacing->blockSignals(false);
letter_spacing->setEnabled(true);
line_spacing->setEnabled(true);
QFont font = font_family->currentFont();
font.setPixelSize(font_size->value());
// mbd: issue 551:
......@@ -869,6 +878,7 @@ void TitleWidget::slotNewText(QGraphicsTextItem *tt)
QColor color = fontColorButton->color();
QColor outlineColor = textOutlineColor->color();
tt->setDefaultTextColor(color);
tt->document()->setDocumentMargin(0);
QTextCursor cur(tt->document());
cur.select(QTextCursor::Document);
......@@ -926,7 +936,7 @@ void TitleWidget::selectionChanged()
l = graphicsView->scene()->items();
foreach(QGraphicsItem * item, l) {
if (item->type() == TEXTITEM && !item->isSelected()) {
QGraphicsTextItem *i = static_cast<QGraphicsTextItem *>(item);
MyTextItem *i = static_cast<MyTextItem *>(item);
i->clearFocus();
}
}
......@@ -1164,7 +1174,7 @@ void TitleWidget::updateDimension(QGraphicsItem *i)
value_w->setValue((int) r->rect().width());
value_h->setValue((int) r->rect().height());
} else if (i->type() == TEXTITEM) {
QGraphicsTextItem *t = static_cast <QGraphicsTextItem *>(i);
MyTextItem *t = static_cast <MyTextItem *>(i);
value_w->setValue((int) t->boundingRect().width());
value_h->setValue((int) t->boundingRect().height());
}
......@@ -1182,7 +1192,7 @@ void TitleWidget::updateCoordinates(QGraphicsItem *i)
if (i->type() == TEXTITEM) {
QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
MyTextItem *rec = static_cast <MyTextItem *>(i);
// Set the correct x coordinate value
if (origin_x_left->isChecked()) {
......@@ -1269,7 +1279,7 @@ void TitleWidget::updatePosition(QGraphicsItem *i)
void TitleWidget::updatePosition(QGraphicsItem *i, int x, int y)
{
if (i->type() == TEXTITEM) {
QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
MyTextItem *rec = static_cast <MyTextItem *>(i);
int posX;
if (origin_x_left->isChecked()) {
......@@ -1422,11 +1432,11 @@ void TitleWidget::slotChanged()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1 && l.at(0)->type() == TEXTITEM) {
textChanged(static_cast <QGraphicsTextItem *>(l.at(0)));
textChanged(static_cast <MyTextItem *>(l.at(0)));
}
}
void TitleWidget::textChanged(QGraphicsTextItem *i)
void TitleWidget::textChanged(MyTextItem *i)
{
/*
* If the user has set origin_x_left (the same for y), we need to look
......@@ -1475,7 +1485,7 @@ void TitleWidget::slotInsertUnicodeString(const QString &text)
QList<QGraphicsItem *> l = graphicsView->scene()->selectedItems();
if (l.size() > 0) {
if (l.at(0)->type() == TEXTITEM) {
QGraphicsTextItem *t = static_cast <QGraphicsTextItem *>(l.at(0));
MyTextItem *t = static_cast <MyTextItem *>(l.at(0));
t->textCursor().insertText(text);
}
}
......@@ -1488,6 +1498,7 @@ void TitleWidget::slotUpdateText()
font.setItalic(buttonItalic->isChecked());
font.setUnderline(buttonUnder->isChecked());
font.setWeight(font_weight_box->itemData(font_weight_box->currentIndex()).toInt());
font.setLetterSpacing(QFont::AbsoluteSpacing, letter_spacing->value());
QColor color = fontColorButton->color();
QColor outlineColor = textOutlineColor->color();
......@@ -1495,10 +1506,10 @@ void TitleWidget::slotUpdateText()
int i;
for (i = 0; i < graphicsView->scene()->selectedItems().length(); ++i) {
QGraphicsTextItem* item = NULL;
MyTextItem* item = NULL;
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.at(i)->type() == TEXTITEM) {
item = static_cast <QGraphicsTextItem *>(l.at(i));
item = static_cast <MyTextItem *>(l.at(i));
}
if (!item) {
// No text item, try next one.
......@@ -1509,14 +1520,13 @@ void TitleWidget::slotUpdateText()
QTextCursor cur(item->document());
cur.select(QTextCursor::Document);
QTextBlockFormat format = cur.blockFormat();
format.setLineHeight(line_spacing->value(), QTextBlockFormat::LineDistanceHeight);
if (buttonAlignLeft->isChecked() || buttonAlignCenter->isChecked() || buttonAlignRight->isChecked()) {
item->setTextWidth(item->boundingRect().width());
if (buttonAlignCenter->isChecked()) format.setAlignment(Qt::AlignHCenter);
else if (buttonAlignRight->isChecked()) format.setAlignment(Qt::AlignRight);
else if (buttonAlignLeft->isChecked()) format.setAlignment(Qt::AlignLeft);
if (buttonAlignCenter->isChecked()) item->setAlignment(Qt::AlignHCenter);
else if (buttonAlignRight->isChecked()) item->setAlignment(Qt::AlignRight);
else if (buttonAlignLeft->isChecked()) item->setAlignment(Qt::AlignLeft);
} else {
format.setAlignment(Qt::AlignLeft);
item->setTextWidth(-1);
item->setAlignment(Qt::AlignLeft);
}
// Set font properties
......@@ -2031,8 +2041,8 @@ void TitleWidget::slotAnimEnd(bool anim)
void TitleWidget::addAnimInfoText()
{
// add text to anim viewport
QGraphicsTextItem *t = new QGraphicsTextItem(i18nc("Indicates the start of an animation", "Start"), m_startViewport);
QGraphicsTextItem *t2 = new QGraphicsTextItem(i18nc("Indicates the end of an animation", "End"), m_endViewport);
MyTextItem *t = new MyTextItem(i18nc("Indicates the start of an animation", "Start"), m_startViewport);
MyTextItem *t2 = new MyTextItem(i18nc("Indicates the end of an animation", "End"), m_endViewport);
QFont font = t->font();
font.setPixelSize(m_startViewport->rect().width() / 10);
QColor col = m_startViewport->pen().color();
......@@ -2050,7 +2060,7 @@ void TitleWidget::updateInfoText()
{
// update info text font
if (!m_startViewport->childItems().isEmpty()) {
QGraphicsTextItem *item = static_cast <QGraphicsTextItem *>(m_startViewport->childItems().at(0));
MyTextItem *item = static_cast <MyTextItem *>(m_startViewport->childItems().at(0));
if (item) {
QFont font = item->font();
font.setPixelSize(m_startViewport->rect().width() / 10);
......@@ -2058,7 +2068,7 @@ void TitleWidget::updateInfoText()
}
}
if (!m_endViewport->childItems().isEmpty()) {
QGraphicsTextItem *item = static_cast <QGraphicsTextItem *>(m_endViewport->childItems().at(0));
MyTextItem *item = static_cast <MyTextItem *>(m_endViewport->childItems().at(0));
if (item) {
QFont font = item->font();
font.setPixelSize(m_endViewport->rect().width() / 10);
......@@ -2408,6 +2418,10 @@ void TitleWidget::prepareTools(QGraphicsItem *referenceItem)
itemrotatey->setEnabled(false);
itemrotatez->setEnabled(false);
frame_properties->setEnabled(false);
letter_spacing->setEnabled(false);
line_spacing->setEnabled(false);
letter_spacing->setValue(0);
line_spacing->setValue(0);
} else {
effect_frame->setEnabled(true);
frame_properties->setEnabled(true);
......@@ -2423,9 +2437,13 @@ void TitleWidget::prepareTools(QGraphicsItem *referenceItem)
itemrotatez->setEnabled(false);
updateInfoText();
}
letter_spacing->setEnabled(referenceItem->type() == TEXTITEM);
line_spacing->setEnabled(referenceItem->type() == TEXTITEM);
if (referenceItem->type() == TEXTITEM) {
showToolbars(TITLE_TEXT);
QGraphicsTextItem* i = static_cast <QGraphicsTextItem *>(referenceItem);
MyTextItem* i = static_cast <MyTextItem *>(referenceItem);
if (!i->toPlainText().isEmpty()) {
// We have an existing text item selected
if (!i->data(100).isNull()) {
......@@ -2504,6 +2522,8 @@ void TitleWidget::prepareTools(QGraphicsItem *referenceItem)
else if (format.alignment() == Qt::AlignHCenter) buttonAlignCenter->setChecked(true);
else if (format.alignment() == Qt::AlignRight) buttonAlignRight->setChecked(true);
else if (format.alignment() == Qt::AlignLeft) buttonAlignLeft->setChecked(true);
letter_spacing->setValue(font.letterSpacing());
line_spacing->setValue(format.lineHeight());
font_size->blockSignals(false);
font_family->blockSignals(false);
......
......@@ -167,7 +167,7 @@ private:
/** @brief Updates the item position. Does not change GUI elements. */
void updatePosition(QGraphicsItem *i, int x, int y);
void textChanged(QGraphicsTextItem *i);
void textChanged(MyTextItem *i);
void updateAxisButtons(QGraphicsItem *i);
void updateTextOriginX();
......@@ -213,7 +213,7 @@ private:
QString getTooltipWithShortcut(const QString& text, QAction *button);
public slots:
void slotNewText(QGraphicsTextItem *tt);
void slotNewText(MyTextItem *tt);
void slotNewRect(QGraphicsRectItem *rect);
void slotChangeBackground();
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment