Basic implementation for Full circumference trigger.

This commit is contained in:
Roman Telezhynskyi 2020-10-01 19:26:56 +03:00
parent 15978bd868
commit a16e6bc082
3 changed files with 41 additions and 3 deletions

View File

@ -561,6 +561,8 @@ void TMainWindow::changeEvent(QEvent *event)
if (mType == MeasurementsType::Multisize)
{
actionFullCircumference->setText(tr("Use full circumference"));
ui->labelMType->setText(tr("Multisize measurements"));
InitDimensionsBaseValue();
@ -1915,6 +1917,14 @@ void TMainWindow::SaveMFullName()
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FullCircumferenceChanged(bool checked)
{
m->SetFullCircumference(checked);
MeasurementsWereSaved(false);
InitDimensionsBaseValue();
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetupMenu()
{
@ -2022,6 +2032,7 @@ void TMainWindow::InitWindow()
if (mType == MeasurementsType::Multisize)
{
InitMenu();
ui->labelMType->setText(tr("Multisize measurements"));
InitDimensionsBaseValue();
@ -2175,13 +2186,29 @@ void TMainWindow::InitWindow()
InitTable();
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitMenu()
{
if (mType == MeasurementsType::Multisize)
{
ui->menuMeasurements->addSeparator();
actionFullCircumference = new QAction(tr("Use full circumference"), this);
actionFullCircumference->setCheckable(true);
actionFullCircumference->setChecked(m->IsFullCircumference());
ui->menuMeasurements->addAction(actionFullCircumference);
connect(actionFullCircumference, &QAction::triggered, this, &TMainWindow::FullCircumferenceChanged);
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitDimensionsBaseValue()
{
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
const QString unit = UnitsToStr(m->MUnit(), true);
const bool fc = m->IsFullCircumference();
auto DimensionsBaseValue = [this, dimensions, unit](int index, QLabel *name, QLabel *base)
auto DimensionsBaseValue = [this, dimensions, unit, fc](int index, QLabel *name, QLabel *base)
{
SCASSERT(name != nullptr)
SCASSERT(base != nullptr)
@ -2193,9 +2220,16 @@ void TMainWindow::InitDimensionsBaseValue()
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
{
if (dimension->Type() != MeasurementDimension::X && fc)
{
base->setText(QString("%1 %2").arg(dimension->BaseValue()*2).arg(unit));
}
else
{
base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit));
}
}
else
{
base->setText(QString::number(dimension->BaseValue()));

View File

@ -127,6 +127,8 @@ private slots:
void SaveMDescription();
void SaveMFullName();
void FullCircumferenceChanged(bool checked);
private:
Q_DISABLE_COPY(TMainWindow)
Ui::TMainWindow *ui;
@ -150,11 +152,13 @@ private:
QLabel *labelPatternUnit;
bool isInitialized;
bool mIsReadOnly;
QAction *actionFullCircumference{nullptr};
QVector<QObject *> hackedWidgets;
void SetupMenu();
void InitWindow();
void InitMenu();
void InitDimensionsBaseValue();
void InitTable();
void SetDecimals();

View File

@ -47,7 +47,7 @@
<string/>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabMeasurements">
<attribute name="icon">