Allow user to setup font family for piece labels.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-07-01 14:41:46 +03:00
parent 018007e87b
commit 275338da4b
10 changed files with 63 additions and 7 deletions

View File

@ -55,6 +55,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
ui->checkBoxHideMainPath->setChecked(qApp->ValentinaSettings()->IsHideMainPath());
ui->fontComboBoxLabelFont->setCurrentFont(qApp->ValentinaSettings()->GetLabelFont());
}
//---------------------------------------------------------------------------------------------------------------------
@ -81,6 +82,7 @@ void PreferencesPatternPage::Apply()
settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked());
settings->SetHideMainPath(ui->checkBoxHideMainPath->isChecked());
qApp->ValentinaSettings()->SetLabelFont(ui->fontComboBoxLabelFont->currentFont());
if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked())
{

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>414</height>
<width>381</width>
<height>444</height>
</rect>
</property>
<property name="windowTitle">
@ -133,6 +133,20 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Label font:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBoxLabelFont"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@ -4350,6 +4350,7 @@ void MainWindow::Preferences()
connect(dlg.data(), &DialogPreferences::UpdateProperties, toolOptions,
&VToolOptionsPropertyBrowser::RefreshOptions);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::RefreshDetailsLabel);
QGuiApplication::restoreOverrideCursor();
if (guard->exec() == QDialog::Accepted)

View File

@ -41,6 +41,7 @@
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
#include "../vtools/tools/vabstracttool.h"
#include "../vtools/tools/vtoolseamallowance.h"
#include <QFileDialog>
#include <QFileInfo>
@ -528,6 +529,25 @@ void MainWindowsNoGUI::PrintTiled()
LayoutPrint();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDetailsLabel call to ecalculate piece labels. For example after changing a font.
*/
void MainWindowsNoGUI::RefreshDetailsLabel()
{
const QHash<quint32, VPiece> *list = pattern->DataPieces();
QHash<quint32, VPiece>::const_iterator i = list->constBegin();
while (i != list->constEnd())
{
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(i.key())))
{
tool->UpdatePatternInfo();
tool->UpdateDetailLabel();
}
++i;
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VPiece> *details)
{

View File

@ -55,6 +55,7 @@ public slots:
void PrintPreviewTiled();
void PrintOrigin();
void PrintTiled();
void RefreshDetailsLabel();
protected:
QVector<VLayoutPiece> listDetails;

View File

@ -385,14 +385,15 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
const VPieceLabelData& data = piece.GetPatternPieceData();
if (data.IsVisible() == true)
{
det.SetDetail(piece.GetName(), data, QApplication::font(), pattern);
det.SetDetail(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern);
}
const VPatternLabelData& geom = piece.GetPatternInfo();
if (geom.IsVisible() == true)
{
VAbstractPattern* pDoc = qApp->getCurrentDocument();
det.SetPatternInfo(pDoc, geom, QApplication::font(), VContainer::size(), VContainer::height(), pattern);
det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), VContainer::size(), VContainer::height(),
pattern);
}
const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry();

View File

@ -39,6 +39,7 @@
#include <QVariant>
#include <QtDebug>
#include <QTextCodec>
#include <QFont>
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
@ -64,6 +65,7 @@ const QString settingPatternUndo = QStringLiteral("pattern/undo");
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
const QString settingLabelFont = QStringLiteral("pattern/labelFont");
const QString settingGeneralRecentFileList = QStringLiteral("recentFileList");
const QString settingGeneralRestoreFileList = QStringLiteral("restoreFileList");
@ -755,3 +757,15 @@ QChar VCommonSettings::GetDefCSVSeparator() const
{
return QChar(',');
}
//---------------------------------------------------------------------------------------------------------------------
QFont VCommonSettings::GetLabelFont() const
{
return qvariant_cast<QFont>(value(settingLabelFont, QApplication::font()));
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLabelFont(const QFont &f)
{
setValue(settingLabelFont, f);
}

View File

@ -157,6 +157,9 @@ public:
QChar GetCSVSeparator() const;
QChar GetDefCSVSeparator() const;
QFont GetLabelFont() const;
void SetLabelFont(const QFont &f);
#if !defined(Q_OS_WIN)
static const QString unixStandardSharePath;
#endif

View File

@ -1557,7 +1557,7 @@ bool VToolSeamAllowance::PrepareLabelData(const VPatternLabelData &labelData, VT
}
labelItem->SetMoveType(type);
QFont fnt = QApplication::font();
QFont fnt = qApp->Settings()->GetLabelFont();
{
const int iFS = labelData.GetFontSize();
iFS < MIN_FONT_SIZE ? fnt.setPixelSize(MIN_FONT_SIZE) : fnt.setPixelSize(iFS);

View File

@ -105,9 +105,9 @@ public slots:
virtual void UpdateAll();
virtual void retranslateUi();
void Highlight(quint32 id);
void UpdateDetailLabel();
void UpdatePatternInfo();
protected slots:
void UpdateDetailLabel();
void UpdatePatternInfo();
void UpdateGrainline();
void SaveMoveDetail(const QPointF &ptPos);
void SaveResizeDetail(qreal dLabelW, int iFontSize);