network: add a new status bar icon for the network disconnected state
This commit is contained in:
@@ -165,7 +165,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
MachineStatus::iterateNIC([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
netDisconnPos = menu->children().count();
|
||||
auto *action = menu->addAction(tr("&Disconnected"), [i] { network_connect(i, !network_is_connected(i)); config_save(); });
|
||||
auto *action = menu->addAction(tr("&Connected"), [this, i] { network_is_connected(i) ? nicDisconnect(i) : nicConnect(i); });
|
||||
action->setCheckable(true);
|
||||
netMenus[i] = menu;
|
||||
nicUpdateMenu(i);
|
||||
@@ -676,6 +676,20 @@ void MediaMenu::moUpdateMenu(int i) {
|
||||
menu->setTitle(QString::asprintf(tr("MO %i (%ls): %ls").toUtf8().constData(), i + 1, busName.toStdU16String().data(), name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::nicConnect(int i) {
|
||||
network_connect(i, 1);
|
||||
ui_sb_update_icon_state(SB_NETWORK|i, 0);
|
||||
nicUpdateMenu(i);
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::nicDisconnect(int i) {
|
||||
network_connect(i, 0);
|
||||
ui_sb_update_icon_state(SB_NETWORK|i, 1);
|
||||
nicUpdateMenu(i);
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::nicUpdateMenu(int i) {
|
||||
if (!netMenus.contains(i))
|
||||
return;
|
||||
@@ -695,7 +709,7 @@ void MediaMenu::nicUpdateMenu(int i) {
|
||||
auto *menu = netMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *connectedAction = dynamic_cast<QAction*>(childs[netDisconnPos]);
|
||||
connectedAction->setChecked(!network_is_connected(i));
|
||||
connectedAction->setChecked(network_is_connected(i));
|
||||
|
||||
menu->setTitle(QString::asprintf(tr("NIC %02i (%ls) %ls").toUtf8().constData(), i + 1, netType.toStdU16String().data(), devName.toStdU16String().data()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user