network: add a new status bar icon for the network disconnected state
This commit is contained in:
@@ -21,7 +21,7 @@ typedef struct {
|
||||
dev_status_empty_active_t mo[MO_NUM];
|
||||
dev_status_empty_active_t cassette;
|
||||
dev_status_active_t hdd[HDD_BUS_USB];
|
||||
dev_status_active_t net[NET_CARD_MAX];
|
||||
dev_status_empty_active_t net[NET_CARD_MAX];
|
||||
dev_status_empty_t cartridge[2];
|
||||
} machine_status_t;
|
||||
|
||||
|
@@ -52,5 +52,6 @@ machine_status_init() {
|
||||
|
||||
for (size_t i = 0; i < NET_CARD_MAX; i++) {
|
||||
machine_status.net[i].active = false;
|
||||
machine_status.net[i].empty = !network_is_connected(i);
|
||||
}
|
||||
}
|
@@ -88,7 +88,7 @@ namespace {
|
||||
PixmapSetEmptyActive zip;
|
||||
PixmapSetEmptyActive mo;
|
||||
PixmapSetActive hd;
|
||||
PixmapSetActive net;
|
||||
PixmapSetEmptyActive net;
|
||||
QPixmap sound;
|
||||
};
|
||||
|
||||
@@ -232,7 +232,7 @@ struct MachineStatus::States {
|
||||
std::array<StateEmptyActive, ZIP_NUM> zip;
|
||||
std::array<StateEmptyActive, MO_NUM> mo;
|
||||
std::array<StateActive, HDD_BUS_USB> hdds;
|
||||
std::array<StateActive, NET_CARD_MAX> net;
|
||||
std::array<StateEmptyActive, NET_CARD_MAX> net;
|
||||
std::unique_ptr<ClickableLabel> sound;
|
||||
std::unique_ptr<QLabel> text;
|
||||
};
|
||||
@@ -369,6 +369,7 @@ void MachineStatus::refreshIcons() {
|
||||
|
||||
for (size_t i = 0; i < NET_CARD_MAX; i++) {
|
||||
d->net[i].setActive(machine_status.net[i].active);
|
||||
d->net[i].setEmpty(machine_status.net[i].empty);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
@@ -518,6 +519,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
|
||||
iterateNIC([this, sbar](int i) {
|
||||
d->net[i].label = std::make_unique<ClickableLabel>();
|
||||
d->net[i].setEmpty(!network_is_connected(i));
|
||||
d->net[i].setActive(false);
|
||||
d->net[i].refresh();
|
||||
d->net[i].label->setToolTip(MediaMenu::ptr->netMenus[i]->title());
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
@@ -57,6 +57,8 @@ public:
|
||||
void moReload(int i);
|
||||
void moUpdateMenu(int i);
|
||||
|
||||
void nicConnect(int i);
|
||||
void nicDisconnect(int i);
|
||||
void nicUpdateMenu(int i);
|
||||
private:
|
||||
QWidget* parentWidget = nullptr;
|
||||
|
@@ -215,6 +215,7 @@ ui_sb_update_icon_state(int tag, int state) {
|
||||
case SB_HDD:
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
machine_status.net[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
<file>win/icons/mo_empty_active.ico</file>
|
||||
<file>win/icons/network.ico</file>
|
||||
<file>win/icons/network_active.ico</file>
|
||||
<file>win/icons/network_empty.ico</file>
|
||||
<file>win/icons/other_peripherals.ico</file>
|
||||
<file>win/icons/other_removable_devices.ico</file>
|
||||
<file>win/icons/ports.ico</file>
|
||||
|
BIN
src/win/icons/network_empty.ico
Normal file
BIN
src/win/icons/network_empty.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
Reference in New Issue
Block a user