d.setWindowTitle(tr("Create Countdown Clip"));
view.font->setValue(height);
}
-
+
// Set single file mode. Default seems to be File::ExistingOnly.
view.path->setMode(KFile::File);
QRectF br = sceneBoundingRect();
double maxw = br.width() / m_cropDuration.frames(m_fps);
double maxh = br.height() / 100.0 * m_keyframeFactor;
- update(br.x() + maxw * (m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
+ update(br.x() + maxw *(m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
m_selectedKeyframe = m_editedKeyframe;
- update(br.x() + maxw * (m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
+ update(br.x() + maxw *(m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
}
int AbstractClipItem::selectedKeyFramePos() const
if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
qreal value = m_timeLine->currentValue();
txtBounding.setWidth(txtBounding.width() * value);
- markerBrush.setColor(QColor(50 + 200 * (1.0 - value), 50, 50, 100 + 50 * value));
+ markerBrush.setColor(QColor(50 + 200 *(1.0 - value), 50, 50, 100 + 50 * value));
} else markerBrush.setColor(QColor(50, 50, 50, 150));
painter->setBrush(markerBrush);
painter->setPen(Qt::NoPen);
//kDebug() << "// PREP AUDIO THMB FRMO : scale:" << pixelForOneFrame<< ", from: " << startpixel << ", to: " << endpixel;
//if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
- for (int startCache = startpixel - startpixel % 100;startCache < endpixel;startCache += 100) {
+ for (int startCache = startpixel - startpixel % 100; startCache < endpixel; startCache += 100) {
//kDebug() << "creating " << startCache;
//if (framePixelWidth!=pixelForOneFrame ||
if (m_framePixelWidth == pixelForOneFrame && m_audioThumbCachePic.contains(startCache))
int channelHeight = m_audioThumbCachePic[startCache].height() / channels;
- for (int i = 0;i < channels;i++) {
+ for (int i = 0; i < channels; i++) {
positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
}
- for (int samples = 0;samples <= 100;samples++) {
+ for (int samples = 0; samples <= 100; samples++) {
double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
int sample = (int)((frame - (int)(frame)) * 20); // AUDIO_FRAME_SIZE
if (frame < 0 || sample < 0 || sample > 19)
continue;
QMap<int, QByteArray> frame_channel_data = baseClip()->m_audioFrameCache[(int)frame];
- for (int channel = 0;channel < channels && frame_channel_data[channel].size() > 0;channel++) {
+ for (int channel = 0; channel < channels && frame_channel_data[channel].size() > 0; channel++) {
int y = channelHeight * channel + channelHeight / 2;
int delta = (int)(frame_channel_data[channel][sample] - 127 / 2) * channelHeight / 64;
negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
}
}
- for (int channel = 0;channel < channels ;channel++)
+ for (int channel = 0; channel < channels ; channel++)
if (fullAreaDraw && samples == 100) {
positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
pixpainter.setPen(QPen(QColor(0, 0, 0)));
pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
- for (int i = 0;i < channels;i++) {
+ for (int i = 0; i < channels; i++) {
if (fullAreaDraw) {
//pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
QTextStream txtNeu(&neu);
if (values.size() > 0)
txtNeu << (int)values[0].toDouble();
- for (int i = 0;i < separators.size() && i + 1 < values.size();i++) {
+ for (int i = 0; i < separators.size() && i + 1 < values.size(); i++) {
txtNeu << separators[i];
txtNeu << (int)(values[i+1].toDouble());
}
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- m_selectionGroup->moveBy(offset.frames(m_document->fps()), trackOffset * (qreal) m_tracksHeight);
+ m_selectionGroup->moveBy(offset.frames(m_document->fps()), trackOffset *(qreal) m_tracksHeight);
kDebug() << "%% GRP NEW POS: " << m_selectionGroup->scenePos().x();
QColor lockedColor = scheme.background(KColorScheme::NegativeBackground).color();
QColor audioColor = palette().alternateBase().color();
QColor base = scheme.background(KColorScheme::NormalBackground).color();
- for (uint i = 0; i < max;i++) {
+ for (uint i = 0; i < max; i++) {
if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(lockedColor));
else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(audioColor));
- painter->drawLine(r.left(), m_tracksHeight * (i + 1), r.right(), m_tracksHeight * (i + 1));
+ painter->drawLine(r.left(), m_tracksHeight *(i + 1), r.right(), m_tracksHeight *(i + 1));
}
int lowerLimit = m_tracksHeight * m_document->tracksCount() + 1;
if (height() > lowerLimit)
tracksMax = qMax(tracksinfo.count(), tracksMax);
tracksMax = qMax(1, tracksMax); // Force existance of one track
if (playlists.count() - 1 < tracksMax ||
- tracks.count() - 1 < tracksMax ||
- tracksinfo.count() < tracksMax) {
+ tracks.count() - 1 < tracksMax ||
+ tracksinfo.count() < tracksMax) {
m_modified = true;
int difference;
if (playlists.count() - 1 < tracksMax) {
}
}
} else for (int i = 0; i < max; i++) {
- QDomNode n = playlists.at(i);
- westley.insertBefore(n, QDomNode());
- QDomElement pl = n.toElement();
- QDomElement track = m_doc.createElement("track");
- QString trackType = pl.attribute("hide");
- if (!trackType.isEmpty())
- track.setAttribute("hide", trackType);
- QString playlist_id = pl.attribute("id");
- if (playlist_id.isEmpty()) {
- playlist_id = "black_track";
- pl.setAttribute("id", playlist_id);
- }
- track.setAttribute("producer", playlist_id);
- //tractor.appendChild(track);
+ QDomNode n = playlists.at(i);
+ westley.insertBefore(n, QDomNode());
+ QDomElement pl = n.toElement();
+ QDomElement track = m_doc.createElement("track");
+ QString trackType = pl.attribute("hide");
+ if (!trackType.isEmpty())
+ track.setAttribute("hide", trackType);
+ QString playlist_id = pl.attribute("id");
+ if (playlist_id.isEmpty()) {
+ playlist_id = "black_track";
+ pl.setAttribute("id", playlist_id);
+ }
+ track.setAttribute("producer", playlist_id);
+ //tractor.appendChild(track);
#define KEEP_TRACK_ORDER 1
#ifdef KEEP_TRACK_ORDER
- tractor.insertAfter(track, QDomNode());
+ tractor.insertAfter(track, QDomNode());
#else
- // Insert the new track in an order that hopefully matches the 3 video, then 2 audio tracks of Kdenlive 0.7.0
- // insertion sort - O( tracks*tracks )
- // Note, this breaks _all_ transitions - but you can move them up and down afterwards.
- QDomElement tractor_elem = tractor.toElement();
- if (! tractor_elem.isNull()) {
- QDomNodeList tracks = tractor_elem.elementsByTagName("track");
- int size = tracks.size();
- if (size == 0) {
- tractor.insertAfter(track, QDomNode());
- } else {
- bool inserted = false;
- for (int i = 0; i < size; ++i) {
- QDomElement track_elem = tracks.at(i).toElement();
- if (track_elem.isNull()) {
- tractor.insertAfter(track, QDomNode());
- inserted = true;
- break;
- } else {
- kDebug() << "playlist_id: " << playlist_id << " producer:" << track_elem.attribute("producer");
- if (playlist_id < track_elem.attribute("producer")) {
- tractor.insertBefore(track, track_elem);
+ // Insert the new track in an order that hopefully matches the 3 video, then 2 audio tracks of Kdenlive 0.7.0
+ // insertion sort - O( tracks*tracks )
+ // Note, this breaks _all_ transitions - but you can move them up and down afterwards.
+ QDomElement tractor_elem = tractor.toElement();
+ if (! tractor_elem.isNull()) {
+ QDomNodeList tracks = tractor_elem.elementsByTagName("track");
+ int size = tracks.size();
+ if (size == 0) {
+ tractor.insertAfter(track, QDomNode());
+ } else {
+ bool inserted = false;
+ for (int i = 0; i < size; ++i) {
+ QDomElement track_elem = tracks.at(i).toElement();
+ if (track_elem.isNull()) {
+ tractor.insertAfter(track, QDomNode());
inserted = true;
break;
+ } else {
+ kDebug() << "playlist_id: " << playlist_id << " producer:" << track_elem.attribute("producer");
+ if (playlist_id < track_elem.attribute("producer")) {
+ tractor.insertBefore(track, track_elem);
+ inserted = true;
+ break;
+ }
}
}
+ // Reach here, no insertion, insert last
+ if (!inserted) {
+ tractor.insertAfter(track, QDomNode());
+ }
}
- // Reach here, no insertion, insert last
- if (!inserted) {
- tractor.insertAfter(track, QDomNode());
- }
+ } else {
+ kWarning() << "tractor was not a QDomElement";
+ tractor.insertAfter(track, QDomNode());
}
- } else {
- kWarning() << "tractor was not a QDomElement";
- tractor.insertAfter(track, QDomNode());
- }
#endif
- }
+ }
tractor.removeChild(multitrack);
// audio track mixing transitions should not be added to track view, so add required attribute
{
m_frameSize = p;
QDomNodeList namenode = m_params.elementsByTagName("parameter");
- for (int i = 0;i < namenode.count() ;i++) {
+ for (int i = 0; i < namenode.count() ; i++) {
QDomNode pa = namenode.item(i);
QDomNode na = pa.firstChildElement("name");
QString type = pa.attributes().namedItem("type").nodeValue();
const int maxFrame = e.attribute("end").toInt();
- for (int i = 0;i < namenode.count() ;i++) {
+ for (int i = 0; i < namenode.count() ; i++) {
kDebug() << "in form";
QDomElement pa = namenode.item(i).toElement();
QDomNode na = pa.firstChildElement("name");
if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems;
//lsval->list->addItems(listitems);
lsval->list->setIconSize(QSize(30, 30));
- for (int i = 0;i < listitems.count();i++) {
+ for (int i = 0; i < listitems.count(); i++) {
lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
QString entry = listitems.at(i);
if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
QDomElement oldparam = m_params.cloneNode().toElement();
QDomNodeList namenode = m_params.elementsByTagName("parameter");
- for (int i = 0;i < namenode.count() ;i++) {
+ for (int i = 0; i < namenode.count() ; i++) {
QDomNode pa = namenode.item(i);
QDomNode na = pa.firstChildElement("name");
QString type = pa.attributes().namedItem("type").nodeValue();
KIcon audioIcon("kdenlive-show-audio");
QListWidgetItem* item;
- for (int i = 0;i < m_clipref->effectsCount();i++) {
+ for (int i = 0; i < m_clipref->effectsCount(); i++) {
QDomElement d = m_clipref->effectAt(i);
QDomNode namenode = d.elementsByTagName("name").item(0);
*/
int determinant;
switch (m_resizeMode) {
- case TopLeft:
- determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
- if (determinant < 0) {
- determinant = (bottomLeft.x() - newpoint.x()) * (bottomRight.y() - newpoint.y()) - (bottomLeft.y() - newpoint.y()) * (bottomRight.x() - newpoint.x());
- if (determinant < 0) {
- // resizePoint is not working for some reason
- newrect.setBottomRight(QPointF(newrect.width() - (transform.inverted().m11() * resizePoint.x() + transform.inverted().m21() * resizePoint.y() + transform.inverted().m31()), newrect.bottom() - (transform.inverted().m22() * resizePoint.y() + transform.inverted().m12() * resizePoint.x() + transform.inverted().m32())));
- m_selectedItem->setPos(resizePoint + itemOrigin);
- }
- }
- break;
- case BottomLeft:
- determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
- if (determinant < 0) {
- determinant = (topRight.x() - newpoint.x()) * (topLeft.y() - newpoint.y()) - (topRight.y() - newpoint.y()) * (topLeft.x() - newpoint.x());
- if (determinant < 0) {
- newrect.setBottomRight(QPointF(newrect.width() - resizePoint.x(), resizePoint.y()));
- m_selectedItem->setPos(QPointF(transform.m11() * resizePoint.x() + transform.m21() * (newrect.bottom() - resizePoint.y()) + transform.m31() + itemOrigin.x(), transform.m22() * (newrect.bottom() - resizePoint.y()) + transform.m12() * resizePoint.x() + transform.m32() + itemOrigin.y()));
- }
- }
- break;
- case TopRight:
- determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
- if (determinant < 0) {
- determinant = (bottomLeft.x() - newpoint.x()) * (bottomRight.y() - newpoint.y()) - (bottomLeft.y() - newpoint.y()) * (bottomRight.x() - newpoint.x());
- if (determinant < 0) {
- newrect.setBottomRight(QPointF(resizePoint.x(), newrect.bottom() - resizePoint.y()));
- m_selectedItem->setPos(QPointF(transform.m11() * (newrect.width() - resizePoint.x()) + transform.m21() * resizePoint.y() + transform.m31() + itemOrigin.x(), transform.m22() * resizePoint.y() + transform.m12() * (newrect.width() - resizePoint.x()) + transform.m32() + itemOrigin.y()));
- }
- }
- break;
- case BottomRight:
- determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
+ case TopLeft:
+ determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
+ if (determinant < 0) {
+ determinant = (bottomLeft.x() - newpoint.x()) * (bottomRight.y() - newpoint.y()) - (bottomLeft.y() - newpoint.y()) * (bottomRight.x() - newpoint.x());
if (determinant < 0) {
- determinant = (topRight.x() - newpoint.x()) * (topLeft.y() - newpoint.y()) - (topRight.y() - newpoint.y()) * (topLeft.x() - newpoint.x());
- if (determinant < 0)
- newrect.setBottomRight(resizePoint);
+ // resizePoint is not working for some reason
+ newrect.setBottomRight(QPointF(newrect.width() - (transform.inverted().m11() * resizePoint.x() + transform.inverted().m21() * resizePoint.y() + transform.inverted().m31()), newrect.bottom() - (transform.inverted().m22() * resizePoint.y() + transform.inverted().m12() * resizePoint.x() + transform.inverted().m32())));
+ m_selectedItem->setPos(resizePoint + itemOrigin);
}
- break;
- case Left:
- determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
+ }
+ break;
+ case BottomLeft:
+ determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
+ if (determinant < 0) {
+ determinant = (topRight.x() - newpoint.x()) * (topLeft.y() - newpoint.y()) - (topRight.y() - newpoint.y()) * (topLeft.x() - newpoint.x());
if (determinant < 0) {
- newrect.setRight(newrect.width() - resizePoint.x());
- m_selectedItem->setPos(QPointF(transform.m11() * resizePoint.x() + transform.m31() + itemOrigin.x(), transform.m12() * resizePoint.x() + transform.m32() + itemOrigin.y()));
+ newrect.setBottomRight(QPointF(newrect.width() - resizePoint.x(), resizePoint.y()));
+ m_selectedItem->setPos(QPointF(transform.m11() * resizePoint.x() + transform.m21() *(newrect.bottom() - resizePoint.y()) + transform.m31() + itemOrigin.x(), transform.m22() *(newrect.bottom() - resizePoint.y()) + transform.m12() * resizePoint.x() + transform.m32() + itemOrigin.y()));
}
- break;
- case Right:
- determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
- if (determinant < 0)
- newrect.setRight(resizePoint.x());
- break;
- case Up:
+ }
+ break;
+ case TopRight:
+ determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
+ if (determinant < 0) {
determinant = (bottomLeft.x() - newpoint.x()) * (bottomRight.y() - newpoint.y()) - (bottomLeft.y() - newpoint.y()) * (bottomRight.x() - newpoint.x());
if (determinant < 0) {
- newrect.setBottom(newrect.bottom() - resizePoint.y());
- m_selectedItem->setPos(QPointF(transform.m21() * resizePoint.y() + transform.m31() + itemOrigin.x(), transform.m22() * resizePoint.y() + transform.m32() + itemOrigin.y()));
+ newrect.setBottomRight(QPointF(resizePoint.x(), newrect.bottom() - resizePoint.y()));
+ m_selectedItem->setPos(QPointF(transform.m11() *(newrect.width() - resizePoint.x()) + transform.m21() * resizePoint.y() + transform.m31() + itemOrigin.x(), transform.m22() * resizePoint.y() + transform.m12() *(newrect.width() - resizePoint.x()) + transform.m32() + itemOrigin.y()));
}
- break;
- case Down:
+ }
+ break;
+ case BottomRight:
+ determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
+ if (determinant < 0) {
determinant = (topRight.x() - newpoint.x()) * (topLeft.y() - newpoint.y()) - (topRight.y() - newpoint.y()) * (topLeft.x() - newpoint.x());
if (determinant < 0)
- newrect.setBottom(resizePoint.y());
- break;
- default:
- QPointF diff = e->scenePos() - m_sceneClickPoint;
- m_sceneClickPoint = e->scenePos();
- m_selectedItem->moveBy(diff.x(), diff.y());
- break;
+ newrect.setBottomRight(resizePoint);
+ }
+ break;
+ case Left:
+ determinant = (bottomRight.x() - newpoint.x()) * (topRight.y() - newpoint.y()) - (bottomRight.y() - newpoint.y()) * (topRight.x() - newpoint.x());
+ if (determinant < 0) {
+ newrect.setRight(newrect.width() - resizePoint.x());
+ m_selectedItem->setPos(QPointF(transform.m11() * resizePoint.x() + transform.m31() + itemOrigin.x(), transform.m12() * resizePoint.x() + transform.m32() + itemOrigin.y()));
+ }
+ break;
+ case Right:
+ determinant = (topLeft.x() - newpoint.x()) * (bottomLeft.y() - newpoint.y()) - (topLeft.y() - newpoint.y()) * (bottomLeft.x() - newpoint.x());
+ if (determinant < 0)
+ newrect.setRight(resizePoint.x());
+ break;
+ case Up:
+ determinant = (bottomLeft.x() - newpoint.x()) * (bottomRight.y() - newpoint.y()) - (bottomLeft.y() - newpoint.y()) * (bottomRight.x() - newpoint.x());
+ if (determinant < 0) {
+ newrect.setBottom(newrect.bottom() - resizePoint.y());
+ m_selectedItem->setPos(QPointF(transform.m21() * resizePoint.y() + transform.m31() + itemOrigin.x(), transform.m22() * resizePoint.y() + transform.m32() + itemOrigin.y()));
+ }
+ break;
+ case Down:
+ determinant = (topRight.x() - newpoint.x()) * (topLeft.y() - newpoint.y()) - (topRight.y() - newpoint.y()) * (topLeft.x() - newpoint.x());
+ if (determinant < 0)
+ newrect.setBottom(resizePoint.y());
+ break;
+ default:
+ QPointF diff = e->scenePos() - m_sceneClickPoint;
+ m_sceneClickPoint = e->scenePos();
+ m_selectedItem->moveBy(diff.x(), diff.y());
+ break;
}
if (m_selectedItem->type() == 3 && m_resizeMode != NoResize) {
QGraphicsRectItem *gi = (QGraphicsRectItem*)m_selectedItem;
eff.appendChild(desc);
Mlt::Properties param_props((mlt_properties) metadata->get_data("parameters"));
- for (int j = 0; param_props.is_valid() && j < param_props.count();j++) {
+ for (int j = 0; param_props.is_valid() && j < param_props.count(); j++) {
QDomElement params = ret.createElement("parameter");
Mlt::Properties paramdesc((mlt_properties) param_props.get_data(param_props.get_name(j)));
desc.appendChild(ret.createTextNode(metadata->get("description")));
Mlt::Properties param_props((mlt_properties) metadata->get_data("parameters"));
- for (int j = 0; param_props.is_valid() && j < param_props.count();j++) {
+ for (int j = 0; param_props.is_valid() && j < param_props.count(); j++) {
QDomElement params = ret.createElement("parameter");
Mlt::Properties paramdesc((mlt_properties) param_props.get_data(param_props.get_name(j)));
m_configSdl.kcfg_audio_driver->addItem(i18n("ARTS daemon"), "artsc");
if (!KdenliveSettings::audiodrivername().isEmpty())
- for (int i = 1;i < m_configSdl.kcfg_audio_driver->count(); i++) {
+ for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) {
if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) {
m_configSdl.kcfg_audio_driver->setCurrentIndex(i);
KdenliveSettings::setAudio_driver((uint) i);
int last_val = 0;
int val = 0;
kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
- for (int z = (int) m_frame;z < (int)(m_frame + m_frameLength) && m_producer.is_valid();z++) {
+ for (int z = (int) m_frame; z < (int)(m_frame + m_frameLength) && m_producer.is_valid(); z++) {
if (stop_me) break;
val = (int)((z - m_frame) / (m_frame + m_frameLength) * 100.0);
if (last_val != val && val > 1) {
qint16* m_pcm = mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples);
- for (int c = 0;c < m_channels;c++) {
+ for (int c = 0; c < m_channels; c++) {
QByteArray m_array;
m_array.resize(m_arrayWidth);
for (int i = 0; i < m_array.size(); i++) {
return;
}
kDebug() << "reading audio thumbs from file";
- for (int z = (int) frame;z < (int)(frame + frameLength);z++) {
- for (int c = 0;c < m_channels;c++) {
+ for (int z = (int) frame; z < (int)(frame + frameLength); z++) {
+ for (int c = 0; c < m_channels; c++) {
QByteArray m_array(arrayWidth, '\x00');
for (int i = 0; i < arrayWidth; i++)
m_array[i] = channelarray[z*arrayWidth*m_channels + c*arrayWidth + i];
defaults = pa.attribute("default").split(";");
QStringList maxv = pa.attribute("max").split(";");
QStringList minv = pa.attribute("min").split(";");
- for (int i = 0;i < maxv.size() && i < minv.size();i++) {
+ for (int i = 0; i < maxv.size() && i < minv.size(); i++) {
if (m_max_y < maxv[i].toInt()) m_max_y = maxv[i].toInt();
if (m_min_y > minv[i].toInt()) m_min_y = minv[i].toInt();
}
- for (int i = 0;i < m_parameterNameList.count();i++) {
+ for (int i = 0; i < m_parameterNameList.count(); i++) {
KPlotObject *plot = new KPlotObject(m_colors[m_plotobjects.size()%m_colors.size()]);
plot->setShowLines(true);
if (!m_stretchFactors.contains(i) && i < maxv.size()) {
QTextStream txtstr(¶mlist);
QDomNode pa = namenode.item(0);
if (namenode.count() > 0) {
- for (int i = 0;i < plotobjs.count();i++) {
+ for (int i = 0; i < plotobjs.count(); i++) {
QList<KPlotPoint*> points = plotobjs[i]->points();
foreach(const KPlotPoint *o, points) {
txtstr << (int)o->y() ;
int i = 0;
foreach(KPlotObject *o, plotObjects()) {
QList<KPlotPoint*> points = o->points();
- for (int p = 0;p < points.size();p++) {
+ for (int p = 0; p < points.size(); p++) {
if (points[p] == m_movepoint && (m_activeIndexPlot == -1 || m_activeIndexPlot == i)) {
QPoint delta = event->pos() - m_oldmousepoint;
double newy = m_movepoint->y() - delta.y() * dataRect().height() / pixRect().height();
Mlt::Filter *dup = new Mlt::Filter(*m_mltProfile, filter->get("mlt_service"));
if (dup && dup->is_valid()) {
Mlt::Properties entries(filter->get_properties());
- for (int i = 0;i < entries.count();i++) {
+ for (int i = 0; i < entries.count(); i++) {
dup->set(entries.get_name(i), entries.get(i));
}
dupService.attach(*dup);
{
QDomNodeList attribs = xml.elementsByTagName("parameter");
QMap<QString, QString> map;
- for (int i = 0;i < attribs.count();i++) {
+ for (int i = 0; i < attribs.count(); i++) {
QDomElement e = attribs.item(i).toElement();
QString name = e.attribute("name");
//kDebug()<<"-- TRANSITION PARAM: "<<name<<" = "<< e.attribute("name")<<" / " << e.attribute("value");
if (values.size() > 0)
txtNeu << (int)values[0].toDouble();
int i = 0;
- for (i = 0;i < separators.size() && i + 1 < values.size();i++) {
+ for (i = 0; i < separators.size() && i + 1 < values.size(); i++) {
txtNeu << separators[i];
txtNeu << (int)(values[i+1].toDouble());
}
content.setAttribute("font-italic", font.italic());
content.setAttribute("font-underline", font.underline());
content.setAttribute("font-color", colorToString(t->defaultTextColor()));
-
- // Only save when necessary.
- if (t->data(OriginXLeft).toInt() == AxisInverted) {
- content.setAttribute("kdenlive-axis-x-inverted", t->data(OriginXLeft).toInt());
- }
- if (t->data(OriginYTop).toInt() == AxisInverted) {
- content.setAttribute("kdenlive-axis-y-inverted", t->data(OriginYTop).toInt());
- }
+
+ // Only save when necessary.
+ if (t->data(OriginXLeft).toInt() == AxisInverted) {
+ content.setAttribute("kdenlive-axis-x-inverted", t->data(OriginXLeft).toInt());
+ }
+ if (t->data(OriginYTop).toInt() == AxisInverted) {
+ content.setAttribute("kdenlive-axis-y-inverted", t->data(OriginYTop).toInt());
+ }
if (t->textWidth() != -1) {
content.setAttribute("alignment", t->textCursor().blockFormat().alignment());
}
if (titles.size()) {
QDomNodeList items = titles.item(0).childNodes();
- for (int i = 0;i < items.count();i++) {
+ for (int i = 0; i < items.count(); i++) {
QGraphicsItem *gitem = NULL;
kDebug() << items.item(i).attributes().namedItem("type").nodeValue();
int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
cur.clearSelection();
txt->setTextCursor(cur);
}
-
- if (!txtProperties.namedItem("kdenlive-axis-x-inverted").isNull()) {
- txt->setData(OriginXLeft, txtProperties.namedItem("kdenlive-axis-x-inverted").nodeValue().toInt());
- }
- if (!txtProperties.namedItem("kdenlive-axis-y-inverted").isNull()) {
- txt->setData(OriginYTop, txtProperties.namedItem("kdenlive-axis-y-inverted").nodeValue().toInt());
- }
+
+ if (!txtProperties.namedItem("kdenlive-axis-x-inverted").isNull()) {
+ txt->setData(OriginXLeft, txtProperties.namedItem("kdenlive-axis-x-inverted").nodeValue().toInt());
+ }
+ if (!txtProperties.namedItem("kdenlive-axis-y-inverted").isNull()) {
+ txt->setData(OriginYTop, txtProperties.namedItem("kdenlive-axis-y-inverted").nodeValue().toInt());
+ }
gitem = txt;
} else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsRectItem") {
class TitleDocument
{
-
+
public:
TitleDocument();
void setScene(QGraphicsScene* scene);
m_endViewport(NULL),
m_render(render),
m_count(0),
- m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
+ m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
m_projectPath(projectPath)
{
setupUi(this);
connect(itemhcenter, SIGNAL(clicked()), this, SLOT(itemHCenter()));
connect(itemvcenter, SIGNAL(clicked()), this, SLOT(itemVCenter()));
- connect(origin_x_left, SIGNAL(clicked()), this, SLOT(slotOriginXClicked()));
- connect(origin_y_top, SIGNAL(clicked()), this, SLOT(slotOriginYClicked()));
+ connect(origin_x_left, SIGNAL(clicked()), this, SLOT(slotOriginXClicked()));
+ connect(origin_y_top, SIGNAL(clicked()), this, SLOT(slotOriginYClicked()));
connect(value_x, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
connect(value_y, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
connect(buttonAlignRight, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
connect(buttonAlignCenter, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
connect(buttonAlignNone, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
- connect(buttonInsertUnicode, SIGNAL(clicked()), this, SLOT(slotInsertUnicode()));
- connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
+ connect(buttonInsertUnicode, SIGNAL(clicked()), this, SLOT(slotInsertUnicode()));
+ connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
connect(displayBg, SIGNAL(stateChanged(int)), this, SLOT(displayBackgroundFrame()));
// mbd
buttonAlignCenter->setIcon(KIcon("format-justify-center"));
buttonAlignLeft->setIcon(KIcon("format-justify-left"));
buttonAlignRight->setIcon(KIcon("format-justify-right"));
- buttonAlignNone->setIcon(KIcon("kdenlive-align-none"));
- buttonInsertUnicode->setIcon(KIcon("kdenlive-insert-unicode"));
+ buttonAlignNone->setIcon(KIcon("kdenlive-align-none"));
+ buttonInsertUnicode->setIcon(KIcon("kdenlive-insert-unicode"));
buttonAlignNone->setToolTip(i18n("No alignment"));
buttonAlignRight->setToolTip(i18n("Align right"));
buttonAlignLeft->setToolTip(i18n("Align left"));
buttonAlignCenter->setToolTip(i18n("Align center"));
- buttonInsertUnicode->setToolTip(i18n("Insert Unicode character (Shift+Ctrl+U)"));
- buttonInsertUnicode->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_U);
- origin_x_left->setToolTip(i18n("Invert x axis and change 0 point"));
- origin_y_top->setToolTip(i18n("Invert y axis and change 0 point"));
- rectBColor->setToolTip(i18n("Select fill color"));
- rectFColor->setToolTip(i18n("Select border color"));
- rectBAlpha->setToolTip(i18n("Fill transparency"));
- rectFAlpha->setToolTip(i18n("Border transparency"));
- zoom_slider->setToolTip(i18n("Zoom"));
- buttonRealSize->setToolTip(i18n("Original size (1:1)"));
- buttonFitZoom->setToolTip(i18n("Fit zoom"));
- kcolorbutton->setToolTip(i18n("Select background color"));
- horizontalSlider->setToolTip(i18n("Background Transparency"));
+ buttonInsertUnicode->setToolTip(i18n("Insert Unicode character (Shift+Ctrl+U)"));
+ buttonInsertUnicode->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_U);
+ origin_x_left->setToolTip(i18n("Invert x axis and change 0 point"));
+ origin_y_top->setToolTip(i18n("Invert y axis and change 0 point"));
+ rectBColor->setToolTip(i18n("Select fill color"));
+ rectFColor->setToolTip(i18n("Select border color"));
+ rectBAlpha->setToolTip(i18n("Fill transparency"));
+ rectFAlpha->setToolTip(i18n("Border transparency"));
+ zoom_slider->setToolTip(i18n("Zoom"));
+ buttonRealSize->setToolTip(i18n("Original size (1:1)"));
+ buttonFitZoom->setToolTip(i18n("Fit zoom"));
+ kcolorbutton->setToolTip(i18n("Select background color"));
+ horizontalSlider->setToolTip(i18n("Background Transparency"));
itemhcenter->setIcon(KIcon("kdenlive-align-hor"));
itemhcenter->setToolTip(i18n("Align item horizontally"));
m_buttonRect = m_toolbar->addAction(KIcon("kdenlive-insert-rect"), i18n("Add Rectangle (Alt+R)"));
m_buttonRect->setCheckable(true);
- m_buttonRect->setShortcut(Qt::ALT + Qt::Key_R);
+ m_buttonRect->setShortcut(Qt::ALT + Qt::Key_R);
connect(m_buttonRect, SIGNAL(triggered()), this, SLOT(slotRectTool()));
m_buttonText = m_toolbar->addAction(KIcon("insert-text"), i18n("Add Text (Alt+T)"));
m_buttonText->setCheckable(true);
- m_buttonText->setShortcut(Qt::ALT + Qt::Key_T);
+ m_buttonText->setShortcut(Qt::ALT + Qt::Key_T);
connect(m_buttonText, SIGNAL(triggered()), this, SLOT(slotTextTool()));
m_buttonImage = m_toolbar->addAction(KIcon("insert-image"), i18n("Add Image (Alt+I)"));
m_buttonImage->setCheckable(false);
- m_buttonImage->setShortcut(Qt::ALT + Qt::Key_I);
+ m_buttonImage->setShortcut(Qt::ALT + Qt::Key_I);
connect(m_buttonImage, SIGNAL(triggered()), this, SLOT(slotImageTool()));
m_buttonCursor = m_toolbar->addAction(KIcon("transform-move"), i18n("Selection Tool (Alt+S)"));
m_buttonCursor->setCheckable(true);
- m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
+ m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
connect(m_buttonCursor, SIGNAL(triggered()), this, SLOT(slotSelectTool()));
m_buttonLoad = m_toolbar->addAction(KIcon("document-open"), i18n("Open Document"));
m_buttonLoad->setCheckable(false);
- m_buttonLoad->setShortcut(Qt::CTRL + Qt::Key_O);
+ m_buttonLoad->setShortcut(Qt::CTRL + Qt::Key_O);
connect(m_buttonLoad, SIGNAL(triggered()), this, SLOT(loadTitle()));
m_buttonSave = m_toolbar->addAction(KIcon("document-save-as"), i18n("Save As"));
m_buttonSave->setCheckable(false);
- m_buttonSave->setShortcut(Qt::CTRL + Qt::Key_S);
+ m_buttonSave->setShortcut(Qt::CTRL + Qt::Key_S);
connect(m_buttonSave, SIGNAL(triggered()), this, SLOT(saveTitle()));
layout->addWidget(m_toolbar);
m_scene = new GraphicsSceneRectMove(this);
graphicsView->setScene(m_scene);
m_titledocument.setScene(m_scene);
- connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(slotChanged()));
+ connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(slotChanged()));
// a gradient background
/*QRadialGradient *gradient = new QRadialGradient(0, 0, 10);
delete m_buttonSave;
delete m_buttonLoad;
- delete m_unicodeDialog;
+ delete m_unicodeDialog;
delete m_frameBorder;
delete m_frameImage;
delete m_startViewport;
itemzoom->blockSignals(true);
itemrotate->blockSignals(true);
if (l.size() == 0) {
- bool blockX = !origin_x_left->signalsBlocked();
- bool blockY = !origin_y_top->signalsBlocked();
- if (blockX) origin_x_left->blockSignals(true);
- if (blockY) origin_y_top->blockSignals(true);
- origin_x_left->setChecked(false);
- origin_y_top->setChecked(false);
- updateTextOriginX();
- updateTextOriginY();
- frame_properties->setEnabled(false);
- text_properties->setEnabled(false);
- rect_properties->setEnabled(false);
- if (blockX) origin_x_left->blockSignals(false);
- if (blockY) origin_y_top->blockSignals(false);
- } else if (l.size() == 1) {
+ bool blockX = !origin_x_left->signalsBlocked();
+ bool blockY = !origin_y_top->signalsBlocked();
+ if (blockX) origin_x_left->blockSignals(true);
+ if (blockY) origin_y_top->blockSignals(true);
+ origin_x_left->setChecked(false);
+ origin_y_top->setChecked(false);
+ updateTextOriginX();
+ updateTextOriginY();
+ frame_properties->setEnabled(false);
+ text_properties->setEnabled(false);
+ rect_properties->setEnabled(false);
+ if (blockX) origin_x_left->blockSignals(false);
+ if (blockY) origin_y_top->blockSignals(false);
+ } else if (l.size() == 1) {
if (l.at(0)->type() == TEXTITEM) {
rect_properties->setHidden(true);
text_properties->setHidden(false);
buttonAlignNone->blockSignals(false);
buttonAlignCenter->blockSignals(false);
- updateAxisButtons(i);
- updateCoordinates(i);
- updateDimension(i);
+ updateAxisButtons(i);
+ updateCoordinates(i);
+ updateDimension(i);
//value_w->setValue((int) i->boundingRect().width());
//value_h->setValue((int) i->boundingRect().height());
frame_properties->setEnabled(true);
- text_properties->setEnabled(true);
- rect_properties->setEnabled(false);
+ text_properties->setEnabled(true);
+ rect_properties->setEnabled(false);
value_w->setEnabled(false);
value_h->setEnabled(false);
settingUp = false;
rectLineWidth->setValue(rec->pen().width());
- updateAxisButtons(l.at(0));
- updateCoordinates(rec);
+ updateAxisButtons(l.at(0));
+ updateCoordinates(rec);
updateDimension(rec);
- //value_w->setValue((int) rec->rect().width());
+ //value_w->setValue((int) rec->rect().width());
//value_h->setValue((int) rec->rect().height());
frame_properties->setEnabled(true);
- text_properties->setEnabled(false);
- rect_properties->setEnabled(true);
+ text_properties->setEnabled(false);
+ rect_properties->setEnabled(true);
value_w->setEnabled(true);
value_h->setEnabled(true);
} else if (l.at(0)->type() == IMAGEITEM) {
- updateCoordinates(l.at(0));
- updateDimension(l.at(0));
+ updateCoordinates(l.at(0));
+ updateDimension(l.at(0));
- frame_properties->setEnabled(true);
- text_properties->setEnabled(false);
- rect_properties->setEnabled(false);
- value_x->setEnabled(true);
- value_w->setEnabled(false);
- value_h->setEnabled(false);
+ frame_properties->setEnabled(true);
+ text_properties->setEnabled(false);
+ rect_properties->setEnabled(false);
+ value_x->setEnabled(true);
+ value_w->setEnabled(false);
+ value_h->setEnabled(false);
- } else {
+ } else {
//toolBox->setCurrentIndex(0);
frame_properties->setEnabled(false);
- text_properties->setEnabled(false);
- rect_properties->setEnabled(false);
+ text_properties->setEnabled(false);
+ rect_properties->setEnabled(false);
}
zValue->setValue((int)l.at(0)->zValue());
itemzoom->setValue((int)(m_transformations.value(l.at(0)).scalex * 100.0 + 0.5));
if (l.at(0)->type() == RECTITEM) {
//rect item
QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
- updatePosition(rec);
- rec->setRect(QRect(0, 0, value_w->value(), value_h->value()));
+ updatePosition(rec);
+ rec->setRect(QRect(0, 0, value_w->value(), value_h->value()));
} else if (l.at(0)->type() == TEXTITEM) {
//text item
updatePosition(l.at(0));
} else if (l.at(0)->type() == IMAGEITEM) {
- //image item
- updatePosition(l.at(0));
- }
+ //image item
+ updatePosition(l.at(0));
+ }
}
}
/** \brief Updates width/height int the text fields, regarding transformation matrix */
void TitleWidget::updateDimension(QGraphicsItem *i)
{
- bool blockW = !value_w->signalsBlocked();
- bool blockH = !value_h->signalsBlocked();
-
- if (blockW) value_w->blockSignals(true);
- if (blockH) value_h->blockSignals(true);
-
-
- if (i->type() == IMAGEITEM) {
- // Get multipliers for rotation/scaling
-
- /*Transform t = m_transformations.value(i);
- QRectF r = i->boundingRect();
- int width = (int) ( abs(r.width()*t.scalex * cos(t.rotate/180.0*M_PI))
- + abs(r.height()*t.scaley * sin(t.rotate/180.0*M_PI)) );
- int height = (int) ( abs(r.height()*t.scaley * cos(t.rotate/180*M_PI))
- + abs(r.width()*t.scalex * sin(t.rotate/180*M_PI)) );*/
-
- value_w->setValue(i->sceneBoundingRect().width());
- value_h->setValue(i->sceneBoundingRect().height());
- } else if (i->type() == RECTITEM) {
- QGraphicsRectItem *r = static_cast <QGraphicsRectItem *> (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);
- value_w->setValue((int) t->boundingRect().width());
- value_h->setValue((int) t->boundingRect().height());
- }
-
- if (blockW) value_w->blockSignals(false);
- if (blockH) value_h->blockSignals(false);
+ bool blockW = !value_w->signalsBlocked();
+ bool blockH = !value_h->signalsBlocked();
+
+ if (blockW) value_w->blockSignals(true);
+ if (blockH) value_h->blockSignals(true);
+
+
+ if (i->type() == IMAGEITEM) {
+ // Get multipliers for rotation/scaling
+
+ /*Transform t = m_transformations.value(i);
+ QRectF r = i->boundingRect();
+ int width = (int) ( abs(r.width()*t.scalex * cos(t.rotate/180.0*M_PI))
+ + abs(r.height()*t.scaley * sin(t.rotate/180.0*M_PI)) );
+ int height = (int) ( abs(r.height()*t.scaley * cos(t.rotate/180*M_PI))
+ + abs(r.width()*t.scalex * sin(t.rotate/180*M_PI)) );*/
+
+ value_w->setValue(i->sceneBoundingRect().width());
+ value_h->setValue(i->sceneBoundingRect().height());
+ } else if (i->type() == RECTITEM) {
+ QGraphicsRectItem *r = static_cast <QGraphicsRectItem *>(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);
+ value_w->setValue((int) t->boundingRect().width());
+ value_h->setValue((int) t->boundingRect().height());
+ }
+
+ if (blockW) value_w->blockSignals(false);
+ if (blockH) value_h->blockSignals(false);
}
/** \brief Updates the coordinates in the text fields from the item */
void TitleWidget::updateCoordinates(QGraphicsItem *i)
{
- bool blockX = !value_x->signalsBlocked();
- bool blockY = !value_y->signalsBlocked();
-
- // Block signals emitted by this method
- if (blockX) value_x->blockSignals(true);
- if (blockY) value_y->blockSignals(true);
-
- if (i->type() == TEXTITEM) {
-
- QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *> (i);
-
- // Set the correct x coordinate value
- if (origin_x_left->isChecked()) {
- // Origin (0 point) is at m_frameWidth, coordinate axis is inverted
- value_x->setValue((int) (m_frameWidth - rec->pos().x() - rec->boundingRect().width()));
- } else {
- // Origin is at 0 (default)
- value_x->setValue((int) rec->pos().x());
- }
-
- // Same for y
- if (origin_y_top->isChecked()) {
- value_y->setValue((int) (m_frameHeight - rec->pos().y() - rec->boundingRect().height()));
- } else {
- value_y->setValue((int) rec->pos().y());
- }
-
- } else if (i->type() == RECTITEM) {
-
- QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *> (i);
-
- if (origin_x_left->isChecked()) {
- // Origin (0 point) is at m_frameWidth
- value_x->setValue((int) (m_frameWidth - rec->pos().x() - rec->rect().width()));
- } else {
- // Origin is at 0 (default)
- value_x->setValue((int) rec->pos().x());
- }
-
- if (origin_y_top->isChecked()) {
- value_y->setValue((int) (m_frameHeight - rec->pos().y() - rec->rect().height()));
- } else {
- value_y->setValue((int) rec->pos().y());
- }
-
- } else if (i->type() == IMAGEITEM) {
-
- if (origin_x_left->isChecked()) {
- value_x->setValue((int) (m_frameWidth - i->pos().x() - i->sceneBoundingRect().width()));
- } else {
- value_x->setValue((int) i->pos().x());
- }
-
- if (origin_y_top->isChecked()) {
- value_y->setValue((int) (m_frameHeight - i->pos().y() - i->sceneBoundingRect().height()));
- } else {
- value_y->setValue((int) i->pos().y());
- }
-
- }
-
- // Stop blocking signals now
- if (!blockX) value_x->blockSignals(false);
- if (!blockY) value_y->blockSignals(false);
+ bool blockX = !value_x->signalsBlocked();
+ bool blockY = !value_y->signalsBlocked();
+
+ // Block signals emitted by this method
+ if (blockX) value_x->blockSignals(true);
+ if (blockY) value_y->blockSignals(true);
+
+ if (i->type() == TEXTITEM) {
+
+ QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
+
+ // Set the correct x coordinate value
+ if (origin_x_left->isChecked()) {
+ // Origin (0 point) is at m_frameWidth, coordinate axis is inverted
+ value_x->setValue((int)(m_frameWidth - rec->pos().x() - rec->boundingRect().width()));
+ } else {
+ // Origin is at 0 (default)
+ value_x->setValue((int) rec->pos().x());
+ }
+
+ // Same for y
+ if (origin_y_top->isChecked()) {
+ value_y->setValue((int)(m_frameHeight - rec->pos().y() - rec->boundingRect().height()));
+ } else {
+ value_y->setValue((int) rec->pos().y());
+ }
+
+ } else if (i->type() == RECTITEM) {
+
+ QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(i);
+
+ if (origin_x_left->isChecked()) {
+ // Origin (0 point) is at m_frameWidth
+ value_x->setValue((int)(m_frameWidth - rec->pos().x() - rec->rect().width()));
+ } else {
+ // Origin is at 0 (default)
+ value_x->setValue((int) rec->pos().x());
+ }
+
+ if (origin_y_top->isChecked()) {
+ value_y->setValue((int)(m_frameHeight - rec->pos().y() - rec->rect().height()));
+ } else {
+ value_y->setValue((int) rec->pos().y());
+ }
+
+ } else if (i->type() == IMAGEITEM) {
+
+ if (origin_x_left->isChecked()) {
+ value_x->setValue((int)(m_frameWidth - i->pos().x() - i->sceneBoundingRect().width()));
+ } else {
+ value_x->setValue((int) i->pos().x());
+ }
+
+ if (origin_y_top->isChecked()) {
+ value_y->setValue((int)(m_frameHeight - i->pos().y() - i->sceneBoundingRect().height()));
+ } else {
+ value_y->setValue((int) i->pos().y());
+ }
+
+ }
+
+ // Stop blocking signals now
+ if (!blockX) value_x->blockSignals(false);
+ if (!blockY) value_y->blockSignals(false);
}
/** \brief Updates the position of an item by reading coordinates from the text fields */
-void TitleWidget::updatePosition(QGraphicsItem *i) {
-
- if (i->type() == TEXTITEM) {
- QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
-
- int posX;
- if (origin_x_left->isChecked()) {
- /* Origin of the x axis is at m_frameWidth,
- * and distance from right border of the item to the right
- * border of the frame is taken.
- * See comment to slotOriginXClicked().
- */
- posX = m_frameWidth - value_x->value() - rec->boundingRect().width();
- } else {
- posX = value_x->value();
- }
-
- int posY;
- if (origin_y_top->isChecked()) {
- /* Same for y axis */
- posY = m_frameHeight - value_y->value() - rec->boundingRect().height();
- } else {
- posY = value_y->value();
- }
-
- rec->setPos(posX, posY);
-
- } else if (i->type() == RECTITEM) {
-
- QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *> (i);
-
- int posX;
- if (origin_x_left->isChecked()) {
- posX = m_frameWidth - value_x->value() - rec->rect().width();
- } else {
- posX = value_x->value();
- }
-
- int posY;
- if (origin_y_top->isChecked()) {
- posY = m_frameHeight - value_y->value() - rec->rect().height();
- } else {
- posY = value_y->value();
- }
-
- rec->setPos(posX, posY);
-
- } else if (i->type() == IMAGEITEM) {
-
- int posX;
- if (origin_x_left->isChecked()) {
- // Use the sceneBoundingRect because this also regards transformations like zoom
- posX = m_frameWidth - value_x->value() - i->sceneBoundingRect().width();
- } else {
- posX = value_x->value();
- }
-
- int posY;
- if (origin_y_top->isChecked()) {
- posY = m_frameHeight - value_y->value() - i->sceneBoundingRect().height();
- } else {
- posY = value_y->value();
- }
-
- i->setPos(posX, posY);
-
- }
+void TitleWidget::updatePosition(QGraphicsItem *i)
+{
+
+ if (i->type() == TEXTITEM) {
+ QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
+
+ int posX;
+ if (origin_x_left->isChecked()) {
+ /* Origin of the x axis is at m_frameWidth,
+ * and distance from right border of the item to the right
+ * border of the frame is taken.
+ * See comment to slotOriginXClicked().
+ */
+ posX = m_frameWidth - value_x->value() - rec->boundingRect().width();
+ } else {
+ posX = value_x->value();
+ }
+
+ int posY;
+ if (origin_y_top->isChecked()) {
+ /* Same for y axis */
+ posY = m_frameHeight - value_y->value() - rec->boundingRect().height();
+ } else {
+ posY = value_y->value();
+ }
+
+ rec->setPos(posX, posY);
+
+ } else if (i->type() == RECTITEM) {
+
+ QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(i);
+
+ int posX;
+ if (origin_x_left->isChecked()) {
+ posX = m_frameWidth - value_x->value() - rec->rect().width();
+ } else {
+ posX = value_x->value();
+ }
+
+ int posY;
+ if (origin_y_top->isChecked()) {
+ posY = m_frameHeight - value_y->value() - rec->rect().height();
+ } else {
+ posY = value_y->value();
+ }
+
+ rec->setPos(posX, posY);
+
+ } else if (i->type() == IMAGEITEM) {
+
+ int posX;
+ if (origin_x_left->isChecked()) {
+ // Use the sceneBoundingRect because this also regards transformations like zoom
+ posX = m_frameWidth - value_x->value() - i->sceneBoundingRect().width();
+ } else {
+ posX = value_x->value();
+ }
+
+ int posY;
+ if (origin_y_top->isChecked()) {
+ posY = m_frameHeight - value_y->value() - i->sceneBoundingRect().height();
+ } else {
+ posY = value_y->value();
+ }
+
+ i->setPos(posX, posY);
+
+ }
}
void TitleWidget::updateTextOriginX()
{
- if (origin_x_left->isChecked()) {
- origin_x_left->setText(i18n("\u2212X"));
- } else {
- origin_x_left->setText(i18n("+X"));
- }
+ if (origin_x_left->isChecked()) {
+ origin_x_left->setText(i18n("\u2212X"));
+ } else {
+ origin_x_left->setText(i18n("+X"));
+ }
}
void TitleWidget::slotOriginXClicked()
{
- // Update the text displayed on the button.
- updateTextOriginX();
+ // Update the text displayed on the button.
+ updateTextOriginX();
- QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() >= 1) {
- updateCoordinates(l.at(0));
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ updateCoordinates(l.at(0));
- // Remember x axis setting
- l.at(0)->setData(TitleDocument::OriginXLeft, origin_x_left->isChecked()?
- TitleDocument::AxisInverted : TitleDocument::AxisDefault);
- }
+ // Remember x axis setting
+ l.at(0)->setData(TitleDocument::OriginXLeft, origin_x_left->isChecked() ?
+ TitleDocument::AxisInverted : TitleDocument::AxisDefault);
+ }
}
void TitleWidget::updateTextOriginY()
{
- if (origin_y_top->isChecked()) {
- origin_y_top->setText(i18n("\u2212Y"));
- } else {
- origin_y_top->setText(i18n("+Y"));
- }
+ if (origin_y_top->isChecked()) {
+ origin_y_top->setText(i18n("\u2212Y"));
+ } else {
+ origin_y_top->setText(i18n("+Y"));
+ }
}
void TitleWidget::slotOriginYClicked()
{
- // Update the text displayed on the button.
- updateTextOriginY();
+ // Update the text displayed on the button.
+ updateTextOriginY();
- QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
- if (l.size() >= 1) {
- updateCoordinates(l.at(0));
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ updateCoordinates(l.at(0));
- l.at(0)->setData(TitleDocument::OriginYTop, origin_y_top->isChecked()?
- TitleDocument::AxisInverted : TitleDocument::AxisDefault);
+ l.at(0)->setData(TitleDocument::OriginYTop, origin_y_top->isChecked() ?
+ TitleDocument::AxisInverted : TitleDocument::AxisDefault);
- }
+ }
}
void TitleWidget::updateAxisButtons(QGraphicsItem *i)
{
- int xAxis = i->data(TitleDocument::OriginXLeft).toInt();
- int yAxis = i->data(TitleDocument::OriginYTop).toInt();
- origin_x_left->blockSignals(true);
- origin_y_top->blockSignals(true);
-
- if (xAxis == TitleDocument::AxisInverted) {
- origin_x_left->setChecked(true);
- } else {
- origin_x_left->setChecked(false);
- }
- updateTextOriginX();
-
- if (yAxis == TitleDocument::AxisInverted) {
- origin_y_top->setChecked(true);
- } else {
- origin_y_top->setChecked(false);
- }
- updateTextOriginY();
-
- origin_x_left->blockSignals(false);
- origin_y_top->blockSignals(false);
+ int xAxis = i->data(TitleDocument::OriginXLeft).toInt();
+ int yAxis = i->data(TitleDocument::OriginYTop).toInt();
+ origin_x_left->blockSignals(true);
+ origin_y_top->blockSignals(true);
+
+ if (xAxis == TitleDocument::AxisInverted) {
+ origin_x_left->setChecked(true);
+ } else {
+ origin_x_left->setChecked(false);
+ }
+ updateTextOriginX();
+
+ if (yAxis == TitleDocument::AxisInverted) {
+ origin_y_top->setChecked(true);
+ } else {
+ origin_y_top->setChecked(false);
+ }
+ updateTextOriginY();
+
+ origin_x_left->blockSignals(false);
+ origin_y_top->blockSignals(false);
}
void TitleWidget::slotChangeBackground()
/**
* Something (yeah) has changed in our QGraphicsScene.
*/
-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)));
- }
+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)));
+ }
}
/**
* it is not valid for text but for its boundingRect. Text may still
* be left-justified.
*/
-void TitleWidget::textChanged(QGraphicsTextItem *i) {
-
- updateDimension(i);
-
- if (origin_x_left->isChecked() || origin_y_top->isChecked()) {
-
- if (!i->toPlainText().isEmpty()) {
- updatePosition(i);
- } else {
- /*
- * Don't do anything if the string is empty. If the position
- * would be updated here, a newly created text field would
- * be set to the position of the last selected text field.
- */
- }
- }
+void TitleWidget::textChanged(QGraphicsTextItem *i)
+{
+
+ updateDimension(i);
+
+ if (origin_x_left->isChecked() || origin_y_top->isChecked()) {
+
+ if (!i->toPlainText().isEmpty()) {
+ updatePosition(i);
+ } else {
+ /*
+ * Don't do anything if the string is empty. If the position
+ * would be updated here, a newly created text field would
+ * be set to the position of the last selected text field.
+ */
+ }
+ }
}
void TitleWidget::slotInsertUnicode()
{
- m_unicodeDialog->showLastUnicode();
- m_unicodeDialog->exec();
+ m_unicodeDialog->showLastUnicode();
+ m_unicodeDialog->exec();
}
void TitleWidget::slotInsertUnicodeString(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));
- t->textCursor().insertText(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));
+ t->textCursor().insertText(text);
+ }
+ }
}
void TitleWidget::slotUpdateText()
qtrans.rotate(x.rotate);
l[0]->setTransform(qtrans);
m_transformations[l.at(0)] = x;
- updateDimension(l.at(0));
+ updateDimension(l.at(0));
}
}
qtrans.rotate(x.rotate);
l[0]->setTransform(qtrans);
m_transformations[l.at(0)] = x;
- updateDimension(l.at(0));
+ updateDimension(l.at(0));
}
}
int newPos = (int)((m_frameWidth - width) / 2);
newPos += item->pos().x() - br.left(); // Check item transformation
item->setPos(newPos, item->pos().y());
- updateCoordinates(item);
+ updateCoordinates(item);
}
}
int newPos = (int)((m_frameHeight - height) / 2);
newPos += item->pos().y() - br.top(); // Check item transformation
item->setPos(item->pos().x(), newPos);
- updateCoordinates(item);
+ updateCoordinates(item);
}
}
QAction *m_buttonCursor;
QAction *m_buttonSave;
QAction *m_buttonLoad;
- /** \brief Dialog for entering unicode in text fields */
- UnicodeDialog *m_unicodeDialog;
+ /** \brief Dialog for entering unicode in text fields */
+ UnicodeDialog *m_unicodeDialog;
/** project path for storing title clips */
QString m_projectPath;
/** \brief Store the current choices of font, background and rect values */
void writeChoices();
/** \brief Read the last stored choices into the dialog */
void readChoices();
- /** \brief Update the displayed X/Y coordinates */
- void updateCoordinates(QGraphicsItem *i);
- void updateDimension(QGraphicsItem *i);
- /** \brief Update the item's position */
- void updatePosition(QGraphicsItem *i);
-
- void textChanged(QGraphicsTextItem *i);
- void updateAxisButtons(QGraphicsItem *i);
-
- void updateTextOriginX();
- void updateTextOriginY();
+ /** \brief Update the displayed X/Y coordinates */
+ void updateCoordinates(QGraphicsItem *i);
+ void updateDimension(QGraphicsItem *i);
+ /** \brief Update the item's position */
+ void updatePosition(QGraphicsItem *i);
+
+ void textChanged(QGraphicsTextItem *i);
+ void updateAxisButtons(QGraphicsItem *i);
+
+ void updateTextOriginX();
+ void updateTextOriginY();
public slots:
void slotNewText(QGraphicsTextItem *tt);
private slots:
void slotAdjustSelectedItem();
-
- /**
- * \brief Switches the origin of the x axis between left and right
- * border of the frame (offset from left/right frame border)
- * \param originLeft Take left border?
- *
- * Called when the origin of the x coorinate has been changed. The
- * x origin will either be at the left or at the right side of the frame.
- *
- * When the origin of the x axis is at the left side, the user can
- * enter the distance between an element's left border and the left
- * side of the frame.
- *
- * When on the right, the distance from the right border of the
- * frame to the right border of the element can be entered. This
- * would result in negative values as long as the element's right
- * border is at the left of the frame's right border. As that is
- * usually the case, I additionally invert the x axis.
- *
- * Default value is left.
- *
- * |----l----->|#######|----r--->|
- * | |---w-->| |
- * | |#######| |
- * | |
- * |----------m_frameWidth------>|
- * | |
- *
- * Left selected: Value = l
- * Right selected: Value = r
- *
- * To calculate between the two coorindate systems:
- * l = m_frameWidth - w - r
- * r = m_frameWidth - w - l
- *
- */
- void slotOriginXClicked();
- /** \brief Same as slotOriginYChanged, but for the Y axis; default is top.
- * \param originTop Take top border? */
- void slotOriginYClicked();
-
- /** \brief Update coorinates of text fields if necessary and text has changed */
- void slotChanged();
-
+
+ /**
+ * \brief Switches the origin of the x axis between left and right
+ * border of the frame (offset from left/right frame border)
+ * \param originLeft Take left border?
+ *
+ * Called when the origin of the x coorinate has been changed. The
+ * x origin will either be at the left or at the right side of the frame.
+ *
+ * When the origin of the x axis is at the left side, the user can
+ * enter the distance between an element's left border and the left
+ * side of the frame.
+ *
+ * When on the right, the distance from the right border of the
+ * frame to the right border of the element can be entered. This
+ * would result in negative values as long as the element's right
+ * border is at the left of the frame's right border. As that is
+ * usually the case, I additionally invert the x axis.
+ *
+ * Default value is left.
+ *
+ * |----l----->|#######|----r--->|
+ * | |---w-->| |
+ * | |#######| |
+ * | |
+ * |----------m_frameWidth------>|
+ * | |
+ *
+ * Left selected: Value = l
+ * Right selected: Value = r
+ *
+ * To calculate between the two coorindate systems:
+ * l = m_frameWidth - w - r
+ * r = m_frameWidth - w - l
+ *
+ */
+ void slotOriginXClicked();
+ /** \brief Same as slotOriginYChanged, but for the Y axis; default is top.
+ * \param originTop Take top border? */
+ void slotOriginYClicked();
+
+ /** \brief Update coorinates of text fields if necessary and text has changed */
+ void slotChanged();
+
void slotZoom(bool up);
void slotUpdateZoom(int pos);
void slotAdjustZoom();
void slotZoomOneToOne();
-
+
void slotUpdateText();
- void slotInsertUnicode();
- void slotInsertUnicodeString(QString);
-
+ void slotInsertUnicode();
+ void slotInsertUnicodeString(QString);
+
void displayBackgroundFrame();
-
+
void setCurrentItem(QGraphicsItem *item);
-
+
void slotTextTool();
void slotRectTool();
void slotSelectTool();
void slotImageTool();
-
+
/** \brief Called when accepted, stores the user selections for next time use */
void slotAccepted();
};
bool Transition::hasGeometry()
{
QDomNodeList namenode = m_parameters.elementsByTagName("parameter");
- for (int i = 0;i < namenode.count() ;i++) {
+ for (int i = 0; i < namenode.count() ; i++) {
QDomElement pa = namenode.item(i).toElement();
if (pa.attribute("type") == "geometry") return true;
}
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
-
+
#include "unicodedialog.h"
/// CONSTANTS
const int MAX_LENGTH_HEX = 4;
const uint MAX_UNICODE_V1 = 65535;
-
-
+
+
/// CONSTRUCTORS/DECONSTRUCTORS
UnicodeDialog::UnicodeDialog(InputMethod inputMeth) : inputMethod(inputMeth), lastCursorPos(0), lastUnicodeNumber("")
{
- setupUi(this);
- connect(unicodeNumber, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
- connect(unicodeNumber, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
- connect(arrowUp, SIGNAL(clicked()), this, SLOT(slotNextUnicode()));
- connect(arrowDown, SIGNAL(clicked()), this, SLOT(slotPrevUnicode()));
-
- switch (inputMethod) {
- case InputHex:
- unicodeNumber->setMaxLength(MAX_LENGTH_HEX);
- break;
-
- case InputDec:
- break;
- }
-
- arrowUp->setShortcut(Qt::Key_Up);
- arrowDown->setShortcut(Qt::Key_Down);
-
- arrowUp->setToolTip(i18n("Next Unicode character (Arrow Up)"));
- arrowDown->setToolTip(i18n("Previous Unicode character (Arrow Down)"));
- unicodeNumber->setToolTip(i18n("Enter your Unicode number here. Allowed characters: [0-9] and [a-f]."));
+ setupUi(this);
+ connect(unicodeNumber, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
+ connect(unicodeNumber, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
+ connect(arrowUp, SIGNAL(clicked()), this, SLOT(slotNextUnicode()));
+ connect(arrowDown, SIGNAL(clicked()), this, SLOT(slotPrevUnicode()));
+
+ switch (inputMethod) {
+ case InputHex:
+ unicodeNumber->setMaxLength(MAX_LENGTH_HEX);
+ break;
+
+ case InputDec:
+ break;
+ }
+
+ arrowUp->setShortcut(Qt::Key_Up);
+ arrowDown->setShortcut(Qt::Key_Down);
+
+ arrowUp->setToolTip(i18n("Next Unicode character (Arrow Up)"));
+ arrowDown->setToolTip(i18n("Previous Unicode character (Arrow Down)"));
+ unicodeNumber->setToolTip(i18n("Enter your Unicode number here. Allowed characters: [0-9] and [a-f]."));
}
UnicodeDialog::~UnicodeDialog()
void UnicodeDialog::showLastUnicode()
{
- unicodeNumber->setText(lastUnicodeNumber);
+ unicodeNumber->setText(lastUnicodeNumber);
}
bool UnicodeDialog::controlCharacter(QString text)
{
- bool isControlCharacter = false;
- QString t = text.toLower();
-
- switch (inputMethod) {
- case InputHex:
- if (t == ""
- || (t.length() == 1 && !(t == "9" || t == "a" || t == "d"))
- || (t.length() == 2 && t.at(0) == QChar('1'))) {
- isControlCharacter = true;
- }
- break;
-
- case InputDec:
- bool ok;
- isControlCharacter = controlCharacter(text.toUInt(&ok, 16));
- break;
- }
-
- return isControlCharacter;
+ bool isControlCharacter = false;
+ QString t = text.toLower();
+
+ switch (inputMethod) {
+ case InputHex:
+ if (t == ""
+ || (t.length() == 1 && !(t == "9" || t == "a" || t == "d"))
+ || (t.length() == 2 && t.at(0) == QChar('1'))) {
+ isControlCharacter = true;
+ }
+ break;
+
+ case InputDec:
+ bool ok;
+ isControlCharacter = controlCharacter(text.toUInt(&ok, 16));
+ break;
+ }
+
+ return isControlCharacter;
}
bool UnicodeDialog::controlCharacter(uint value)
{
- bool isControlCharacter = false;
-
- if (value < 32 && !(value == 9 || value == 10 || value == 13)) {
- isControlCharacter = true;
- }
- return isControlCharacter;
-
+ bool isControlCharacter = false;
+
+ if (value < 32 && !(value == 9 || value == 10 || value == 13)) {
+ isControlCharacter = true;
+ }
+ return isControlCharacter;
+
}
QString UnicodeDialog::trimmedUnicodeNumber(QString text)
{
- while (text.length() > 0 && text.at(0) == QChar('0')) {
- text = text.remove(0, 1);
- }
- return text;
+ while (text.length() > 0 && text.at(0) == QChar('0')) {
+ text = text.remove(0, 1);
+ }
+ return text;
}
QString UnicodeDialog::unicodeInfo(QString unicode_number)
{
- QString infoText(i18n("<small>(no character selected)</small>"));
- if (unicode_number.length() == 0) return infoText;
-
- QString u = trimmedUnicodeNumber(unicode_number).toLower();
-
- if (controlCharacter(u)) {
- infoText = i18n("Control character. Cannot be inserted/printed. See <a href=\"http://en.wikipedia.org/wiki/Control_character\">Wikipedia:Control_character</a>");
- } else if (u == "a") {
- infoText = i18n("Line Feed (newline character, \\\\n)");
- } else if (u == "20") {
- infoText = i18n("Standard space character. (See U+00a0 and U+2000–200b)");
- } else if (u == "a0") {
- infoText = i18n("No-break space. &nbsp; in HTML. See U+0020.");
- } else if (u == "2002") {
- infoText = i18n("En Space (width of an n)");
- } else if (u == "2003") {
- infoText = i18n("Em Space (width of an m)");
- } else if (u == "2004") {
- infoText = i18n("Three-Per-Em Space. Width: 1/3 of one <em>em</em>");
- } else if (u == "2005") {
- infoText = i18n("Four-Per-Em Space. Width: 1/4 of one <em>em</em>");
- } else if (u == "2006") {
- infoText = i18n("Six-Per-Em Space. Width: 1/6 of one <em>em</em>");
- } else if (u == "2007") {
- infoText = i18n("Figure space (non-breaking). Width of a digit if digits have fixed width in this font.");
- } else if (u == "2008") {
- infoText = i18n("Punctuation Space. Width the same as between a punctuation character and the next character.");
- } else if (u == "2009") {
- infoText = i18n("Thin space, in HTML also &thinsp;. See <a href=\"http://en.wikipedia.org/wiki/Space_(punctuation)\">Wikipedia:Space_(punctuation)</a>");
- } else if (u == "200a") {
- infoText = i18n("Hair Space. Thinner than U+2009.");
- } else if (u == "2019") {
- infoText = i18n("Punctuation Apostrophe. Should be used instead of U+0027. See <a href=\"http://en.wikipedia.org/wiki/Apostrophe\">Wikipedia:Apostrophe</a>");
- } else if (u == "2013") {
- infoText = i18n("An en Dash (dash of the width of an n). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
- } else if (u == "2014") {
- infoText = i18n("An em Dash (dash of the widht of an m). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
- } else if (u == "2026") {
- infoText = i18n("Ellipsis: If text has been left out. See <a href=\"http://en.wikipedia.org/wiki/Ellipsis\">Wikipedia:Ellipsis</a>");
- } else {
- infoText = i18n("<small>No additional information available for this character.</small>");
- }
-
- return infoText;
+ QString infoText(i18n("<small>(no character selected)</small>"));
+ if (unicode_number.length() == 0) return infoText;
+
+ QString u = trimmedUnicodeNumber(unicode_number).toLower();
+
+ if (controlCharacter(u)) {
+ infoText = i18n("Control character. Cannot be inserted/printed. See <a href=\"http://en.wikipedia.org/wiki/Control_character\">Wikipedia:Control_character</a>");
+ } else if (u == "a") {
+ infoText = i18n("Line Feed (newline character, \\\\n)");
+ } else if (u == "20") {
+ infoText = i18n("Standard space character. (See U+00a0 and U+2000–200b)");
+ } else if (u == "a0") {
+ infoText = i18n("No-break space. &nbsp; in HTML. See U+0020.");
+ } else if (u == "2002") {
+ infoText = i18n("En Space (width of an n)");
+ } else if (u == "2003") {
+ infoText = i18n("Em Space (width of an m)");
+ } else if (u == "2004") {
+ infoText = i18n("Three-Per-Em Space. Width: 1/3 of one <em>em</em>");
+ } else if (u == "2005") {
+ infoText = i18n("Four-Per-Em Space. Width: 1/4 of one <em>em</em>");
+ } else if (u == "2006") {
+ infoText = i18n("Six-Per-Em Space. Width: 1/6 of one <em>em</em>");
+ } else if (u == "2007") {
+ infoText = i18n("Figure space (non-breaking). Width of a digit if digits have fixed width in this font.");
+ } else if (u == "2008") {
+ infoText = i18n("Punctuation Space. Width the same as between a punctuation character and the next character.");
+ } else if (u == "2009") {
+ infoText = i18n("Thin space, in HTML also &thinsp;. See <a href=\"http://en.wikipedia.org/wiki/Space_(punctuation)\">Wikipedia:Space_(punctuation)</a>");
+ } else if (u == "200a") {
+ infoText = i18n("Hair Space. Thinner than U+2009.");
+ } else if (u == "2019") {
+ infoText = i18n("Punctuation Apostrophe. Should be used instead of U+0027. See <a href=\"http://en.wikipedia.org/wiki/Apostrophe\">Wikipedia:Apostrophe</a>");
+ } else if (u == "2013") {
+ infoText = i18n("An en Dash (dash of the width of an n). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
+ } else if (u == "2014") {
+ infoText = i18n("An em Dash (dash of the widht of an m). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
+ } else if (u == "2026") {
+ infoText = i18n("Ellipsis: If text has been left out. See <a href=\"http://en.wikipedia.org/wiki/Ellipsis\">Wikipedia:Ellipsis</a>");
+ } else {
+ infoText = i18n("<small>No additional information available for this character.</small>");
+ }
+
+ return infoText;
}
QString UnicodeDialog::validateText(QString text)
{
- QRegExp regex("([0-9]|[a-f])", Qt::CaseInsensitive, QRegExp::RegExp2);
- QString newText = "";
- int pos = 0;
-
- switch (inputMethod) {
- case InputHex:
- // Remove all characters we don't want
- while ((pos = regex.indexIn(text, pos)) != -1) {
- newText += regex.cap(1);
- pos++;
- }
- break;
-
- case InputDec:
- // TODO
- break;
- }
-
- return newText;
+ QRegExp regex("([0-9]|[a-f])", Qt::CaseInsensitive, QRegExp::RegExp2);
+ QString newText = "";
+ int pos = 0;
+
+ switch (inputMethod) {
+ case InputHex:
+ // Remove all characters we don't want
+ while ((pos = regex.indexIn(text, pos)) != -1) {
+ newText += regex.cap(1);
+ pos++;
+ }
+ break;
+
+ case InputDec:
+ // TODO
+ break;
+ }
+
+ return newText;
}
void UnicodeDialog::updateOverviewChars(uint unicode)
{
- QString left = "";
- QString right = "";
- uint i;
-
- for (i = 1; i <= 4; i++) {
- if (unicode > i && !controlCharacter(unicode-i)) {
- left = " " + left;
- left = QChar(unicode-i) + left;
- }
- }
-
- for (i = 1; i <= 8; i++) {
- if (unicode + i <= MAX_UNICODE_V1 && !controlCharacter(unicode+i)) {
- right += QChar(unicode+i);
- right += " ";
- }
- }
-
- leftChars->setText(left);
- rightChars->setText(right);
-
+ QString left = "";
+ QString right = "";
+ uint i;
+
+ for (i = 1; i <= 4; i++) {
+ if (unicode > i && !controlCharacter(unicode - i)) {
+ left = " " + left;
+ left = QChar(unicode - i) + left;
+ }
+ }
+
+ for (i = 1; i <= 8; i++) {
+ if (unicode + i <= MAX_UNICODE_V1 && !controlCharacter(unicode + i)) {
+ right += QChar(unicode + i);
+ right += " ";
+ }
+ }
+
+ leftChars->setText(left);
+ rightChars->setText(right);
+
}
void UnicodeDialog::clearOverviewChars()
{
- leftChars->setText("");
- rightChars->setText("");
+ leftChars->setText("");
+ rightChars->setText("");
}
QString UnicodeDialog::nextUnicode(QString text, Direction direction)
{
- uint value = 0;
- QString newText = "";
- bool ok;
-
- switch (inputMethod) {
- case InputHex:
- value = text.toUInt(&ok, 16);
- switch (direction) {
- case Backward:
- value--;
- break;
- default:
- value++;
- break;
- }
- // Wrapping
- if (value == (uint) -1) value = MAX_UNICODE_V1;
- if (value > MAX_UNICODE_V1) value = 0;
-
- newText.setNum(value, 16);
- break;
-
- case InputDec:
- break;
- }
-
- return newText;
+ uint value = 0;
+ QString newText = "";
+ bool ok;
+
+ switch (inputMethod) {
+ case InputHex:
+ value = text.toUInt(&ok, 16);
+ switch (direction) {
+ case Backward:
+ value--;
+ break;
+ default:
+ value++;
+ break;
+ }
+ // Wrapping
+ if (value == (uint) - 1) value = MAX_UNICODE_V1;
+ if (value > MAX_UNICODE_V1) value = 0;
+
+ newText.setNum(value, 16);
+ break;
+
+ case InputDec:
+ break;
+ }
+
+ return newText;
}
*/
void UnicodeDialog::slotTextChanged(QString text)
{
- unicodeNumber->blockSignals(true);
-
- QString newText = validateText(text);
- if (newText.length() == 0) {
- unicodeChar->setText("");
- unicodeNumber->setText("");
- clearOverviewChars();
- lastCursorPos = 0;
- lastUnicodeNumber = "";
- labelInfoText->setText(unicodeInfo(""));
-
- } else {
-
- int cursorPos = unicodeNumber->cursorPosition();
-
- unicodeNumber->setText(newText);
- unicodeNumber->setCursorPosition(cursorPos);
-
- // Get the decimal number as uint to create the QChar from
- bool ok;
- uint value = 0;
- switch (inputMethod) {
- case InputHex:
- value = newText.toUInt(&ok, 16);
- break;
- case InputDec:
- value = newText.toUInt(&ok, 10);
- break;
- }
- updateOverviewChars(value);
-
- if (!ok) {
- // Impossible! validateText never fails!
- }
-
- // If an invalid character has been entered:
- // Reset the cursor position because the entered char has been deleted.
- if (text != newText && newText == lastUnicodeNumber) {
- unicodeNumber->setCursorPosition(lastCursorPos);
- }
-
- lastCursorPos = unicodeNumber->cursorPosition();
- lastUnicodeNumber = newText;
-
- labelInfoText->setText(unicodeInfo(newText));
- unicodeChar->setText(QChar(value));
- }
-
- unicodeNumber->blockSignals(false);
+ unicodeNumber->blockSignals(true);
+
+ QString newText = validateText(text);
+ if (newText.length() == 0) {
+ unicodeChar->setText("");
+ unicodeNumber->setText("");
+ clearOverviewChars();
+ lastCursorPos = 0;
+ lastUnicodeNumber = "";
+ labelInfoText->setText(unicodeInfo(""));
+
+ } else {
+
+ int cursorPos = unicodeNumber->cursorPosition();
+
+ unicodeNumber->setText(newText);
+ unicodeNumber->setCursorPosition(cursorPos);
+
+ // Get the decimal number as uint to create the QChar from
+ bool ok;
+ uint value = 0;
+ switch (inputMethod) {
+ case InputHex:
+ value = newText.toUInt(&ok, 16);
+ break;
+ case InputDec:
+ value = newText.toUInt(&ok, 10);
+ break;
+ }
+ updateOverviewChars(value);
+
+ if (!ok) {
+ // Impossible! validateText never fails!
+ }
+
+ // If an invalid character has been entered:
+ // Reset the cursor position because the entered char has been deleted.
+ if (text != newText && newText == lastUnicodeNumber) {
+ unicodeNumber->setCursorPosition(lastCursorPos);
+ }
+
+ lastCursorPos = unicodeNumber->cursorPosition();
+ lastUnicodeNumber = newText;
+
+ labelInfoText->setText(unicodeInfo(newText));
+ unicodeChar->setText(QChar(value));
+ }
+
+ unicodeNumber->blockSignals(false);
}
/**
* When return pressed, we return the selected unicode character
* if it was not a control character.
*/
-void UnicodeDialog::slotReturnPressed()
+void UnicodeDialog::slotReturnPressed()
{
- QString text = trimmedUnicodeNumber(unicodeNumber->text());
- if (!controlCharacter(text)) {
- emit charSelected(unicodeChar->text());
- }
- emit accept();
+ QString text = trimmedUnicodeNumber(unicodeNumber->text());
+ if (!controlCharacter(text)) {
+ emit charSelected(unicodeChar->text());
+ }
+ emit accept();
}
void UnicodeDialog::slotNextUnicode()
{
- QString text = unicodeNumber->text();
- unicodeNumber->setText(nextUnicode(text, Forward));
+ QString text = unicodeNumber->text();
+ unicodeNumber->setText(nextUnicode(text, Forward));
}
void UnicodeDialog::slotPrevUnicode()
{
- QString text = unicodeNumber->text();
- unicodeNumber->setText(nextUnicode(text, Backward));
+ QString text = unicodeNumber->text();
+ unicodeNumber->setText(nextUnicode(text, Backward));
}
#include "unicodedialog.moc"
class UnicodeDialog : public QDialog, public Ui::UnicodeDialog_UI
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /** \brief The input method for the dialog. Atm only InputHex supported. */
- enum InputMethod { InputHex, InputDec };
-
- UnicodeDialog(InputMethod inputMeth);
- ~UnicodeDialog();
-
- /** \brief Returns infos about a unicode number. Extendable/improvable ;) */
- QString unicodeInfo(QString unicode_number);
-
- void showLastUnicode();
+ /** \brief The input method for the dialog. Atm only InputHex supported. */
+ enum InputMethod { InputHex, InputDec };
+
+ UnicodeDialog(InputMethod inputMeth);
+ ~UnicodeDialog();
+
+ /** \brief Returns infos about a unicode number. Extendable/improvable ;) */
+ QString unicodeInfo(QString unicode_number);
+
+ void showLastUnicode();
private:
- Ui::UnicodeDialog_UI m_view;
-
- enum Direction { Forward, Backward };
-
- /** Selected input method */
- InputMethod inputMethod;
-
- /** \brief Validates text and removes all invalid characters (non-hex e.g.) */
- QString validateText(QString text);
- /** \brief Removes all leading zeros */
- QString trimmedUnicodeNumber(QString text);
- /** \brief Checks whether the given string is a control character */
- bool controlCharacter(QString text);
- /** \brief Checks whether the given uint is a control character */
- bool controlCharacter(uint value);
-
- /** \brief Returns the next available unicode. */
- QString nextUnicode(QString text, Direction direction);
-
- /** \brief Paints previous and next characters around current char */
- void updateOverviewChars(uint unicode);
- void clearOverviewChars();
-
- int lastCursorPos;
- QString lastUnicodeNumber;
+ Ui::UnicodeDialog_UI m_view;
+
+ enum Direction { Forward, Backward };
+
+ /** Selected input method */
+ InputMethod inputMethod;
+
+ /** \brief Validates text and removes all invalid characters (non-hex e.g.) */
+ QString validateText(QString text);
+ /** \brief Removes all leading zeros */
+ QString trimmedUnicodeNumber(QString text);
+ /** \brief Checks whether the given string is a control character */
+ bool controlCharacter(QString text);
+ /** \brief Checks whether the given uint is a control character */
+ bool controlCharacter(uint value);
+
+ /** \brief Returns the next available unicode. */
+ QString nextUnicode(QString text, Direction direction);
+
+ /** \brief Paints previous and next characters around current char */
+ void updateOverviewChars(uint unicode);
+ void clearOverviewChars();
+
+ int lastCursorPos;
+ QString lastUnicodeNumber;
signals:
- /** \brief Contains the selected unicode character; emitted when Enter is pressed. */
- void charSelected(const QString&);
+ /** \brief Contains the selected unicode character; emitted when Enter is pressed. */
+ void charSelected(const QString&);
private slots:
- void slotTextChanged(QString text);
- void slotReturnPressed();
- void slotNextUnicode();
- void slotPrevUnicode();
+ void slotTextChanged(QString text);
+ void slotReturnPressed();
+ void slotNextUnicode();
+ void slotPrevUnicode();
};
#define DBG_AREA
//#include "config.h"
-extern "C"
-{
+extern "C" {
KDE_EXPORT ThumbCreator *new_creator() {
return new MltPreview;
}