diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-20 10:19:23 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-20 10:19:23 +0200 |
commit | 55d5e04ad2d5999d6d646ebda48ed77967e5521a (patch) | |
tree | 68c3db133b18a759be25628d99ba8e3c0d55bd3b /src | |
parent | WebView: close context menu when buttons are pressed (diff) | |
download | smolbote-55d5e04ad2d5999d6d646ebda48ed77967e5521a.tar.xz |
Add mute button to WebView context menu
Diffstat (limited to 'src')
-rw-r--r-- | src/webengine/webview.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 25f7b70..d7281e9 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -145,8 +145,6 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) }); buttonsLayout->addWidget(forwardButton); - buttonsLayout->addStretch(); - auto *refreshButton = new QToolButton(this); refreshButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload)); connect(refreshButton, &QToolButton::clicked, this, [this, menu]() { @@ -155,6 +153,21 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) }); buttonsLayout->addWidget(refreshButton); + buttonsLayout->addStretch(); + + auto *muteButton = new QToolButton(this); + muteButton->setCheckable(true); + muteButton->setChecked(this->page()->isAudioMuted()); + QIcon muteIcon; + muteIcon.addPixmap(style()->standardPixmap(QStyle::SP_MediaVolume), QIcon::Normal, QIcon::Off); + muteIcon.addPixmap(style()->standardPixmap(QStyle::SP_MediaVolumeMuted), QIcon::Normal, QIcon::On); + muteButton->setIcon(muteIcon); + connect(muteButton, &QToolButton::clicked, this, [this, menu](bool checked) { + this->page()->setAudioMuted(checked); + menu->close(); + }); + buttonsLayout->addWidget(muteButton); + buttons->setLayout(buttonsLayout); navButtons->setDefaultWidget(buttons); |