From b6ad741cd9497a63f1b483a1351347e1da77cf23 Mon Sep 17 00:00:00 2001 From: Yann Lossouarn Date: Fri, 23 Feb 2024 09:35:32 +0000 Subject: [PATCH] Bugfix: suppressing horizontal scrolling on Preferences>Pattern and... --- src/app/puzzle/carousel/vpcarrousel.cpp | 6 ++-- .../dialogs/dialogpuzzlepreferences.cpp | 2 +- .../puzzle/dialogs/dialogpuzzlepreferences.h | 2 +- src/app/puzzle/layout/vppiece.cpp | 6 ++-- src/app/puzzle/layout/vppiece.h | 2 +- src/app/puzzle/scene/vpgraphicspiece.cpp | 6 +--- src/app/puzzle/share/resources/puzzle.rc | 8 ++--- src/app/puzzle/version.h | 9 ++--- src/app/puzzle/vpapplication.cpp | 14 ++++++-- src/app/puzzle/vpsettings.cpp | 35 ++++++++++++------- src/app/puzzle/vpsettings.h | 14 +++++--- src/app/puzzle/xml/vplayoutfilereader.cpp | 2 +- .../configpages/preferencespatternpage.cpp | 9 ++--- .../configpages/preferencespatternpage.ui | 14 +++++++- src/libs/vlayout/vlayoutpiece.h | 2 +- 15 files changed, 81 insertions(+), 50 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index dd6a505bc..6128e1ec3 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -90,8 +90,7 @@ void VPCarrousel::Refresh() // Do not rely on m_layout because we do not control it. m_pieceLists = QList(); - VPLayoutPtr const layout = m_layout.toStrongRef(); - if (not layout.isNull()) + if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull()) { { VPCarrouselSheet carrouselSheet; @@ -216,8 +215,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index) if (not sheet.isNull()) { - VPSheetPtr const activeSheet = layout->GetFocusedSheet(); - if (not activeSheet.isNull()) + if (VPSheetPtr const activeSheet = layout->GetFocusedSheet(); not activeSheet.isNull()) { activeSheet->ClearSelection(); } diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp index 3b7dfb1b6..2521c4677 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp @@ -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) { diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h index 9bb8956db..c3e460164 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h @@ -60,7 +60,7 @@ protected: private slots: void Apply(); void Ok(); - void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); + void PageChanged(const QListWidgetItem *current, QListWidgetItem * const previous); private: // cppcheck-suppress unknownMacro diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index 28835f743..10c90038a 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -157,7 +157,7 @@ void VPPiece::Update(const VPPiecePtr &piece) SetInternalPaths(piece->GetInternalPaths()); SetPassmarks(piece->GetPassmarks()); SetPlaceLabels(piece->GetPlaceLabels()); - SetGrainline(piece->GetGrainline()); + SetVPGrainline(piece->GetGrainline()); SetPieceLabelRect(piece->GetPieceLabelRect()); SetPieceLabelData(piece->GetPieceLabelData()); 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); } @@ -682,7 +682,7 @@ void VPPiece::CleanPosition(const VPPiecePtr &piece) { VPieceGrainline grainline = piece->GetGrainline(); grainline.SetMainLine(matrix.map(grainline.GetMainLine())); - piece->SetGrainline(grainline); + piece->SetVPGrainline(grainline); } piece->SetPieceLabelRect(MapVector(piece->GetPieceLabelRect(), matrix)); diff --git a/src/app/puzzle/layout/vppiece.h b/src/app/puzzle/layout/vppiece.h index 8fc74e415..29645c7cf 100644 --- a/src/app/puzzle/layout/vppiece.h +++ b/src/app/puzzle/layout/vppiece.h @@ -96,7 +96,7 @@ public: auto Layout() const -> VPLayoutPtr; void SetLayout(const VPLayoutPtr &layout); - void SetGrainline(const VPieceGrainline &grainline); + void SetVPGrainline(const VPieceGrainline &grainline); /** * @brief Flip verticvally mirror around center of bounding rect diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index eea80b685..aa9fe8fc8 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -855,11 +855,8 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece) m_passmarks.addPath(passmarkPath); 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; for (const auto &line : passmark.lines) { @@ -868,7 +865,6 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece) } const QTransform matrix = VGObject::FlippingMatrix(seamAllowanceMirrorLine); m_passmarks.addPath(matrix.map(mirroredPassmaksPath)); - } } if (painter != nullptr) diff --git a/src/app/puzzle/share/resources/puzzle.rc b/src/app/puzzle/share/resources/puzzle.rc index cb9a658b4..f6f8234b4 100644 --- a/src/app/puzzle/share/resources/puzzle.rc +++ b/src/app/puzzle/share/resources/puzzle.rc @@ -62,14 +62,14 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", VER_COMPANYNAME_STR - VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileDescription", "Valentina's manual layout creator." VALUE "FileVersion", VER_FILEVERSION_STR - VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "InternalName", "Puzzle" VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR - VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR - VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "OriginalFilename", "puzzle.exe" + VALUE "ProductName", "Puzzle" VALUE "ProductVersion", VER_PRODUCTVERSION_STR END END diff --git a/src/app/puzzle/version.h b/src/app/puzzle/version.h index bde0ae5b0..300d63027 100644 --- a/src/app/puzzle/version.h +++ b/src/app/puzzle/version.h @@ -29,11 +29,12 @@ #ifndef VERSION_H #define VERSION_H +#include #include "../../libs/vmisc/projectversion.h" -#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." +extern const QString verInternalNameStr; +extern const QString verOriginalFilenameStr; +extern const QString verProductNameStr; +extern const QString verFileDescriptionStr; #endif // VERSION_H diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 63f4c1848..3c5d1c0f5 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -71,6 +71,16 @@ Q_LOGGING_CATEGORY(pApp, "p.application") // NOLINT 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, 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) : VAbstractApplication(argc, argv) { - setApplicationDisplayName(QStringLiteral(VER_PRODUCTNAME_STR)); - setApplicationName(QStringLiteral(VER_INTERNALNAME_STR)); + setApplicationDisplayName(verProductNameStr); + setApplicationName(verInternalNameStr); setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR)); setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR)); // Setting the Application version diff --git a/src/app/puzzle/vpsettings.cpp b/src/app/puzzle/vpsettings.cpp index e95ae0a80..1a3672ed2 100644 --- a/src/app/puzzle/vpsettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -76,7 +76,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsRawLayoutData, ("paths/rawL QT_WARNING_POP -int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) } // namespace #ifndef QPRINTENGINE_H @@ -84,15 +83,15 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT #endif //--------------------------------------------------------------------------------------------------------------------- -VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, - QObject *parent) - : VCommonSettings(format, scope, organization, application, parent){REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)} +VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, QObject *parent) + : VCommonSettings(format, scope, organization, application, parent), cachedLineWidth(-1) { + REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF) +} - //--------------------------------------------------------------------------------------------------------------------- - VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent) - : VCommonSettings(fileName, format, parent) -{ - REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF) +//--------------------------------------------------------------------------------------------------------------------- +VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent) + : VCommonSettings(fileName, format, parent), cachedLineWidth(-1) { + 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) { cachedLineWidth = qvariant_cast(value(*settingLayoutLineWidth, 3)); @@ -364,11 +367,17 @@ auto VPSettings::GetLayoutLineWidth() const -> int return cachedLineWidth; } +//--------------------------------------------------------------------------------------------------------------------- +auto VPSettings::GetLayoutLineWidth() -> int +{ + return GetCachedLineWidth(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPSettings::SetLayoutLineWidth(int width) { - cachedLineWidth = qBound(1, width, 10); - setValue(*settingLayoutLineWidth, cachedLineWidth); + SetCachedLineWidth(qBound(1, width, 10)); + setValue(*settingLayoutLineWidth, GetCachedLineWidth()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpsettings.h b/src/app/puzzle/vpsettings.h index 39edda649..8bc08f165 100644 --- a/src/app/puzzle/vpsettings.h +++ b/src/app/puzzle/vpsettings.h @@ -36,9 +36,12 @@ class VPSettings : public VCommonSettings { Q_OBJECT // NOLINT +private: + Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT + int cachedLineWidth; + public: - VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), - QObject *parent = nullptr); + VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr); ~VPSettings() override = default; @@ -105,14 +108,15 @@ public: auto GetLayoutExportFormat() const -> qint8; void SetLayoutExportFormat(qint8 format); - auto GetLayoutLineWidth() const -> int; + void SetCachedLineWidth(int lineWidth); + auto GetCachedLineWidth() -> int; + + auto GetLayoutLineWidth() -> int; void SetLayoutLineWidth(int width); auto GetShowGrainline() const -> bool; void SetShowGrainline(bool value); -private: - Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT }; #endif // VPSETTINGS_H diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 8ac9c7177..f4a506bb1 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -662,7 +662,7 @@ void VPLayoutFileReader::ReadGrainline(const VPPiecePtr &piece) grainline.SetMainLine(mainLine); } - piece->SetGrainline(grainline); + piece->SetVPGrainline(grainline); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index e587d1ea0..6d8f2f185 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -353,8 +353,8 @@ void PreferencesPatternPage::InitSingleLineFonts() const qreal dpiY = primaryScreen->physicalDotsPerInchY(); const qreal scale = primaryScreen->devicePixelRatio(); - int const previewWidth = 250; - int const previewHeight = QFontMetrics(QGuiApplication::font()).height(); + int previewWidth = 128; + int previewHeight = QFontMetrics(QGuiApplication::font()).height() / 2; // Calculate the desired image size in physical pixels const int desiredWidthInPixels = qRound(previewWidth * dpiX / 96.0); @@ -368,7 +368,7 @@ void PreferencesPatternPage::InitSingleLineFonts() ui->comboBoxSingleLineFont->setMinimumSize(QSize(previewScaledWidthPixels, 0)); 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)); VSvgFontDatabase *db = VAbstractApplication::VApp()->SVGFontDatabase(); @@ -377,7 +377,7 @@ void PreferencesPatternPage::InitSingleLineFonts() 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(); if (!svgFont.IsValid()) @@ -396,6 +396,7 @@ void PreferencesPatternPage::InitSingleLineFonts() engine.Draw(&painter, QPointF(0, 0), engine.FontSample()); ui->comboBoxSingleLineFont->addItem(pixmap, svgFont.FamilyName(), svgFont.FamilyName()); + } ui->comboBoxSingleLineFont->setInsertPolicy(QComboBox::NoInsert); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui index e39a9efed..66c18b7a3 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui @@ -6,16 +6,28 @@ 0 0 - 553 + 550 979 + + + 0 + 0 + + Pattern + + QLayout::SetMaximumSize + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + true diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index f89fbcd37..31a5c19c0 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -123,7 +123,7 @@ public: void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font, 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 GetMappedGrainlineShape() const -> GrainlineShape; auto GetGrainlineShape() const -> GrainlineShape;