Skip to content

Add mute option #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/icons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ qt_add_resources(
green_flag.svg
stop.svg
turbo.svg
mute.svg
)
9 changes: 9 additions & 0 deletions res/icons/mute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/app/appmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ AppMenuBar::AppMenuBar(QObject *parent) :
m_editMenu->addItem(m_fps60ModeItem);
connect(m_fps60ModeItem, &MenuItemModel::checkedChanged, this, &AppMenuBar::fps60ModeChanged);

// Edit -> Mute
m_muteItem = new MenuItemModel(m_editMenu);
m_muteItem->setText(tr("Mute"));
m_muteItem->setCheckable(true);
m_muteItem->setChecked(false);
m_editMenu->addItem(m_muteItem);
connect(m_muteItem, &MenuItemModel::checkedChanged, this, &AppMenuBar::muteChanged);

// Edit -> Project settings
m_projectSettingsItem = new MenuItemModel(m_editMenu);
m_projectSettingsItem->setText(tr("Project settings..."));
Expand Down Expand Up @@ -133,3 +141,17 @@ void AppMenuBar::setFps60Mode(bool newFps60Mode)
m_fps60ModeItem->setChecked(newFps60Mode);
emit fps60ModeChanged();
}

bool AppMenuBar::mute() const
{
return m_muteItem->checked();
}

void AppMenuBar::setMute(bool newMute)
{
if (m_muteItem->checked() == newMute)
return;

m_muteItem->setChecked(newMute);
emit muteChanged();
}
6 changes: 6 additions & 0 deletions src/app/appmenubar.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AppMenuBar : public QObject
Q_PROPERTY(uicomponents::MenuBarModel *model READ model NOTIFY modelChanged)
Q_PROPERTY(bool turboMode READ turboMode WRITE setTurboMode NOTIFY turboModeChanged)
Q_PROPERTY(bool fps60Mode READ fps60Mode WRITE setFps60Mode NOTIFY fps60ModeChanged)
Q_PROPERTY(bool mute READ mute WRITE setMute NOTIFY muteChanged)

public:
explicit AppMenuBar(QObject *parent = nullptr);
Expand All @@ -41,11 +42,15 @@ class AppMenuBar : public QObject
bool fps60Mode() const;
void setFps60Mode(bool newFps60Mode);

bool mute() const;
void setMute(bool newMute);

signals:
void modelChanged();
void fileOpened(const QString &fileName);
void turboModeChanged();
void fps60ModeChanged();
void muteChanged();
void projectSettingsTriggered();
void aboutAppTriggered();

Expand All @@ -65,6 +70,7 @@ class AppMenuBar : public QObject
uicomponents::MenuModel *m_editMenu = nullptr;
uicomponents::MenuItemModel *m_turboModeItem = nullptr;
uicomponents::MenuItemModel *m_fps60ModeItem = nullptr;
uicomponents::MenuItemModel *m_muteItem = nullptr;
uicomponents::MenuItemModel *m_projectSettingsItem = nullptr;

uicomponents::MenuModel *m_helpMenu = nullptr;
Expand Down
12 changes: 12 additions & 0 deletions src/app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ ApplicationWindow {
AppMenuBar.fps60Mode = !AppMenuBar.fps60Mode
break;

case Qt.ControlModifier:
AppMenuBar.mute = !AppMenuBar.mute
break;

default:
player.stop()
player.start()
Expand All @@ -96,6 +100,13 @@ ApplicationWindow {
}
}

IconLabel {
icon.name: "mute"
icon.color: "transparent"
text: ""
visible: AppMenuBar.mute
}

IconLabel {
icon.name: "turbo"
icon.color: "transparent"
Expand Down Expand Up @@ -141,6 +152,7 @@ ApplicationWindow {
activeFocusOnTab: true
focus: true
turboMode: AppMenuBar.turboMode
mute: AppMenuBar.mute
}
}
}
Loading