qt: The sound icon's menu is now a submenu of the Tools menu

Replaces (and includes) the standalone Sound gain option
This commit is contained in:
Alexander Babikov
2025-04-11 05:26:01 +05:00
parent 1819539c97
commit 40ee98d6f3
29 changed files with 110 additions and 33 deletions

View File

@@ -270,7 +270,6 @@ MachineStatus::MachineStatus(QObject *parent)
, refreshTimer(new QTimer(this))
{
d = std::make_unique<MachineStatus::States>(this);
muteUnmuteAction = nullptr;
soundMenu = nullptr;
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
refreshTimer->start(75);
@@ -279,9 +278,9 @@ MachineStatus::MachineStatus(QObject *parent)
MachineStatus::~MachineStatus() = default;
void
MachineStatus::setSoundGainAction(QAction* action)
MachineStatus::setSoundMenu(QMenu* menu)
{
soundGainAction = action;
soundMenu = menu;
}
bool
@@ -519,28 +518,6 @@ 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.sound.disabled : d->pixmaps.sound.normal);
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());
@@ -710,8 +687,6 @@ MachineStatus::refresh(QStatusBar *sbar)
d->sound = std::make_unique<ClickableLabel>();
d->sound->setPixmap(sound_muted ? d->pixmaps.sound.disabled : d->pixmaps.sound.normal);
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()));
@@ -727,6 +702,13 @@ MachineStatus::refresh(QStatusBar *sbar)
refreshEmptyIcons();
}
void
MachineStatus::updateSoundIcon()
{
if (d->sound)
d->sound->setPixmap(sound_muted ? d->pixmaps.sound.disabled : d->pixmaps.sound.normal);
}
void
MachineStatus::message(const QString &msg)
{