Merge with develop.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-25 13:29:03 +02:00
commit 2c795281dd
20 changed files with 167 additions and 106 deletions

View file

@ -49,6 +49,7 @@
- [#595] GapWidth affecting to the margins. - [#595] GapWidth affecting to the margins.
- [#589] Valentina lock up if not enough space for label. - [#589] Valentina lock up if not enough space for label.
- [#606] Mac OS X. Cant type in measurements due to digit count limitation. - [#606] Mac OS X. Cant type in measurements due to digit count limitation.
- [#612] Valentina crashes when network is disabled on Linux.
# Version 0.4.6 # Version 0.4.6
- [#594] Broken export on Mac. - [#594] Broken export on Mac.

View file

@ -25,6 +25,21 @@ win32{
VCOPY = $$QMAKE_COPY /D VCOPY = $$QMAKE_COPY /D
} }
# See question on StackOwerflow "QSslSocket error when SSL is NOT used" (http://stackoverflow.com/a/31277055/3045403)
# Copy of answer:
# We occasionally had customers getting very similar warning messages but the software was also crashing.
# We determined it was because, although we weren't using SSL either, the program found a copy of OpenSSL on the
# customer's computer and tried interfacing with it. The version it found was too old though (from Qt 5.2 onwards v1.0.0
# or later is required).
#
# Our solution was to distribute the OpenSSL DLLs along with our application (~1.65 MB). The alternative is to compile
# Qt from scratch without OpenSSL support.
win32 {
INSTALL_OPENSSL += \
../../../dist/win/libeay32.dll \
../../../dist/win/ssleay32.dll
}
macx{ macx{
# QTBUG-31034 qmake doesn't allow override QMAKE_CXX # QTBUG-31034 qmake doesn't allow override QMAKE_CXX
CONFIG+=no_ccache CONFIG+=no_ccache

BIN
dist/win/libeay32.dll vendored Normal file

Binary file not shown.

BIN
dist/win/ssleay32.dll vendored Normal file

Binary file not shown.

View file

@ -60,6 +60,8 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close);
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
{ {
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
}); });

View file

@ -56,9 +56,6 @@ int main(int argc, char *argv[])
MApplication app(argc, argv); MApplication app(argc, argv);
app.InitOptions(); app.InitOptions();
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
QTimer::singleShot(0, &app, SLOT(ProcessCMD())); QTimer::singleShot(0, &app, SLOT(ProcessCMD()));
return app.exec(); return app.exec();

View file

@ -259,6 +259,15 @@ unix{
} }
} }
win32 {
for(DIR, INSTALL_OPENSSL) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
openssl_path += $${PWD}/$$DIR
}
copyToDestdir($$openssl_path, $$shell_path($${OUT_PWD}/$$DESTDIR))
}
# Compilation will fail without this files after we added them to this section. # Compilation will fail without this files after we added them to this section.
OTHER_FILES += \ OTHER_FILES += \
share/resources/tapeicon/64x64/logo.ico \ # Tape's logo. share/resources/tapeicon/64x64/logo.ico \ # Tape's logo.

View file

@ -69,7 +69,10 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
} }
}); });
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, [](){ connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
}); });

View file

