Resolved issue #725. Improve labels on drawing.
--HG-- branch : develop
This commit is contained in:
parent
3b51ccb31d
commit
5838537033
|
@ -17,6 +17,7 @@
|
|||
- New placelabel shape Circle.
|
||||
- Two new passmark types: U and Box.
|
||||
- [#969] Fix length to label after soom.
|
||||
- [#725] Improve labels on drawing.
|
||||
|
||||
# Version 0.6.2 (unreleased)
|
||||
- [#903] Bug in tool Cut Spline path.
|
||||
|
|
|
@ -2055,6 +2055,69 @@ void MainWindow::ToolBarTools()
|
|||
|
||||
connect(ui->actionPreviousPatternPiece, &QAction::triggered, this, &MainWindow::PreviousPatternPiece);
|
||||
connect(ui->actionNextPatternPiece, &QAction::triggered, this, &MainWindow::NextPatternPiece);
|
||||
|
||||
ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus));
|
||||
connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]()
|
||||
{
|
||||
VSettings *settings = qApp->ValentinaSettings();
|
||||
settings->SetLabelFontSize(settings->GetLabelFontSize() + 1);
|
||||
if (sceneDraw)
|
||||
{
|
||||
sceneDraw->update();
|
||||
}
|
||||
|
||||
if (sceneDetails)
|
||||
{
|
||||
sceneDetails->update();
|
||||
}
|
||||
});
|
||||
|
||||
ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus));
|
||||
connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]()
|
||||
{
|
||||
VSettings *settings = qApp->ValentinaSettings();
|
||||
settings->SetLabelFontSize(settings->GetLabelFontSize() - 1);
|
||||
if (sceneDraw)
|
||||
{
|
||||
sceneDraw->update();
|
||||
}
|
||||
|
||||
if (sceneDetails)
|
||||
{
|
||||
sceneDetails->update();
|
||||
}
|
||||
});
|
||||
|
||||
ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0));
|
||||
connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]()
|
||||
{
|
||||
VSettings *settings = qApp->ValentinaSettings();
|
||||
settings->SetLabelFontSize(settings->GetDefLabelFontSize());
|
||||
if (sceneDraw)
|
||||
{
|
||||
sceneDraw->update();
|
||||
}
|
||||
|
||||
if (sceneDetails)
|
||||
{
|
||||
sceneDetails->update();
|
||||
}
|
||||
});
|
||||
|
||||
ui->actionHideLabels->setShortcut(QKeySequence(Qt::AltModifier + Qt::Key_L));
|
||||
connect(ui->actionHideLabels, &QAction::triggered, this, [this](bool checked)
|
||||
{
|
||||
qApp->ValentinaSettings()->SetHideLabels(checked);
|
||||
if (sceneDraw)
|
||||
{
|
||||
sceneDraw->update();
|
||||
}
|
||||
|
||||
if (sceneDetails)
|
||||
{
|
||||
sceneDetails->update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -3018,6 +3081,10 @@ void MainWindow::Clear()
|
|||
m_taskbarProgress->setVisible(false);
|
||||
#endif
|
||||
m_statusLabel->setVisible(true);
|
||||
ui->actionIncreaseLabelFont->setEnabled(false);
|
||||
ui->actionDecreaseLabelFont->setEnabled(false);
|
||||
ui->actionOriginalLabelFont->setEnabled(false);
|
||||
ui->actionHideLabels->setEnabled(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -3370,6 +3437,10 @@ void MainWindow::SetEnableWidgets(bool enable)
|
|||
ui->actionUnloadMeasurements->setEnabled(enable && designStage);
|
||||
ui->actionPreviousPatternPiece->setEnabled(enable && drawStage);
|
||||
ui->actionNextPatternPiece->setEnabled(enable && drawStage);
|
||||
ui->actionIncreaseLabelFont->setEnabled(enable);
|
||||
ui->actionDecreaseLabelFont->setEnabled(enable);
|
||||
ui->actionOriginalLabelFont->setEnabled(enable);
|
||||
ui->actionHideLabels->setEnabled(enable);
|
||||
|
||||
actionDockWidgetToolOptions->setEnabled(enable && designStage);
|
||||
actionDockWidgetGroups->setEnabled(enable && designStage);
|
||||
|
|
|
@ -1744,6 +1744,11 @@
|
|||
<addaction name="actionPreviousPatternPiece"/>
|
||||
<addaction name="actionNextPatternPiece"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionIncreaseLabelFont"/>
|
||||
<addaction name="actionDecreaseLabelFont"/>
|
||||
<addaction name="actionOriginalLabelFont"/>
|
||||
<addaction name="actionHideLabels"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLast_tool"/>
|
||||
<addaction name="actionShowCurveDetails"/>
|
||||
</widget>
|
||||
|
@ -2760,6 +2765,56 @@
|
|||
<string>Ctrl+PgUp</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionIncreaseLabelFont">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-in"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Increase label font</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDecreaseLabelFont">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-out"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Decrease label font</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOriginalLabelFont">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-original"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Original label font</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHideLabels">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide labels</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
|
@ -62,6 +62,9 @@ const qreal defCurveApproximationScale = 0.5;
|
|||
const qreal minCurveApproximationScale = 0.1;
|
||||
const qreal maxCurveApproximationScale = 10.0;
|
||||
|
||||
const int minLabelFontSize = 5;
|
||||
const int maxLabelFontSize = 100;
|
||||
|
||||
//functions
|
||||
const QString degTorad_F = QStringLiteral("degTorad");
|
||||
const QString radTodeg_F = QStringLiteral("radTodeg");
|
||||
|
|
|
@ -75,6 +75,9 @@ extern const qreal defCurveApproximationScale;
|
|||
extern const qreal minCurveApproximationScale;
|
||||
extern const qreal maxCurveApproximationScale;
|
||||
|
||||
extern const int minLabelFontSize;
|
||||
extern const int maxLabelFontSize;
|
||||
|
||||
enum class NodeDetail : char { Contour, Modeling };
|
||||
enum class SceneObject : char { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown };
|
||||
enum class MeasurementsType : char { Multisize, Individual , Unknown};
|
||||
|
|
|
@ -76,6 +76,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String
|
|||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, (QLatin1String("pattern/curveApproximationScale")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels")))
|
||||
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList")))
|
||||
|
@ -104,6 +106,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1St
|
|||
qreal curveApproximationCached = -1;
|
||||
Q_GLOBAL_STATIC(QString, localeCached)
|
||||
qreal lineWidthCached = 0;
|
||||
int labelFontSizeCached = 0;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
|
||||
|
@ -962,6 +965,48 @@ void VCommonSettings::SetLabelFont(const QFont &f)
|
|||
setValue(*settingPatternLabelFont, f);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VCommonSettings::GetLabelFontSize() const
|
||||
{
|
||||
if (labelFontSizeCached <= 0)
|
||||
{
|
||||
bool ok = false;
|
||||
labelFontSizeCached = value(*settingPatternLabelFontSize, GetDefLabelFontSize()).toInt(&ok);
|
||||
if (not ok)
|
||||
{
|
||||
labelFontSizeCached = GetDefLabelFontSize();
|
||||
}
|
||||
labelFontSizeCached = qBound(minLabelFontSize, labelFontSizeCached, maxLabelFontSize);
|
||||
}
|
||||
return labelFontSizeCached;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetLabelFontSize(int size)
|
||||
{
|
||||
size = qBound(minLabelFontSize, size, maxLabelFontSize);
|
||||
setValue(*settingPatternLabelFontSize, size);
|
||||
labelFontSizeCached = size;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VCommonSettings::GetDefLabelFontSize()
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommonSettings::GetHideLabels() const
|
||||
{
|
||||
return value(*settingPatternHideLabels, false).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetHideLabels(bool value)
|
||||
{
|
||||
setValue(*settingPatternHideLabels, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetLabelDateFormat() const
|
||||
{
|
||||
|
|
|
@ -181,6 +181,13 @@ public:
|
|||
QFont GetLabelFont() const;
|
||||
void SetLabelFont(const QFont &f);
|
||||
|
||||
int GetLabelFontSize() const;
|
||||
void SetLabelFontSize(int size);
|
||||
static int GetDefLabelFontSize();
|
||||
|
||||
bool GetHideLabels() const;
|
||||
void SetHideLabels(bool value);
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
static const QString unixStandardSharePath;
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
*/
|
||||
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
|
||||
: QGraphicsSimpleTextItem(parent),
|
||||
m_fontSize(0),
|
||||
selectionType(SelectionType::ByMouseRelease),
|
||||
m_oldScale(1),
|
||||
m_showParentTooltip(true)
|
||||
|
@ -73,7 +72,6 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
|
|||
*/
|
||||
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent )
|
||||
: QGraphicsSimpleTextItem(text, parent),
|
||||
m_fontSize(0),
|
||||
selectionType(SelectionType::ByMouseRelease),
|
||||
m_oldScale(1),
|
||||
m_showParentTooltip(true)
|
||||
|
@ -92,6 +90,13 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
|
|||
}
|
||||
};
|
||||
|
||||
QFont font = this->font();
|
||||
if (font.pointSize() != qApp->Settings()->GetLabelFontSize())
|
||||
{
|
||||
font.setPointSize(qApp->Settings()->GetLabelFontSize());
|
||||
setFont(font);
|
||||
}
|
||||
|
||||
QGraphicsScene *scene = this->scene();
|
||||
const qreal scale = SceneScale(scene);
|
||||
if (scale > 1 && not VFuzzyComparePossibleNulls(m_oldScale, scale))
|
||||
|
@ -381,9 +386,8 @@ void VGraphicsSimpleTextItem::Init()
|
|||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
this->setAcceptHoverEvents(true);
|
||||
QFont font = this->font();
|
||||
font.setPointSize(font.pointSize()+20);
|
||||
m_fontSize = font.pointSize();
|
||||
this->setFont(font);
|
||||
m_oldScale = minVisibleFontSize / m_fontSize;
|
||||
font.setPointSize(qApp->Settings()->GetLabelFontSize());
|
||||
setFont(font);
|
||||
m_oldScale = minVisibleFontSize / qApp->Settings()->GetLabelFontSize();
|
||||
setScale(m_oldScale);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
explicit VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr );
|
||||
virtual ~VGraphicsSimpleTextItem() =default;
|
||||
|
||||
qint32 BaseFontSize()const;
|
||||
virtual int type() const override {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem)};
|
||||
|
||||
|
@ -92,8 +91,6 @@ protected:
|
|||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) override;
|
||||
virtual void keyReleaseEvent ( QKeyEvent * event ) override;
|
||||
private:
|
||||
/** @brief fontSize label font size. */
|
||||
qint32 m_fontSize;
|
||||
SelectionType selectionType;
|
||||
qreal m_oldScale;
|
||||
bool m_showParentTooltip;
|
||||
|
@ -105,14 +102,4 @@ private:
|
|||
void CorrectLabelPosition();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FontSize return label font size.
|
||||
* @return font size.
|
||||
*/
|
||||
inline qint32 VGraphicsSimpleTextItem::BaseFontSize() const
|
||||
{
|
||||
return m_fontSize;
|
||||
}
|
||||
|
||||
#endif // VGRAPHICSSIMPLETEXTITEM_H
|
||||
|
|
|
@ -66,7 +66,7 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||
{
|
||||
const qreal scale = SceneScale(scene());
|
||||
|
||||
if (m_namePoint->BaseFontSize()*scale < minVisibleFontSize)
|
||||
if (qApp->Settings()->GetLabelFontSize()*scale < minVisibleFontSize || qApp->Settings()->GetHideLabels())
|
||||
{
|
||||
m_namePoint->setVisible(false);
|
||||
m_lineName->setVisible(false);
|
||||
|
|
Loading…
Reference in New Issue
Block a user