Skip to content

Commit

Permalink
Merge pull request herace#18 from FoxyHawk/qt515_support
Browse files Browse the repository at this point in the history
Qt515 support
  • Loading branch information
herace authored Oct 13, 2020
2 parents e88c647 + 5d0bbec commit 331f7fd
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 38 deletions.
5 changes: 4 additions & 1 deletion src/core/GridMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ 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;
float t = 0.0f;
float r = 0.0f;
float b = 0.0f;
for (int i = 0; i < mVertexCount; ++i)
{
auto pos = positions[i];
Expand Down
28 changes: 16 additions & 12 deletions src/core/TimeFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a
return QString::number(aFrame+1);

case TimeFormatType_Relative_FPS: {
QString number;
return number.sprintf("%.1f", static_cast<double>(aFrame) / mFps);
QString number = QString("%1")
.arg(static_cast<double>(aFrame) / mFps, 0, 'f');
return number;
}

case TimeFormatType_Seconds_Frames: { // (SS:FF)
Expand All @@ -31,10 +32,9 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a
int rangeMaxSeconds = static_cast<int>(util::MathUtil::remap(mRange.max(),min,max,nMin,nMax));
double seconds = util::MathUtil::remap(aFrame,min,max,nMin,nMax);

QString n;
n.sprintf("%0*d:%02d",
QString::number(rangeMaxSeconds).length(), static_cast<int>(seconds),
static_cast<int>(util::MathUtil::cycle(aFrame, 0.0, 60.0)));
QString n = QString("%1:%2")
.arg(static_cast<int>(seconds), rangeMaxSeconds, 10, QLatin1Char('0'))
.arg(static_cast<int>(util::MathUtil::cycle(aFrame, 0.0, 60.0)), 2, 10, QLatin1Char('0'));

return n;
}
Expand All @@ -50,10 +50,11 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a

DDHHMMSSmmm timeStruct = msToDDHHMMSSmmm(ms);

QString n;
n.sprintf("%02d:%02d:%02d:%02d",
timeStruct.hours, timeStruct.minutes,timeStruct.seconds,
static_cast<int>(util::MathUtil::cycle(aFrame, 0.0, 60.0)));
QString n = QString("%1:%2:%3:%4")
.arg(timeStruct.hours, 2, 10, QLatin1Char('0'))
.arg(timeStruct.minutes, 2, 10, QLatin1Char('0'))
.arg(timeStruct.seconds, 2, 10, QLatin1Char('0'))
.arg(static_cast<int>(util::MathUtil::cycle(aFrame, 0.0, 60.0)), 2, 10, QLatin1Char('0'));

return n;
}
Expand All @@ -69,8 +70,11 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a

DDHHMMSSmmm timeStruct = msToDDHHMMSSmmm(ms);

QString n;
n.sprintf("%02d:%02d:%02d:%03d", timeStruct.hours, timeStruct.minutes,timeStruct.seconds,timeStruct.milliseconds);
QString n = QString("%1:%2:%3:%4")
.arg(timeStruct.hours, 2, 10, QLatin1Char('0'))
.arg(timeStruct.minutes, 2, 10, QLatin1Char('0'))
.arg(timeStruct.seconds, 2, 10, QLatin1Char('0'))
.arg(timeStruct.milliseconds, 3, 10, QLatin1Char('0'));

return n;
}
Expand Down
6 changes: 5 additions & 1 deletion src/ctrl/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ bool Exporter::FFMpeg::start(const QString& aArgments)
this->mFinished = true;
});

mProcess->start(program + " " + aArgments, QIODevice::ReadWrite);
// TODO improve the arguments build process
QStringList arguments;
arguments = aArgments.split(' ');

mProcess->start(program, arguments, QIODevice::ReadWrite);

return !mErrorOccurred;
}
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
2 changes: 1 addition & 1 deletion src/ctrl/TimeLineUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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
2 changes: 2 additions & 0 deletions src/gl/FontDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "gl/Global.h"
#include "gl/Util.h"

#include <QPainterPath>

namespace
{
static const int kAttachmentId = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MainDisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,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/ObjectTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,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, aParent));
util::TreePos removePos(this->indexFromItem(item));
XC_ASSERT(removePos.isValid());
//qDebug() << "remove"; removePos.dump();
Expand Down Expand Up @@ -885,7 +885,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/TimeLineEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool TimeLineEditorWidget::updateCursor(const core::AbstractCursor& aCursor)

void TimeLineEditorWidget::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 @@ -245,7 +245,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 @@ -78,7 +78,7 @@ class TimeLineWidget : public QScrollArea

// for animation
QTimer mTimer;
QTime mElapsed;
QElapsedTimer mElapsed;
core::Frame mBeginFrame;
core::Frame mLastFrame;
bool mDoesLoop;
Expand Down
5 changes: 0 additions & 5 deletions src/gui/tool/tool_FlowLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ QLayoutItem* FlowLayout::takeAt(int aIndex)
return mItemList.takeAt(aIndex);
}

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

bool FlowLayout::hasHeightForWidth() const
{
return true;
Expand Down
1 change: 0 additions & 1 deletion src/gui/tool/tool_FlowLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class FlowLayout : public QLayout
void addItem(QLayoutItem* aItem);
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const;
bool hasHeightForWidth() const;
int heightForWidth(int) const;
int count() const;
Expand Down
8 changes: 5 additions & 3 deletions src/gui/tool/tool_ModePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ 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();
int l = margins.left();
int r = margins.right();
int b = margins.bottom();

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

Expand Down
6 changes: 4 additions & 2 deletions src/gui/tool/tool_ViewPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ 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();
int l = margins.left();
int r = margins.right();
int b = margins.bottom();

auto height = mLayout.heightForWidth(aWidth - l - r);
this->setGeometry(aPos.x(), aPos.y(), aWidth, height + b);
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
2 changes: 1 addition & 1 deletion src/util/MathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ float MathUtil::getClockwiseRotationRad(const QVector2D& aFrom, const QVector2D&

const float from = getAngleRad(aFrom);
const float to = getAngleRad(aTo);
const double rotate = static_cast<const double>(to - from);
const double rotate = static_cast<double>(to - from);
return static_cast<float>(rotate < 0 ? rotate : (rotate - 2.0 * M_PI));
}

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

0 comments on commit 331f7fd

Please sign in to comment.