Made managing of PanelState object consistent with the managing of other state objects
This commit is contained in:
@@ -97,6 +97,9 @@ namespace Bloom
|
|||||||
);
|
);
|
||||||
this->ioUnavailableWidget = this->windowContainer->findChild<Label*>("io-inspection-unavailable");
|
this->ioUnavailableWidget = this->windowContainer->findChild<Label*>("io-inspection-unavailable");
|
||||||
|
|
||||||
|
auto* horizontalContentLayout = this->container->findChild<QHBoxLayout*>("horizontal-content-layout");
|
||||||
|
auto* verticalContentLayout = this->container->findChild<QVBoxLayout*>("vertical-content-layout");
|
||||||
|
|
||||||
auto* fileMenu = this->mainMenuBar->findChild<QMenu*>("file-menu");
|
auto* fileMenu = this->mainMenuBar->findChild<QMenu*>("file-menu");
|
||||||
auto* helpMenu = this->mainMenuBar->findChild<QMenu*>("help-menu");
|
auto* helpMenu = this->mainMenuBar->findChild<QMenu*>("help-menu");
|
||||||
auto* quitAction = fileMenu->findChild<QAction*>("close-insight");
|
auto* quitAction = fileMenu->findChild<QAction*>("close-insight");
|
||||||
@@ -107,8 +110,25 @@ namespace Bloom
|
|||||||
this->header = this->windowContainer->findChild<QWidget*>("header");
|
this->header = this->windowContainer->findChild<QWidget*>("header");
|
||||||
this->refreshIoInspectionButton = this->header->findChild<SvgToolButton*>("refresh-io-inspection-btn");
|
this->refreshIoInspectionButton = this->header->findChild<SvgToolButton*>("refresh-io-inspection-btn");
|
||||||
|
|
||||||
|
// Create panel states
|
||||||
|
if (!this->insightProjectSettings.previousLeftPanelState.has_value()) {
|
||||||
|
this->insightProjectSettings.previousLeftPanelState = PanelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->insightProjectSettings.previousBottomPanelState.has_value()) {
|
||||||
|
this->insightProjectSettings.previousBottomPanelState = PanelState();
|
||||||
|
}
|
||||||
|
|
||||||
this->leftMenuBar = this->container->findChild<QWidget*>("left-side-menu-bar");
|
this->leftMenuBar = this->container->findChild<QWidget*>("left-side-menu-bar");
|
||||||
this->leftPanel = this->container->findChild<PanelWidget*>("left-panel");
|
this->leftPanel = new PanelWidget(
|
||||||
|
PanelWidgetType::LEFT,
|
||||||
|
this->insightProjectSettings.previousLeftPanelState.value(),
|
||||||
|
this->container
|
||||||
|
);
|
||||||
|
this->leftPanel->setObjectName("left-panel");
|
||||||
|
this->leftPanel->setHandleSize(6);
|
||||||
|
this->leftPanel->setMinimumResize(300);
|
||||||
|
horizontalContentLayout->insertWidget(0, this->leftPanel);
|
||||||
|
|
||||||
this->targetRegistersButton = this->container->findChild<QToolButton*>("target-registers-btn");
|
this->targetRegistersButton = this->container->findChild<QToolButton*>("target-registers-btn");
|
||||||
auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>();
|
auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>();
|
||||||
@@ -118,7 +138,14 @@ namespace Bloom
|
|||||||
targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop);
|
targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop);
|
||||||
|
|
||||||
this->bottomMenuBar = this->container->findChild<QWidget*>("bottom-menu-bar");
|
this->bottomMenuBar = this->container->findChild<QWidget*>("bottom-menu-bar");
|
||||||
this->bottomPanel = this->container->findChild<PanelWidget*>("bottom-panel");
|
this->bottomPanel = new PanelWidget(
|
||||||
|
PanelWidgetType::BOTTOM,
|
||||||
|
this->insightProjectSettings.previousBottomPanelState.value(),
|
||||||
|
this->container
|
||||||
|
);
|
||||||
|
this->bottomPanel->setObjectName("bottom-panel");
|
||||||
|
this->bottomPanel->setHandleSize(10);
|
||||||
|
verticalContentLayout->insertWidget(1, this->bottomPanel);
|
||||||
|
|
||||||
this->ramInspectionButton = this->container->findChild<QToolButton*>("ram-inspection-btn");
|
this->ramInspectionButton = this->container->findChild<QToolButton*>("ram-inspection-btn");
|
||||||
this->eepromInspectionButton = this->container->findChild<QToolButton*>("eeprom-inspection-btn");
|
this->eepromInspectionButton = this->container->findChild<QToolButton*>("eeprom-inspection-btn");
|
||||||
@@ -276,7 +303,6 @@ namespace Bloom
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InsightWindow::closeEvent(QCloseEvent* event) {
|
void InsightWindow::closeEvent(QCloseEvent* event) {
|
||||||
this->recordInsightSettings();
|
|
||||||
|
|
||||||
return QMainWindow::closeEvent(event);
|
return QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
@@ -997,16 +1023,4 @@ namespace Bloom
|
|||||||
void InsightWindow::onProgrammingModeDisabled() {
|
void InsightWindow::onProgrammingModeDisabled() {
|
||||||
this->onTargetStateUpdate(this->targetState);
|
this->onTargetStateUpdate(this->targetState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsightWindow::recordInsightSettings() {
|
|
||||||
if (this->activated) {
|
|
||||||
if (this->leftPanel != nullptr) {
|
|
||||||
this->insightProjectSettings.previousLeftPanelState = this->leftPanel->getCurrentState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->bottomPanel != nullptr) {
|
|
||||||
this->insightProjectSettings.previousBottomPanelState = this->bottomPanel->getCurrentState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,5 @@ namespace Bloom
|
|||||||
void onEepromInspectionPaneStateChanged();
|
void onEepromInspectionPaneStateChanged();
|
||||||
void onProgrammingModeEnabled();
|
void onProgrammingModeEnabled();
|
||||||
void onProgrammingModeDisabled();
|
void onProgrammingModeDisabled();
|
||||||
|
|
||||||
void recordInsightSettings();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout" name="vertical-content-layout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -191,37 +191,14 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout" name="horizontal-content-layout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<!-- The left panel is inserted here. See InsightWindow::InsightWindow() for more -->
|
||||||
<widget class="PanelWidget" name="left-panel">
|
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="maximumWidth">
|
|
||||||
<number>300</number>
|
|
||||||
</property>
|
|
||||||
<property name="minimumResize">
|
|
||||||
<number>300</number>
|
|
||||||
</property>
|
|
||||||
<property name="handleSize">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="left-panel-layout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="TargetPackageWidgetContainer" name="io-container">
|
<widget class="TargetPackageWidgetContainer" name="io-container">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -244,27 +221,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<!-- The bottom panel is inserted here. See InsightWindow::InsightWindow() for more -->
|
||||||
<widget class="PanelWidget" name="bottom-panel">
|
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="panelType">
|
|
||||||
<enum>PanelWidgetType::BOTTOM</enum>
|
|
||||||
</property>
|
|
||||||
<property name="handleSize">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="bottom-panel-layout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <QtUiTools>
|
#include <QtUiTools>
|
||||||
|
|
||||||
// Custom widgets
|
// Custom widgets
|
||||||
#include "Widgets/PanelWidget.hpp"
|
|
||||||
#include "Widgets/Label.hpp"
|
#include "Widgets/Label.hpp"
|
||||||
#include "Widgets/RotatableLabel.hpp"
|
#include "Widgets/RotatableLabel.hpp"
|
||||||
#include "Widgets/LabeledSeparator.hpp"
|
#include "Widgets/LabeledSeparator.hpp"
|
||||||
@@ -19,15 +18,6 @@ namespace Bloom
|
|||||||
|
|
||||||
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||||
this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) {
|
this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) {
|
||||||
{
|
|
||||||
"PanelWidget",
|
|
||||||
[this] (QWidget* parent, const QString& name) {
|
|
||||||
auto* widget = new PanelWidget(parent);
|
|
||||||
widget->setObjectName(name);
|
|
||||||
widget->setStyleSheet(parent->styleSheet());
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Label",
|
"Label",
|
||||||
[this] (QWidget* parent, const QString& name) {
|
[this] (QWidget* parent, const QString& name) {
|
||||||
|
|||||||
@@ -6,7 +6,5 @@ namespace Bloom::Widgets
|
|||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
bool open = false;
|
bool open = false;
|
||||||
|
|
||||||
PanelState(int size, bool open): size(size), open(open) {};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,66 @@
|
|||||||
#include "PanelWidget.hpp"
|
#include "PanelWidget.hpp"
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
#include "PaneWidget.hpp"
|
#include "PaneWidget.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
PanelWidget::PanelWidget(QWidget* parent): QFrame(parent) {
|
PanelWidget::PanelWidget(PanelWidgetType type, PanelState& state, QWidget* parent)
|
||||||
|
: panelType(type)
|
||||||
|
, state(state)
|
||||||
|
, QFrame(parent)
|
||||||
|
{
|
||||||
this->setMouseTracking(false);
|
this->setMouseTracking(false);
|
||||||
this->setAttribute(Qt::WA_Hover, true);
|
this->setAttribute(Qt::WA_Hover, true);
|
||||||
|
|
||||||
|
if (this->panelType == PanelWidgetType::LEFT) {
|
||||||
|
this->resizeCursor = Qt::SplitHCursor;
|
||||||
|
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
|
auto* layout = new QVBoxLayout(this);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setLayout(layout);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this->resizeCursor = Qt::SplitVCursor;
|
||||||
|
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
auto* layout = new QHBoxLayout(this);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setLayout(layout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelWidget::setMinimumResize(int minimumResize) {
|
void PanelWidget::setMinimumResize(int minimumResize) {
|
||||||
this->minimumResize = minimumResize;
|
this->minimumResize = minimumResize;
|
||||||
|
|
||||||
const auto currentSize = this->size();
|
if (this->state.size < this->minimumResize) {
|
||||||
|
this->setSize(this->minimumResize);
|
||||||
if (this->panelType == PanelWidgetType::LEFT && currentSize.width() < this->minimumResize) {
|
|
||||||
this->setFixedWidth(this->minimumResize);
|
|
||||||
|
|
||||||
} else if (this->panelType == PanelWidgetType::BOTTOM && currentSize.height() < this->minimumResize) {
|
|
||||||
this->setFixedHeight(this->minimumResize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelWidget::setMaximumResize(int maximumResize) {
|
void PanelWidget::setMaximumResize(int maximumResize) {
|
||||||
this->maximumResize = maximumResize;
|
this->maximumResize = maximumResize;
|
||||||
|
|
||||||
const auto currentSize = this->size();
|
if (this->state.size > this->maximumResize) {
|
||||||
|
this->setSize(this->maximumResize);
|
||||||
if (this->panelType == PanelWidgetType::LEFT && currentSize.width() > this->maximumResize) {
|
|
||||||
this->setFixedWidth(this->maximumResize);
|
|
||||||
|
|
||||||
} else if (this->panelType == PanelWidgetType::BOTTOM && currentSize.height() > this->maximumResize) {
|
|
||||||
this->setFixedHeight(this->maximumResize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PanelWidget::setPanelType(PanelWidgetType panelType) {
|
|
||||||
this->panelType = panelType;
|
|
||||||
|
|
||||||
if (this->panelType == PanelWidgetType::LEFT) {
|
|
||||||
this->resizeCursor = Qt::SplitHCursor;
|
|
||||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this->resizeCursor = Qt::SplitVCursor;
|
|
||||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelWidget::setSize(int size) {
|
void PanelWidget::setSize(int size) {
|
||||||
if (this->panelType == PanelWidgetType::LEFT) {
|
if (this->panelType == PanelWidgetType::LEFT) {
|
||||||
this->setFixedWidth(std::min(std::max(size, this->minimumResize), this->maximumResize));
|
const auto width = std::min(std::max(size, this->minimumResize), this->maximumResize);
|
||||||
|
this->setFixedWidth(width);
|
||||||
|
this->state.size = width;
|
||||||
|
|
||||||
} else if (this->panelType == PanelWidgetType::BOTTOM) {
|
} else if (this->panelType == PanelWidgetType::BOTTOM) {
|
||||||
this->setFixedHeight(std::min(std::max(size, this->minimumResize), this->maximumResize));
|
const auto height = std::min(std::max(size, this->minimumResize), this->maximumResize);
|
||||||
|
this->setFixedHeight(height);
|
||||||
|
this->state.size = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,9 +90,11 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::Type::Close || event->type() == QEvent::Type::Hide) {
|
if (event->type() == QEvent::Type::Close || event->type() == QEvent::Type::Hide) {
|
||||||
|
this->state.open = false;
|
||||||
emit this->closed();
|
emit this->closed();
|
||||||
|
|
||||||
} else if (event->type() == QEvent::Type::Show) {
|
} else if (event->type() == QEvent::Type::Show) {
|
||||||
|
this->state.open = true;
|
||||||
emit this->opened();
|
emit this->opened();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int handleSize READ getHandleSize WRITE setHandleSize DESIGNABLE true)
|
Q_PROPERTY(int handleSize READ getHandleSize WRITE setHandleSize DESIGNABLE true)
|
||||||
Q_PROPERTY(int minimumResize READ getMinimumResize WRITE setMinimumResize DESIGNABLE true)
|
Q_PROPERTY(int minimumResize READ getMinimumResize WRITE setMinimumResize DESIGNABLE true)
|
||||||
Q_PROPERTY(Bloom::Widgets::PanelWidgetType panelType READ getPanelType WRITE setPanelType DESIGNABLE true)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PanelWidget(QWidget* parent);
|
PanelState& state;
|
||||||
|
|
||||||
|
explicit PanelWidget(PanelWidgetType type, PanelState& state, QWidget* parent);
|
||||||
|
|
||||||
void setHandleSize(int handleSize) {
|
void setHandleSize(int handleSize) {
|
||||||
this->handleSize = handleSize;
|
this->handleSize = handleSize;
|
||||||
@@ -37,8 +38,6 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
void setMaximumResize(int maximumResize);
|
void setMaximumResize(int maximumResize);
|
||||||
|
|
||||||
void setPanelType(PanelWidgetType panelType);
|
|
||||||
|
|
||||||
void setSize(int size);
|
void setSize(int size);
|
||||||
|
|
||||||
[[nodiscard]] int getHandleSize() const {
|
[[nodiscard]] int getHandleSize() const {
|
||||||
@@ -53,17 +52,6 @@ namespace Bloom::Widgets
|
|||||||
return this->maximumResize;
|
return this->maximumResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelWidgetType getPanelType() {
|
|
||||||
return this->panelType;
|
|
||||||
}
|
|
||||||
|
|
||||||
PanelState getCurrentState() {
|
|
||||||
return PanelState(
|
|
||||||
this->panelType == PanelWidgetType::LEFT ? this->width() : this->height(),
|
|
||||||
this->isVisible()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will evaluate whether the panel should still be visible or not (depending on whether there are any
|
* Will evaluate whether the panel should still be visible or not (depending on whether there are any
|
||||||
* visible and attached child panes).
|
* visible and attached child panes).
|
||||||
|
|||||||
Reference in New Issue
Block a user