30 #include <QStandardItemModel>
33 #include <SimoxUtility/algorithm/string/string_tools.h>
38 m_channel_name{channel_config.name},
39 m_channel_prefs{channel_prefs}
41 m_widget.setupUi(
this);
43 const QString q_channel_name = QString::fromStdString(channel_config.name);
44 m_widget.channels_config->setTitle(QString{
"Channel: "} + q_channel_name);
45 m_widget.channels_config->setChecked(not channel_config.disabled);
46 m_widget.name->setText(q_channel_name);
50 m_widget.file_format->addItem(QString::fromStdString(reg_entry.hr_name));
53 m_widget.file_format->setCurrentText(q_format_str);
55 update_file_formats(channel_prefs.requiresLossless);
56 set_visible_file_fps(m_widget.file_format->currentText());
58 connect(m_widget.name, SIGNAL(textEdited(QString)),
this, SLOT(channel_name_changed(QString)));
59 connect(m_widget.file_format, SIGNAL(currentTextChanged(QString)),
this, SLOT(file_format_changed(QString)));
61 m_widget.lossless->setChecked(channel_prefs.requiresLossless);
62 connect(m_widget.lossless, SIGNAL(stateChanged(
int)),
this, SLOT(lossless_state_changed(
int)));
75 return m_channel_name;
82 m_widget.channels_config->setTitle(QString::fromStdString(
"Channel: " + new_name));
83 m_channel_name = new_name;
91 ARMARX_WARNING <<
"Invalid name '" << new_name <<
"' for channel (already taken).";
98 update_file_formats(channel_prefs.requiresLossless);
102 visionx::imrec::ChannelConfig
105 imrec::ChannelConfig cc;
106 cc.name = m_channel_name;
107 cc.disabled = disabled or not m_widget.channels_config->isChecked();
110 cc.fps = m_widget.file_fps->value();
116 visionx::ChannelConfigWidget::update_file_formats(
bool require_lossless)
118 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_widget.file_format->model());
119 for (
int i = 0; i < m_widget.file_format->count(); ++i)
121 QStandardItem* item = model->item(i);
124 item->setFlags(disabled ? item->flags() & ~Qt::ItemIsEnabled : item->flags() | Qt::ItemIsEnabled);
128 if (require_lossless)
130 const std::string format_str = m_widget.file_format->currentText().toStdString();
135 m_widget.file_format->setCurrentText(q_format_str);
142 visionx::ChannelConfigWidget::set_visible_file_fps(
const QString& q_format_str)
144 const std::string format_str = q_format_str.toStdString();
151 visionx::ChannelConfigWidget::set_visible_file_fps(
bool visible)
153 m_widget.file_fps->setVisible(visible);
154 m_widget.label_file_fps->setVisible(visible);
159 visionx::ChannelConfigWidget::channel_name_changed(
const QString& q_new_name)
161 const std::string new_name = simox::alg::trim_copy(q_new_name.toStdString());
162 const std::string old_name = m_channel_name;
163 if (new_name != old_name)
165 emit channelRenamed(old_name, new_name);
171 visionx::ChannelConfigWidget::lossless_state_changed(
int state)
173 update_file_formats(state == Qt::Checked);
178 visionx::ChannelConfigWidget::file_format_changed(
const QString& new_format_str)
180 set_visible_file_fps(new_format_str);