Skip to content

Commit

Permalink
adc: primary plot cannot be deleted
Browse files Browse the repository at this point in the history
- fixed MapStackedWidget not updating size based on content size

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w authored and adisuciu committed Sep 16, 2024
1 parent c22a50f commit 2009bf7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gui/include/gui/mapstackedwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class SCOPY_GUI_EXPORT MapStackedWidget : public QStackedWidget
virtual QString getKey(QWidget *w);
virtual bool contains(QString key);
virtual QWidget *get(QString key);

QSize sizeHint() const override;
QSize minimumSizeHint() const override;

public Q_SLOTS:
virtual bool show(QString key);

Expand Down
16 changes: 16 additions & 0 deletions gui/src/mapstackedwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ QWidget *MapStackedWidget::get(QString key)
return nullptr;
}

QSize MapStackedWidget::sizeHint() const
{
if(currentWidget()) {
return currentWidget()->sizeHint();
}
return QStackedWidget::sizeHint();
}

QSize MapStackedWidget::minimumSizeHint() const
{
if(currentWidget()) {
return currentWidget()->minimumSizeHint();
}
return QStackedWidget::minimumSizeHint();
}

bool MapStackedWidget::show(QString key)
{
QWidget *w = map[key];
Expand Down
6 changes: 6 additions & 0 deletions plugins/adc/src/time/timeplotcomponentsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ TimePlotComponentSettings::TimePlotComponentSettings(TimePlotComponent *plt, QWi
}

void TimePlotComponentSettings::showDeleteButtons(bool b)
{
m_deletePlotHover->setVisible(b);
m_deletePlot->setVisible(b);
}

void TimePlotComponentSettings::showPlotButtons(bool b)
{
m_plotComponent->timePlot()->plotButtonManager()->setVisible(b);
m_deletePlot->setVisible(b);
Expand Down
1 change: 1 addition & 0 deletions plugins/adc/src/time/timeplotcomponentsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SCOPY_ADC_EXPORT TimePlotComponentSettings : public QWidget, public ToolCo
~TimePlotComponentSettings();

void showDeleteButtons(bool b);
void showPlotButtons(bool b);

public Q_SLOTS:
void addChannel(ChannelComponent *c);
Expand Down
5 changes: 4 additions & 1 deletion plugins/adc/src/time/timeplotmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ void TimePlotManager::multiPlotUpdate()

for(PlotComponent *p : qAsConst(m_plots)) {
auto plt = dynamic_cast<TimePlotComponent *>(p);
plt->plotMenu()->showDeleteButtons(b);
plt->plotMenu()->showPlotButtons(b);

// do not allow users to delete the primary plot
plt->plotMenu()->showDeleteButtons(b && plt != m_primary);
}

for(PlotManagerCombobox *cb : m_channelPlotcomboMap) {
Expand Down

0 comments on commit 2009bf7

Please sign in to comment.