Merge remote-tracking branch 'origin/master' into cdrom_changes

This commit is contained in:
OBattler
2025-03-06 22:56:10 +01:00
52 changed files with 219 additions and 92 deletions

BIN
src/qt/icons/sound_mute.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -19,9 +19,6 @@
#include "qt_machinestatus.hpp"
extern "C" {
#define EMU_CPU_H // superhack - don't want timer.h to include cpu.h here, and some combo is preventing a compile
extern uint64_t tsc;
#include <86box/hdd.h>
#include <86box/timer.h>
#include <86box/86box.h>
@@ -42,6 +39,7 @@ extern uint64_t tsc;
#include <86box/network.h>
#include <86box/ui.h>
#include <86box/machine_status.h>
#include <86box/config.h>
};
#include <QIcon>
@@ -92,7 +90,7 @@ struct Pixmaps {
PixmapSetEmptyActive mo;
PixmapSetActive hd;
PixmapSetEmptyActive net;
QPixmap sound;
QPixmap sound, soundMuted;
};
struct StateActive {
@@ -218,6 +216,7 @@ struct MachineStatus::States {
pixmaps.hd.load("/hard_disk%1.ico");
pixmaps.net.load("/network%1.ico");
pixmaps.sound = ProgSettings::loadIcon("/sound.ico").pixmap(pixmap_size);
pixmaps.soundMuted = ProgSettings::loadIcon("/sound_mute.ico").pixmap(pixmap_size);
cartridge[0].pixmaps = &pixmaps.cartridge;
cartridge[1].pixmaps = &pixmaps.cartridge;
@@ -259,12 +258,19 @@ MachineStatus::MachineStatus(QObject *parent)
, refreshTimer(new QTimer(this))
{
d = std::make_unique<MachineStatus::States>(this);
muteUnmuteAction = nullptr;
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
refreshTimer->start(75);
}
MachineStatus::~MachineStatus() = default;
void
MachineStatus::setSoundGainAction(QAction* action)
{
soundGainAction = action;
}
bool
MachineStatus::hasCassette()
{
@@ -497,6 +503,28 @@ MachineStatus::refresh(QStatusBar *sbar)
}
sbar->removeWidget(d->sound.get());
if (!muteUnmuteAction) {
muteUnmuteAction = new QAction;
connect(muteUnmuteAction, &QAction::triggered, this, [this]() {
sound_muted ^= 1;
config_save();
if (d->sound)
d->sound->setPixmap(sound_muted ? d->pixmaps.soundMuted : d->pixmaps.sound);
muteUnmuteAction->setText(sound_muted ? tr("&Unmute") : tr("&Mute"));
});
}
if (!soundMenu) {
soundMenu = new QMenu((QWidget*)parent());
soundMenu->addAction(muteUnmuteAction);
soundMenu->addSeparator();
soundMenu->addAction(soundGainAction);
muteUnmuteAction->setParent(soundMenu);
}
if (cassette_enable) {
d->cassette.label = std::make_unique<ClickableLabel>();
d->cassette.setEmpty(QString(cassette_fname).isEmpty());
@@ -665,12 +693,14 @@ MachineStatus::refresh(QStatusBar *sbar)
}
d->sound = std::make_unique<ClickableLabel>();
d->sound->setPixmap(d->pixmaps.sound);
connect(d->sound.get(), &ClickableLabel::doubleClicked, d->sound.get(), [](QPoint pos) {
SoundGain gain(main_window);
gain.exec();
d->sound->setPixmap(sound_muted ? d->pixmaps.soundMuted : d->pixmaps.sound);
if (muteUnmuteAction)
muteUnmuteAction->setText(sound_muted ? tr("&Unmute") : tr("&Mute"));
connect(d->sound.get(), &ClickableLabel::clicked, this, [this](QPoint pos) {
this->soundMenu->popup(pos - QPoint(0, this->soundMenu->sizeHint().height()));
});
d->sound->setToolTip(tr("Sound"));
sbar->addWidget(d->sound.get());
d->text = std::make_unique<QLabel>();

View File

@@ -1,6 +1,8 @@
#ifndef QT_MACHINESTATUS_HPP
#define QT_MACHINESTATUS_HPP
#include <QAction>
#include <QMenu>
#include <QWidget>
#include <QLabel>
#include <QMouseEvent>
@@ -71,6 +73,7 @@ public:
QString getMessage();
void clearActivity();
void setSoundGainAction(QAction* action);
public slots:
void refresh(QStatusBar *sbar);
void message(const QString &msg);
@@ -82,6 +85,9 @@ private:
struct States;
std::unique_ptr<States> d;
QTimer *refreshTimer;
QAction *soundGainAction;
QAction *muteUnmuteAction;
QMenu *soundMenu;
};
#endif // QT_MACHINESTATUS_HPP

View File

@@ -86,6 +86,7 @@ extern MainWindow *main_window;
extern "C" {
#include <86box/keyboard.h>
#include "cpu.h"
#include <86box/timer.h>
#include <86box/nvr.h>
extern int qt_nvr_save(void);

View File

@@ -48,11 +48,10 @@ extern "C" {
#include <86box/machine.h>
#include <86box/vid_ega.h>
#include <86box/version.h>
#if 0
#include <86box/acpi.h> /* Requires timer.h include, which conflicts with Qt headers */
#endif
extern atomic_int acpi_pwrbut_pressed;
extern int acpi_enabled;
#include <86box/timer.h>
#include <86box/apm.h>
#include <86box/nvr.h>
#include <86box/acpi.h>
#ifdef USE_VNC
# include <86box/vnc.h>
@@ -179,6 +178,7 @@ MainWindow::MainWindow(QWidget *parent)
extern MainWindow *main_window;
main_window = this;
ui->setupUi(this);
status->setSoundGainAction(ui->actionSound_gain);
ui->stackedWidget->setMouseTracking(true);
statusBar()->setVisible(!hide_status_bar);
statusBar()->setStyleSheet("QStatusBar::item {border: None; } QStatusBar QLabel { margin-right: 2px; margin-bottom: 1px; }");

View File

@@ -220,9 +220,9 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
int secondaryFlags = video_card_get_flags(c);
if (video_card_available(c)
&& device_is_valid(video_dev, machineId)
&& !((secondaryFlags == primaryFlags) && (secondaryFlags != VIDEO_FLAG_TYPE_SPECIAL))
&& !(((primaryFlags == VIDEO_FLAG_TYPE_8514) || (primaryFlags == VIDEO_FLAG_TYPE_XGA)) && (secondaryFlags != VIDEO_FLAG_TYPE_MDA) && (secondaryFlags != VIDEO_FLAG_TYPE_SPECIAL))
&& !((primaryFlags != VIDEO_FLAG_TYPE_MDA) && (primaryFlags != VIDEO_FLAG_TYPE_SPECIAL) && ((secondaryFlags == VIDEO_FLAG_TYPE_8514) || (secondaryFlags == VIDEO_FLAG_TYPE_XGA)))) {
&& !((secondaryFlags == primaryFlags) && (secondaryFlags != VIDEO_FLAG_TYPE_SECONDARY))
&& !(((primaryFlags == VIDEO_FLAG_TYPE_8514) || (primaryFlags == VIDEO_FLAG_TYPE_XGA)) && (secondaryFlags != VIDEO_FLAG_TYPE_MDA) && (secondaryFlags != VIDEO_FLAG_TYPE_SECONDARY))
&& !((primaryFlags != VIDEO_FLAG_TYPE_MDA) && (primaryFlags != VIDEO_FLAG_TYPE_SECONDARY) && ((secondaryFlags == VIDEO_FLAG_TYPE_8514) || (secondaryFlags == VIDEO_FLAG_TYPE_XGA)))) {
ui->comboBoxVideoSecondary->addItem(name, c);
if (c == curVideoCard_2)
ui->comboBoxVideoSecondary->setCurrentIndex(ui->comboBoxVideoSecondary->count() - 1);

View File

@@ -32,13 +32,9 @@ extern "C" {
#include <86box/config.h>
#include <86box/device.h>
#include <86box/machine.h>
#include <86box/nvr.h>
}
// from nvr.h, which we can't import into CPP code
#define TIME_SYNC_DISABLED 0
#define TIME_SYNC_ENABLED 1
#define TIME_SYNC_UTC 2
#include "qt_deviceconfig.hpp"
#include "qt_models_common.hpp"