Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code for QT5 #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/GridMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ bool GridMesh::deserialize(Deserializer& aIn)
{
// note: the bug on version 0.4 or lower. mVertexRect doesn't be serialized.
auto positions = mPositions.data();
float l, t, r, b = 0.0f;
float l = 0.0f, t = 0.0f, r = 0.0f, b = 0.0f;
for (int i = 0; i < mVertexCount; ++i)
{
auto pos = positions[i];
Expand Down
46 changes: 31 additions & 15 deletions src/ctrl/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Exporter::FFMpeg::FFMpeg()
{
}

bool Exporter::FFMpeg::start(const QString& aArgments)
bool Exporter::FFMpeg::start(const QStringList& aArgments)
{
#if defined(Q_OS_WIN)
const QFileInfo localEncoderInfo("./tools/ffmpeg.exe");
Expand Down Expand Up @@ -125,7 +125,7 @@ bool Exporter::FFMpeg::start(const QString& aArgments)
this->mFinished = true;
});

mProcess->start(program + " " + aArgments, QIODevice::ReadWrite);
mProcess->start(program, aArgments, QIODevice::ReadWrite);

return !mErrorOccurred;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ bool Exporter::FFMpeg::finish(const std::function<bool()>& aWaiter)
return (exitStatus == QProcess::NormalExit);
}

