From 5a1ae665ac6ee80cb7a8cae600a1efffa512442f Mon Sep 17 00:00:00 2001 From: Nav Date: Thu, 2 Sep 2021 21:20:48 +0100 Subject: [PATCH] QFP pin widget tidying --- .../Widgets/TargetWidgets/QFP/PinWidget.cpp | 27 +++++++++++++++++++ .../Widgets/TargetWidgets/QFP/PinWidget.hpp | 27 ++----------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp index 45c62f3c..d50d7efa 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp @@ -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); + } +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp index dcb6ffeb..a8b962eb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp @@ -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; }; }