Merge branch 'develop' into 'develop'

Bugfix: suppressing horizontal scrolling on Preferences>Pattern and...

See merge request smart-pattern/valentina!17
This commit is contained in:
Roman Telezhynskyi 2024-02-23 09:35:32 +00:00
commit db245ed644
15 changed files with 81 additions and 50 deletions

View File

@ -90,8 +90,7 @@ void VPCarrousel::Refresh()
// Do not rely on m_layout because we do not control it. // Do not rely on m_layout because we do not control it.
m_pieceLists = QList<VPCarrouselSheet>(); m_pieceLists = QList<VPCarrouselSheet>();
VPLayoutPtr const layout = m_layout.toStrongRef(); if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
if (not layout.isNull())
{ {
{ {
VPCarrouselSheet carrouselSheet; VPCarrouselSheet carrouselSheet;
@ -216,8 +215,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
if (not sheet.isNull()) if (not sheet.isNull())
{ {
VPSheetPtr const activeSheet = layout->GetFocusedSheet(); if (VPSheetPtr const activeSheet = layout->GetFocusedSheet(); not activeSheet.isNull())
if (not activeSheet.isNull())
{ {
activeSheet->ClearSelection(); activeSheet->ClearSelection();
} }

View File

@ -175,7 +175,7 @@ void DialogPuzzlePreferences::Ok()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPuzzlePreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *previous) void DialogPuzzlePreferences::PageChanged(const QListWidgetItem * current, QListWidgetItem * const previous)
{ {
if (current == nullptr) if (current == nullptr)
{ {

View File

@ -60,7 +60,7 @@ protected:
private slots: private slots:
void Apply(); void Apply();
void Ok(); void Ok();
void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); void PageChanged(const QListWidgetItem *current, QListWidgetItem * const previous);
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro

View File

@ -157,7 +157,7 @@ void VPPiece::Update(const VPPiecePtr &piece)
SetInternalPaths(piece->GetInternalPaths()); SetInternalPaths(piece->GetInternalPaths());
SetPassmarks(piece->GetPassmarks()); SetPassmarks(piece->GetPassmarks());
SetPlaceLabels(piece->GetPlaceLabels()); SetPlaceLabels(piece->GetPlaceLabels());
SetGrainline(piece->GetGrainline()); SetVPGrainline(piece->GetGrainline());
SetPieceLabelRect(piece->GetPieceLabelRect()); SetPieceLabelRect(piece->GetPieceLabelRect());
SetPieceLabelData(piece->GetPieceLabelData()); SetPieceLabelData(piece->GetPieceLabelData());
SetPatternLabelRect(piece->GetPatternLabelRect()); SetPatternLabelRect(piece->GetPatternLabelRect());
@ -294,7 +294,7 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetGrainline(const VPieceGrainline &grainline) void VPPiece::SetVPGrainline(const VPieceGrainline &grainline)
{ {
VLayoutPiece::SetGrainline(grainline); VLayoutPiece::SetGrainline(grainline);
} }
@ -682,7 +682,7 @@ void VPPiece::CleanPosition(const VPPiecePtr &piece)
{ {
VPieceGrainline grainline = piece->GetGrainline(); VPieceGrainline grainline = piece->GetGrainline();
grainline.SetMainLine(matrix.map(grainline.GetMainLine())); grainline.SetMainLine(matrix.map(grainline.GetMainLine()));
piece->SetGrainline(grainline); piece->SetVPGrainline(grainline);
} }
piece->SetPieceLabelRect(MapVector(piece->GetPieceLabelRect(), matrix)); piece->SetPieceLabelRect(MapVector(piece->GetPieceLabelRect(), matrix));

View File

@ -96,7 +96,7 @@ public:
auto Layout() const -> VPLayoutPtr; auto Layout() const -> VPLayoutPtr;
void SetLayout(const VPLayoutPtr &layout); void SetLayout(const VPLayoutPtr &layout);
void SetGrainline(const VPieceGrainline &grainline); void SetVPGrainline(const VPieceGrainline &grainline);
/** /**
* @brief Flip verticvally mirror around center of bounding rect * @brief Flip verticvally mirror around center of bounding rect

View File

@ -855,11 +855,8 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece)
m_passmarks.addPath(passmarkPath); m_passmarks.addPath(passmarkPath);
QLineF const seamAllowanceMirrorLine = piece->GetMappedSeamAllowanceMirrorLine(); QLineF const seamAllowanceMirrorLine = piece->GetMappedSeamAllowanceMirrorLine();
if (!seamAllowanceMirrorLine.isNull() && piece->IsShowFullPiece()) if (!seamAllowanceMirrorLine.isNull() && piece->IsShowFullPiece() && !VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), seamAllowanceMirrorLine.p1(), seamAllowanceMirrorLine.p2()))
{ {
if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), seamAllowanceMirrorLine.p1(),
seamAllowanceMirrorLine.p2()))
{
QPainterPath mirroredPassmaksPath; QPainterPath mirroredPassmaksPath;
for (const auto &line : passmark.lines) for (const auto &line : passmark.lines)
{ {
@ -868,7 +865,6 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece)
} }
const QTransform matrix = VGObject::FlippingMatrix(seamAllowanceMirrorLine); const QTransform matrix = VGObject::FlippingMatrix(seamAllowanceMirrorLine);
m_passmarks.addPath(matrix.map(mirroredPassmaksPath)); m_passmarks.addPath(matrix.map(mirroredPassmaksPath));
}
} }
if (painter != nullptr) if (painter != nullptr)

View File

@ -62,14 +62,14 @@ BEGIN
BLOCK "040904E4" BLOCK "040904E4"
BEGIN BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR VALUE "FileDescription", "Valentina's manual layout creator."
VALUE "FileVersion", VER_FILEVERSION_STR VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR VALUE "InternalName", "Puzzle"
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR VALUE "OriginalFilename", "puzzle.exe"
VALUE "ProductName", VER_PRODUCTNAME_STR VALUE "ProductName", "Puzzle"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END END
END END

View File

@ -29,11 +29,12 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#include <QString>
#include "../../libs/vmisc/projectversion.h" #include "../../libs/vmisc/projectversion.h"
#define VER_INTERNALNAME_STR "Puzzle" extern const QString verInternalNameStr;
#define VER_ORIGINALFILENAME_STR "puzzle.exe" extern const QString verOriginalFilenameStr;
#define VER_PRODUCTNAME_STR "Puzzle" extern const QString verProductNameStr;
#define VER_FILEDESCRIPTION_STR "Valentina's manual layout creator." extern const QString verFileDescriptionStr;
#endif // VERSION_H #endif // VERSION_H

View File

@ -71,6 +71,16 @@ Q_LOGGING_CATEGORY(pApp, "p.application") // NOLINT
QT_WARNING_POP QT_WARNING_POP
const QString verInternalNameStr = QStringLiteral("Puzzle");
const QString verOriginalFilenameStr = QStringLiteral("puzzle.exe");
const QString verProductNameStr = QStringLiteral("Puzzle");
const QString verFileDescriptionStr = QStringLiteral("Valentina's manual layout creator.");
//#define VER_INTERNALNAME_STR "Puzzle"
//#define VER_ORIGINALFILENAME_STR "puzzle.exe"
//#define VER_PRODUCTNAME_STR "Puzzle"
//#define VER_FILEDESCRIPTION_STR "Valentina's manual layout creator."
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context,
const QString &msg) // NOLINT(readability-function-cognitive-complexity) const QString &msg) // NOLINT(readability-function-cognitive-complexity)
@ -249,8 +259,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
VPApplication::VPApplication(int &argc, char **argv) VPApplication::VPApplication(int &argc, char **argv)
: VAbstractApplication(argc, argv) : VAbstractApplication(argc, argv)
{ {
setApplicationDisplayName(QStringLiteral(VER_PRODUCTNAME_STR)); setApplicationDisplayName(verProductNameStr);
setApplicationName(QStringLiteral(VER_INTERNALNAME_STR)); setApplicationName(verInternalNameStr);
setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR)); setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR));
setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR)); setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR));
// Setting the Application version // Setting the Application version

View File

@ -76,7 +76,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsRawLayoutData, ("paths/rawL
QT_WARNING_POP QT_WARNING_POP
int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace } // namespace
#ifndef QPRINTENGINE_H #ifndef QPRINTENGINE_H
@ -84,15 +83,15 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, QObject *parent)
QObject *parent) : VCommonSettings(format, scope, organization, application, parent), cachedLineWidth(-1) {
: VCommonSettings(format, scope, organization, application, parent){REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)} REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent) VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent) : VCommonSettings(fileName, format, parent), cachedLineWidth(-1) {
{ REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -354,8 +353,12 @@ void VPSettings::SetLayoutExportFormat(qint8 format)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutLineWidth() const -> int void VPSettings::SetCachedLineWidth(int lineWidth) {
{ cachedLineWidth = lineWidth;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetCachedLineWidth() -> int {
if (cachedLineWidth == -1) if (cachedLineWidth == -1)
{ {
cachedLineWidth = qvariant_cast<int>(value(*settingLayoutLineWidth, 3)); cachedLineWidth = qvariant_cast<int>(value(*settingLayoutLineWidth, 3));
@ -364,11 +367,17 @@ auto VPSettings::GetLayoutLineWidth() const -> int
return cachedLineWidth; return cachedLineWidth;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutLineWidth() -> int
{
return GetCachedLineWidth();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPSettings::SetLayoutLineWidth(int width) void VPSettings::SetLayoutLineWidth(int width)
{ {
cachedLineWidth = qBound(1, width, 10); SetCachedLineWidth(qBound(1, width, 10));
setValue(*settingLayoutLineWidth, cachedLineWidth); setValue(*settingLayoutLineWidth, GetCachedLineWidth());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -36,9 +36,12 @@ class VPSettings : public VCommonSettings
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
private:
Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT
int cachedLineWidth;
public: public:
VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr);
QObject *parent = nullptr);
VPSettings(const QString &fileName, Format format, QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr);
~VPSettings() override = default; ~VPSettings() override = default;
@ -105,14 +108,15 @@ public:
auto GetLayoutExportFormat() const -> qint8; auto GetLayoutExportFormat() const -> qint8;
void SetLayoutExportFormat(qint8 format); void SetLayoutExportFormat(qint8 format);
auto GetLayoutLineWidth() const -> int; void SetCachedLineWidth(int lineWidth);
auto GetCachedLineWidth() -> int;
auto GetLayoutLineWidth() -> int;
void SetLayoutLineWidth(int width); void SetLayoutLineWidth(int width);
auto GetShowGrainline() const -> bool; auto GetShowGrainline() const -> bool;
void SetShowGrainline(bool value); void SetShowGrainline(bool value);
private:
Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT
}; };
#endif // VPSETTINGS_H #endif // VPSETTINGS_H

View File

@ -662,7 +662,7 @@ void VPLayoutFileReader::ReadGrainline(const VPPiecePtr &piece)
grainline.SetMainLine(mainLine); grainline.SetMainLine(mainLine);
} }
piece->SetGrainline(grainline); piece->SetVPGrainline(grainline);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -353,8 +353,8 @@ void PreferencesPatternPage::InitSingleLineFonts()
const qreal dpiY = primaryScreen->physicalDotsPerInchY(); const qreal dpiY = primaryScreen->physicalDotsPerInchY();
const qreal scale = primaryScreen->devicePixelRatio(); const qreal scale = primaryScreen->devicePixelRatio();
int const previewWidth = 250; int previewWidth = 128;
int const previewHeight = QFontMetrics(QGuiApplication::font()).height(); int previewHeight = QFontMetrics(QGuiApplication::font()).height() / 2;
// Calculate the desired image size in physical pixels // Calculate the desired image size in physical pixels
const int desiredWidthInPixels = qRound(previewWidth * dpiX / 96.0); const int desiredWidthInPixels = qRound(previewWidth * dpiX / 96.0);
@ -368,7 +368,7 @@ void PreferencesPatternPage::InitSingleLineFonts()
ui->comboBoxSingleLineFont->setMinimumSize(QSize(previewScaledWidthPixels, 0)); ui->comboBoxSingleLineFont->setMinimumSize(QSize(previewScaledWidthPixels, 0));
ui->comboBoxSingleLineFont->setIconSize(QSize(previewScaledWidthPixels, previewScaledHeightPixels)); ui->comboBoxSingleLineFont->setIconSize(QSize(previewScaledWidthPixels, previewScaledHeightPixels));
QPen pen(Qt::SolidPattern, 1 * scale, Qt::SolidLine, Qt::RoundCap, Qt::SvgMiterJoin); QPen pen(Qt::SolidPattern, 1, Qt::SolidLine, Qt::RoundCap, Qt::SvgMiterJoin);
pen.setColor(ui->comboBoxSingleLineFont->palette().color(QPalette::Text)); pen.setColor(ui->comboBoxSingleLineFont->palette().color(QPalette::Text));
VSvgFontDatabase *db = VAbstractApplication::VApp()->SVGFontDatabase(); VSvgFontDatabase *db = VAbstractApplication::VApp()->SVGFontDatabase();
@ -377,7 +377,7 @@ void PreferencesPatternPage::InitSingleLineFonts()
for (const auto &family : families) for (const auto &family : families)
{ {
VSvgFontEngine engine = db->FontEngine(family, SVGFontStyle::Normal, SVGFontWeight::Normal); VSvgFontEngine engine = db->FontEngine(family, SVGFontStyle::Normal, SVGFontWeight::Thin);
VSvgFont const svgFont = engine.Font(); VSvgFont const svgFont = engine.Font();
if (!svgFont.IsValid()) if (!svgFont.IsValid())
@ -396,6 +396,7 @@ void PreferencesPatternPage::InitSingleLineFonts()
engine.Draw(&painter, QPointF(0, 0), engine.FontSample()); engine.Draw(&painter, QPointF(0, 0), engine.FontSample());
ui->comboBoxSingleLineFont->addItem(pixmap, svgFont.FamilyName(), svgFont.FamilyName()); ui->comboBoxSingleLineFont->addItem(pixmap, svgFont.FamilyName(), svgFont.FamilyName());
} }
ui->comboBoxSingleLineFont->setInsertPolicy(QComboBox::NoInsert); ui->comboBoxSingleLineFont->setInsertPolicy(QComboBox::NoInsert);

View File

@ -6,16 +6,28 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>553</width> <width>550</width>
<height>979</height> <height>979</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string notr="true">Pattern</string> <string notr="true">Pattern</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -123,7 +123,7 @@ public:
void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font, void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font,
const QString &SVGFontFamily, const VContainer *pattern); const QString &SVGFontFamily, const VContainer *pattern);
void SetGrainline(const VGrainlineData &geom, const VContainer *pattern); virtual void SetGrainline(const VGrainlineData &geom, const VContainer *pattern);
auto GetGrainline() const -> VPieceGrainline; auto GetGrainline() const -> VPieceGrainline;
auto GetMappedGrainlineShape() const -> GrainlineShape; auto GetMappedGrainlineShape() const -> GrainlineShape;
auto GetGrainlineShape() const -> GrainlineShape; auto GetGrainlineShape() const -> GrainlineShape;