Compare commits

...

4 Commits

Author SHA1 Message Date
Roman Telezhynskyi abdbf9241c Fix .cirrus.yml 2024-02-10 15:55:16 +02:00
Roman Telezhynskyi 1ac5a4167f Support for AppImage. 2024-02-10 15:53:02 +02:00
Roman Telezhynskyi 63292fa235 Sonar warnings. 2024-02-08 18:37:59 +02:00
Roman Telezhynskyi 91611cedfe Let the analyzer detect the number of threads automatically. 2024-02-08 18:15:19 +02:00
41 changed files with 313 additions and 1065 deletions

View File

@ -62,8 +62,8 @@ linux_qt6_sonar_task_template: &LINUX_QT6_TASK_SONAR_TEMPLATE
- qbs setup-qt /usr/bin/qmake6 qt6
- qbs config profiles.qt6.baseProfile ${COMPILER}
- qbs config defaultProfile qt6
- build-wrapper-linux-x86-64 --out-dir bw-output qbs build --no-install -f valentina.qbs -d build profile:qt6 config:release modules.buildconfig.enableCcache:false modules.cpp.linkerVariant:mold
- sonar-scanner -Dsonar.cfamily.threads=$(nproc) -Dsonar.scm.revision=${CIRRUS_CHANGE_IN_REPO} -Dsonar.links.ci=https://cirrus-ci.com/task/${CIRRUS_TASK_ID} -Dsonar.branch.name=${CIRRUS_BRANCH}
- build-wrapper-linux-x86-64 --out-dir bw-output qbs build --no-install -f valentina.qbs -d build --jobs $(nproc) profile:qt6 config:release modules.buildconfig.enableCcache:false modules.cpp.linkerVariant:mold
- sonar-scanner -Dsonar.scm.revision=${CIRRUS_CHANGE_IN_REPO} -Dsonar.links.ci=https://cirrus-ci.com/task/${CIRRUS_TASK_ID} -Dsonar.branch.name=${CIRRUS_BRANCH}
linux_qt5_qmake_task_template: &LINUX_QT5_QMAKE_TASK_TEMPLATE
install_script:
@ -111,6 +111,35 @@ linux_qt5_qbs_task_template: &LINUX_QT5_QBS_TASK_TEMPLATE
- qbs -p autotest-runner -d build profile:qt5 config:release
- ccache -s
linuxdeployqt_task_template: &LINUXDEPLOYQT_TASK_TEMPLATE
install_script:
- bash -c "$PACKAGE_MANAGER_INSTALL qt515base qt515svg qt515tools qt515xmlpatterns qt515translations qt515doc qt515imageformats poppler-utils git xvfb ccache build-essential"
build_script:
- uname -a
- mkdir -pm 0700 $XDG_RUNTIME_DIR
- Xvfb $DISPLAY -ac -screen 0 1600x1200x24+32 -nolisten tcp -nolisten unix &
- sleep 1
- ccache --set-config sloppiness=pch_defines,time_macros max_size="$CCACHE_SIZE"
- echo $PATH
- which qmake
- which qbs
- pwd
- ls -l /usr/bin/ | grep -E "${COMPILER_REGEX}"
- ${COMPILER} --version
- qmake --version
- qbs --version
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /opt/qt515/bin/qmake qt5
- qbs config defaultProfile qt5
- qbs config profiles.qt5.baseProfile ${COMPILER}
- qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build --jobs $(nproc) profile:qt5 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root modules.buildconfig.enableAppImage:true
- qbs -p autotest-runner -d build profile:qt5 config:release
- linuxdeployqt $CIRRUS_WORKING_DIR/build/install-root/usr/local/share/applications/ua.com.smart-pattern.valentina.desktop -appimage -qmake='/opt/qt515/bin/qmake' -executable-dir=$CIRRUS_WORKING_DIR/build/install-root/usr/local/bin -extra-plugins=iconengines,platformthemes/libqgtk3.so
- ccache -s
deploy_script:
- pwd
- $CIRRUS_WORKING_DIR/scripts/appimage-deploy.sh
linux_task:
<< : *REGULER_TASK_TEMPLATE
env:
@ -174,6 +203,28 @@ linux_task:
container:
cpu: 2
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
- container:
image: dismine/linuxdeployqt:latest
env:
COMPILER: gcc
QMAKE_SPEC: "linux-g++"
GCC_COLORS: 'error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
COMPILER_REGEX: "gcc|g\\+\\+"
matrix:
- name: 'AppImage'
<< : *LINUXDEPLOYQT_TASK_TEMPLATE
env:
ACCESS_TOKEN: ENCRYPTED[81e0b2381ffb628b73f5c94f834010e6631191e0ad03cdd0850d440fb2737a74b68131d842030f010c1bf73ab4cdc1ae]
DEPLOY: "true"
QT_SELECT: "qt5"
ENABLE_CCACHE: true
VERSION: "continuous"
QT_VERSION: Qt6
ARCH: x86_64
TARGET_PLATFORM: "Linux"
container:
cpu: 4
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
- container:
image: dismine/gcc-ubuntu:latest
env:

