Merge pull request #2453 from elyosh/qtstatusbar
qt: switch to polling for status bar updating
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
#include <86box/thread.h>
|
||||
#include <86box/version.h>
|
||||
#include <86box/gdbstub.h>
|
||||
#include <86box/machine_status.h>
|
||||
|
||||
// Disable c99-designator to avoid the warnings about int ng
|
||||
#ifdef __clang__
|
||||
@@ -891,6 +892,8 @@ pc_init_modules(void)
|
||||
|
||||
video_reset_close();
|
||||
|
||||
machine_status_init();
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
add_executable(86Box 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
|
||||
dma.c ddma.c discord.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c
|
||||
mca.c usb.c fifo8.c device.c nvr.c nvr_at.c nvr_ps2.c)
|
||||
mca.c usb.c fifo8.c device.c nvr.c nvr_at.c nvr_ps2.c machine_status.c)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
add_compile_definitions(_FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE=1 _LARGEFILE64_SOURCE=1)
|
||||
|
@@ -1642,9 +1642,6 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
|
||||
disabled, the Read Multiple operation is rejected with an Aborted Com-
|
||||
mand error. */
|
||||
ide->blockcount = 0;
|
||||
/* Turn on the activity indicator *here* so that it gets turned on
|
||||
less times. */
|
||||
ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1);
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
case WIN_READ:
|
||||
@@ -1658,6 +1655,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
|
||||
ide->atastat = BSY_STAT;
|
||||
|
||||
if (ide->type == IDE_HDD) {
|
||||
ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1);
|
||||
uint32_t sec_count;
|
||||
double wait_time;
|
||||
if ((val == WIN_READ_DMA) || (val == WIN_READ_DMA_ALT)) {
|
||||
@@ -1908,7 +1906,7 @@ ide_read_data(ide_t *ide, int length)
|
||||
double xfer_time = ide_get_xfer_time(ide, 512);
|
||||
ide_set_callback(ide, seek_time + xfer_time);
|
||||
}
|
||||
} else if (ide->command != WIN_READ_MULTIPLE)
|
||||
} else
|
||||
ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0);
|
||||
}
|
||||
}
|
||||
|
32
src/include/86box/machine_status.h
Normal file
32
src/include/86box/machine_status.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef EMU_MACHINE_STATUS_H
|
||||
#define EMU_MACHINE_STATUS_H
|
||||
|
||||
typedef struct {
|
||||
atomic_bool_t empty;
|
||||
atomic_bool_t active;
|
||||
} dev_status_empty_active_t;
|
||||
|
||||
typedef struct {
|
||||
atomic_bool_t active;
|
||||
} dev_status_active_t;
|
||||
|
||||
typedef struct {
|
||||
atomic_bool_t empty;
|
||||
} dev_status_empty_t;
|
||||
|
||||
typedef struct {
|
||||
dev_status_empty_active_t fdd[FDD_NUM];
|
||||
dev_status_empty_active_t cdrom[CDROM_NUM];
|
||||
dev_status_empty_active_t zip[ZIP_NUM];
|
||||
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;
|
||||
dev_status_empty_t cartridge[2];
|
||||
} machine_status_t;
|
||||
|
||||
extern machine_status_t machine_status;
|
||||
|
||||
extern void machine_status_init();
|
||||
|
||||
#endif /*EMU_MACHINE_STATUS_H*/
|
@@ -70,10 +70,12 @@ extern int strnicmp(const char* s1, const char* s2, size_t n);
|
||||
#ifdef __cplusplus
|
||||
#include <atomic>
|
||||
#define atomic_flag_t std::atomic_flag
|
||||
#define atomic_bool_t std::atomic_bool
|
||||
extern "C" {
|
||||
#else
|
||||
#include <stdatomic.h>
|
||||
#define atomic_flag_t atomic_flag
|
||||
#define atomic_bool_t atomic_bool
|
||||
#endif
|
||||
|
||||
/* Global variables residing in the platform module. */
|
||||
|
@@ -70,8 +70,8 @@ extern void ui_sb_update_panes(void);
|
||||
extern void ui_sb_update_text(void);
|
||||
extern void ui_sb_update_tip(int meaning);
|
||||
extern void ui_sb_timer_callback(int pane);
|
||||
extern void ui_sb_update_icon(int tag, int val);
|
||||
extern void ui_sb_update_icon_state(int tag, int active);
|
||||
extern void ui_sb_update_icon(int tag, int active);
|
||||
extern void ui_sb_update_icon_state(int tag, int state);
|
||||
extern void ui_sb_set_text_w(wchar_t *wstr);
|
||||
extern void ui_sb_set_text(char *str);
|
||||
extern void ui_sb_bugui(char *str);
|
||||
|
52
src/machine_status.c
Normal file
52
src/machine_status.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/scsi.h>
|
||||
#include <86box/scsi_device.h>
|
||||
#include <86box/cartridge.h>
|
||||
#include <86box/cassette.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/mo.h>
|
||||
#include <86box/hdd.h>
|
||||
#include <86box/machine_status.h>
|
||||
|
||||
machine_status_t machine_status;
|
||||
|
||||
void
|
||||
machine_status_init() {
|
||||
for (size_t i = 0; i < FDD_NUM; ++i) {
|
||||
machine_status.fdd[i].empty = (strlen(floppyfns[i]) == 0);
|
||||
machine_status.fdd[i].active = false;
|
||||
}
|
||||
for (size_t i = 0; i < CDROM_NUM; ++i) {
|
||||
machine_status.cdrom[i].empty = cdrom[i].host_drive != 200 || (strlen(cdrom[i].image_path) == 0);
|
||||
machine_status.cdrom[i].active = false;
|
||||
}
|
||||
for (size_t i = 0; i < ZIP_NUM; i++) {
|
||||
machine_status.zip[i].empty = (strlen(zip_drives[i].image_path) == 0);
|
||||
machine_status.zip[i].active = false;
|
||||
}
|
||||
for (size_t i = 0; i < MO_NUM; i++) {
|
||||
machine_status.mo[i].empty = (strlen(mo_drives[i].image_path) == 0);
|
||||
machine_status.mo[i].active = false;
|
||||
}
|
||||
|
||||
machine_status.cassette.empty = (strlen(cassette_fname) == 0);
|
||||
|
||||
for (size_t i = 0; i < HDD_BUS_USB; i++) {
|
||||
machine_status.hdd[i].active = false;
|
||||
}
|
||||
|
||||
machine_status.net.active = false;
|
||||
}
|
@@ -39,6 +39,7 @@ extern uint64_t tsc;
|
||||
#include <86box/machine.h>
|
||||
#include <86box/network.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/machine_status.h>
|
||||
};
|
||||
|
||||
#include <QIcon>
|
||||
@@ -92,17 +93,21 @@ namespace {
|
||||
|
||||
struct StateActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
QTimer timer;
|
||||
PixmapSetActive* pixmaps = nullptr;
|
||||
bool active = false;
|
||||
|
||||
void setActive(bool b) {
|
||||
active = b;
|
||||
if (! label) {
|
||||
if (!label || b == active)
|
||||
return;
|
||||
active = b;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!label)
|
||||
return;
|
||||
}
|
||||
label->setPixmap(active ? pixmaps->active : pixmaps->normal);
|
||||
timer.start(75);
|
||||
}
|
||||
};
|
||||
struct StateEmpty {
|
||||
@@ -111,33 +116,42 @@ namespace {
|
||||
bool empty = false;
|
||||
|
||||
void setEmpty(bool e) {
|
||||
empty = e;
|
||||
if (! label) {
|
||||
if (!label || e == empty)
|
||||
return;
|
||||
empty = e;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!label)
|
||||
return;
|
||||
}
|
||||
label->setPixmap(empty ? pixmaps->empty : pixmaps->normal);
|
||||
}
|
||||
};
|
||||
struct StateEmptyActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
QTimer timer;
|
||||
PixmapSetEmptyActive* pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
bool active = false;
|
||||
|
||||
void setActive(bool b) {
|
||||
if (!label || b == active)
|
||||
return;
|
||||
|
||||
active = b;
|
||||
refresh();
|
||||
timer.start(75);
|
||||
}
|
||||
void setEmpty(bool b) {
|
||||
if (!label || b == empty)
|
||||
return;
|
||||
|
||||
empty = b;
|
||||
refresh();
|
||||
}
|
||||
void refresh() {
|
||||
if (! label) {
|
||||
if (!label)
|
||||
return;
|
||||
}
|
||||
if (empty) {
|
||||
label->setPixmap(active ? pixmaps->empty_active : pixmaps->empty);
|
||||
} else {
|
||||
@@ -190,26 +204,20 @@ struct MachineStatus::States {
|
||||
cartridge[0].pixmaps = &pixmaps.cartridge;
|
||||
cartridge[1].pixmaps = &pixmaps.cartridge;
|
||||
cassette.pixmaps = &pixmaps.cassette;
|
||||
QObject::connect(&cassette.timer, &QTimer::timeout, parent, [&]{ cassette.setActive(false); });
|
||||
for (auto& f : fdd) {
|
||||
f.pixmaps = &pixmaps.floppy_disabled;
|
||||
QObject::connect(&f.timer, &QTimer::timeout, parent, [&]{ f.setActive(false); });
|
||||
}
|
||||
for (auto& c : cdrom) {
|
||||
c.pixmaps = &pixmaps.cdrom;
|
||||
QObject::connect(&c.timer, &QTimer::timeout, parent, [&]{ c.setActive(false); });
|
||||
}
|
||||
for (auto& z : zip) {
|
||||
z.pixmaps = &pixmaps.zip;
|
||||
QObject::connect(&z.timer, &QTimer::timeout, parent, [&]{ z.setActive(false); });
|
||||
}
|
||||
for (auto& m : mo) {
|
||||
m.pixmaps = &pixmaps.mo;
|
||||
QObject::connect(&m.timer, &QTimer::timeout, parent, [&]{ m.setActive(false); });
|
||||
}
|
||||
for (auto& h : hdds) {
|
||||
h.pixmaps = &pixmaps.hd;
|
||||
QObject::connect(&h.timer, &QTimer::timeout, parent, [&]{ h.setActive(false); });
|
||||
}
|
||||
net.pixmaps = &pixmaps.net;
|
||||
}
|
||||
@@ -227,9 +235,12 @@ struct MachineStatus::States {
|
||||
};
|
||||
|
||||
MachineStatus::MachineStatus(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent),
|
||||
refreshTimer(new QTimer(this))
|
||||
{
|
||||
d = std::make_unique<MachineStatus::States>(this);
|
||||
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
|
||||
refreshTimer->start(75);
|
||||
}
|
||||
|
||||
MachineStatus::~MachineStatus() = default;
|
||||
@@ -321,6 +332,38 @@ static int hdd_count(int bus) {
|
||||
return(c);
|
||||
}
|
||||
|
||||
void MachineStatus::refreshIcons() {
|
||||
for (size_t i = 0; i < FDD_NUM; ++i) {
|
||||
d->fdd[i].setActive(machine_status.fdd[i].active);
|
||||
d->fdd[i].setEmpty(machine_status.fdd[i].empty);
|
||||
}
|
||||
for (size_t i = 0; i < CDROM_NUM; ++i) {
|
||||
d->cdrom[i].setActive(machine_status.cdrom[i].active);
|
||||
d->cdrom[i].setEmpty(machine_status.cdrom[i].empty);
|
||||
}
|
||||
for (size_t i = 0; i < ZIP_NUM; i++) {
|
||||
d->zip[i].setActive(machine_status.zip[i].active);
|
||||
d->zip[i].setEmpty(machine_status.zip[i].empty);
|
||||
}
|
||||
for (size_t i = 0; i < MO_NUM; i++) {
|
||||
d->mo[i].setActive(machine_status.mo[i].active);
|
||||
d->mo[i].setEmpty(machine_status.mo[i].empty);
|
||||
}
|
||||
|
||||
d->cassette.setEmpty(machine_status.cassette.empty);
|
||||
|
||||
for (size_t i = 0; i < HDD_BUS_USB; i++) {
|
||||
d->hdds[i].setActive(machine_status.hdd[i].active);
|
||||
}
|
||||
|
||||
d->net.setActive(machine_status.net.active);
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
d->cartridge[i].setEmpty(machine_status.cartridge[i].empty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
bool has_mfm = machine_has_flags(machine, MACHINE_MFM) > 0;
|
||||
bool has_xta = machine_has_flags(machine, MACHINE_XTA) > 0;
|
||||
@@ -358,6 +401,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
if (cassette_enable) {
|
||||
d->cassette.label = std::make_unique<ClickableLabel>();
|
||||
d->cassette.setEmpty(QString(cassette_fname).isEmpty());
|
||||
d->cassette.refresh();
|
||||
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
||||
MediaMenu::ptr->cassetteMenu->popup(pos - QPoint(0, MediaMenu::ptr->cassetteMenu->sizeHint().height()));
|
||||
});
|
||||
@@ -373,6 +417,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
d->cartridge[i].label = std::make_unique<ClickableLabel>();
|
||||
d->cartridge[i].setEmpty(QString(cart_fns[i]).isEmpty());
|
||||
d->cartridge[i].refresh();
|
||||
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->cartridgeMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cartridgeMenus[i]->sizeHint().height()));
|
||||
});
|
||||
@@ -397,6 +442,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->fdd[i].label = std::make_unique<ClickableLabel>();
|
||||
d->fdd[i].setEmpty(QString(floppyfns[i]).isEmpty());
|
||||
d->fdd[i].setActive(false);
|
||||
d->fdd[i].refresh();
|
||||
connect((ClickableLabel*)d->fdd[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->floppyMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->floppyMenus[i]->sizeHint().height()));
|
||||
});
|
||||
@@ -412,6 +458,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->cdrom[i].label = std::make_unique<ClickableLabel>();
|
||||
d->cdrom[i].setEmpty(cdrom[i].host_drive != 200 || QString(cdrom[i].image_path).isEmpty());
|
||||
d->cdrom[i].setActive(false);
|
||||
d->cdrom[i].refresh();
|
||||
connect((ClickableLabel*)d->cdrom[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->cdromMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cdromMenus[i]->sizeHint().height()));
|
||||
});
|
||||
@@ -427,6 +474,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->zip[i].label = std::make_unique<ClickableLabel>();
|
||||
d->zip[i].setEmpty(QString(zip_drives[i].image_path).isEmpty());
|
||||
d->zip[i].setActive(false);
|
||||
d->zip[i].refresh();
|
||||
connect((ClickableLabel*)d->zip[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->zipMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->zipMenus[i]->sizeHint().height()));
|
||||
});
|
||||
@@ -442,6 +490,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->mo[i].label = std::make_unique<ClickableLabel>();
|
||||
d->mo[i].setEmpty(QString(mo_drives[i].image_path).isEmpty());
|
||||
d->mo[i].setActive(false);
|
||||
d->mo[i].refresh();
|
||||
connect((ClickableLabel*)d->mo[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->moMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->moMenus[i]->sizeHint().height()));
|
||||
});
|
||||
@@ -457,24 +506,28 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
if ((has_mfm || hdc_name.left(5) == QStringLiteral("st506")) && c_mfm > 0) {
|
||||
d->hdds[HDD_BUS_MFM].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_MFM].setActive(false);
|
||||
d->hdds[HDD_BUS_MFM].refresh();
|
||||
d->hdds[HDD_BUS_MFM].label->setToolTip(tr("Hard disk (%s)").replace("%s", "MFM/RLL"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_MFM].label.get());
|
||||
}
|
||||
if ((has_esdi || hdc_name.left(4) == QStringLiteral("esdi")) && c_esdi > 0) {
|
||||
d->hdds[HDD_BUS_ESDI].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_ESDI].setActive(false);
|
||||
d->hdds[HDD_BUS_ESDI].refresh();
|
||||
d->hdds[HDD_BUS_ESDI].label->setToolTip(tr("Hard disk (%s)").replace("%s", "ESDI"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_ESDI].label.get());
|
||||
}
|
||||
if ((has_xta || hdc_name.left(3) == QStringLiteral("xta")) && c_xta > 0) {
|
||||
d->hdds[HDD_BUS_XTA].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_XTA].setActive(false);
|
||||
d->hdds[HDD_BUS_XTA].refresh();
|
||||
d->hdds[HDD_BUS_XTA].label->setToolTip(tr("Hard disk (%s)").replace("%s", "XTA"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_XTA].label.get());
|
||||
}
|
||||
if ((hasIDE() || hdc_name.left(5) == QStringLiteral("xtide") || hdc_name.left(3) == QStringLiteral("ide")) && c_ide > 0) {
|
||||
d->hdds[HDD_BUS_IDE].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_IDE].setActive(false);
|
||||
d->hdds[HDD_BUS_IDE].refresh();
|
||||
d->hdds[HDD_BUS_IDE].label->setToolTip(tr("Hard disk (%s)").replace("%s", "IDE"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_IDE].label.get());
|
||||
}
|
||||
@@ -482,6 +535,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)) && c_scsi > 0) {
|
||||
d->hdds[HDD_BUS_SCSI].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_SCSI].setActive(false);
|
||||
d->hdds[HDD_BUS_SCSI].refresh();
|
||||
d->hdds[HDD_BUS_SCSI].label->setToolTip(tr("Hard disk (%s)").replace("%s", "SCSI"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_SCSI].label.get());
|
||||
}
|
||||
@@ -489,6 +543,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
if (do_net) {
|
||||
d->net.label = std::make_unique<QLabel>();
|
||||
d->net.setActive(false);
|
||||
d->net.refresh();
|
||||
d->net.label->setToolTip(tr("Network"));
|
||||
sbar->addWidget(d->net.label.get());
|
||||
}
|
||||
@@ -505,72 +560,6 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
sbar->addWidget(d->text.get());
|
||||
}
|
||||
|
||||
void MachineStatus::setActivity(int tag, bool active) {
|
||||
int category = tag & 0xfffffff0;
|
||||
int item = tag & 0xf;
|
||||
switch (category) {
|
||||
case SB_CASSETTE:
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
d->fdd[item].setActive(active);
|
||||
break;
|
||||
case SB_CDROM:
|
||||
d->cdrom[item].setActive(active);
|
||||
break;
|
||||
case SB_ZIP:
|
||||
d->zip[item].setActive(active);
|
||||
break;
|
||||
case SB_MO:
|
||||
d->mo[item].setActive(active);
|
||||
break;
|
||||
case SB_HDD:
|
||||
d->hdds[item].setActive(active);
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
d->net.setActive(active);
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::setEmpty(int tag, bool empty) {
|
||||
int category = tag & 0xfffffff0;
|
||||
int item = tag & 0xf;
|
||||
switch (category) {
|
||||
case SB_CASSETTE:
|
||||
d->cassette.setEmpty(empty);
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
d->cartridge[item].setEmpty(empty);
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
d->fdd[item].setEmpty(empty);
|
||||
break;
|
||||
case SB_CDROM:
|
||||
d->cdrom[item].setEmpty(empty);
|
||||
break;
|
||||
case SB_ZIP:
|
||||
d->zip[item].setEmpty(empty);
|
||||
break;
|
||||
case SB_MO:
|
||||
d->mo[item].setEmpty(empty);
|
||||
break;
|
||||
case SB_HDD:
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::message(const QString &msg) {
|
||||
d->text->setText(msg);
|
||||
}
|
||||
|
@@ -70,14 +70,14 @@ public:
|
||||
QString getMessage();
|
||||
public slots:
|
||||
void refresh(QStatusBar* sbar);
|
||||
void setActivity(int tag, bool active);
|
||||
void setEmpty(int tag, bool active);
|
||||
void message(const QString& msg);
|
||||
void updateTip(int tag);
|
||||
void refreshIcons();
|
||||
|
||||
private:
|
||||
struct States;
|
||||
std::unique_ptr<States> d;
|
||||
QTimer *refreshTimer;
|
||||
};
|
||||
|
||||
#endif // QT_MACHINESTATUS_HPP
|
||||
|
@@ -268,8 +268,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
});
|
||||
connect(this, &MainWindow::updateStatusBarPanes, this, &MainWindow::refreshMediaMenu);
|
||||
connect(this, &MainWindow::updateStatusBarTip, status.get(), &MachineStatus::updateTip);
|
||||
connect(this, &MainWindow::updateStatusBarActivity, status.get(), &MachineStatus::setActivity);
|
||||
connect(this, &MainWindow::updateStatusBarEmpty, status.get(), &MachineStatus::setEmpty);
|
||||
connect(this, &MainWindow::statusBarMessage, status.get(), &MachineStatus::message, Qt::QueuedConnection);
|
||||
|
||||
ui->actionKeyboard_requires_capture->setChecked(kbd_req_capture);
|
||||
|
@@ -132,8 +132,6 @@ void ProgSettings::accept()
|
||||
main_window->refreshMediaMenu();
|
||||
main_window->status->message(msg);
|
||||
connect(main_window, &MainWindow::updateStatusBarTip, main_window->status.get(), &MachineStatus::updateTip);
|
||||
connect(main_window, &MainWindow::updateStatusBarActivity, main_window->status.get(), &MachineStatus::setActivity);
|
||||
connect(main_window, &MainWindow::updateStatusBarEmpty, main_window->status.get(), &MachineStatus::setEmpty);
|
||||
connect(main_window, &MainWindow::statusBarMessage, main_window->status.get(), &MachineStatus::message, Qt::QueuedConnection);
|
||||
mouse_sensitivity = mouseSensitivity;
|
||||
QDialog::accept();
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "qt_mainwindow.hpp"
|
||||
#include "qt_machinestatus.hpp"
|
||||
|
||||
MainWindow* main_window = nullptr;
|
||||
|
||||
@@ -36,6 +37,20 @@ extern "C" {
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/scsi.h>
|
||||
#include <86box/scsi_device.h>
|
||||
#include <86box/cartridge.h>
|
||||
#include <86box/cassette.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/mo.h>
|
||||
#include <86box/hdd.h>
|
||||
#include <86box/machine_status.h>
|
||||
|
||||
void
|
||||
plat_delay_ms(uint32_t count)
|
||||
@@ -174,16 +189,70 @@ void ui_sb_set_ready(int ready) {
|
||||
|
||||
void
|
||||
ui_sb_update_icon_state(int tag, int state) {
|
||||
if (main_window == nullptr) {
|
||||
return;
|
||||
int category = tag & 0xfffffff0;
|
||||
int item = tag & 0xf;
|
||||
switch (category) {
|
||||
case SB_CASSETTE:
|
||||
machine_status.cassette.empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
machine_status.cartridge[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
machine_status.fdd[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_CDROM:
|
||||
machine_status.cdrom[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_ZIP:
|
||||
machine_status.zip[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_MO:
|
||||
machine_status.mo[item].empty = state > 0 ? true : false;
|
||||
break;
|
||||
case SB_HDD:
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
}
|
||||
main_window->updateStatusBarEmpty(tag, state > 0 ? true : false);
|
||||
}
|
||||
|
||||
void
|
||||
ui_sb_update_icon(int tag, int active) {
|
||||
if (!update_icons) return;
|
||||
main_window->updateStatusBarActivity(tag, active > 0 ? true : false);
|
||||
int category = tag & 0xfffffff0;
|
||||
int item = tag & 0xf;
|
||||
switch (category) {
|
||||
case SB_CASSETTE:
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
machine_status.fdd[item].active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_CDROM:
|
||||
machine_status.cdrom[item].active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_ZIP:
|
||||
machine_status.zip[item].active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_MO:
|
||||
machine_status.mo[item].active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_HDD:
|
||||
machine_status.hdd[item].active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
machine_status.net.active = active > 0 ? true : false;
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user