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.
m_pieceLists = QList<VPCarrouselSheet>();
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();
}

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)
{

View File

@ -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

View File

@ -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));

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -29,11 +29,12 @@
#ifndef VERSION_H
#define VERSION_H
#include <QString>
#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

View File

@ -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

View File

@ -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<int>(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());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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

View File

@ -662,7 +662,7 @@ void VPLayoutFileReader::ReadGrainline(const VPPiecePtr &piece)
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 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);

View File

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

View File

@ -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;