View File

@ -2,7 +2,7 @@
Type=Application
Name=Puzzle
Exec=puzzle %F
Version=1.1
Version=1.0
GenericName=Valentina's layout editor
GenericName[uk]=Редактор розкладки Валентини
Comment=Create and edit layouts
@ -12,5 +12,5 @@ Terminal=false
MimeType=application/x-valentina-layout;
Categories=Qt;Utility;FileTools;
TryExec=puzzle
Keywords=layout;nesting
Keywords=layout;nesting;
StartupWMClass=puzzle

View File

@ -2,7 +2,7 @@
Type=Application
Name=Tape
Exec=tape %F
Version=1.1
Version=1.0
GenericName=Valentina's measurements editor
GenericName[uk]=Редактор мірок Валентини
Comment=Create and edit measurements
@ -12,5 +12,5 @@ Terminal=false
MimeType=application/x-valentina-s-measurements;application/x-valentina-i-measurements;application/x-valentina-k-measurements
Categories=Qt;Utility;FileTools;
TryExec=tape
Keywords=measurements
Keywords=measurements;
StartupWMClass=tape

View File

@ -2,7 +2,7 @@
Type=Application
Name=Valentina
Exec=valentina %F
Version=1.1
Version=1.0
GenericName=Pattern making program
GenericName[uk]=Програма створення викрійок
Comment=Creating pattern of clothes
@ -10,7 +10,7 @@ Comment[uk]=Створеня викрійок одягу
Icon=valentina
Terminal=false
MimeType=application/x-valentina-pattern;
Categories=Graphics;VectorGraphics;2DGraphics;Qt;Engineering;
Categories=Graphics;VectorGraphics;2DGraphics;Qt;Engineering;FileTools;
TryExec=valentina
Keywords=pattern
Keywords=pattern;
StartupWMClass=valentina

View File

@ -33,21 +33,6 @@ VApp {
cpp.dynamicLibraries: ["icudata", "icui18n", "icuuc"]
}
Group {
name: "freedesktop"
prefix: project.sourceDirectory + "/dist/"
files: [
"ua.com.smart-pattern." + product.targetName + ".desktop"
]
}
freedesktop2.desktopKeys: ({
'Exec': FileInfo.joinPaths(qbs.installPrefix,
product.installDir,
product.targetName) + ' %F',
'X-Application-Version': product.version,
})
Group {
name: "Translations"
condition: product.primaryApp || (qbs.targetOS.contains("macos") && (!bundle.isBundle || (bundle.isBundle && buildconfig.enableMultiBundle)))

View File

@ -132,6 +132,7 @@ Module {
if (enableAppImage && qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos"))
defines.push('APPIMAGE');
defines.push('APPIMAGE_QT_TRANSLATIONS="' + FileInfo.joinPaths(qbs.installPrefix, "translations") + '"');
if (enableMultiBundle)
defines.push('MULTI_BUNDLE');

34
scripts/appimage-deploy.sh Executable file
View File

@ -0,0 +1,34 @@
print_error() {
echo "[CI] ERROR: $1"
}
print_info() {
echo "[CI] INFO: $1"
}
check_failure() {
if [ $? -ne 0 ] ; then
if [ -z $1 ] ; then
print_error $1
else
print_error "Failure exit code is detected."
fi
exit 1
fi
}
if [[ "$DEPLOY" == "true" ]]; then
print_info "Start cleaning.";
python3 $CIRRUS_WORKING_DIR/scripts/deploy.py clean $ACCESS_TOKEN;
check_failure "Unable to clean stale artifacts.";
print_info "Start uploading.";
python3 $CIRRUS_WORKING_DIR/scripts/deploy.py upload $ACCESS_TOKEN $CIRRUS_WORKING_DIR/Valentina-continuous-x86_64.AppImage "/0.7.x/Linux/valentina-${TARGET_PLATFORM}-${ARCH}-${CIRRUS_BRANCH}-${CIRRUS_CHANGE_IN_REPO}.AppImage";
check_failure "Unable to upload Valentina's AppImage.";
print_info "Successfully uploaded.";
else
print_info "No deployment needed.";
fi

View File

@ -141,7 +141,8 @@ def run_clean(refresh_token):
r'^valentina-macOS_10.13\+-Qt.*-x64-develop-[a-f0-9]{40}\.dmg$',
r'^valentina-macOS_10.13\+-Qt.*-x64-develop-multibundle-[a-f0-9]{40}\.dmg$',
r'^valentina-macOS.*\+-Qt.*-arm.*-develop-[a-f0-9]{40}\.dmg$',
r'^valentina-macOS.*\+-Qt.*-arm.*-develop-multibundle-[a-f0-9]{40}\.dmg$']
r'^valentina-macOS.*\+-Qt.*-arm.*-develop-multibundle-[a-f0-9]{40}\.dmg$',
r'^valentina-Linux-x86_64-develop-[a-f0-9]{40}\.AppImage$']
item_types = {}

View File

@ -346,8 +346,13 @@ auto VPPiece::StickyPosition(qreal &dx, qreal &dy) const -> bool
return false;
}
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wnoexcept")
VStickyDistance match;
QT_WARNING_POP
if (!StickySheet(match))
{
return false;

View File

@ -31,11 +31,6 @@
#include "vpapplication.h"
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
#include "../vmisc/appimage.h"
#include <QScopeGuard>
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <xercesc/util/PlatformUtils.hpp>
#endif
@ -71,12 +66,6 @@
auto main(int argc, char *argv[]) -> int
{
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
/* Fix path to ICU_DATA when run AppImage.*/
char *exe_dir = IcuDataPath("/../share/icu");
auto FreeMemory = qScopeGuard([exe_dir] { free(exe_dir); });
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(puzzleicon); // NOLINT
Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); // NOLINT
@ -123,12 +112,5 @@ auto main(int argc, char *argv[]) -> int
QTimer::singleShot(0, &app, &VPApplication::ProcessCMD);
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
if (exe_dir)
{
qDebug() << "Path to ICU folder:" << exe_dir;
}
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return VPApplication::exec();
}

