#include "titlewidget.h"
#include "kdenlivesettings.h"
+#include "KoSliderCombo.h"
#include <cmath>
frame_properties->setEnabled(false);
frame_properties->setFixedHeight(frame_toolbar->height());
+ // Set combo sliders values
+ textAlpha->setMinimum(0);
+ textAlpha->setMaximum(255);
+ textAlpha->setDecimals(0);
+ textAlpha->setValue(255);
+ textAlpha->setToolTip(i18n("Font color opacity"));
+
+ textOutlineAlpha->setMinimum(0);
+ textOutlineAlpha->setMaximum(255);
+ textOutlineAlpha->setDecimals(0);
+ textOutlineAlpha->setValue(255);
+ textOutlineAlpha->setToolTip(i18n("Outline color opacity"));
+
+ textOutline->setMinimum(0);
+ textOutline->setMaximum(200);
+ textOutline->setDecimals(0);
+ textOutline->setValue(0);
+ textOutline->setToolTip(i18n("Outline width"));
+
itemzoom->setSuffix(i18n("%"));
m_frameWidth = render->renderWidth();
m_frameHeight = render->renderHeight();
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
connect(fontColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
+ connect(textOutlineColor, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
connect(font_family, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotUpdateText())) ;
connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
- connect(textAlpha, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
+ connect(textAlpha, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotUpdateText()));
+ connect(textOutline, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotUpdateText()));
+ connect(textOutlineAlpha, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotUpdateText()));
connect(font_weight_box, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateText()));
connect(font_family, SIGNAL(editTextChanged(const QString &)), this, SLOT(slotFontText(const QString&)));
m_unicodeAction->setToolTip(i18n("Insert Unicode character") + ' ' + m_unicodeAction->shortcut().toString());
connect(m_unicodeAction, SIGNAL(triggered()), this, SLOT(slotInsertUnicode()));
buttonInsertUnicode->setDefaultAction(m_unicodeAction);
-
+
m_zUp = new QAction(KIcon("kdenlive-zindex-up"), QString(), this);
m_zUp->setShortcut(Qt::Key_PageUp);
m_zUp->setToolTip(i18n("Raise object"));
connect(m_zUp, SIGNAL(triggered()), this, SLOT(slotZIndexUp()));
zUp->setDefaultAction(m_zUp);
-
+
m_zDown = new QAction(KIcon("kdenlive-zindex-down"), QString(), this);
m_zDown->setShortcut(Qt::Key_PageDown);
m_zDown->setToolTip(i18n("Lower object"));
connect(m_zDown, SIGNAL(triggered()), this, SLOT(slotZIndexDown()));
zDown->setDefaultAction(m_zDown);
-
+
m_zTop = new QAction(KIcon("kdenlive-zindex-top"), QString(), this);
m_zTop->setShortcut(Qt::Key_Home);
m_zTop->setToolTip(i18n("Raise object to top"));
connect(m_zTop, SIGNAL(triggered()), this, SLOT(slotZIndexTop()));
zTop->setDefaultAction(m_zTop);
-
+
m_zBottom = new QAction(KIcon("kdenlive-zindex-bottom"), QString(), this);
m_zBottom->setShortcut(Qt::Key_End);
m_zBottom->setToolTip(i18n("Lower object to bottom"));
connect(m_zBottom, SIGNAL(triggered()), this, SLOT(slotZIndexBottom()));
zBottom->setDefaultAction(m_zBottom);
-
+
zDown->setIcon(KIcon("kdenlive-zindex-down"));
zTop->setIcon(KIcon("kdenlive-zindex-top"));
zBottom->setIcon(KIcon("kdenlive-zindex-bottom"));
graphicsView->setScene(m_scene);
m_titledocument.setScene(m_scene, m_frameWidth, m_frameHeight);
connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(slotChanged()));
+ connect(font_size, SIGNAL(valueChanged(int)), m_scene, SLOT(slotUpdateFontSize(int)));
// a gradient background
/*QRadialGradient *gradient = new QRadialGradient(0, 0, 10);
QColor color = fontColorButton->color();
color.setAlpha(textAlpha->value());
tt->setDefaultTextColor(color);
+
+ QTextCursor cur(tt->document());
+ cur.select(QTextCursor::Document);
+ QTextBlockFormat format = cur.blockFormat();
+ QTextCharFormat cformat = cur.charFormat();
+ QColor outlineColor = textOutlineColor->color();
+ outlineColor.setAlpha(textOutlineAlpha->value());
+ double outlineWidth = textOutline->value() / 10.0;
+
+ tt->setData(101, outlineWidth);
+ tt->setData(102, outlineColor);
+ if (outlineWidth > 0.0) cformat.setTextOutline(QPen(outlineColor, outlineWidth));
+
+ cformat.setForeground(QBrush(color));
+ cur.setCharFormat(cformat);
+ cur.setBlockFormat(format);
+ tt->setTextCursor(cur);
tt->setZValue(m_count++);
setCurrentItem(tt);
}
effect_stack->setHidden(true);
}
#else
- effect_list->blockSignals(true);
+ effect_list->blockSignals(true);
effect_list->setCurrentIndex(effect_list->findData((int) NOEFFECT));
effect_list->blockSignals(false);
effect_stack->setHidden(true);
QFont font = i->font();
font_family->setCurrentFont(font);
font_size->setValue(font.pixelSize());
+ m_scene->slotUpdateFontSize(font.pixelSize());
buttonItalic->setChecked(font.italic());
buttonUnder->setChecked(font.underline());
setFontBoxWeight(font.weight());
- QColor color = i->defaultTextColor();
+ QTextCursor cursor(i->document());
+ cursor.select(QTextCursor::Document);
+ QColor color = cursor.charFormat().foreground().color();
fontColorButton->setColor(color);
textAlpha->setValue(color.alpha());
+ if (!i->data(101).isNull()) {
+ textOutline->blockSignals(true);
+ textOutline->setValue(i->data(101).toDouble()*10);
+ textOutline->blockSignals(false);
+ }
+ if (!i->data(102).isNull()) {
+ textOutlineColor->blockSignals(true);
+ textOutlineAlpha->blockSignals(true);
+ textOutlineColor->setColor(i->data(102).toString());
+ textOutlineAlpha->setValue(QColor(i->data(102).toString()).alpha());
+ textOutlineColor->blockSignals(false);
+ textOutlineAlpha->blockSignals(false);
+ }
QTextCursor cur = i->textCursor();
QTextBlockFormat format = cur.blockFormat();
if (i->textWidth() == -1) buttonAlignNone->setChecked(true);
value_h->blockSignals(true);
zValue->blockSignals(true);
- zValue->setValue((int) i->zValue());
+ zValue->setValue((int) i->zValue());
if (i->type() == IMAGEITEM) {
// Get multipliers for rotation/scaling
value_h->setValue((int) t->boundingRect().height());
}
- zValue->blockSignals(false);
+ zValue->blockSignals(false);
value_w->blockSignals(false);
value_h->blockSignals(false);
}
QColor color = fontColorButton->color();
color.setAlpha(textAlpha->value());
+ QColor outlineColor = textOutlineColor->color();
+ outlineColor.setAlpha(textOutlineAlpha->value());
+ double outlineWidth = textOutline->value() / 10.0;
QGraphicsTextItem* item = NULL;
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
}
if (!item) return;
//if (item->textCursor().selection ().isEmpty())
- QTextCursor cur = item->textCursor();
+ QTextCursor cur(item->document());
+ cur.select(QTextCursor::Document);
QTextBlockFormat format = cur.blockFormat();
if (buttonAlignLeft->isChecked() || buttonAlignCenter->isChecked() || buttonAlignRight->isChecked()) {
item->setTextWidth(item->boundingRect().width());
item->setTextWidth(-1);
}
- {
- item->setFont(font);
- item->setDefaultTextColor(color);
- cur.select(QTextCursor::Document);
- cur.setBlockFormat(format);
- item->setTextCursor(cur);
- cur.clearSelection();
- item->setTextCursor(cur);
+ item->setFont(font);
+ QTextCharFormat cformat = cur.charFormat();
- }
+ item->setData(101, outlineWidth);
+ item->setData(102, outlineColor);
+ if (outlineWidth > 0.0) cformat.setTextOutline(QPen(outlineColor, outlineWidth));
+
+ cformat.setForeground(QBrush(color));
+ cur.setCharFormat(cformat);
+ cur.setBlockFormat(format);
+ item->setTextCursor(cur);
+ cur.clearSelection();
+ item->setTextCursor(cur);
}
void TitleWidget::rectChanged()
// read the entries
font_family->setCurrentFont(titleConfig.readEntry("font_family", font_family->currentFont()));
font_size->setValue(titleConfig.readEntry("font_pixel_size", font_size->value()));
+ m_scene->slotUpdateFontSize(font_size->value());
fontColorButton->setColor(titleConfig.readEntry("font_color", fontColorButton->color()));
textAlpha->setValue(titleConfig.readEntry("font_alpha", textAlpha->value()));
int weight;
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
int effect = effect_list->itemData(ix).toInt();
if (effect == NOEFFECT) {
- if (l.size() == 1) l[0]->setData(100, QVariant());
+ if (l.size() == 1) l[0]->setData(100, QVariant());
effect_stack->setHidden(true);
return;
}
qreal TitleWidget::zIndexBounds(bool maxBound)
{
- qreal bound = maxBound? -99 : 99;
- QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() > 0) {
- QList<QGraphicsItem*> lItems = graphicsView->scene()->items(l[0]->sceneBoundingRect(), Qt::IntersectsItemShape);
- if (lItems.size() > 0) {
- int n = lItems.size();
- qreal z;
- if (maxBound) {
- for (int i = 0; i < n; i++) {
- z = lItems[i]->zValue();
- if (z > bound && !lItems[i]->isSelected()) {
- bound = z;
- }
- }
- } else {
- // Get minimum z index.
- for (int i = 0; i < n; i++) {
- z = lItems[i]->zValue();
- if (z < bound && !lItems[i]->isSelected() && z > -999) {
- // There are items at the very bottom (background e.g.) with z-index < -1000.
- bound = z;
- }
- }
- }
- }
- }
- return bound;
-}
-
-void TitleWidget::slotZIndexUp()
+ qreal bound = maxBound ? -99 : 99;
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() > 0) {
+ QList<QGraphicsItem*> lItems = graphicsView->scene()->items(l[0]->sceneBoundingRect(), Qt::IntersectsItemShape);
+ if (lItems.size() > 0) {
+ int n = lItems.size();
+ qreal z;
+ if (maxBound) {
+ for (int i = 0; i < n; i++) {
+ z = lItems[i]->zValue();
+ if (z > bound && !lItems[i]->isSelected()) {
+ bound = z;
+ }
+ }
+ } else {
+ // Get minimum z index.
+ for (int i = 0; i < n; i++) {
+ z = lItems[i]->zValue();
+ if (z < bound && !lItems[i]->isSelected() && z > -999) {
+ // There are items at the very bottom (background e.g.) with z-index < -1000.
+ bound = z;
+ }
+ }
+ }
+ }
+ }
+ return bound;
+}
+
+void TitleWidget::slotZIndexUp()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1) {
- qreal currentZ = l[0]->zValue();
- qreal max = zIndexBounds(true);
- if (currentZ <= max) {
- l[0]->setZValue(currentZ+1);
- updateDimension(l[0]);
- }
+ qreal currentZ = l[0]->zValue();
+ qreal max = zIndexBounds(true);
+ if (currentZ <= max) {
+ l[0]->setZValue(currentZ + 1);
+ updateDimension(l[0]);
+ }
}
}
-void TitleWidget::slotZIndexTop()
+void TitleWidget::slotZIndexTop()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1) {
- qreal currentZ = l[0]->zValue();
- qreal max = zIndexBounds(true);
- if (currentZ <= max) {
- l[0]->setZValue(max+1);
- updateDimension(l[0]);
- }
+ qreal currentZ = l[0]->zValue();
+ qreal max = zIndexBounds(true);
+ if (currentZ <= max) {
+ l[0]->setZValue(max + 1);
+ updateDimension(l[0]);
+ }
}
}
-void TitleWidget::slotZIndexDown()
+void TitleWidget::slotZIndexDown()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1) {
- qreal currentZ = l[0]->zValue();
- qreal min = zIndexBounds(false);
- if (currentZ >= min) {
- l[0]->setZValue(currentZ-1);
- updateDimension(l[0]);
- }
+ qreal currentZ = l[0]->zValue();
+ qreal min = zIndexBounds(false);
+ if (currentZ >= min) {
+ l[0]->setZValue(currentZ - 1);
+ updateDimension(l[0]);
+ }
}
}
-void TitleWidget::slotZIndexBottom()
+void TitleWidget::slotZIndexBottom()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1) {
- qreal currentZ = l[0]->zValue();
- qreal min = zIndexBounds(false);
- if (currentZ >= min) {
- l[0]->setZValue(min-1);
- updateDimension(l[0]);
- }
+ qreal currentZ = l[0]->zValue();
+ qreal min = zIndexBounds(false);
+ if (currentZ >= min) {
+ l[0]->setZValue(min - 1);
+ updateDimension(l[0]);
+ }
}
}