summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webengine/api/qquickwebengineview.cpp13
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--tests/auto/quick/qmltests/data/tst_audioMuted.qml63
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro1
4 files changed, 75 insertions, 3 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index c56014a57..804d81e54 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -129,6 +129,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio())
, m_webChannel(0)
, m_webChannelWorld(0)
+ , m_defaultAudioMuted(false)
, m_isBeingAdopted(false)
, m_backgroundColor(Qt::white)
, m_zoomFactor(1.0)
@@ -906,6 +907,9 @@ void QQuickWebEngineViewPrivate::initializationFinished()
adapter->setWebChannel(m_webChannel, m_webChannelWorld);
#endif
+ if (m_defaultAudioMuted != adapter->isAudioMuted())
+ adapter->setAudioMuted(m_defaultAudioMuted);
+
if (devToolsView && devToolsView->d_ptr->adapter)
adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter);
@@ -1426,15 +1430,18 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color)
bool QQuickWebEngineView::isAudioMuted() const
{
const Q_D(QQuickWebEngineView);
- return d->adapter->isAudioMuted();
+ if (d->adapter->isInitialized())
+ return d->adapter->isAudioMuted();
+ return d->m_defaultAudioMuted;
}
void QQuickWebEngineView::setAudioMuted(bool muted)
{
Q_D(QQuickWebEngineView);
- bool wasAudioMuted = d->adapter->isAudioMuted();
+ bool wasAudioMuted = isAudioMuted();
+ d->m_defaultAudioMuted = muted;
d->adapter->setAudioMuted(muted);
- if (wasAudioMuted != d->adapter->isAudioMuted())
+ if (wasAudioMuted != isAudioMuted())
Q_EMIT audioMutedChanged(muted);
}
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index e696f6a0c..12a991ffa 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -217,6 +217,7 @@ public:
QPointer<QQuickWebEngineView> inspectedView;
QPointer<QQuickWebEngineView> devToolsView;
uint m_webChannelWorld;
+ bool m_defaultAudioMuted;
bool m_isBeingAdopted;
mutable QQuickWebEngineAction *actions[QQuickWebEngineView::WebActionCount];
QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *widget = nullptr;
diff --git a/tests/auto/quick/qmltests/data/tst_audioMuted.qml b/tests/auto/quick/qmltests/data/tst_audioMuted.qml
new file mode 100644
index 000000000..c626d07a0
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_audioMuted.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.4
+
+TestWebEngineView {
+ id: view
+ width: 400
+ height: 400
+
+ SignalSpy {
+ id: spy
+ target: view
+ signalName: "audioMutedChanged"
+ }
+
+ TestCase {
+ id: test
+ name: "WebEngineViewAudioMuted"
+
+ function test_audioMuted() {
+ compare(view.audioMuted, false);
+ view.audioMuted = true;
+ view.url = "about:blank";
+ verify(view.waitForLoadSucceeded());
+ compare(view.audioMuted, true);
+ compare(spy.count, 1);
+ compare(spy.signalArguments[0][0], true);
+ view.audioMuted = false;
+ compare(view.audioMuted, false);
+ compare(spy.count, 2);
+ compare(spy.signalArguments[1][0], false);
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 0b3ff7c7e..5c57f7ad9 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -31,6 +31,7 @@ OTHER_FILES += \
$$PWD/data/titleupdate.js \
$$PWD/data/tst_action.qml \
$$PWD/data/tst_activeFocusOnPress.qml \
+ $$PWD/data/tst_audioMuted.qml \
$$PWD/data/tst_contextMenu.qml \
$$PWD/data/tst_desktopBehaviorLoadHtml.qml \
$$PWD/data/tst_download.qml \