Added number and PLI toggles.

This commit is contained in:
Leonardo Zide
2021-01-17 11:05:50 -08:00
parent 00f3f0588f
commit cc75291125
4 changed files with 85 additions and 28 deletions
+43 -1
View File
@@ -21,6 +21,8 @@ lcInstructions::lcInstructions(Project* Project)
mPageSettings.Columns = 1;
mPageSettings.Direction = lcInstructionsDirection::Horizontal;
mStepProperties[static_cast<int>(lcInstructionsPropertyType::ShowStepNumber)].Value = true;
mStepProperties[static_cast<int>(lcInstructionsPropertyType::ShowStepPLI)].Value = true;
mStepProperties[static_cast<int>(lcInstructionsPropertyType::StepNumberFont)].Value = QFont("Arial", 72).toString();
mStepProperties[static_cast<int>(lcInstructionsPropertyType::StepNumberColor)].Value = LC_RGBA(0, 0, 0, 255);
mStepProperties[static_cast<int>(lcInstructionsPropertyType::StepBackgroundColor)].Value = LC_RGBA(255, 255, 255, 0);
@@ -31,11 +33,40 @@ lcInstructions::lcInstructions(Project* Project)
// mStepProperties[static_cast<int>(lcInstructionsPropertyType::PLIBorderWidth)].Value = 2.0f;
// mStepProperties[static_cast<int>(lcInstructionsPropertyType::PLIBorderRound)].Value = true;
static_assert(static_cast<int>(lcInstructionsPropertyType::Count) == 7, "Missing default property");
static_assert(static_cast<int>(lcInstructionsPropertyType::Count) == 9, "Missing default property");
CreatePages();
}
QString lcInstructions::GetPropertyLabel(lcInstructionsPropertyType Type)
{
switch (Type)
{
case lcInstructionsPropertyType::ShowStepNumber:
return tr("Show Step Number");
case lcInstructionsPropertyType::ShowStepPLI:
return tr("Show Parts List");
case lcInstructionsPropertyType::StepNumberFont:
return tr("Font:");
case lcInstructionsPropertyType::StepNumberColor:
return tr("Text Color:");
case lcInstructionsPropertyType::StepBackgroundColor:
return tr("Background Color:");
case lcInstructionsPropertyType::PLIBackgroundColor:
return tr("Background Color:");
case lcInstructionsPropertyType::PLIFont:
return tr("Font:");
case lcInstructionsPropertyType::PLITextColor:
return tr("Text Color:");
case lcInstructionsPropertyType::PLIBorderColor:
return tr("Border Color:");
case lcInstructionsPropertyType::Count:
break;
}
return QString();
}
void lcInstructions::SetDefaultPageSettings(const lcInstructionsPageSettings& PageSettings)
{
mPageSettings = PageSettings;
@@ -43,6 +74,12 @@ void lcInstructions::SetDefaultPageSettings(const lcInstructionsPageSettings& Pa
CreatePages();
}
bool lcInstructions::GetBoolProperty(lcInstructionsPropertyType Type, lcModel* Model, lcStep Step) const
{
QVariant Value = GetProperty(Type, Model, Step);
return Value.toBool();
}
QColor lcInstructions::GetColorProperty(lcInstructionsPropertyType Type, lcModel* Model, lcStep Step) const
{
QVariant Value = GetProperty(Type, Model, Step);
@@ -82,6 +119,11 @@ QVariant lcInstructions::GetProperty(lcInstructionsPropertyType Type, lcModel* M
return Value;
}
void lcInstructions::SetDefaultBool(lcInstructionsPropertyType Type, bool Enabled)
{
SetDefaultProperty(Type, Enabled);
}
void lcInstructions::SetDefaultColor(lcInstructionsPropertyType Type, const QColor& Color)
{
SetDefaultProperty(Type, lcRGBAFromQColor(Color));
+7
View File
@@ -36,6 +36,8 @@ enum class lcInstructionsPropertyMode
enum class lcInstructionsPropertyType
{
ShowStepNumber,
ShowStepPLI,
StepNumberFont,
StepNumberColor,
StepBackgroundColor,
@@ -84,14 +86,19 @@ class lcInstructions : public QObject
public:
lcInstructions(Project* Project = nullptr);
static QString GetPropertyLabel(lcInstructionsPropertyType Type);
void SetDefaultPageSettings(const lcInstructionsPageSettings& PageSettings);
bool GetBoolProperty(lcInstructionsPropertyType Type, lcModel* Model, lcStep Step) const;
QColor GetColorProperty(lcInstructionsPropertyType Type, lcModel* Model, lcStep Step) const;
QFont GetFontProperty(lcInstructionsPropertyType Type, lcModel* Model, lcStep Step) const;
void SetDefaultBool(lcInstructionsPropertyType Type, bool Enabled);
void SetDefaultColor(lcInstructionsPropertyType Type, const QColor& Color);
void SetDefaultFont(lcInstructionsPropertyType Type, const QFont& Font);
//protected:
std::vector<lcInstructionsPage> mPages;
lcInstructionsPageSettings mPageSettings;
lcInstructionsPageSetup mPageSetup;
+31 -24
View File
@@ -35,6 +35,9 @@ lcInstructionsStepNumberItem::lcInstructionsStepNumberItem(QGraphicsItem* Parent
void lcInstructionsStepNumberItem::Update()
{
bool Visible = mInstructions->GetBoolProperty(lcInstructionsPropertyType::ShowStepNumber, mModel, mStep);
setVisible(Visible);
QFont StepNumberFont = mInstructions->GetFontProperty(lcInstructionsPropertyType::StepNumberFont, mModel, mStep);
setFont(StepNumberFont);
@@ -50,6 +53,12 @@ lcInstructionsPartsListItem::lcInstructionsPartsListItem(QGraphicsItem* Parent,
void lcInstructionsPartsListItem::Update()
{
bool Visible = mInstructions->GetBoolProperty(lcInstructionsPropertyType::ShowStepPLI, mModel, mStep);
setVisible(Visible);
if (!Visible)
return;
QColor BackgroundColor = mInstructions->GetColorProperty(lcInstructionsPropertyType::PLIBackgroundColor, mModel, mStep);
QFont Font = mInstructions->GetFontProperty(lcInstructionsPropertyType::PLIFont, mModel, mStep);
QColor TextColor = mInstructions->GetColorProperty(lcInstructionsPropertyType::PLITextColor, mModel, mStep);
@@ -295,34 +304,26 @@ lcInstructionsPropertiesWidget::lcInstructionsPropertiesWidget(QWidget* Parent,
Layout->setRowStretch(3, 1);
}
void lcInstructionsPropertiesWidget::AddColorProperty(lcInstructionsPropertyType Type)
void lcInstructionsPropertiesWidget::AddBoolProperty(lcInstructionsPropertyType Type)
{
QString Label;
const QString Label = mInstructions->GetPropertyLabel(Type);
const int Row = mPropertiesLayout->rowCount();
switch (Type)
QCheckBox* CheckBox = new QCheckBox(Label);
mPropertiesLayout->addWidget(CheckBox, Row, 0, 1, -1);
bool Enabled = mInstructions->GetBoolProperty(Type, mModel, mStep);
CheckBox->setChecked(Enabled);
connect(CheckBox, &QToolButton::toggled, [this, Type](bool Checked)
{
case lcInstructionsPropertyType::StepNumberColor:
case lcInstructionsPropertyType::PLITextColor:
Label = tr("Text Color:");
break;
case lcInstructionsPropertyType::StepBackgroundColor:
case lcInstructionsPropertyType::PLIBackgroundColor:
Label = tr("Background Color:");
break;
case lcInstructionsPropertyType::PLIBorderColor:
Label = tr("Border Color:");
break;
case lcInstructionsPropertyType::StepNumberFont:
case lcInstructionsPropertyType::PLIFont:
// case lcInstructionsPropertyType::PLIBorderWidth:
// case lcInstructionsPropertyType::PLIBorderRound:
case lcInstructionsPropertyType::Count:
break;
mInstructions->SetDefaultBool(Type, Checked);
} );
}
void lcInstructionsPropertiesWidget::AddColorProperty(lcInstructionsPropertyType Type)
{
const QString Label = mInstructions->GetPropertyLabel(Type);
const int Row = mPropertiesLayout->rowCount();
mPropertiesLayout->addWidget(new QLabel(Label), Row, 0);
@@ -366,6 +367,8 @@ void lcInstructionsPropertiesWidget::AddColorProperty(lcInstructionsPropertyType
Title = tr("Select Parts List Text Color");
break;
case lcInstructionsPropertyType::ShowStepNumber:
case lcInstructionsPropertyType::ShowStepPLI:
case lcInstructionsPropertyType::StepNumberFont:
case lcInstructionsPropertyType::PLIFont:
// case lcInstructionsPropertyType::StepPLIBorderWidth:
@@ -387,7 +390,7 @@ void lcInstructionsPropertiesWidget::AddColorProperty(lcInstructionsPropertyType
void lcInstructionsPropertiesWidget::AddFontProperty(lcInstructionsPropertyType Type)
{
const QString Label = tr("Font:");
const QString Label = mInstructions->GetPropertyLabel(Type);
const int Row = mPropertiesLayout->rowCount();
mPropertiesLayout->addWidget(new QLabel(Label), Row, 0);
@@ -418,6 +421,8 @@ void lcInstructionsPropertiesWidget::AddFontProperty(lcInstructionsPropertyType
Title = tr("Select Parts List Font");
break;
case lcInstructionsPropertyType::ShowStepNumber:
case lcInstructionsPropertyType::ShowStepPLI:
case lcInstructionsPropertyType::StepNumberColor:
case lcInstructionsPropertyType::StepBackgroundColor:
case lcInstructionsPropertyType::PLIBackgroundColor:
@@ -474,6 +479,8 @@ void lcInstructionsPropertiesWidget::SelectionChanged(QGraphicsItem* FocusItem)
mModel = ImageItem->GetModel();
mStep = ImageItem->GetStep();
AddBoolProperty(lcInstructionsPropertyType::ShowStepNumber);
AddBoolProperty(lcInstructionsPropertyType::ShowStepPLI);
AddColorProperty(lcInstructionsPropertyType::StepBackgroundColor);
return;
+1
View File
@@ -141,6 +141,7 @@ public:
void SelectionChanged(QGraphicsItem* FocusItem);
protected:
void AddBoolProperty(lcInstructionsPropertyType Type);
void AddColorProperty(lcInstructionsPropertyType Type);
void AddFontProperty(lcInstructionsPropertyType Type);