Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adc delete tool bug fix #1733

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugins/adc/src/adcinstrumentcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ void ADCInstrumentController::setEnableAddRemovePlot(bool) {}
void ADCInstrumentController::setEnableAddRemoveInstrument(bool b)
{
m_ui->addBtn->setVisible(b);
m_ui->removeBtn->setVisible(b);
if(!m_isMainInstrument) {
m_ui->removeBtn->setVisible(b);
}
}

void ADCInstrumentController::init() {}
Expand Down Expand Up @@ -186,4 +188,12 @@ void ADCInstrumentController::setupChannelMeasurement(PlotManager *c, ChannelCom
}
}

bool ADCInstrumentController::isMainInstrument() const { return m_isMainInstrument; }

void ADCInstrumentController::setIsMainInstrument(bool newIsMainInstrument)
{
m_isMainInstrument = newIsMainInstrument;
m_ui->removeBtn->setVisible(!newIsMainInstrument);
}

ADCInstrument *ADCInstrumentController::ui() const { return m_ui; }
4 changes: 4 additions & 0 deletions plugins/adc/src/adcinstrumentcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class SCOPY_ADC_EXPORT ADCInstrumentController : public QObject,
public:
ADCInstrument *ui() const;

bool isMainInstrument() const;
void setIsMainInstrument(bool newIsMainInstrument);

public Q_SLOTS:
virtual void init();
virtual void deinit();
Expand Down Expand Up @@ -83,6 +86,7 @@ protected Q_SLOTS:
QMap<AcqTreeNode *, ToolComponent *> m_acqNodeComponentMap;

bool m_refreshTimerRunning;
bool m_isMainInstrument = false;
};

} // namespace adc
Expand Down
10 changes: 6 additions & 4 deletions plugins/adc/src/adcplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ void ADCPlugin::newInstrument(ADCInstrumentType t, AcqTreeNode *root)
connect(root, &AcqTreeNode::deletedChild, dynamic_cast<ADCTimeInstrumentController *>(adc),
&ADCTimeInstrumentController::removeChannel, Qt::QueuedConnection);

connect(ui, &ADCInstrument::requestNewInstrument, this,
[=](ADCInstrumentType t) { newInstrument(t, root); });
connect(ui, &ADCInstrument::requestNewInstrument, this, [=]() { newInstrument(t, root); });

connect(ui, &ADCInstrument::requestDeleteInstrument, this, [=]() {
ToolMenuEntry *t = nullptr;
Expand Down Expand Up @@ -278,8 +277,7 @@ void ADCPlugin::newInstrument(ADCInstrumentType t, AcqTreeNode *root)
connect(root, &AcqTreeNode::deletedChild, dynamic_cast<ADCFFTInstrumentController *>(adc),
&ADCFFTInstrumentController::removeChannel, Qt::QueuedConnection);

connect(ui, &ADCInstrument::requestNewInstrument, this,
[=](ADCInstrumentType t) { newInstrument(t, root); });
connect(ui, &ADCInstrument::requestNewInstrument, this, [=]() { newInstrument(t, root); });

connect(ui, &ADCInstrument::requestDeleteInstrument, this, [=]() {
ToolMenuEntry *t = nullptr;
Expand All @@ -304,6 +302,10 @@ void ADCPlugin::newInstrument(ADCInstrumentType t, AcqTreeNode *root)

adc->setEnableAddRemovePlot(Preferences::get("adc_add_remove_plot").toBool());
adc->setEnableAddRemoveInstrument(Preferences::get("adc_add_remove_instrument").toBool());

// prevent user from deleting first time and fft tool
if(idx <= 2)
adc->setIsMainInstrument(true);
}

void ADCPlugin::deleteInstrument(ToolMenuEntry *tool)
Expand Down
Loading