QStringList l = s.split(',');
if (l.size() < 4)
return QRectF();
- return QRectF(l[0].toDouble(), l[1].toDouble(), l[2].toDouble(), l[3].toDouble()).normalized();
+ return QRectF(l.at(0).toDouble(), l.at(1).toDouble(), l.at(2).toDouble(), l.at(3).toDouble()).normalized();
}
QColor TitleDocument::stringToColor(const QString & s)
QStringList l = s.split(',');
if (l.size() < 4)
return QColor();
- return QColor(l[0].toInt(), l[1].toInt(), l[2].toInt(), l[3].toInt());;
+ return QColor(l.at(0).toInt(), l.at(1).toInt(), l.at(2).toInt(), l.at(3).toInt());;
}
QTransform TitleDocument::stringToTransform(const QString& s)
{
if (l.size() < 9)
return QTransform();
return QTransform(
- l[0].toDouble(), l[1].toDouble(), l[2].toDouble(),
- l[3].toDouble(), l[4].toDouble(), l[5].toDouble(),
- l[6].toDouble(), l[7].toDouble(), l[8].toDouble()
+ l.at(0).toDouble(), l.at(1).toDouble(), l.at(2).toDouble(),
+ l.at(3).toDouble(), l.at(4).toDouble(), l.at(5).toDouble(),
+ l.at(6).toDouble(), l.at(7).toDouble(), l.at(8).toDouble()
);
}
int settingUp = false;
+const int IMAGEITEM = 7;
+const int RECTITEM = 3;
+const int TEXTITEM = 8;
+
TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent) :
QDialog(parent),
Ui::TitleWidget_UI(),
value_y->blockSignals(true);
value_w->blockSignals(true);
value_h->blockSignals(true);
- //kDebug() << "//////// SELECTION CHANGED; ITEMS: " << l.size();
+ itemzoom->blockSignals(true);
+ itemrotate->blockSignals(true);
if (l.size() == 1) {
- if ((l[0])->type() == 8) {
+ if (l.at(0)->type() == TEXTITEM) {
rect_properties->setHidden(true);
text_properties->setHidden(false);
- QGraphicsTextItem* i = ((QGraphicsTextItem*)l[0]);
+ QGraphicsTextItem* i = static_cast <QGraphicsTextItem *>(l.at(0));
//if (l[0]->hasFocus())
//ktextedit->setHtml(i->toHtml());
toolBox->setCurrentIndex(0);
frame_properties->setEnabled(true);
value_w->setEnabled(false);
value_h->setEnabled(false);
- } else if ((l[0])->type() == 3) {
+ } else if ((l.at(0))->type() == RECTITEM) {
rect_properties->setHidden(false);
text_properties->setHidden(true);
settingUp = true;
- QGraphicsRectItem *rec = ((QGraphicsRectItem*)l[0]);
+ QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
toolBox->setCurrentIndex(0);
//toolBox->setItemEnabled(3, true);
rectFAlpha->setValue(rec->pen().color().alpha());
//toolBox->setCurrentIndex(0);
frame_properties->setEnabled(false);
}
- zValue->setValue((int)l[0]->zValue());
- itemzoom->setValue((int)(m_transformations[l[0]].scalex * 100));
- itemrotate->setValue((int)(m_transformations[l[0]].rotate));
+ zValue->setValue((int)l.at(0)->zValue());
+ itemzoom->setValue((int)(m_transformations.value(l.at(0)).scalex * 100.0 + 0.5));
+ itemrotate->setValue((int)(m_transformations.value(l.at(0)).rotate));
value_x->blockSignals(false);
value_y->blockSignals(false);
value_w->blockSignals(false);
value_h->blockSignals(false);
+ itemzoom->blockSignals(false);
+ itemrotate->blockSignals(false);
} else frame_properties->setEnabled(false);
}
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() >= 1) {
- if (l[0]->type() == 3) {
+ if (l.at(0)->type() == RECTITEM) {
//rect item
- QGraphicsRectItem *rec = ((QGraphicsRectItem*)l[0]);
+ QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
rec->setPos(value_x->value(), value_y->value());
rec->setRect(QRect(0, 0, value_w->value(), value_h->value()));
- } else if (l[0]->type() == 8) {
+ } else if (l.at(0)->type() == TEXTITEM) {
//text item
- QGraphicsTextItem *rec = ((QGraphicsTextItem*)l[0]);
+ QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(l.at(0));
rec->setPos(value_x->value(), value_y->value());
}
}
void TitleWidget::textChanged()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() == 1 && (l[0])->type() == 8 && !l[0]->hasFocus()) {
+ if (l.size() == 1 && l.at(0)->type() == TEXTITEM && !l.at(0)->hasFocus()) {
//kDebug() << ktextedit->document()->toHtml();
//((QGraphicsTextItem*)l[0])->setHtml(ktextedit->toHtml());
}
QGraphicsTextItem* item = NULL;
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() == 1 && (l[0])->type() == 8) {
- item = (QGraphicsTextItem*)l[0];
+ if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
+ item = static_cast <QGraphicsTextItem *>(l.at(0));
}
if (!item) return;
//if (item->textCursor().selection ().isEmpty())
void TitleWidget::rectChanged()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() == 1 && (l[0])->type() == 3 && !settingUp) {
- QGraphicsRectItem *rec = (QGraphicsRectItem*)l[0];
+ if (l.size() == 1 && l.at(0)->type() == RECTITEM && !settingUp) {
+ QGraphicsRectItem *rec = static_cast<QGraphicsRectItem *>(l.at(0));
QColor f = rectFColor->color();
f.setAlpha(rectFAlpha->value());
QPen penf(f);
void TitleWidget::fontBold()
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() == 1 && (l[0])->type() == 8 && !l[0]->hasFocus()) {
+ if (l.size() == 1 && l.at(0)->type() == TEXTITEM && !l.at(0)->hasFocus()) {
//ktextedit->document()->setTextOption();
}
}
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
- Transform x = m_transformations[l[0]];
+ Transform x = m_transformations.value(l.at(0));
x.scalex = (double)val / 100.0;
x.scaley = (double)val / 100.0;
QTransform qtrans;
qtrans.scale(x.scalex, x.scaley);
qtrans.rotate(x.rotate);
l[0]->setTransform(qtrans);
- m_transformations[l[0]] = x;
+ m_transformations[l.at(0)] = x;
}
}
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
- Transform x = m_transformations[l[0]];
+ Transform x = m_transformations[l.at(0)];
x.rotate = (double)val;
QTransform qtrans;
qtrans.scale(x.scalex, x.scaley);
qtrans.rotate(x.rotate);
l[0]->setTransform(qtrans);
- m_transformations[l[0]] = x;
+ m_transformations[l.at(0)] = x;
}
}
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
- QGraphicsItem *item = l[0];
+ QGraphicsItem *item = l.at(0);
QRectF br;
- if (item->type() == 3) {
+ if (item->type() == RECTITEM) {
br = ((QGraphicsRectItem*)item)->rect();
- } else br = item->boundingRect();
+ } else br = item->sceneBoundingRect();
int width = (int) br.width();
int newPos = (int)((m_frameWidth - width) / 2);
item->setPos(newPos, item->pos().y());
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
- QGraphicsItem *item = l[0];
+ QGraphicsItem *item = l.at(0);
QRectF br;
- if (item->type() == 3) {
+ if (item->type() == RECTITEM) {
br = ((QGraphicsRectItem*)item)->rect();
- } else br = item->boundingRect();
+ } else br = item->sceneBoundingRect();
int height = (int) br.height();
int newPos = (int)((m_frameHeight - height) / 2);
item->setPos(item->pos().x(), newPos);
void TitleWidget::setXml(QDomDocument doc)
{
m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport);
+ m_transformations.clear();
+ QList <QGraphicsItem *> items = graphicsView->scene()->items();
+ const double PI = 4.0 * atan(1.0);
+ for (int i = 0; i < items.count(); i++) {
+ QTransform t = items.at(i)->transform();
+ Transform x;
+ x.scalex = t.m11();
+ x.scaley = t.m22();
+ x.rotate = 180. / PI * atan2(-t.m21(), t.m11());
+ m_transformations[items.at(i)] = x;
+ }
// mbd: Update the GUI color selectors to match the stuff from the loaded document
QColor background_color = m_titledocument.getBackgroundColor();
horizontalSlider->blockSignals(true);