bool Exporter::FFMpeg::execute(const QString& aArgments,
bool Exporter::FFMpeg::execute(const QStringList& aArgments,
const std::function<bool()>& aWaiter)
{
if (!start(aArgments)) return false;
Expand Down Expand Up @@ -278,9 +278,9 @@ Exporter::Result Exporter::execute(const CommonParam& aCommon, const GifParam& a
{

auto waiter = [=]()->bool { return true; };
if (mFFMpeg.execute(" -i " + workFile + " -vf palettegen -y " + palette, waiter))
if (mFFMpeg.execute({"-i", workFile, "-vf", "palettegen", "-y", palette}, waiter))
{
mFFMpeg.execute(" -i " + workFile + " -i " + palette + " -lavfi paletteuse -y " + outFile, waiter);
mFFMpeg.execute({"-i", workFile, "-i", palette, "-lavfi", "paletteuse", "-y", outFile}, waiter);
}

QFile::remove(workFile);
Expand Down Expand Up @@ -395,17 +395,33 @@ Exporter::Result Exporter::execute(const CommonParam& aCommon, const VideoParam&

if (videoCodec.command.isEmpty())
{
videoCodec.command = "-y -f image2pipe -framerate $ifps -vcodec $icodec -i - -b:v $obps -r $ofps $opath";
videoCodec.command = QStringList({"-y", "-f", "image2pipe", "-framerate", "$ifps", "-vcodec", "$icodec", "-i", "-", "-b:v", "$obps", "-r", "$ofps", "$opath"});
}
videoCodec.command.replaceInStrings(QRegExp("\\$ifps(\\s|$)"), QString::number(mCommonParam.fps) + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$icodec(\\s|$)"), videoCodec.icodec + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$obps(\\s|$)"), QString::number(aVideo.bps) + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$ofps(\\s|$)"), QString::number(mCommonParam.fps) + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$ocodec(\\s|$)"), videoCodec.name + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$opath(\\s|$)"), outPath + "\\1");
videoCodec.command.replaceInStrings(QRegExp("\\$pixfmt(\\s|$)"), aVideo.pixfmt + "\\1");

int index;
while ((index = videoCodec.command.indexOf("$arg_colorfilter"))) {
if (colorIndex == 0) {
videoCodec.command.removeAt(index);
} else {
videoCodec.command.replace(index, "colormatrix=bt601:bt709");
videoCodec.command.insert(index, "-vf");
}
}
while ((index = videoCodec.command.indexOf("$arg_colorspace"))) {
if (colorIndex == 0) {
videoCodec.command.replace(index, "bt709");
} else {
videoCodec.command.replace(index, "smpte170");
}
videoCodec.command.insert(index, "-colorspace");
}
videoCodec.command.replace(QRegExp("\\$ifps(\\s|$)"), QString::number(mCommonParam.fps) + "\\1");
videoCodec.command.replace(QRegExp("\\$icodec(\\s|$)"), videoCodec.icodec + "\\1");
videoCodec.command.replace(QRegExp("\\$obps(\\s|$)"), QString::number(aVideo.bps) + "\\1");
videoCodec.command.replace(QRegExp("\\$ofps(\\s|$)"), QString::number(mCommonParam.fps) + "\\1");
videoCodec.command.replace(QRegExp("\\$ocodec(\\s|$)"), videoCodec.name + "\\1");
videoCodec.command.replace(QRegExp("\\$opath(\\s|$)"), outPath + "\\1");
videoCodec.command.replace(QRegExp("\\$pixfmt(\\s|$)"), aVideo.pixfmt + "\\1");
videoCodec.command.replace(QRegExp("\\$arg_colorfilter(\\s|$)"), (colorIndex == 0 ? QString("-vf colormatrix=bt601:bt709") : QString("")) + "\\1");
videoCodec.command.replace(QRegExp("\\$arg_colorspace(\\s|$)"), QString("-colorspace ") + (colorIndex == 0 ? QString("bt709") : QString("smpte170m")) + "\\1");

qDebug() << videoCodec.command;

Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/Exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ class Exporter
{
public:
FFMpeg();
bool start(const QString& aArgments);
bool start(const QStringList& aArgments);
void write(const QByteArray& aBytes);
bool finish(const std::function<bool()>& aWaiter);
bool execute(const QString& aArgments,
bool execute(const QStringList& aArgments,
const std::function<bool()>& aWaiter);
bool errorOccurred() const { return mErrorOccurred; }
QString errorString() const { return mErrorString; }
Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/Painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void GLCorePaintEngine::drawImage(
auto cache = new TextureCaches::Cache();
cache->obj.reset(new QOpenGLTexture(ptr->mirrored()));
cache->key = key;
cache->size = (size_t)ptr->byteCount();
cache->size = (size_t)ptr->sizeInBytes();

cache->obj->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
cache->obj->setMagnificationFilter(QOpenGLTexture::Linear);
Expand All @@ -207,7 +207,7 @@ void GLCorePaintEngine::drawPixmap(const QRectF& aRect, const QPixmap& aPixmap,
auto image = ptr->toImage();
cache->obj.reset(new QOpenGLTexture(image.mirrored()));
cache->key = key;
cache->size = (size_t)image.byteCount();
cache->size = (size_t)image.sizeInBytes();

cache->obj->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
cache->obj->setMagnificationFilter(QOpenGLTexture::Linear);
Expand Down
3 changes: 2 additions & 1 deletion src/ctrl/TimeLineUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <QDebug>
#include "cmnd/BasicCommands.h"
#include "cmnd/ScopedMacro.h"
Expand Down Expand Up @@ -30,7 +31,7 @@ MoveFrameOfKey::MoveFrameOfKey(const TimeLineEvent& aCommandEvent)
mSortedTargets.push_back(target);
}
// sort targets for the purpose of the move with no conflict.
qSort(mSortedTargets.begin(), mSortedTargets.end(), lessThan);
std::sort(mSortedTargets.begin(), mSortedTargets.end(), lessThan);
}

bool MoveFrameOfKey::lessThan(const TimeLineEvent::Target& aLhs, const TimeLineEvent::Target& aRhs)
Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/VideoFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VideoCodec
QString name;
QString label;
QString icodec;
QString command;
QStringList command;
QStringList pixfmts;
bool lossless;
bool transparent;
Expand All @@ -29,7 +29,7 @@ class VideoFormat
QString name;
QString label;
QString icodec;
QString command;
QStringList command;
QList<VideoCodec> codecs;
};

Expand Down
3 changes: 1 addition & 2 deletions src/ctrl/time/time_Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ void Renderer::renderHeader(int aHeight, int aFps)

if (attr.showNumber)
{
QString number;
number.sprintf("%.1f", (float)i / aFps);
QString number = QString::number((float)i / aFps);
const int width = numberWidth * number.size();
const int left = pos.x() - (width >> 1);
const int top = lt.y() - 1;
Expand Down
1 change: 1 addition & 0 deletions src/gl/FontDrawer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <QPainterPath>
#include "gl/FontDrawer.h"
#include "gl/Global.h"
#include "gl/Util.h"
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MainDisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void MainDisplayWidget::mouseReleaseEvent(QMouseEvent* aEvent)

void MainDisplayWidget::wheelEvent(QWheelEvent* aEvent)
{
if (mCanvasMover.updateByWheel(QVector2D(aEvent->pos()), aEvent->delta(),
if (mCanvasMover.updateByWheel(QVector2D(aEvent->position()), aEvent->angleDelta().y(),
mViaPoint.mouseSetting().invertMainViewScaling))
{
updateRender();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/MainMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void MainMenuBar::loadVideoFormats()
// optional attributes
format.label = domFormat.attribute("label");
format.icodec = domFormat.attribute("icodec");
format.command = domFormat.attribute("command");
format.command = domFormat.attribute("command").split(' ');
if (format.label.isEmpty()) format.label = format.name;
if (format.icodec.isEmpty()) format.icodec = "png";
// add one format
Expand All @@ -301,7 +301,7 @@ void MainMenuBar::loadVideoFormats()
// optional attributes
codec.label = domCodec.attribute("label");
codec.icodec = domCodec.attribute("icodec");
codec.command = domCodec.attribute("command");
codec.command = domCodec.attribute("command").split(' ');
if (codec.label.isEmpty()) codec.label = codec.name;
if (codec.icodec.isEmpty()) codec.icodec = format.icodec;
if (codec.command.isEmpty()) codec.command = format.command;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/ObjectTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ obj::Item* ObjectTreeWidget::createFolderItem(core::ObjectNode& aNode)

obj::Item* item = new obj::Item(*this, aNode);
item->setSizeHint(kItemColumn, QSize(kItemSize, itemHeight(aNode)));
item->setBackgroundColor(kItemColumn, QColor(235, 235, 235, 255));
item->setBackground(kItemColumn, QBrush(QColor(235, 235, 235, 255)));
item->setIcon(kItemColumn, mResources.icon("folder"));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(kItemColumn, aNode.isVisible() ? Qt::Checked : Qt::Unchecked);
Expand Down Expand Up @@ -843,7 +843,7 @@ void ObjectTreeWidget::rowsAboutToBeRemoved(const QModelIndex& aParent, int aSta
if (mStoreInsert)
{
XC_ASSERT(aStart == aEnd);
QTreeWidgetItem* item = this->itemFromIndex(aParent.child(aStart, kItemColumn));
QTreeWidgetItem* item = this->itemFromIndex(aParent.model()->index(aStart, kItemColumn));
util::TreePos removePos(this->indexFromItem(item));
XC_ASSERT(removePos.isValid());
//qDebug() << "remove"; removePos.dump();
Expand Down Expand Up @@ -879,7 +879,7 @@ void ObjectTreeWidget::rowsInserted(const QModelIndex& aParent, int aStart, int
if (mStoreInsert)
{
XC_ASSERT(aStart == aEnd);
QTreeWidgetItem* item = this->itemFromIndex(aParent.child(aStart, kItemColumn));
QTreeWidgetItem* item = this->itemFromIndex(aParent.model()->index(aStart, kItemColumn, aParent));
util::TreePos insertPos(this->indexFromItem(item));
XC_ASSERT(insertPos.isValid());
//qDebug() << "insert"; insertPos.dump();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ObjectTreeWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class ObjectTreeWidget : public QTreeWidget
util::SlotId mTimeLineSlot;

bool mStoreInsert;
QVector<util::TreePos> mRemovedPositions;
QVector<util::TreePos> mInsertedPositions;
QVector<util::TreePos> mRemovedPositions;
util::PlacePointer<cmnd::ScopedMacro> mMacroScope;
core::ObjectTreeNotifier* mObjTreeNotifier;
QModelIndex mDragIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/TimeLineInnerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ bool TimeLineInnerWidget::updateCursor(const core::AbstractCursor& aCursor)

void TimeLineInnerWidget::updateWheel(QWheelEvent* aEvent)
{
mEditor->updateWheel(aEvent->delta(), mViaPoint.mouseSetting().invertTimeLineScaling);
mEditor->updateWheel(aEvent->angleDelta().y(), mViaPoint.mouseSetting().invertTimeLineScaling);
updateSize();
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/TimeLineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void TimeLineWidget::mouseDoubleClickEvent(QMouseEvent* aEvent)
void TimeLineWidget::wheelEvent(QWheelEvent* aEvent)
{
QPoint viewTrans = viewportTransform();
const QPoint cursor = aEvent->pos();
const QPoint cursor = aEvent->position().toPoint();
const QRect rectPrev = mInner->rect();

mInner->updateWheel(aEvent);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/TimeLineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TimeLineWidget : public QScrollArea

// for animation
QTimer mTimer;
QTime mElapsed;
QElapsedTimer mElapsed;
core::Frame mBeginFrame;
core::Frame mLastFrame;
bool mDoesLoop;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tool/tool_FlowLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ QLayoutItem* FlowLayout::takeAt(int aIndex)

Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
return Qt::Orientations();
}

bool FlowLayout::hasHeightForWidth() const
Expand Down
9 changes: 4 additions & 5 deletions src/gui/tool/tool_ModePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ void ModePanel::pushButton(ctrl::ToolType aId)

int ModePanel::updateGeometry(const QPoint& aPos, int aWidth)
{
int l, t, r, b;
this->getContentsMargins(&l, &t, &r, &b);
QMargins margins = this->contentsMargins();

auto height = mLayout.heightForWidth(aWidth - l - r);
this->setGeometry(aPos.x(), aPos.y(), aWidth, height + b);
auto height = mLayout.heightForWidth(aWidth - margins.left() - margins.right());
this->setGeometry(aPos.x(), aPos.y(), aWidth, height + margins.bottom());

return aPos.y() + height + b;
return aPos.y() + height + margins.bottom();
}

} // namespace tool
Expand Down
9 changes: 4 additions & 5 deletions src/gui/tool/tool_ViewPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ void ViewPanel::addButton(const QString& aIconName, bool aCheckable,

int ViewPanel::updateGeometry(const QPoint& aPos, int aWidth)
{
int l, t, r, b;
this->getContentsMargins(&l, &t, &r, &b);
QMargins margins = this->contentsMargins();

auto height = mLayout.heightForWidth(aWidth - l - r);
this->setGeometry(aPos.x(), aPos.y(), aWidth, height + b);
auto height = mLayout.heightForWidth(aWidth - margins.left() - margins.right());
this->setGeometry(aPos.x(), aPos.y(), aWidth, height + margins.bottom());

return aPos.y() + height + b;
return aPos.y() + height + margins.bottom();
}

} // namespace tool
Expand Down
2 changes: 1 addition & 1 deletion src/img/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ std::pair<XCMemBlock, QRect> Util::createTextureImage(const QImage& aImage)
return std::pair<XCMemBlock, QRect>(block, QRect(0, 0, 1, 1));
}

const size_t length = (size_t)aImage.byteCount();
const size_t length = (size_t)aImage.sizeInBytes();

XCMemBlock workImage;
workImage.size = length;
Expand Down
5 changes: 2 additions & 3 deletions src/util/TreePos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ void TreePos::dump() const
QString text;
for (size_t i = 0; i < mRows.size(); ++i)
{
QString row;
row.sprintf("%d,", mRows[i]);
text += row;
text += QString::number(mRows[i]);
text += ",";
}
qDebug() << text;
}
Expand Down