diff --git a/CMakeLists.txt b/CMakeLists.txt index c41ccb2d..7911b21c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,7 @@ add_executable(Bloom src/Insight/InsightWorker/Tasks/SetTargetPinState.cpp # Target package widgets + src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.cpp diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index cc01b04e..5021b001 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -64,7 +64,9 @@ InsightWindow::InsightWindow( + "/src/Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg" ) )); - this->ioContainerWidget = this->mainWindowWidget->findChild("io-container"); + this->ioContainerWidget = this->mainWindowWidget->findChild( + "io-container" + ); this->ioUnavailableWidget = this->mainWindowWidget->findChild("io-inspection-unavailable"); this->mainMenuBar = this->mainWindowWidget->findChild("menu-bar"); @@ -345,6 +347,7 @@ void InsightWindow::selectVariant(const TargetVariant* variant) { this->targetPackageWidget->hide(); this->targetPackageWidget->deleteLater(); this->targetPackageWidget = nullptr; + this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); } this->selectedVariant = variant; @@ -369,6 +372,7 @@ void InsightWindow::selectVariant(const TargetVariant* variant) { } if (this->targetPackageWidget != nullptr) { + this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); this->targetPackageWidget->setTargetState(this->targetState); if (this->targetState == TargetState::STOPPED) { @@ -379,6 +383,13 @@ void InsightWindow::selectVariant(const TargetVariant* variant) { }); } + this->mainWindowWidget->setMinimumSize( + this->targetPackageWidget->width() + 500, + this->targetPackageWidget->height() + 150 + ); + + this->ioContainerWidget->resize(this->ioContainerWidget->size()); + this->targetPackageWidget->show(); } } diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index c7b5b61c..d22617ca 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -13,6 +13,7 @@ #include "src/Targets/TargetDescriptor.hpp" #include "src/Targets/TargetVariant.hpp" +#include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" #include "Widgets/TargetWidgets/TargetPackageWidget.hpp" #include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp" #include "AboutWindow.hpp" @@ -48,7 +49,7 @@ namespace Bloom Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr; QToolButton* targetRegistersButton = nullptr; - QWidget* ioContainerWidget = nullptr; + Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr; QLabel* ioUnavailableWidget = nullptr; Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr; diff --git a/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui b/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui index 3751e003..6d0e5cb2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui +++ b/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui @@ -209,7 +209,7 @@ - + diff --git a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp index e00941d6..fc625793 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp @@ -8,7 +8,7 @@ #include "Widgets/SvgToolButton.hpp" #include "Widgets/ExpandingWidget.hpp" #include "Widgets/ExpandingHeightScrollAreaWidget.hpp" -#include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp" +#include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" #include "src/Logger/Logger.hpp" @@ -71,6 +71,15 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { return widget; } }, + { + "TargetPackageWidgetContainer", + [this](QWidget* parent, const QString& name) { + auto widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp new file mode 100644 index 00000000..7c98e103 --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp @@ -0,0 +1,26 @@ +#include "TargetPackageWidgetContainer.hpp" + +using namespace Bloom; +using namespace Bloom::Widgets::InsightTargetWidgets; + +TargetPackageWidgetContainer::TargetPackageWidgetContainer(QWidget* parent): QWidget(parent) { + this->packageWidget = this->findChild(); +} + +void TargetPackageWidgetContainer::resizeEvent(QResizeEvent* event) { + if (this->packageWidget == nullptr) { + return; + } + + const auto packageSize = this->packageWidget->size(); + this->packageWidget->setGeometry( + (this->width() / 2) - (packageSize.width() / 2), + (this->height() / 2) - (packageSize.height() / 2), + packageSize.width(), + packageSize.height() + ); +} + +void TargetPackageWidgetContainer::setPackageWidget(TargetPackageWidget* packageWidget) { + this->packageWidget = packageWidget; +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp new file mode 100644 index 00000000..605e6ea6 --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "TargetPackageWidget.hpp" + +namespace Bloom::Widgets::InsightTargetWidgets +{ + class TargetPackageWidgetContainer: public QWidget + { + Q_OBJECT + private: + TargetPackageWidget* packageWidget = nullptr; + + protected: + void resizeEvent(QResizeEvent* event) override; + + public: + TargetPackageWidgetContainer(QWidget* parent); + + void setPackageWidget(TargetPackageWidget* packageWidget); + }; +}