View File

@ -337,6 +337,22 @@ VToolApp {
fileTags:["svg_fonts"]
}
Group {
name: "freedesktop"
condition: !buildconfig.enableAppImage && qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos")
prefix: project.sourceDirectory + "/dist/"
files: [
"ua.com.smart-pattern." + product.targetName + ".desktop"
]
}
freedesktop2.desktopKeys: ({
'Exec': FileInfo.joinPaths(qbs.installPrefix,
product.installDir,
product.targetName) + ' %F',
'X-Application-Version': product.version,
})
Rule {
condition: product.qbs.targetOS.contains("macos") && product.buildconfig.enableMultiBundle
inputs: ["svg_fonts"]

View File

@ -31,11 +31,6 @@
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer>
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
#include "../vmisc/appimage.h"
#include <QScopeGuard>
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <xercesc/util/PlatformUtils.hpp>
#endif
@ -71,12 +66,6 @@
auto main(int argc, char *argv[]) -> int
{
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
/* Fix path to ICU_DATA when run AppImage.*/
char *exe_dir = IcuDataPath("/../share/icu");
auto FreeMemory = qScopeGuard([exe_dir] { free(exe_dir); });
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(tapeicon); // NOLINT
Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); // NOLINT
@ -121,12 +110,5 @@ auto main(int argc, char *argv[]) -> int
QTimer::singleShot(0, &app, &MApplication::ProcessCMD);
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
if (exe_dir)
{
qDebug() << "Path to ICU folder:" << exe_dir;
}
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return MApplication::exec();
}

View File

@ -74,10 +74,6 @@
#define BUILD_REVISION VCS_REPO_STATE_REVISION
#endif
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
#include "../vmisc/appimage.h"
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include "../vmisc/compatibility.h"
#endif

View File

@ -245,4 +245,20 @@ VToolApp {
"k-measurements.iconset"
]
}
Group {
name: "freedesktop"
condition: !buildconfig.enableAppImage && qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos")
prefix: project.sourceDirectory + "/dist/"
files: [
"ua.com.smart-pattern." + product.targetName + ".desktop"
]
}
freedesktop2.desktopKeys: ({
'Exec': FileInfo.joinPaths(qbs.installPrefix,
product.installDir,
product.targetName) + ' %F',
'X-Application-Version': product.version,
})
}

View File

@ -35,11 +35,6 @@
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer>
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
#include "../vmisc/appimage.h"
#include <QScopeGuard>
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <xercesc/util/PlatformUtils.hpp>
#endif
@ -77,12 +72,6 @@
auto main(int argc, char *argv[]) -> int
{
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
/* Fix path to ICU_DATA when run AppImage.*/
char *exe_dir = IcuDataPath("/../share/icu");
auto FreeMemory = qScopeGuard([exe_dir] { free(exe_dir); });
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(cursor); // NOLINT
Q_INIT_RESOURCE(toolcursor); // NOLINT
Q_INIT_RESOURCE(icon); // NOLINT
@ -158,12 +147,5 @@ auto main(int argc, char *argv[]) -> int
QTimer::singleShot(msec, &w, &MainWindow::ProcessCMD);
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
if (exe_dir)
{
qDebug() << "Path to ICU folder:" << exe_dir;
}
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return VApplication::exec();
}