@ -285,6 +285,8 @@ win32:*-g++ {
$$PWD/../../../dist/win/s-measurements.ico \ $$PWD/../../../dist/win/s-measurements.ico \
$$PWD/../../../dist/win/pattern.ico \ $$PWD/../../../dist/win/pattern.ico \
$$PWD/../../../dist/win/pdftops.exe \ $$PWD/../../../dist/win/pdftops.exe \
$$PWD/../../../dist/win/libeay32.dll \
$$PWD/../../../dist/win/ssleay32.dll \
$$PWD/../../../AUTHORS.txt \ $$PWD/../../../AUTHORS.txt \
$$PWD/../../../LICENSE_GPL.txt \ $$PWD/../../../LICENSE_GPL.txt \
$$PWD/../../../README.txt \ $$PWD/../../../README.txt \
@ -437,6 +439,13 @@ win32 {
pdftops_path += $${PWD}/$$DIR pdftops_path += $${PWD}/$$DIR
} }
copyToDestdir($$pdftops_path, $$shell_path($${OUT_PWD}/$$DESTDIR)) copyToDestdir($$pdftops_path, $$shell_path($${OUT_PWD}/$$DESTDIR))
for(DIR, INSTALL_OPENSSL) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
openssl_path += $${PWD}/$$DIR
}
copyToDestdir($$openssl_path, $$shell_path($${OUT_PWD}/$$DESTDIR))
} }
noRunPath{ # For enable run qmake with CONFIG+=noRunPath noRunPath{ # For enable run qmake with CONFIG+=noRunPath

View file

@ -61,12 +61,7 @@ FvUpdater* FvUpdater::sharedUpdater()
if (m_Instance.isNull()) if (m_Instance.isNull())
{ {
mutex.lock(); mutex.lock();
m_Instance = new FvUpdater;
if (m_Instance.isNull())
{
m_Instance = new FvUpdater;
}
mutex.unlock(); mutex.unlock();
} }
@ -92,6 +87,7 @@ FvUpdater::FvUpdater()
m_qnam(), m_qnam(),
m_reply(nullptr), m_reply(nullptr),
m_httpRequestAborted(false), m_httpRequestAborted(false),
m_dropOnFinnish(true),
m_xml() m_xml()
{ {
// noop // noop
@ -101,6 +97,7 @@ FvUpdater::FvUpdater()
FvUpdater::~FvUpdater() FvUpdater::~FvUpdater()
{ {
hideUpdaterWindow(); hideUpdaterWindow();
delete m_reply;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -142,6 +139,18 @@ QString FvUpdater::GetFeedURL() const
return m_feedURL.toString(); return m_feedURL.toString();
} }
//---------------------------------------------------------------------------------------------------------------------
bool FvUpdater::IsDropOnFinnish() const
{
return m_dropOnFinnish;
}
//---------------------------------------------------------------------------------------------------------------------
void FvUpdater::SetDropOnFinnish(bool value)
{
m_dropOnFinnish = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointer<FvAvailableUpdate> FvUpdater::GetProposedUpdate() QPointer<FvAvailableUpdate> FvUpdater::GetProposedUpdate()
{ {
@ -255,10 +264,19 @@ bool FvUpdater::CheckForUpdatesSilent()
{ {
if (qApp->Settings()->GetDateOfLastRemind().daysTo(QDate::currentDate()) >= 1) if (qApp->Settings()->GetDateOfLastRemind().daysTo(QDate::currentDate()) >= 1)
{ {
return CheckForUpdates(true); const bool success = CheckForUpdates(true);
if (m_dropOnFinnish && not success)
{
drop();
}
return success;
} }
else else
{ {
if (m_dropOnFinnish)
{
drop();
}
return true; return true;
} }
} }
@ -266,7 +284,12 @@ bool FvUpdater::CheckForUpdatesSilent()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool FvUpdater::CheckForUpdatesNotSilent() bool FvUpdater::CheckForUpdatesNotSilent()
{ {
return CheckForUpdates(false); const bool success = CheckForUpdates(false);
if (m_dropOnFinnish && not success)
{
drop();
}
return success;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -281,7 +304,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
m_reply = m_qnam.get(request); m_reply = m_qnam.get(request);
connect(m_reply, &QNetworkReply::readyRead, RECEIVER(this)[this]() connect(m_reply.data(), &QNetworkReply::readyRead, RECEIVER(this)[this]()
{ {
// this slot gets called every time the QNetworkReply has new data. // this slot gets called every time the QNetworkReply has new data.
// We read all of its new data and write it into the file. // We read all of its new data and write it into the file.
@ -289,7 +312,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
// signal of the QNetworkReply // signal of the QNetworkReply
m_xml.addData(m_reply->readAll()); m_xml.addData(m_reply->readAll());
}); });
connect(m_reply, &QNetworkReply::downloadProgress, RECEIVER(this)[this](qint64 bytesRead, qint64 totalBytes) connect(m_reply.data(), &QNetworkReply::downloadProgress, RECEIVER(this)[this](qint64 bytesRead, qint64 totalBytes)
{ {
Q_UNUSED(bytesRead) Q_UNUSED(bytesRead)
Q_UNUSED(totalBytes) Q_UNUSED(totalBytes)
@ -299,7 +322,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
return; return;
} }
}); });
connect(m_reply, &QNetworkReply::finished, this, &FvUpdater::httpFeedDownloadFinished); connect(m_reply.data(), &QNetworkReply::finished, this, &FvUpdater::httpFeedDownloadFinished);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -344,7 +367,11 @@ void FvUpdater::httpFeedDownloadFinished()
} }
m_reply->deleteLater(); m_reply->deleteLater();
m_reply = 0;
if (m_dropOnFinnish)
{
drop();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -460,10 +487,7 @@ bool FvUpdater::searchDownloadedFeedForUpdates(const QString &xmlEnclosureUrl,
// to the user. // to the user.
// //
if (m_proposedUpdate) delete m_proposedUpdate;
{
delete m_proposedUpdate;
}
m_proposedUpdate = new FvAvailableUpdate(this); m_proposedUpdate = new FvAvailableUpdate(this);
m_proposedUpdate->SetEnclosureUrl(xmlEnclosureUrl); m_proposedUpdate->SetEnclosureUrl(xmlEnclosureUrl);
m_proposedUpdate->SetEnclosureVersion(xmlEnclosureVersion); m_proposedUpdate->SetEnclosureVersion(xmlEnclosureVersion);

View file

@ -55,6 +55,9 @@ public:
void SetFeedURL(const QString &feedURL); void SetFeedURL(const QString &feedURL);
QString GetFeedURL() const; QString GetFeedURL() const;
bool IsDropOnFinnish() const;
void SetDropOnFinnish(bool value);
public slots: public slots:
// Check for updates // Check for updates
bool CheckForUpdates(bool silentAsMuchAsItCouldGet = true); bool CheckForUpdates(bool silentAsMuchAsItCouldGet = true);
@ -102,10 +105,11 @@ private:
// //
// HTTP feed fetcher infrastructure // HTTP feed fetcher infrastructure
// //
QUrl m_feedURL; // Feed URL that will be fetched QUrl m_feedURL; // Feed URL that will be fetched
QNetworkAccessManager m_qnam; QNetworkAccessManager m_qnam;
QNetworkReply* m_reply; QPointer<QNetworkReply> m_reply;
bool m_httpRequestAborted; bool m_httpRequestAborted;
bool m_dropOnFinnish;
QXmlStreamReader m_xml; // XML data collector and parser QXmlStreamReader m_xml; // XML data collector and parser

View file

@ -36,8 +36,7 @@ class QWidget;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
FvUpdateWindow::FvUpdateWindow(QWidget *parent) FvUpdateWindow::FvUpdateWindow(QWidget *parent)
: QDialog(parent), : QDialog(parent),
m_ui(new Ui::FvUpdateWindow), m_ui(new Ui::FvUpdateWindow)
m_appIconScene(nullptr)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);

View file

@ -51,8 +51,6 @@ private:
Q_DISABLE_COPY(FvUpdateWindow) Q_DISABLE_COPY(FvUpdateWindow)
Ui::FvUpdateWindow* m_ui; Ui::FvUpdateWindow* m_ui;
QGraphicsScene* m_appIconScene;
}; };
#endif // FVUPDATEWINDOW_H #endif // FVUPDATEWINDOW_H

View file

@ -191,7 +191,7 @@ bool VBank::Prepare()
for (int i=0; i < details.size(); ++i) for (int i=0; i < details.size(); ++i)
{ {
details[i].SetLayoutWidth(layoutWidth); details[i].SetLayoutWidth(layoutWidth);
details[i].SetLayoutAllowencePoints(); details[i].SetLayoutAllowancePoints();
const qreal d = details.at(i).Diagonal(); const qreal d = details.at(i).Diagonal();
if (d > diagonal) if (d > diagonal)

View file

@ -88,7 +88,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
{ {
VLayoutPiece det; VLayoutPiece det;
det.SetCountourPoints(piece.MainPathPoints(pattern)); det.SetCountourPoints(piece.MainPathPoints(pattern));
det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance()); det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance());
det.SetInternlaPathsPoints(piece.GetInternalPathsPoints(pattern)); det.SetInternlaPathsPoints(piece.GetInternalPathsPoints(pattern));
det.SetName(piece.GetName()); det.SetName(piece.GetName());
const VPatternPieceData& data = piece.GetPatternPieceData(); const VPatternPieceData& data = piece.GetPatternPieceData();
@ -134,34 +134,34 @@ void VLayoutPiece::SetCountourPoints(const QVector<QPointF> &points)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
QVector<QPointF> VLayoutPiece::GetSeamAllowencePoints() const QVector<QPointF> VLayoutPiece::GetSeamAllowancePoints() const
{ {
return Map(d->seamAllowence); return Map(d->seamAllowance);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence) void VLayoutPiece::SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance)
{ {
if (seamAllowence) if (seamAllowance)
{ {
SetSeamAllowance(seamAllowence); SetSeamAllowance(seamAllowance);
d->seamAllowence = points; d->seamAllowance = points;
if (not d->seamAllowence.isEmpty()) if (not d->seamAllowance.isEmpty())
{ {
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence), false); d->seamAllowance = RemoveDublicates(RoundPoints(d->seamAllowance), false);
} }
else else
{ {
qWarning()<<"Seam allowence is empty."; qWarning()<<"Seam allowance is empty.";
SetSeamAllowance(false); SetSeamAllowance(false);
} }
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::GetLayoutAllowencePoints() const QVector<QPointF> VLayoutPiece::GetLayoutAllowancePoints() const
{ {
return Map(d->layoutAllowence); return Map(d->layoutAllowance);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -370,7 +370,7 @@ int VLayoutPiece::DetailEdgesCount() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VLayoutPiece::LayoutEdgesCount() const int VLayoutPiece::LayoutEdgesCount() const
{ {
return d->layoutAllowence.count(); return d->layoutAllowance.count();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -382,7 +382,7 @@ QLineF VLayoutPiece::DetailEdge(int i) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QLineF VLayoutPiece::LayoutEdge(int i) const QLineF VLayoutPiece::LayoutEdge(int i) const
{ {
return Edge(d->layoutAllowence, i); return Edge(d->layoutAllowance, i);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -394,7 +394,7 @@ int VLayoutPiece::DetailEdgeByPoint(const QPointF &p1) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const
{ {
return EdgeByPoint(d->layoutAllowence, p1); return EdgeByPoint(d->layoutAllowance, p1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -403,7 +403,7 @@ QRectF VLayoutPiece::DetailBoundingRect() const
QVector<QPointF> points; QVector<QPointF> points;
if (IsSeamAllowance()) if (IsSeamAllowance())
{ {
points = GetSeamAllowencePoints(); points = GetSeamAllowancePoints();
} }
else else
{ {
@ -417,7 +417,7 @@ QRectF VLayoutPiece::DetailBoundingRect() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VLayoutPiece::LayoutBoundingRect() const QRectF VLayoutPiece::LayoutBoundingRect() const
{ {
QVector<QPointF> points = GetLayoutAllowencePoints(); QVector<QPointF> points = GetLayoutAllowancePoints();
points.append(points.first()); points.append(points.first());
return QPolygonF(points).boundingRect(); return QPolygonF(points).boundingRect();
} }
@ -434,7 +434,7 @@ bool VLayoutPiece::isNull() const
{ {
if (d->contour.isEmpty() == false && d->layoutWidth > 0) if (d->contour.isEmpty() == false && d->layoutWidth > 0)
{ {
if (IsSeamAllowance() && d->seamAllowence.isEmpty() == false) if (IsSeamAllowance() && d->seamAllowance.isEmpty() == false)
{ {
return false; return false;
} }
@ -452,50 +452,50 @@ bool VLayoutPiece::isNull() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qint64 VLayoutPiece::Square() const qint64 VLayoutPiece::Square() const
{ {
if (d->layoutAllowence.isEmpty()) //-V807 if (d->layoutAllowance.isEmpty()) //-V807
{ {
return 0; return 0;
} }
const qreal res = SumTrapezoids(d->layoutAllowence); const qreal res = SumTrapezoids(d->layoutAllowance);
const qint64 sq = qFloor(qAbs(res/2.0)); const qint64 sq = qFloor(qAbs(res/2.0));
return sq; return sq;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetLayoutAllowencePoints() void VLayoutPiece::SetLayoutAllowancePoints()
{ {
if (d->layoutWidth > 0) if (d->layoutWidth > 0)
{ {
if (IsSeamAllowance()) if (IsSeamAllowance())
{ {
d->layoutAllowence = Equidistant(PrepareAllowance(GetSeamAllowencePoints()), d->layoutWidth); d->layoutAllowance = Equidistant(PrepareAllowance(GetSeamAllowancePoints()), d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false) if (d->layoutAllowance.isEmpty() == false)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->layoutAllowence.remove(d->layoutAllowence.size() - 1); d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
#else #else
d->layoutAllowence.removeLast(); d->layoutAllowance.removeLast();
#endif #endif
} }
} }
else else
{ {
d->layoutAllowence = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth); d->layoutAllowance = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false) if (d->layoutAllowance.isEmpty() == false)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->layoutAllowence.remove(d->layoutAllowence.size() - 1); d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
#else #else
d->layoutAllowence.removeLast(); d->layoutAllowance.removeLast();
#endif #endif
} }
} }
} }
else else
{ {
d->layoutAllowence.clear(); d->layoutAllowance.clear();
} }
} }
@ -557,10 +557,10 @@ QPainterPath VLayoutPiece::ContourPath() const
} }
path.lineTo(points.at(0)); path.lineTo(points.at(0));
// seam allowence // seam allowance
if (IsSeamAllowance() == true) if (IsSeamAllowance() == true)
{ {
points = GetSeamAllowencePoints(); points = GetSeamAllowancePoints();
if (points.last().toPoint() != points.first().toPoint()) if (points.last().toPoint() != points.first().toPoint())
{ {
@ -759,12 +759,12 @@ void VLayoutPiece::CreateTextItem(int i, QGraphicsItem *parent) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VLayoutPiece::LayoutAllowencePath() const QPainterPath VLayoutPiece::LayoutAllowancePath() const
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
const QVector<QPointF> points = GetLayoutAllowencePoints(); const QVector<QPointF> points = GetLayoutAllowancePoints();
path.moveTo(points.at(0)); path.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i) for (qint32 i = 1; i < points.count(); ++i)
{ {
@ -841,7 +841,7 @@ QVector<QPointF> VLayoutPiece::DetailPath() const
{ {
if (IsSeamAllowance()) if (IsSeamAllowance())
{ {
return d->seamAllowence; return d->seamAllowance;
} }
else else
{ {

View file

@ -73,11 +73,11 @@ public:
QVector<QPointF> GetContourPoints() const; QVector<QPointF> GetContourPoints() const;
void SetCountourPoints(const QVector<QPointF> &points); void SetCountourPoints(const QVector<QPointF> &points);
QVector<QPointF> GetSeamAllowencePoints() const; QVector<QPointF> GetSeamAllowancePoints() const;
void SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence = true); void SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance = true);
QVector<QPointF> GetLayoutAllowencePoints() const; QVector<QPointF> GetLayoutAllowancePoints() const;
void SetLayoutAllowencePoints(); void SetLayoutAllowancePoints();
QVector<QVector<QPointF>> GetInternlaPathsPoints() const; QVector<QVector<QPointF>> GetInternlaPathsPoints() const;
void SetInternlaPathsPoints(const QVector<QVector<QPointF>> &internalPathsPoints); void SetInternlaPathsPoints(const QVector<QVector<QPointF>> &internalPathsPoints);
@ -119,7 +119,7 @@ public:
qint64 Square() const; qint64 Square() const;
QPainterPath ContourPath() const; QPainterPath ContourPath() const;
QPainterPath LayoutAllowencePath() const; QPainterPath LayoutAllowancePath() const;
QGraphicsItem *GetItem() const Q_REQUIRED_RESULT; QGraphicsItem *GetItem() const Q_REQUIRED_RESULT;
private: private:

View file

@ -48,8 +48,8 @@ class VLayoutPieceData : public QSharedData
public: public:
VLayoutPieceData() VLayoutPieceData()
: contour(), : contour(),
seamAllowence(), seamAllowance(),
layoutAllowence(), layoutAllowance(),
m_internalPaths(), m_internalPaths(),
matrix(), matrix(),
layoutWidth(0), layoutWidth(0),
@ -68,8 +68,8 @@ public:
VLayoutPieceData(const VLayoutPieceData &detail) VLayoutPieceData(const VLayoutPieceData &detail)
: QSharedData(detail), : QSharedData(detail),
contour(detail.contour), contour(detail.contour),
seamAllowence(detail.seamAllowence), seamAllowance(detail.seamAllowance),
layoutAllowence(detail.layoutAllowence), layoutAllowance(detail.layoutAllowance),
m_internalPaths(detail.m_internalPaths), m_internalPaths(detail.m_internalPaths),
matrix(detail.matrix), matrix(detail.matrix),
layoutWidth(detail.layoutWidth), layoutWidth(detail.layoutWidth),
@ -90,19 +90,19 @@ public:
/** @brief contour list of contour points. */ /** @brief contour list of contour points. */
QVector<QPointF> contour; QVector<QPointF> contour;
/** @brief seamAllowence list of seam allowence points. */ /** @brief seamAllowance list of seam allowance points. */
QVector<QPointF> seamAllowence; QVector<QPointF> seamAllowance;
/** @brief layoutAllowence list of layout allowence points. */ /** @brief layoutAllowance list of layout allowance points. */
QVector<QPointF> layoutAllowence; QVector<QPointF> layoutAllowance;
/** @brief m_layoutAllowence list of internal paths points. */ /** @brief m_internalPaths list of internal paths points. */
QVector<QVector<QPointF>> m_internalPaths; QVector<QVector<QPointF>> m_internalPaths;
/** @brief matrix transformation matrix*/ /** @brief matrix transformation matrix*/
QTransform matrix; QTransform matrix;
/** @brief layoutWidth value layout allowence width in pixels. */ /** @brief layoutWidth value layout allowance width in pixels. */
qreal layoutWidth; qreal layoutWidth;
bool mirror; bool mirror;

View file

@ -178,7 +178,7 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutPiece &detail, i
#ifdef SHOW_CANDIDATE #ifdef SHOW_CANDIDATE
paint.setPen(QPen(Qt::darkGreen, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.setPen(QPen(Qt::darkGreen, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p = DrawContour(detail.GetLayoutAllowencePoints()); p = DrawContour(detail.GetLayoutAllowancePoints());
p.translate(biasWidth/2, biasHeight/2); p.translate(biasWidth/2, biasHeight/2);
paint.drawPath(p); paint.drawPath(p);
#else #else
@ -386,7 +386,7 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
} }
const QPainterPath gPath = gContour.ContourPath(); const QPainterPath gPath = gContour.ContourPath();
if (not gPath.intersects(detail.LayoutAllowencePath()) && not gPath.contains(detail.ContourPath())) if (not gPath.intersects(detail.LayoutAllowancePath()) && not gPath.contains(detail.ContourPath()))
{ {
return CrossingType::NoIntersection; return CrossingType::NoIntersection;
} }

View file

@ -44,7 +44,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPoster::VPoster(const QPrinter *printer) VPoster::VPoster(const QPrinter *printer)
:printer(printer), allowence(static_cast<quint32>(qRound(10./25.4*PrintDPI)))//1 cm :printer(printer), allowance(static_cast<quint32>(qRound(10./25.4*PrintDPI)))//1 cm
{ {
} }
@ -92,7 +92,7 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
data.append(line); data.append(line);
auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_vertical.png"), parent); auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_vertical.png"), parent);
scissors->setPos(rec.x(), rec.y() + rec.height()-static_cast<int>(allowence)); scissors->setPos(rec.x(), rec.y() + rec.height()-static_cast<int>(allowance));
data.append(scissors); data.append(scissors);
} }
@ -100,8 +100,8 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
{// Right border {// Right border
auto *line = new QGraphicsLineItem(parent); auto *line = new QGraphicsLineItem(parent);
line->setPen(pen); line->setPen(pen);
line->setLine(rec.x() + rec.width()-static_cast<int>(allowence), rec.y(), line->setLine(rec.x() + rec.width()-static_cast<int>(allowance), rec.y(),
rec.x() + rec.width()-static_cast<int>(allowence), rec.y() + rec.height()); rec.x() + rec.width()-static_cast<int>(allowance), rec.y() + rec.height());
data.append(line); data.append(line);
} }
@ -113,7 +113,7 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
data.append(line); data.append(line);
auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_horizontal.png"), parent); auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_horizontal.png"), parent);
scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowence), rec.y()); scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowance), rec.y());
data.append(scissors); data.append(scissors);
} }
@ -122,15 +122,15 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
// Bottom border (mandatory) // Bottom border (mandatory)
auto *line = new QGraphicsLineItem(parent); auto *line = new QGraphicsLineItem(parent);
line->setPen(pen); line->setPen(pen);
line->setLine(rec.x(), rec.y() + rec.height()-static_cast<int>(allowence), line->setLine(rec.x(), rec.y() + rec.height()-static_cast<int>(allowance),
rec.x() + rec.width(), rec.y() + rec.height()-static_cast<int>(allowence)); rec.x() + rec.width(), rec.y() + rec.height()-static_cast<int>(allowance));
data.append(line); data.append(line);
if (img.row == img.rows-1) if (img.row == img.rows-1)
{ {
auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_horizontal.png"), parent); auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_horizontal.png"), parent);
scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowence), scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowance),
rec.y() + rec.height()-static_cast<int>(allowence)); rec.y() + rec.height()-static_cast<int>(allowance));
data.append(scissors); data.append(scissors);
} }
} }
@ -140,8 +140,8 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
const int layoutX = 15; const int layoutX = 15;
const int layoutY = 5; const int layoutY = 5;
labels->setPos(rec.x() + layoutX, rec.y() + rec.height()-static_cast<int>(allowence)+layoutY); labels->setPos(rec.x() + layoutX, rec.y() + rec.height()-static_cast<int>(allowance)+layoutY);
labels->setTextWidth(rec.width()-(static_cast<int>(allowence)+layoutX)); labels->setTextWidth(rec.width()-(static_cast<int>(allowance)+layoutX));
const QString grid = tr("Grid ( %1 , %2 )").arg(img.row+1).arg(img.column+1); const QString grid = tr("Grid ( %1 , %2 )").arg(img.row+1).arg(img.column+1);
const QString page = tr("Page %1 of %2").arg(img.row*(img.columns)+img.column+1).arg(img.rows*img.columns); const QString page = tr("Page %1 of %2").arg(img.row*(img.columns)+img.column+1).arg(img.rows*img.columns);
@ -198,18 +198,18 @@ int VPoster::CountRows(int height) const
// * // *
// ― // ―
const int pCount = qCeil(imgLength/pageLength);// Pages count without allowence (or allowence = 0) (3) const int pCount = qCeil(imgLength/pageLength);// Pages count without allowance (or allowance = 0) (3)
// Calculate how many pages will be after using allowence. // Calculate how many pages will be after using allowance.
// We know start pages count. This number not enought because // We know start pages count. This number not enought because
// each n-1 pages add (n-1)*allowence length to page (1). // each n-1 pages add (n-1)*allowance length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowence); //-V636 const qreal addionalLength = (pCount-1)*static_cast<int>(allowance); //-V636
// Calculate additional length form pages that will cover this length (2). // Calculate additional length form pages that will cover this length (2).
// In the end add page length (3). // In the end add page length (3).
// Bottom page have mandatory border (4) // Bottom page have mandatory border (4)
return qCeil((addionalLength + return qCeil((addionalLength +
qCeil(addionalLength/pageLength)*static_cast<int>(allowence) + static_cast<int>(allowence) + qCeil(addionalLength/pageLength)*static_cast<int>(allowance) + static_cast<int>(allowance) +
imgLength)/pageLength); imgLength)/pageLength);
} }
@ -228,16 +228,16 @@ int VPoster::CountColumns(int width) const
// |----| // |----|
// ^ // ^
// (2) // (2)
const int pCount = qCeil(imgLength/pageLength);// Pages count without allowence (or allowence = 0) (3) const int pCount = qCeil(imgLength/pageLength);// Pages count without allowance (or allowance = 0) (3)
// Calculate how many pages will be after using allowence. // Calculate how many pages will be after using allowance.
// We know start pages count. This number not enought because // We know start pages count. This number not enought because
// each n-1 pages add (n-1)*allowence length to page (1). // each n-1 pages add (n-1)*allowance length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowence); //-V636 const qreal addionalLength = (pCount-1)*static_cast<int>(allowance); //-V636
// Calculate additional length form pages that will cover this length (2). // Calculate additional length form pages that will cover this length (2).
// In the end add page length (3). // In the end add page length (3).
return qCeil((addionalLength + qCeil(addionalLength/pageLength)*static_cast<int>(allowence) + return qCeil((addionalLength + qCeil(addionalLength/pageLength)*static_cast<int>(allowance) +
imgLength)/pageLength); imgLength)/pageLength);
} }
@ -246,8 +246,8 @@ PosterData VPoster::Cut(int i, int j, const QRect &imageRect) const
{ {
Q_UNUSED(imageRect) Q_UNUSED(imageRect)
const int x = j*PageRect().width() - j*static_cast<int>(allowence); const int x = j*PageRect().width() - j*static_cast<int>(allowance);
const int y = i*PageRect().height() - i*static_cast<int>(allowence); const int y = i*PageRect().height() - i*static_cast<int>(allowance);
SCASSERT(x <= imageRect.width()) SCASSERT(x <= imageRect.width())
SCASSERT(y <= imageRect.height()) SCASSERT(y <= imageRect.height())

View file

@ -48,7 +48,7 @@ struct PosterData
rect(){} rect(){}
quint32 index; // paper index quint32 index; // paper index
quint32 row; // positions in the greed quint32 row; // positions in the grid
quint32 column; quint32 column;
quint32 rows; quint32 rows;
quint32 columns; quint32 columns;
@ -66,7 +66,7 @@ public:
QVector<QGraphicsItem *> Borders(QGraphicsItem *parent, const PosterData &img, int sheets) const; QVector<QGraphicsItem *> Borders(QGraphicsItem *parent, const PosterData &img, int sheets) const;
private: private:
const QPrinter *printer; const QPrinter *printer;
quint32 allowence; quint32 allowance;
int CountRows(int height) const; int CountRows(int height) const;
int CountColumns(int width) const; int CountColumns(int width) const;