t->setTextInteractionFlags(Qt::NoTextInteraction);
setCursor(Qt::ClosedHandCursor);
} else if (item->type() == 3 || item->type() == 13 || item->type() == 7) {
- QRectF r = item->boundingRect();
+ QRectF r;
+ if (m_selectedItem->type() == 3) {
+ r = ((QGraphicsRectItem*)m_selectedItem)->rect();
+ } else r = m_selectedItem->boundingRect();
+
r.translate(item->scenePos());
if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
resizeMode = TopLeft;
if (m_selectedItem && e->buttons() & Qt::LeftButton) {
if (m_selectedItem->type() == 3 || m_selectedItem->type() == 13 || m_selectedItem->type() == 7) {
- QRectF newrect = m_selectedItem->boundingRect();
+ QRectF newrect;
+ if (m_selectedItem->type() == 3) {
+ newrect = ((QGraphicsRectItem*)m_selectedItem)->rect();
+ } else newrect = m_selectedItem->boundingRect();
+
QPointF newpoint = e->scenePos();
//newpoint -= m_selectedItem->scenePos();
switch (resizeMode) {
m_selectedItem->moveBy(diff.x(), diff.y());
break;
}
- if (m_selectedItem->type() == 3) {
+ if (m_selectedItem->type() == 3 && resizeMode != NoResize) {
QGraphicsRectItem *gi = (QGraphicsRectItem*)m_selectedItem;
gi->setRect(newrect);
}
setCursor(Qt::OpenHandCursor);
break;
} else if (g->type() == 3 && g->zValue() > -1000) {
- QRectF r = g->boundingRect();
+ QRectF r = ((QGraphicsRectItem*)g)->rect();
r.translate(g->scenePos());
itemFound = true;
if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
#include <KLocale>
#include <KFileDialog>
#include <KIO/NetAccess>
-
+#include <KApplication>
#include "kdenlivedoc.h"
#include "docclipbase.h"
void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
QString titlesFolder = projectFolder().path() + "/titles/";
KStandardDirs::makeDir(titlesFolder);
- TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, 0);
+ TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, kapp->activeWindow());
if (dia_ui->exec() == QDialog::Accepted) {
QString titleName = "title";
int counter = 0;
}
void KdenliveDoc::editTextClip(QString path, int id) {
- TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, 0);
+ TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, kapp->activeWindow());
if (dia_ui->exec() == QDialog::Accepted) {
QPixmap pix = dia_ui->renderedPixmap();
pix.save(path + ".png");
connect(zValue, SIGNAL(valueChanged(int)), this, SLOT(zIndexChanged(int)));
connect(itemzoom, SIGNAL(valueChanged(int)), this, SLOT(itemScaled(int)));
connect(itemrotate, SIGNAL(valueChanged(int)), this, SLOT(itemRotate(int)));
+ connect(itemhcenter, SIGNAL(clicked()), this, SLOT(itemHCenter()));
+ connect(itemvcenter, SIGNAL(clicked()), this, SLOT(itemVCenter()));
connect(value_x, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
connect(value_y, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
}
}
+void TitleWidget::itemHCenter() {
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1) {
+ QGraphicsItem *item = l[0];
+ QRectF br;
+ if (item->type() == 3) {
+ br = ((QGraphicsRectItem*)item)->rect();
+ } else br = item->boundingRect();
+ int width = (int) br.width();
+ int newPos = (int)((m_frameWidth - width) / 2);
+ item->setPos(newPos, item->pos().y());
+ }
+}
+
+void TitleWidget::itemVCenter() {
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1) {
+ QGraphicsItem *item = l[0];
+ QRectF br;
+ if (item->type() == 3) {
+ br = ((QGraphicsRectItem*)item)->rect();
+ } else br = item->boundingRect();
+ int height = (int) br.height();
+ int newPos = (int)((m_frameHeight - height) / 2);
+ item->setPos(item->pos().x(), newPos);
+ }
+}
void TitleWidget::setupViewports() {
double aspect_ratio = 4.0 / 3.0;//read from project
void zIndexChanged(int);
void itemScaled(int);
void itemRotate(int);
+ void itemHCenter();
+ void itemVCenter();
void saveTitle(KUrl url = KUrl());
void loadTitle();
QPixmap renderedPixmap();
</sizepolicy>
</property>
<property name="windowTitle" >
- <string>Dialog</string>
+ <string>Title Clip</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="2" column="1" colspan="8" >
<widget class="QGraphicsView" name="graphicsView" />
<widget class="QToolBox" name="toolBox" >
<property name="currentIndex" >
- <number>1</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="BasicOperations" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>309</width>
- <height>140</height>
+ <width>227</width>
+ <height>154</height>
</rect>
</property>
<attribute name="label" >
<string>BasicOperations</string>
</attribute>
<layout class="QGridLayout" >
- <item row="0" column="0" >
+ <item row="2" column="0" colspan="3" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
</item>
</layout>
</item>
+ <item row="0" column="1" >
+ <widget class="QToolButton" name="itemvcenter" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QToolButton" name="itemhcenter" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="Background" >
<rect>
<x>0</x>
<y>0</y>
- <width>309</width>
- <height>140</height>
+ <width>227</width>
+ <height>154</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>273</width>
- <height>224</height>
+ <width>229</width>
+ <height>212</height>
</rect>
</property>
<attribute name="label" >