View File

@ -261,10 +261,33 @@ VToolApp {
name: "freedesktop"
prefix: project.sourceDirectory + "/dist/"
files: [
"ua.com.smart-pattern." + product.targetName + ".metainfo.xml"
"ua.com.smart-pattern." + product.targetName + ".metainfo.xml",
"ua.com.smart-pattern." + product.targetName + ".desktop"
]
}
freedesktop2.desktopKeys: {
var desktopKeys = {
'Exec': FileInfo.joinPaths(qbs.installPrefix,
product.installDir,
product.targetName) + ' %F',
'X-Application-Version': product.version,
};
if (buildconfig.enableAppImage) {
var mimeTypes = [
'application/x-valentina-pattern',
'application/x-valentina-s-measurements',
'application/x-valentina-i-measurements',
'application/x-valentina-k-measurements',
'application/x-valentina-layout'
];
desktopKeys['MimeType'] = mimeTypes.join(';');
}
return (desktopKeys);
}
Group {
name: "48x48/apps"
prefix: project.sourceDirectory + "/share/icons/48x48/apps/"

View File

@ -1993,13 +1993,13 @@ auto VDxfEngine::NotchPrecedingPoint(const QVector<VLayoutPoint> &boundary, QPoi
if (VFuzzyComparePoints(boundary.constFirst(), notchBase))
{
point = boundary.constFirst();
point = boundary.constFirst().ToQPointF();
return true;
}
if (VFuzzyComparePoints(boundary.constLast(), notchBase))
{
point = boundary.constLast();
point = boundary.constLast().ToQPointF();
return true;
}
@ -2016,7 +2016,7 @@ auto VDxfEngine::NotchPrecedingPoint(const QVector<VLayoutPoint> &boundary, QPoi
const qreal length = QLineF(notchBase, cPoint).length();
if (length < bestDistance)
{
candidatePoint = boundary.at(i);
candidatePoint = boundary.at(i).ToQPointF();
bestDistance = length;
found = true;
}

View File

@ -374,37 +374,31 @@ auto VGObject::ContactPoints(const QPointF &p, const QPointF &center, qreal radi
*/
auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPointF
{
qreal x1, y1, x2, y2;
qreal x1 = 0;
qreal y1 = 0;
qreal x2 = 0;
qreal y2 = 0;
rec.getCoords(&x1, &y1, &x2, &y2);
// Define lines representing each side of the rectangle
QLineF const topLine(QPointF(x1, y1), QPointF(x2, y1));
QLineF const bottomLine(QPointF(x1, y2), QPointF(x2, y2));
QLineF const leftLine(QPointF(x1, y1), QPointF(x1, y2));
QLineF const rightLine(QPointF(x2, y1), QPointF(x2, y2));
QPointF point;
QLineF::IntersectType type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point);
if (type == QLineF::BoundedIntersection)
// Check intersections with each side of the rectangle
if (line.intersects(topLine, &point) == QLineF::BoundedIntersection ||
line.intersects(bottomLine, &point) == QLineF::BoundedIntersection ||
line.intersects(leftLine, &point) == QLineF::BoundedIntersection ||
line.intersects(rightLine, &point) == QLineF::BoundedIntersection)
{
return point;
}
type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point);
if (type == QLineF::BoundedIntersection)
{
return point;
}
type = line.intersects(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point);
if (type == QLineF::BoundedIntersection)
{
return point;
}
type = line.intersects(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point);
if (type == QLineF::BoundedIntersection)
{
return point;
}
return point;
// Return the point (which would be (0,0) if no intersection is found)
return {};
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,7 +55,7 @@ COPY_CONSTRUCTOR_IMPL_2(VPointF, VGObject)
//---------------------------------------------------------------------------------------------------------------------
VPointF::VPointF(const QPointF &point)
: VGObject(VPointF()),
: VGObject(GOType::Point, 0, Draw::Calculation),
d(new VPointFData(point))
{
}

View File

@ -609,7 +609,7 @@ auto AngleBySecondRightAngle(QVector<VRawSAPoint> points, QPointF p1, QPointF p2
if (success)
{
points = temp;
px = points.constLast();
px = points.constLast().ToQPointF();
}
if (countBefore > 0)
@ -852,7 +852,7 @@ void RollbackBySecondEdgeRightAngle(QVector<VRawSAPoint> &ekvPoints, const QVect
if (success)
{
ekvPoints = temp;
px = ekvPoints.constLast();
px = ekvPoints.constLast().ToQPointF();
}
QLineF seam(px, points.at(1));
@ -1322,23 +1322,28 @@ auto VAbstractPiece::EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Lin
break;
case PieceNodeAngle::ByLength:
case PieceNodeAngle::ByLengthCurve:
return AngleByLength(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2, p2Line1,
width, needRollback);
return AngleByLength(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(), p1Line2.ToQPointF(),
bigLine1, crosPoint, bigLine2, p2Line1, width, needRollback);
case PieceNodeAngle::ByPointsIntersection:
return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
p2Line1, width, needRollback);
return AngleByIntersection(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
needRollback);
case PieceNodeAngle::ByFirstEdgeSymmetry:
return AngleByFirstSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
p2Line1, width, needRollback);
return AngleByFirstSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
needRollback);
case PieceNodeAngle::BySecondEdgeSymmetry:
return AngleBySecondSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
p2Line1, width, needRollback);
return AngleBySecondSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
needRollback);
case PieceNodeAngle::ByFirstEdgeRightAngle:
return AngleByFirstRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
p2Line1, width, needRollback);
return AngleByFirstRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
width, needRollback);
case PieceNodeAngle::BySecondEdgeRightAngle:
return AngleBySecondRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
p2Line1, width, needRollback);
return AngleBySecondRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
width, needRollback);
}
QT_WARNING_POP

