2
0
forked from Ivasoft/DSView

When all channels disabled, the device options dialog not allowed to close

This commit is contained in:
dreamsourcelabTAI
2024-01-09 11:06:48 +08:00
parent 7c9736cfd9
commit 4ab59723f9
2 changed files with 20 additions and 4 deletions

View File

@@ -50,7 +50,7 @@ ChannelLabel::ChannelLabel(IChannelCheck *check, QWidget *parent, int chanIndex)
: QWidget(parent)
{
_checked = check;
_index = chanIndex;
_index = chanIndex;
QGridLayout *lay = new QGridLayout();
lay->setContentsMargins(0,0,0,0);
@@ -100,6 +100,7 @@ DeviceOptions::DeviceOptions(QWidget *parent) :
_container_lay = NULL;
_isBuilding = false;
_cur_analog_tag_index = 0;
_have_no_channel = false;
SigSession *session = AppControl::Instance()->GetSession();
_device_agent = session->get_device();
@@ -222,11 +223,14 @@ void DeviceOptions::accept()
it++;
}
QDialog::accept();
_have_no_channel = false;
QDialog::accept();
}
else {
_have_no_channel = true;
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_ALL_CHANNEL_DISABLE), "All channel disabled! Please enable at least one channel."));
MsgBox::Show(strMsg);
MsgBox::Show(strMsg);
}
}
@@ -834,7 +838,6 @@ void DeviceOptions::build_dynamic_panel()
_isBuilding = false;
}
int bb = 0;
void DeviceOptions::try_resize_scroll()
{
this->update_font();
@@ -891,5 +894,15 @@ void DeviceOptions::try_resize_scroll()
}
}
void DeviceOptions::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape && _have_no_channel) {
event->ignore();
return;
}
QDialog::keyPressEvent(event);
}
} // namespace dialogs
} // namespace pv

View File

@@ -111,6 +111,8 @@ private:
void channel_checkbox_clicked(QCheckBox *sc);
void keyPressEvent(QKeyEvent *) override;
private:
//IChannelCheck
void ChannelChecked(int index, QObject *object);
@@ -149,6 +151,7 @@ private:
std::vector<pv::prop::binding::ProbeOptions *> _probe_options_binding_list;
std::vector<ChannelModePair> _channel_mode_indexs;
std::vector<struct sr_channel*> _dso_channel_list;
bool _have_no_channel;
};
} // namespace dialogs