mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Allow message_aggregator example to not join on he loopback interface
This commit is contained in:
parent
d953c455fe
commit
499704d275
@ -107,13 +107,16 @@ MessageAggregatorMainWindow::MessageAggregatorMainWindow ()
|
||||
auto flags = QNetworkInterface::IsRunning | QNetworkInterface::CanMulticast;
|
||||
if ((net_if.flags () & flags) == flags)
|
||||
{
|
||||
auto is_loopback = net_if.flags () & QNetworkInterface::IsLoopBack;
|
||||
if (net_if.flags () & QNetworkInterface::IsLoopBack)
|
||||
{
|
||||
loopback_interface_name_ = net_if.name ();
|
||||
}
|
||||
auto item = network_interfaces_combo_box_->addCheckItem (net_if.humanReadableName ()
|
||||
, net_if.name ()
|
||||
, is_loopback ? Qt::Checked : Qt::Unchecked);
|
||||
item->setEnabled (!is_loopback);
|
||||
auto tip = QString {"name(index): %1(%2) - %3"}.arg (net_if.name ()).arg (net_if.index ())
|
||||
.arg (net_if.flags () & QNetworkInterface::IsUp ? "Up" : "Down");
|
||||
, Qt::Unchecked);
|
||||
auto tip = QString {"name(index): %1(%2) - %3"}
|
||||
.arg (net_if.name ()).arg (net_if.index ())
|
||||
.arg (net_if.flags () & QNetworkInterface::IsUp ? "Up" : "Down");
|
||||
auto hw_addr = net_if.hardwareAddress ();
|
||||
if (hw_addr.size ())
|
||||
{
|
||||
@ -131,6 +134,8 @@ MessageAggregatorMainWindow::MessageAggregatorMainWindow ()
|
||||
item->setToolTip (tip);
|
||||
}
|
||||
}
|
||||
connect (network_interfaces_combo_box_, &QComboBox::currentTextChanged, this, &MessageAggregatorMainWindow::validate_network_interfaces);
|
||||
validate_network_interfaces (QString {});
|
||||
|
||||
log_table_view_->setModel (log_);
|
||||
log_table_view_->verticalHeader ()->hide ();
|
||||
@ -369,4 +374,30 @@ void MessageAggregatorMainWindow::change_highlighting (QString const& call, QCol
|
||||
}
|
||||
}
|
||||
|
||||
void MessageAggregatorMainWindow::validate_network_interfaces (QString const& /*text*/)
|
||||
{
|
||||
auto model = static_cast<QStandardItemModel *> (network_interfaces_combo_box_->model ());
|
||||
bool has_checked {false};
|
||||
int loopback_row {-1};
|
||||
for (int row = 0; row < model->rowCount (); ++row)
|
||||
{
|
||||
if (model->item (row)->data ().toString () == loopback_interface_name_)
|
||||
{
|
||||
loopback_row = row;
|
||||
}
|
||||
else if (Qt::Checked == model->item (row)->checkState ())
|
||||
{
|
||||
has_checked = true;
|
||||
}
|
||||
}
|
||||
if (loopback_row >= 0)
|
||||
{
|
||||
if (!has_checked)
|
||||
{
|
||||
model->item (loopback_row)->setCheckState (Qt::Checked);
|
||||
}
|
||||
model->item (loopback_row)->setEnabled (has_checked);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_MessageAggregatorMainWindow.cpp"
|
||||
|
@ -46,6 +46,7 @@ private:
|
||||
void remove_client (ClientKey const&);
|
||||
void change_highlighting (QString const& call, QColor const& bg = QColor {}, QColor const& fg = QColor {},
|
||||
bool last_only = false);
|
||||
Q_SLOT void validate_network_interfaces (QString const&);
|
||||
|
||||
// maps client id to widgets
|
||||
using ClientsDictionary = QHash<ClientKey, ClientWidget *>;
|
||||
@ -59,6 +60,7 @@ private:
|
||||
QSpinBox * port_spin_box_;
|
||||
QLineEdit * multicast_group_line_edit_;
|
||||
CheckableItemComboBox * network_interfaces_combo_box_;
|
||||
QString loopback_interface_name_;
|
||||
QLabel * network_interfaces_form_label_widget_;
|
||||
QTableView * log_table_view_;
|
||||
QListWidget * calls_of_interest_;
|
||||
|
Loading…
Reference in New Issue
Block a user