diff --git a/src/core/GridMesh.cpp b/src/core/GridMesh.cpp index 068eadf7..b748c635 100644 --- a/src/core/GridMesh.cpp +++ b/src/core/GridMesh.cpp @@ -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]; diff --git a/src/ctrl/Exporter.cpp b/src/ctrl/Exporter.cpp index db09f5b0..8e5f1232 100644 --- a/src/ctrl/Exporter.cpp +++ b/src/ctrl/Exporter.cpp @@ -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"); @@ -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; } @@ -156,7 +156,7 @@ bool Exporter::FFMpeg::finish(const std::function& aWaiter) return (exitStatus == QProcess::NormalExit); } -bool Exporter::FFMpeg::execute(const QString& aArgments, +bool Exporter::FFMpeg::execute(const QStringList& aArgments, const std::function& aWaiter) { if (!start(aArgments)) return false; @@ -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); @@ -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; diff --git a/src/ctrl/Exporter.h b/src/ctrl/Exporter.h index 0cddfde0..8d0fd984 100644 --- a/src/ctrl/Exporter.h +++ b/src/ctrl/Exporter.h @@ -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& aWaiter); - bool execute(const QString& aArgments, + bool execute(const QStringList& aArgments, const std::function& aWaiter); bool errorOccurred() const { return mErrorOccurred; } QString errorString() const { return mErrorString; } diff --git a/src/ctrl/Painter.cpp b/src/ctrl/Painter.cpp index c146648b..231293d1 100644 --- a/src/ctrl/Painter.cpp +++ b/src/ctrl/Painter.cpp @@ -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); @@ -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); diff --git a/src/ctrl/TimeLineUtil.cpp b/src/ctrl/TimeLineUtil.cpp index cad79d5f..1a5db4ae 100644 --- a/src/ctrl/TimeLineUtil.cpp +++ b/src/ctrl/TimeLineUtil.cpp @@ -1,3 +1,4 @@ +#include #include #include "cmnd/BasicCommands.h" #include "cmnd/ScopedMacro.h" @@ -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) diff --git a/src/ctrl/VideoFormat.h b/src/ctrl/VideoFormat.h index d942b90e..f67acc43 100644 --- a/src/ctrl/VideoFormat.h +++ b/src/ctrl/VideoFormat.h @@ -14,7 +14,7 @@ class VideoCodec QString name; QString label; QString icodec; - QString command; + QStringList command; QStringList pixfmts; bool lossless; bool transparent; @@ -29,7 +29,7 @@ class VideoFormat QString name; QString label; QString icodec; - QString command; + QStringList command; QList codecs; }; diff --git a/src/ctrl/time/time_Renderer.cpp b/src/ctrl/time/time_Renderer.cpp index 6a96824d..3b80291b 100644 --- a/src/ctrl/time/time_Renderer.cpp +++ b/src/ctrl/time/time_Renderer.cpp @@ -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; diff --git a/src/gl/FontDrawer.cpp b/src/gl/FontDrawer.cpp index 30599193..1efded12 100644 --- a/src/gl/FontDrawer.cpp +++ b/src/gl/FontDrawer.cpp @@ -1,3 +1,4 @@ +#include #include "gl/FontDrawer.h" #include "gl/Global.h" #include "gl/Util.h" diff --git a/src/gui/MainDisplayWidget.cpp b/src/gui/MainDisplayWidget.cpp index 88164835..c91b16da 100644 --- a/src/gui/MainDisplayWidget.cpp +++ b/src/gui/MainDisplayWidget.cpp @@ -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(); diff --git a/src/gui/MainMenuBar.cpp b/src/gui/MainMenuBar.cpp index 6579a7f9..580db24a 100644 --- a/src/gui/MainMenuBar.cpp +++ b/src/gui/MainMenuBar.cpp @@ -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 @@ -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; diff --git a/src/gui/ObjectTreeWidget.cpp b/src/gui/ObjectTreeWidget.cpp index 8386e6fc..34d5df69 100644 --- a/src/gui/ObjectTreeWidget.cpp +++ b/src/gui/ObjectTreeWidget.cpp @@ -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); @@ -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(); @@ -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(); diff --git a/src/gui/ObjectTreeWidget.h b/src/gui/ObjectTreeWidget.h index ab47e500..d815938b 100644 --- a/src/gui/ObjectTreeWidget.h +++ b/src/gui/ObjectTreeWidget.h @@ -96,8 +96,8 @@ class ObjectTreeWidget : public QTreeWidget util::SlotId mTimeLineSlot; bool mStoreInsert; - QVector mRemovedPositions; QVector mInsertedPositions; + QVector mRemovedPositions; util::PlacePointer mMacroScope; core::ObjectTreeNotifier* mObjTreeNotifier; QModelIndex mDragIndex; diff --git a/src/gui/TimeLineInnerWidget.cpp b/src/gui/TimeLineInnerWidget.cpp index 28aa8fd6..97a40056 100644 --- a/src/gui/TimeLineInnerWidget.cpp +++ b/src/gui/TimeLineInnerWidget.cpp @@ -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(); } diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 06afb4e8..05472c6e 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -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); diff --git a/src/gui/TimeLineWidget.h b/src/gui/TimeLineWidget.h index 55fe1d86..1ae4ed25 100644 --- a/src/gui/TimeLineWidget.h +++ b/src/gui/TimeLineWidget.h @@ -69,7 +69,7 @@ class TimeLineWidget : public QScrollArea // for animation QTimer mTimer; - QTime mElapsed; + QElapsedTimer mElapsed; core::Frame mBeginFrame; core::Frame mLastFrame; bool mDoesLoop; diff --git a/src/gui/tool/tool_FlowLayout.cpp b/src/gui/tool/tool_FlowLayout.cpp index 7943f700..02c282cf 100644 --- a/src/gui/tool/tool_FlowLayout.cpp +++ b/src/gui/tool/tool_FlowLayout.cpp @@ -64,7 +64,7 @@ QLayoutItem* FlowLayout::takeAt(int aIndex) Qt::Orientations FlowLayout::expandingDirections() const { - return 0; + return Qt::Orientations(); } bool FlowLayout::hasHeightForWidth() const diff --git a/src/gui/tool/tool_ModePanel.cpp b/src/gui/tool/tool_ModePanel.cpp index 4d5bccee..5a763f58 100644 --- a/src/gui/tool/tool_ModePanel.cpp +++ b/src/gui/tool/tool_ModePanel.cpp @@ -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 diff --git a/src/gui/tool/tool_ViewPanel.cpp b/src/gui/tool/tool_ViewPanel.cpp index 7171473b..0d0c04d5 100644 --- a/src/gui/tool/tool_ViewPanel.cpp +++ b/src/gui/tool/tool_ViewPanel.cpp @@ -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 diff --git a/src/img/Util.cpp b/src/img/Util.cpp index b6b90250..41d59a2a 100644 --- a/src/img/Util.cpp +++ b/src/img/Util.cpp @@ -261,7 +261,7 @@ std::pair Util::createTextureImage(const QImage& aImage) return std::pair(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; diff --git a/src/util/TreePos.cpp b/src/util/TreePos.cpp index f455815c..7efe24d8 100644 --- a/src/util/TreePos.cpp +++ b/src/util/TreePos.cpp @@ -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; }