QFP pin widget tidying

This commit is contained in:
Nav
2021-09-02 21:20:48 +01:00
parent 9680f06df8
commit 5a1ae665ac
2 changed files with 29 additions and 25 deletions

View File

@@ -99,3 +99,30 @@ PinWidget::PinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor,
connect(this->bodyWidget, &PinBodyWidget::clicked, this, &TargetPinWidget::onWidgetBodyClicked);
}
void PinWidget::updatePinState(const Targets::TargetPinState& pinState) {
TargetPinWidget::updatePinState(pinState);
if (pinState.ioDirection.has_value()) {
this->pinDirectionLabel->setText(
pinState.ioDirection.value() == Targets::TargetPinState::IoDirection::INPUT ? "IN" : "OUT"
);
} else {
this->pinDirectionLabel->setText("");
}
if (this->bodyWidget != nullptr) {
this->bodyWidget->setPinState(pinState);
}
this->setLabelColor(this->pinStateChanged ? "#4d7bba" : "#a6a7aa");
}
void PinWidget::setLabelColor(const QString& hexColor) {
auto style = QString("QLabel { color: " + hexColor + "; }");
if (this->pinNameLabel != nullptr) {
this->pinNameLabel->setStyleSheet(style);
}
}

View File

@@ -25,13 +25,7 @@ namespace Bloom::Widgets::InsightTargetWidgets::Qfp
bool isRightLayout = false;
bool isTopLayout = false;
void setLabelColor(const QString& hexColor) {
auto style = QString("QLabel { color: " + hexColor + "; }");
if (this->pinNameLabel != nullptr) {
this->pinNameLabel->setStyleSheet(style);
}
}
void setLabelColor(const QString& hexColor);
public:
static const int PIN_WIDGET_LAYOUT_PADDING = 46;
@@ -53,23 +47,6 @@ namespace Bloom::Widgets::InsightTargetWidgets::Qfp
const Targets::TargetVariant& targetVariant
);
void updatePinState(const Targets::TargetPinState& pinState) override {
TargetPinWidget::updatePinState(pinState);
if (pinState.ioDirection.has_value()) {
this->pinDirectionLabel->setText(
pinState.ioDirection.value() == Targets::TargetPinState::IoDirection::INPUT ? "IN" : "OUT"
);
} else {
this->pinDirectionLabel->setText("");
}
if (this->bodyWidget != nullptr) {
this->bodyWidget->setPinState(pinState);
}
this->setLabelColor(this->pinStateChanged ? "#4d7bba" : "#a6a7aa");
}
void updatePinState(const Targets::TargetPinState& pinState) override;
};
}