View File

@ -797,8 +797,7 @@ inline auto VAbstractPiece::SubdividePath(const QVector<T> &boundary, const QPoi
continue;
}
if (!VGObject::IsPointOnLineSegment(p, static_cast<QPointF>(boundary.at(i)),
static_cast<QPointF>(boundary.at(i + 1))))
if (!VGObject::IsPointOnLineSegment(p, boundary.at(i).ToQPointF(), boundary.at(i + 1).ToQPointF()))
{
sub1.append(boundary.at(i));
continue;
@ -858,7 +857,7 @@ inline auto VAbstractPiece::MirrorPath<VLayoutPoint>(const QVector<VLayoutPoint>
for (const auto &p : points)
{
VLayoutPoint tmp = p;
QPointF const flippedPoint = matrix.map(static_cast<QPointF>(p));
QPointF const flippedPoint = matrix.map(p.ToQPointF());
tmp.setX(flippedPoint.x());
tmp.setY(flippedPoint.y());
flipped.append(tmp);

View File

@ -223,56 +223,60 @@ auto VFoldLine::FoldLineMarkPoints() const -> QVector<QVector<QPointF>>
//---------------------------------------------------------------------------------------------------------------------
auto VFoldLine::LabelPosition(bool &ok) const -> FoldLabelPosData
{
FoldLabelPosData posData;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wnoexcept")
TextPosData data;
FoldLabelPosData posData;
std::unique_ptr<TextPosData> data;
QT_WARNING_POP
if (m_type == FoldLineType::Text)
{
data = TextData();
data = std::make_unique<TextPosData>(TextData());
}
else if (m_type == FoldLineType::TwoArrowsTextAbove)
{
data = TwoArrowsTextAboveData();
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextAboveData());
}
else
{
data = TwoArrowsTextUnderData();
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextUnderData());
}
if (data.base.isNull())
if (data->base.isNull())
{
ok = false;
return {};
}
qreal const height = data.labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
qreal const margin = qMax(0., height - data.labelHeight);
qreal const height = data->labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
qreal const margin = qMax(0., height - data->labelHeight);
QPointF const center = TrueCenter(data.base, data.labelWidth);
QPointF const center = TrueCenter(data->base, data->labelWidth);
QLineF baseLine(center, data.base.p1());
baseLine.setLength(data.labelWidth / 2);
QLineF baseLine(center, data->base.p1());
baseLine.setLength(data->labelWidth / 2);
Swap(baseLine);
baseLine.setLength(baseLine.length() * 2);
baseLine = SimpleParallelLine(baseLine.p1(), baseLine.p2(), -(margin + data.labelHeight));
baseLine = SimpleParallelLine(baseLine.p1(), baseLine.p2(), -(margin + data->labelHeight));
posData.font = LabelOutlineFont();
QFontMetrics const fm(posData.font);
posData.label = fm.elidedText(FoldLineLabel(), Qt::ElideRight, qFloor(data.labelWidth));
posData.label = fm.elidedText(FoldLineLabel(), Qt::ElideRight, qFloor(data->labelWidth));
if (m_alignment & Qt::AlignHCenter) // NOLINT(readability-implicit-bool-conversion)
{
qreal const shift = (data.labelWidth - fm.horizontalAdvance(posData.label)) / 2;
qreal const shift = (data->labelWidth - fm.horizontalAdvance(posData.label)) / 2;
baseLine.setLength(baseLine.length() - shift);
}
else if (m_alignment & Qt::AlignRight) // NOLINT(readability-implicit-bool-conversion)
{
qreal const shift = data.labelWidth - fm.horizontalAdvance(posData.label);
qreal const shift = data->labelWidth - fm.horizontalAdvance(posData.label);
baseLine.setLength(baseLine.length() - shift);
}
posData.pos = baseLine.p2();
posData.angle = QLineF(center, data.base.p1()).angle();
posData.angle = QLineF(center, data->base.p1()).angle();
ok = true;
return posData;

View File

@ -544,7 +544,7 @@ void InitFoldLine(VLayoutPiece &det, const VPiece &piece, const VContainer *patt
//---------------------------------------------------------------------------------------------------------------------
auto operator<<(QDataStream &dataStream, const VLayoutPoint &p) -> QDataStream &
{
dataStream << static_cast<QPointF>(p); // NOLINT(cppcoreguidelines-slicing)
dataStream << p.ToQPointF();
dataStream << p.TurnPoint();
dataStream << p.CurvePoint();
return dataStream;
@ -570,7 +570,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPoint &p) -> QDataStream &
//---------------------------------------------------------------------------------------------------------------------
auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &
{
dataStream << static_cast<VAbstractPiece>(piece); // NOLINT(cppcoreguidelines-slicing)
const VAbstractPiece &abstractPiece = piece;
dataStream << abstractPiece;
dataStream << *piece.d;
return dataStream;
}
@ -584,11 +585,16 @@ auto operator>>(QDataStream &dataStream, VLayoutPiece &piece) -> QDataStream &
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wnoexcept")
VLayoutPiece::VLayoutPiece()
: d(new VLayoutPieceData)
{
}
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
COPY_CONSTRUCTOR_IMPL_2(VLayoutPiece, VAbstractPiece)

View File

@ -56,3 +56,9 @@ auto VLayoutPoint::toJson() const -> QJsonObject
return pointObject;
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPoint::ToQPointF() const -> QPointF
{
return {x(), y()};
}

View File

@ -52,6 +52,7 @@ public:
Q_DECL_RELAXED_CONSTEXPR void SetCurvePoint(bool newCurvePoint);
auto toJson() const -> QJsonObject;
auto ToQPointF() const -> QPointF;
private:
bool m_turnPoint{false};

View File

@ -46,12 +46,7 @@ QT_WARNING_DISABLE_CLANG("-Wnon-virtual-dtor")
class VSAPoint final : public VLayoutPoint
{
public:
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wnoexcept")
Q_DECL_CONSTEXPR VSAPoint() = default;
QT_WARNING_POP
Q_DECL_CONSTEXPR VSAPoint() noexcept;
Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos);
Q_DECL_CONSTEXPR explicit VSAPoint(QPointF p);
@ -114,6 +109,11 @@ private:
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint() noexcept // NOLINT(hicpp-use-equals-default)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
: VLayoutPoint(xpos, ypos)

View File

@ -27,45 +27,15 @@
*************************************************************************/
#include "appimage.h"
#include <stdlib.h>
#include <unicode/putil.h>
#include <QString>
#include <QCoreApplication>
#include <cstring>
#include <QString>
#include <QVector>
extern "C" {
#include "binreloc.h"
}
#include "../vmisc/def.h"
#include <unicode/putil.h>
#include "compatibility.h"
#include "def.h"
//---------------------------------------------------------------------------------------------------------------------
/* When deploying with AppImage based on OpenSuse, the ICU library has a hardcoded path to the icudt*.dat file.
* This prevents the library from using shared in memory data. There are few ways to resolve this issue. According
* to documentation we can either use ICU_DATA environment variable or the function u_setDataDirectory().
*/
char* IcuDataPath(const char* correction)
{
char * data_path = nullptr;
BrInitError error;
if (br_init (&error))
{
char *path = br_find_exe_dir(nullptr);
if (path)
{
data_path = static_cast<char *> (malloc(strlen(path) + strlen(correction) + 1));
if(data_path)
{
strcpy(data_path, path);
strcat(data_path, correction);
u_setDataDirectory(data_path);
}
free(path);
}
}
return data_path;
}
using namespace Qt::Literals::StringLiterals;
//---------------------------------------------------------------------------------------------------------------------
/**
@ -89,7 +59,7 @@ QString AppImageRoot(const QString &applicationDir, const QString &defaultAppDir
if (appSub.isEmpty() || defaultSub.isEmpty() || appSub.size() <= defaultSub.size())
{
return QString();
return {};
}
appSub = Reverse(appSub);
@ -99,12 +69,12 @@ QString AppImageRoot(const QString &applicationDir, const QString &defaultAppDir
{
if (defaultSub.at(i) != appSub.at(i))
{
return QString();
return {};
}
}
QStringList rootSub = appSub.mid(defaultSub.size());
rootSub = Reverse(rootSub);
return '/' + rootSub.join('/');
return '/'_L1 + rootSub.join('/');
}

View File

@ -30,8 +30,6 @@
class QString;
char* IcuDataPath(const char* correction);
QString AppImageRoot();
QString AppImageRoot(const QString &applicationDir, const QString &defaultAppDir);

View File

@ -1,758 +0,0 @@
/*
* BinReloc - a library for creating relocatable executables
*
* Originally written by: Hongli Lai <h.lai@chello.nl>
* http://autopackage.org/ (defunct)
*
* Maintained by: Wolfgang 'datenwolf' Draxinger <coding@datenwolf.net>
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/limits.h>
#include "binreloc.h"
#ifndef SSIZE_MAX
#define SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))
#endif
/** @internal
* Find the canonical filename of the executable. Returns the filename
* (which must be freed) or NULL on error. If the parameter 'error' is
* not NULL, the error code will be stored there, if an error occured.
*/
static char *
_br_find_exe (BrInitError *error)
{
char *path, *path2, *line, *result;
size_t buf_size;
struct stat stat_buf;
FILE *f;
/* Read from /proc/self/exe (symlink) */
if (sizeof (path) > SSIZE_MAX)
buf_size = SSIZE_MAX - 1;
else
buf_size = PATH_MAX - 1;
path = (char *) malloc (buf_size);
if (path == NULL) {
/* Cannot allocate memory. */
if (error)
*error = BR_INIT_ERROR_NOMEM;
return NULL;
}
path2 = (char *) malloc (buf_size);
if (path2 == NULL) {
/* Cannot allocate memory. */
if (error)
*error = BR_INIT_ERROR_NOMEM;
free (path);
return NULL;
}
strncpy (path2, "/proc/self/exe", buf_size - 1);
while (1) {
int i;
ssize_t size = readlink (path2, path, buf_size - 1);
if (size == -1) {
/* Error. */
free (path2);
break;
}
/* readlink() success. */
path[size] = '\0';
/* Check whether the symlink's target is also a symlink.
* We want to get the final target. */
i = stat (path, &stat_buf);
if (i == -1) {
/* Error. */
free (path2);
break;
}
/* stat() success. */
if (!S_ISLNK (stat_buf.st_mode)) {
/* path is not a symlink. Done. */
free (path2);
return path;
}
/* path is a symlink. Continue loop and resolve this. */
strncpy (path, path2, buf_size - 1);
}
/* readlink() or stat() failed; this can happen when the program is
* running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
buf_size = PATH_MAX + 128;
line = (char *) realloc (path, buf_size);
if (line == NULL) {
/* Cannot allocate memory. */
free (path);
if (error)
*error = BR_INIT_ERROR_NOMEM;
return NULL;
}
f = fopen ("/proc/self/maps", "r");
if (f == NULL) {
free (line);
if (error)
*error = BR_INIT_ERROR_OPEN_MAPS;
return NULL;
}
/* The first entry should be the executable name. */
result = fgets (line, (int) buf_size, f);
if (result == NULL) {
fclose (f);
free (line);
if (error)
*error = BR_INIT_ERROR_READ_MAPS;
return NULL;
}
/* Get rid of newline character. */
buf_size = strlen (line);
if (buf_size == 0) {
/* Huh? An empty string? */
fclose (f);
free (line);
if (error)
*error = BR_INIT_ERROR_INVALID_MAPS;
return NULL;
}
if (line[buf_size - 1] == 10)
line[buf_size - 1] = 0;
/* Extract the filename; it is always an absolute path. */
path = strchr (line, '/');
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || path == NULL) {
fclose (f);
free (line);
if (error)
*error = BR_INIT_ERROR_INVALID_MAPS;
return NULL;
}
path = strdup (path);
free (line);
fclose (f);
return path;
}
/** @internal
* Find the canonical filename of the executable which owns symbol.
* Returns a filename which must be freed, or NULL on error.
*/
static char *
_br_find_exe_for_symbol (const void *symbol, BrInitError *error)
{
#define SIZE PATH_MAX + 100
FILE *f;
size_t address_string_len;
char *address_string, line[SIZE], *found;
if (symbol == NULL)
return (char *) NULL;
f = fopen ("/proc/self/maps", "r");
if (f == NULL)
return (char *) NULL;
address_string_len = 4;
address_string = (char *) malloc (address_string_len);
found = (char *) NULL;
while (!feof (f)) {
char *start_addr, *end_addr, *end_addr_end, *file;
void *start_addr_p, *end_addr_p;
size_t len;
if (fgets (line, SIZE, f) == NULL)
break;
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL)
continue;
/* Parse line. */
start_addr = line;
end_addr = strchr (line, '-');
file = strchr (line, '/');
/* More sanity check. */
if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-'))
continue;
end_addr[0] = '\0';
end_addr++;
end_addr_end = strchr (end_addr, ' ');
if (end_addr_end == NULL)
continue;
end_addr_end[0] = '\0';
len = strlen (file);
if (len == 0)
continue;
if (file[len - 1] == '\n')
file[len - 1] = '\0';
/* Get rid of "(deleted)" from the filename. */
len = strlen (file);
if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0)
file[len - 10] = '\0';
/* I don't know whether this can happen but better safe than sorry. */
len = strlen (start_addr);
if (len != strlen (end_addr))
continue;
/* Transform the addresses into a string in the form of 0xdeadbeef,
* then transform that into a pointer. */
if (address_string_len < len + 3) {
address_string_len = len + 3;
char *new_address_string = (char *) realloc (address_string, address_string_len);
if (new_address_string == NULL){
*error = BR_INIT_ERROR_NOMEM;
free (address_string);
fclose (f);
return (char *) NULL;
}
else
address_string = new_address_string;
}
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, start_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &start_addr_p);
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, end_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &end_addr_p);
if (symbol >= start_addr_p && symbol < end_addr_p) {
found = file;
break;
}
}
free (address_string);
fclose (f);
if (found == NULL)
return (char *) NULL;
else
return strdup (found);
}
#ifndef BINRELOC_RUNNING_DOXYGEN
#undef NULL
#define NULL ((void *) 0) /* typecasted as char* for C++ type safeness */
#endif
static char *exe = (char *) NULL;
/** Initialize the BinReloc library (for applications).
*
* This function must be called before using any other BinReloc functions.
* It attempts to locate the application's canonical filename.
*
* @note If you want to use BinReloc for a library, then you should call
* br_init_lib() instead.
*
* @param error If BinReloc failed to initialize, then the error code will
* be stored in this variable. Set to NULL if you want to
* ignore this. See #BrInitError for a list of error codes.
*
* @returns 1 on success, 0 if BinReloc failed to initialize.
*/
int
br_init (BrInitError *error)
{
exe = _br_find_exe (error);
return exe != NULL;
}
/** Initialize the BinReloc library (for libraries).
*
* This function must be called before using any other BinReloc functions.
* It attempts to locate the calling library's canonical filename.
*
* @note The BinReloc source code MUST be included in your library, or this
* function won't work correctly.
*
* @param error If BinReloc failed to initialize, then the error code will
* be stored in this variable. Set to NULL if you want to
* ignore this. See #BrInitError for a list of error codes.
*
* @returns 1 on success, 0 if a filename cannot be found.
*/
int
br_init_lib (BrInitError *error)
{
exe = _br_find_exe_for_symbol ((const void *) "", error);
return exe != NULL;
}
/** Find the canonical filename of the current application.
*
* @param default_exe A default filename which will be used as fallback.
* @returns A string containing the application's canonical filename,
* which must be freed when no longer necessary. If BinReloc is
* not initialized, or if br_init() failed, then a copy of
* default_exe will be returned. If default_exe is NULL, then
* NULL will be returned.
*/
char *
br_find_exe (const char *default_exe)
{
if (exe == (char *) NULL) {
/* BinReloc is not initialized. */
if (default_exe != (const char *) NULL)
return strdup (default_exe);
else
return (char *) NULL;
}
return strdup (exe);
}
/** Locate the directory in which the current application is installed.
*
* The prefix is generated by the following pseudo-code evaluation:
* \code
* dirname(exename)
* \endcode
*
* @param default_dir A default directory which will used as fallback.
* @return A string containing the directory, which must be freed when no
* longer necessary. If BinReloc is not initialized, or if the
* initialization function failed, then a copy of default_dir
* will be returned. If default_dir is NULL, then NULL will be
* returned.
*/
char *
br_find_exe_dir (const char *default_dir)
{
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_dir != NULL)
return strdup (default_dir);
else
return NULL;
}
return br_dirname (exe);
}
/** Locate the prefix in which the current application is installed.
*
* The prefix is generated by the following pseudo-code evaluation:
* \code
* dirname(dirname(exename))
* \endcode
*
* @param default_prefix A default prefix which will used as fallback.
* @return A string containing the prefix, which must be freed when no
* longer necessary. If BinReloc is not initialized, or