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.
- [#589] Valentina lock up if not enough space for label.
- [#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
- [#594] Broken export on Mac.

View file

@ -25,6 +25,21 @@ win32{
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{
# QTBUG-31034 qmake doesn't allow override QMAKE_CXX
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->pushButtonCheckUpdate, &QPushButton::clicked, []()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
});

View file

@ -56,9 +56,6 @@ int main(int argc, char *argv[])
MApplication app(argc, argv);
app.InitOptions();
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
QTimer::singleShot(0, &app, SLOT(ProcessCMD()));
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.
OTHER_FILES += \
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();
});

View file

@ -285,6 +285,8 @@ win32:*-g++ {
$$PWD/../../../dist/win/s-measurements.ico \
$$PWD/../../../dist/win/pattern.ico \
$$PWD/../../../dist/win/pdftops.exe \
$$PWD/../../../dist/win/libeay32.dll \
$$PWD/../../../dist/win/ssleay32.dll \
$$PWD/../../../AUTHORS.txt \
$$PWD/../../../LICENSE_GPL.txt \
$$PWD/../../../README.txt \
@ -437,6 +439,13 @@ win32 {
pdftops_path += $${PWD}/$$DIR
}
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

View file

@ -61,12 +61,7 @@ FvUpdater* FvUpdater::sharedUpdater()
if (m_Instance.isNull())
{
mutex.lock();
if (m_Instance.isNull())
{
m_Instance = new FvUpdater;
}
m_Instance = new FvUpdater;
mutex.unlock();
}
@ -92,6 +87,7 @@ FvUpdater::FvUpdater()
m_qnam(),
m_reply(nullptr),
m_httpRequestAborted(false),
m_dropOnFinnish(true),
m_xml()
{
// noop
@ -101,6 +97,7 @@ FvUpdater::FvUpdater()
FvUpdater::~FvUpdater()
{
hideUpdaterWindow();
delete m_reply;
}
//---------------------------------------------------------------------------------------------------------------------
@ -142,6 +139,18 @@ QString FvUpdater::GetFeedURL() const
return m_feedURL.toString();
}
//---------------------------------------------------------------------------------------------------------------------
bool FvUpdater::IsDropOnFinnish() const
{
return m_dropOnFinnish;
}
//---------------------------------------------------------------------------------------------------------------------
void FvUpdater::SetDropOnFinnish(bool value)
{
m_dropOnFinnish = value;
}
//---------------------------------------------------------------------------------------------------------------------
QPointer<FvAvailableUpdate> FvUpdater::GetProposedUpdate()
{
@ -255,10 +264,19 @@ bool FvUpdater::CheckForUpdatesSilent()
{
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
{
if (m_dropOnFinnish)
{
drop();
}
return true;
}
}
@ -266,7 +284,12 @@ bool FvUpdater::CheckForUpdatesSilent()
//---------------------------------------------------------------------------------------------------------------------
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);
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.
// 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
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(totalBytes)
@ -299,7 +322,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
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 = 0;
if (m_dropOnFinnish)
{
drop();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -460,10 +487,7 @@ bool FvUpdater::searchDownloadedFeedForUpdates(const QString &xmlEnclosureUrl,
// to the user.
//
if (m_proposedUpdate)
{
delete m_proposedUpdate;
}
delete m_proposedUpdate;
m_proposedUpdate = new FvAvailableUpdate(this);
m_proposedUpdate->SetEnclosureUrl(xmlEnclosureUrl);
m_proposedUpdate->SetEnclosureVersion(xmlEnclosureVersion);

View file

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

View file

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

View file

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

View file

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

View file

@ -88,7 +88,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
{
VLayoutPiece det;
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.SetName(piece.GetName());
const VPatternPieceData& data = piece.GetPatternPieceData();
@ -134,34 +134,34 @@ void VLayoutPiece::SetCountourPoints(const QVector<QPointF> &points)
//---------------------------------------------------------------------------------------------------------------------
// 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);
d->seamAllowence = points;
if (not d->seamAllowence.isEmpty())
SetSeamAllowance(seamAllowance);
d->seamAllowance = points;
if (not d->seamAllowance.isEmpty())
{
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence), false);
d->seamAllowance = RemoveDublicates(RoundPoints(d->seamAllowance), false);
}
else
{
qWarning()<<"Seam allowence is empty.";
qWarning()<<"Seam allowance is empty.";
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
{
return d->layoutAllowence.count();
return d->layoutAllowance.count();
}
//---------------------------------------------------------------------------------------------------------------------
@ -382,7 +382,7 @@ QLineF VLayoutPiece::DetailEdge(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
{
return EdgeByPoint(d->layoutAllowence, p1);
return EdgeByPoint(d->layoutAllowance, p1);
}
//---------------------------------------------------------------------------------------------------------------------
@ -403,7 +403,7 @@ QRectF VLayoutPiece::DetailBoundingRect() const
QVector<QPointF> points;
if (IsSeamAllowance())
{
points = GetSeamAllowencePoints();
points = GetSeamAllowancePoints();
}
else
{
@ -417,7 +417,7 @@ QRectF VLayoutPiece::DetailBoundingRect() const
//---------------------------------------------------------------------------------------------------------------------
QRectF VLayoutPiece::LayoutBoundingRect() const
{
QVector<QPointF> points = GetLayoutAllowencePoints();
QVector<QPointF> points = GetLayoutAllowancePoints();
points.append(points.first());
return QPolygonF(points).boundingRect();
}
@ -434,7 +434,7 @@ bool VLayoutPiece::isNull() const
{
if (d->contour.isEmpty() == false && d->layoutWidth > 0)
{
if (IsSeamAllowance() && d->seamAllowence.isEmpty() == false)
if (IsSeamAllowance() && d->seamAllowance.isEmpty() == false)
{
return false;
}
@ -452,50 +452,50 @@ bool VLayoutPiece::isNull() const
//---------------------------------------------------------------------------------------------------------------------
qint64 VLayoutPiece::Square() const
{
if (d->layoutAllowence.isEmpty()) //-V807
if (d->layoutAllowance.isEmpty()) //-V807
{
return 0;
}
const qreal res = SumTrapezoids(d->layoutAllowence);
const qreal res = SumTrapezoids(d->layoutAllowance);
const qint64 sq = qFloor(qAbs(res/2.0));
return sq;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetLayoutAllowencePoints()
void VLayoutPiece::SetLayoutAllowancePoints()
{
if (d->layoutWidth > 0)
{
if (IsSeamAllowance())
{
d->layoutAllowence = Equidistant(PrepareAllowance(GetSeamAllowencePoints()), d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false)
d->layoutAllowance = Equidistant(PrepareAllowance(GetSeamAllowancePoints()), d->layoutWidth);
if (d->layoutAllowance.isEmpty() == false)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->layoutAllowence.remove(d->layoutAllowence.size() - 1);
d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
#else
d->layoutAllowence.removeLast();
d->layoutAllowance.removeLast();
#endif
}
}
else
{
d->layoutAllowence = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false)
d->layoutAllowance = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth);
if (d->layoutAllowance.isEmpty() == false)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->layoutAllowence.remove(d->layoutAllowence.size() - 1);
d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
#else
d->layoutAllowence.removeLast();
d->layoutAllowance.removeLast();
#endif
}
}
}
else
{
d->layoutAllowence.clear();
d->layoutAllowance.clear();
}
}
@ -557,10 +557,10 @@ QPainterPath VLayoutPiece::ContourPath() const
}
path.lineTo(points.at(0));
// seam allowence
// seam allowance
if (IsSeamAllowance() == true)
{
points = GetSeamAllowencePoints();
points = GetSeamAllowancePoints();
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;
path.setFillRule(Qt::WindingFill);
const QVector<QPointF> points = GetLayoutAllowencePoints();
const QVector<QPointF> points = GetLayoutAllowancePoints();
path.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i)
{
@ -841,7 +841,7 @@ QVector<QPointF> VLayoutPiece::DetailPath() const
{
if (IsSeamAllowance())
{
return d->seamAllowence;
return d->seamAllowance;
}
else
{

View file

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

View file

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

View file

@ -178,7 +178,7 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutPiece &detail, i
#ifdef SHOW_CANDIDATE
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);
paint.drawPath(p);
#else
@ -386,7 +386,7 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
}
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;
}

View file

@ -44,7 +44,7 @@
//---------------------------------------------------------------------------------------------------------------------
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);
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);
}
@ -100,8 +100,8 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
{// Right border
auto *line = new QGraphicsLineItem(parent);
line->setPen(pen);
line->setLine(rec.x() + rec.width()-static_cast<int>(allowence), rec.y(),
rec.x() + rec.width()-static_cast<int>(allowence), rec.y() + rec.height());
line->setLine(rec.x() + rec.width()-static_cast<int>(allowance), rec.y(),
rec.x() + rec.width()-static_cast<int>(allowance), rec.y() + rec.height());
data.append(line);
}
@ -113,7 +113,7 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
data.append(line);
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);
}
@ -122,15 +122,15 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
// Bottom border (mandatory)
auto *line = new QGraphicsLineItem(parent);
line->setPen(pen);
line->setLine(rec.x(), rec.y() + rec.height()-static_cast<int>(allowence),
rec.x() + rec.width(), 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>(allowance));
data.append(line);
if (img.row == img.rows-1)
{
auto *scissors = new QGraphicsPixmapItem(QPixmap("://scissors_horizontal.png"), parent);
scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowence),
rec.y() + rec.height()-static_cast<int>(allowence));
scissors->setPos(rec.x() + rec.width()-static_cast<int>(allowance),
rec.y() + rec.height()-static_cast<int>(allowance));
data.append(scissors);
}
}
@ -140,8 +140,8 @@ QVector<QGraphicsItem *> VPoster::Borders(QGraphicsItem *parent, const PosterDat
const int layoutX = 15;
const int layoutY = 5;
labels->setPos(rec.x() + layoutX, rec.y() + rec.height()-static_cast<int>(allowence)+layoutY);
labels->setTextWidth(rec.width()-(static_cast<int>(allowence)+layoutX));
labels->setPos(rec.x() + layoutX, rec.y() + rec.height()-static_cast<int>(allowance)+layoutY);
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 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
// each n-1 pages add (n-1)*allowence length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowence); //-V636
// each n-1 pages add (n-1)*allowance length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowance); //-V636
// Calculate additional length form pages that will cover this length (2).
// In the end add page length (3).
// Bottom page have mandatory border (4)
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);
}
@ -228,16 +228,16 @@ int VPoster::CountColumns(int width) const
// |----|
// ^
// (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
// each n-1 pages add (n-1)*allowence length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowence); //-V636
// each n-1 pages add (n-1)*allowance length to page (1).
const qreal addionalLength = (pCount-1)*static_cast<int>(allowance); //-V636
// Calculate additional length form pages that will cover this length (2).
// 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);
}
@ -246,8 +246,8 @@ PosterData VPoster::Cut(int i, int j, const QRect &imageRect) const
{
Q_UNUSED(imageRect)
const int x = j*PageRect().width() - j*static_cast<int>(allowence);
const int y = i*PageRect().height() - i*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>(allowance);
SCASSERT(x <= imageRect.width())
SCASSERT(y <= imageRect.height())

View file

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