Add global mute option
This commit is contained in:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user