优化了一些bad smells

dev-LayerStyle
ArgonarioD 2023-03-18 03:49:15 +08:00
parent 789d282393
commit 73719905db
2 changed files with 20 additions and 20 deletions

View File

@ -15,12 +15,12 @@ StrokeStyleWidget::StrokeStyleWidget(
QWidget* parent
) : QWidget(parent), stroke(stroke)
{
QVBoxLayout* viewLayout = new QVBoxLayout(this);
auto* viewLayout = new QVBoxLayout(this);
this->setLayout(viewLayout);
initStrokeSettings();
QWidget* strokeProperties = new QWidget(this);
QHBoxLayout* strokePropertiesLayout = new QHBoxLayout(strokeProperties);
auto* strokeProperties = new QWidget(this);
auto* strokePropertiesLayout = new QHBoxLayout(strokeProperties);
strokePropertiesLayout->setMargin(0);
strokeProperties->setLayout(strokePropertiesLayout);
@ -72,7 +72,7 @@ void StrokeStyleWidget::initStrokeSettings()
this->widthField = new QtMaterialTextField(this);
widthField->setLabel(QStringLiteral("±¾²àÃè±ß¿í¶È"));
widthField->setText(QString::number(stroke->halfWidth));
QDoubleValidator* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
auto* widthValidator = new QDoubleValidator(0.1, std::numeric_limits<float>::max(), 3, widthField);
widthValidator->setNotation(QDoubleValidator::StandardNotation);
widthField->setValidator(widthValidator);
connect(widthField, &QtMaterialTextField::textChanged, [this](const QString& changed) {
@ -139,30 +139,30 @@ void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient
void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& material)
{
QTableWidgetItem* widthItem = new QTableWidgetItem;
auto* widthItem = new QTableWidgetItem;
widthItem->setData(Qt::EditRole, width);
strokeTable->setItem(row, COLUMN_WIDTH, widthItem);
QColor* colorPtr = &(material.color);
QTableWidgetItem* colorItem = new QTableWidgetItem;
auto* colorItem = new QTableWidgetItem;
colorItem->setData(Qt::DisplayRole, *colorPtr);
strokeTable->setItem(row, COLUMN_COLOR, colorItem);
ColorPicker* colorPicker = new ColorPicker(*colorPtr, strokeTable);
auto* colorPicker = new ColorPicker(*colorPtr, strokeTable);
strokeTable->setCellWidget(row, COLUMN_COLOR, colorPicker);
connect(colorPicker, &ColorPicker::colorChanged, [this, colorPtr](QColor color) {
*colorPtr = color;
this->strokeTable->update();
});
QTableWidgetItem* metallicItem = new QTableWidgetItem;
auto* metallicItem = new QTableWidgetItem;
metallicItem->setData(Qt::EditRole, material.metallicF());
strokeTable->setItem(row, COLUMN_METALLIC, metallicItem);
QTableWidgetItem* roughnessItem = new QTableWidgetItem;
auto* roughnessItem = new QTableWidgetItem;
roughnessItem->setData(Qt::EditRole, material.roughnessF());
strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
QtMaterialRaisedButton* removeButton = new QtMaterialRaisedButton("-", strokeTable);
auto* removeButton = new QtMaterialRaisedButton("-", strokeTable);
removeButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
removeButton->setFixedSize(20, 20);
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);

View File

@ -41,21 +41,21 @@ std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
QWidget* StrokeElementLayerStyle::getInputWidget()
{
QWidget* w = new QWidget;
QListView* materialList = new QListView;
auto* w = new QWidget;
auto* materialList = new QListView;
QVBoxLayout* layout = new QVBoxLayout(w);
auto* layout = new QVBoxLayout(w);
layout->setMargin(0);
StrokeStyleWidget* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w);
auto* leftStrokeView = new StrokeStyleWidget(this->strokePair.first, w);
layout->addWidget(leftStrokeView);
QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w);
auto* checkEachSideIndependent = new QtMaterialCheckBox(w);
checkEachSideIndependent->setText(QStringLiteral("ÓÒ²à¶ÀÁ¢Ãè±ß"));
checkEachSideIndependent->setChecked(enableEachSideIndependent);
layout->addWidget(checkEachSideIndependent);
StrokeStyleWidget* rightStrokeView = new StrokeStyleWidget(this->strokePair.second, w);
auto* rightStrokeView = new StrokeStyleWidget(this->strokePair.second, w);
layout->addWidget(rightStrokeView);
rightStrokeView->setDisabled(!this->enableEachSideIndependent);
@ -262,17 +262,17 @@ std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
QWidget* FillElementLayerStyle::getInputWidget()
{
// TODO
QLineEdit* name = new QLineEdit;
auto* name = new QLineEdit;
name->setText(QStringLiteral("Ìî³ä"));
return name;
}
QWidget* FillElementLayerStyle::getListDisplayWidget() const
{
QWidget* w = new QWidget;
QLabel* name = new QLabel(w);
auto* w = new QWidget;
auto* name = new QLabel(w);
name->setText(QStringLiteral("Ìî³ä"));
QHBoxLayout* layout = new QHBoxLayout(w);
auto* layout = new QHBoxLayout(w);
layout->setMargin(0);
layout->addWidget(name);
return w;