Add global mute option
This commit is contained in:
@@ -213,6 +213,7 @@ int do_auto_pause = 0; /* (C) Auto-pa
|
||||
int hook_enabled = 1; /* (C) Keyboard hook is enabled */
|
||||
int test_mode = 0; /* (C) Test mode */
|
||||
char uuid[MAX_UUID_LEN] = { '\0' }; /* (C) UUID or machine identifier */
|
||||
int sound_muted = 0; /* (C) Is sound muted? */
|
||||
|
||||
int other_ide_present = 0; /* IDE controllers from non-IDE cards are
|
||||
present */
|
||||
|
||||
@@ -168,6 +168,7 @@ load_general(void)
|
||||
kbd_req_capture = ini_section_get_int(cat, "kbd_req_capture", 0);
|
||||
hide_status_bar = ini_section_get_int(cat, "hide_status_bar", 0);
|
||||
hide_tool_bar = ini_section_get_int(cat, "hide_tool_bar", 0);
|
||||
sound_muted = ini_section_get_int(cat, "sound_muted", 0);
|
||||
|
||||
confirm_reset = ini_section_get_int(cat, "confirm_reset", 1);
|
||||
confirm_exit = ini_section_get_int(cat, "confirm_exit", 1);
|
||||
@@ -1846,6 +1847,10 @@ save_general(void)
|
||||
|
||||
const char *va_name;
|
||||
|
||||
ini_section_set_int(cat, "sound_muted", sound_muted);
|
||||
if (sound_muted == 0)
|
||||
ini_section_delete_var(cat, "sound_muted");
|
||||
|
||||
ini_section_set_int(cat, "vid_resize", vid_resize);
|
||||
if (vid_resize == 0)
|
||||
ini_section_delete_var(cat, "vid_resize");
|
||||
|
||||
@@ -158,6 +158,7 @@ extern int other_scsi_present; /* SCSI controllers from non-SCSI ca
|
||||
extern int hard_reset_pending;
|
||||
extern int fixed_size_x;
|
||||
extern int fixed_size_y;
|
||||
extern int sound_muted; /* (C) Is sound muted? */
|
||||
extern int do_auto_pause; /* (C) Auto-pause the emulator on focus loss */
|
||||
extern int auto_paused;
|
||||
extern double mouse_sensitivity; /* (C) Mouse sensitivity scale */
|
||||
|
||||
BIN
src/qt/icons/sound_mute.ico
Normal file
BIN
src/qt/icons/sound_mute.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
@@ -39,6 +39,7 @@ extern "C" {
|
||||
#include <86box/network.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/machine_status.h>
|
||||
#include <86box/config.h>
|
||||
};
|
||||
|
||||
#include <QIcon>
|
||||
@@ -89,7 +90,7 @@ struct Pixmaps {
|
||||
PixmapSetEmptyActive mo;
|
||||
PixmapSetActive hd;
|
||||
PixmapSetEmptyActive net;
|
||||
QPixmap sound;
|
||||
QPixmap sound, soundMuted;
|
||||
};
|
||||
|
||||
struct StateActive {
|
||||
@@ -215,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;
|
||||
@@ -256,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()
|
||||
{
|
||||
@@ -494,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());
|
||||
@@ -662,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>();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -178,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; }");
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<file>qt/icons/other_removable_devices.ico</file>
|
||||
<file>qt/icons/ports.ico</file>
|
||||
<file>qt/icons/sound.ico</file>
|
||||
<file>qt/icons/sound_mute.ico</file>
|
||||
<file>qt/icons/storage_controllers.ico</file>
|
||||
<file>qt/icons/zip.ico</file>
|
||||
<file>qt/icons/zip_active.ico</file>
|
||||
|
||||
@@ -278,7 +278,7 @@ givealbuffer_common(const void *buf, const uint8_t src, const int size, const in
|
||||
|
||||
alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed);
|
||||
if (processed >= 1) {
|
||||
const double gain = pow(10.0, (double) sound_gain / 20.0);
|
||||
const double gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0);
|
||||
alListenerf(AL_GAIN, (float) gain);
|
||||
|
||||
alSourceUnqueueBuffers(source[src], 1, &buffer);
|
||||
|
||||
@@ -245,7 +245,7 @@ givealbuffer_common(const void *buf, IXAudio2SourceVoice *sourcevoice, const siz
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
(void) IXAudio2MasteringVoice_SetVolume(mastervoice, pow(10.0, (double) sound_gain / 20.0),
|
||||
(void) IXAudio2MasteringVoice_SetVolume(mastervoice, sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0),
|
||||
XAUDIO2_COMMIT_NOW);
|
||||
XAUDIO2_BUFFER buffer = { 0 };
|
||||
buffer.Flags = 0;
|
||||
|
||||
Reference in New Issue
Block a user