mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
TabModel: Add AudioPlayingRole and AudioMutedRole
This commit is contained in:
parent
47be65f903
commit
188082b690
|
@ -95,6 +95,12 @@ QVariant TabModel::data(const QModelIndex &index, int role) const
|
|||
case LoadingRole:
|
||||
return t->isLoading();
|
||||
|
||||
case AudioPlayingRole:
|
||||
return t->isPlaying();
|
||||
|
||||
case AudioMutedRole:
|
||||
return t->isMuted();
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -204,6 +210,8 @@ void TabModel::tabInserted(int index)
|
|||
connect(tab, &WebTab::restoredChanged, this, std::bind(emitDataChanged, tab, RestoredRole));
|
||||
connect(tab, &WebTab::currentTabChanged, this, std::bind(emitDataChanged, tab, CurrentTabRole));
|
||||
connect(tab, &WebTab::loadingChanged, this, std::bind(emitDataChanged, tab, LoadingRole));
|
||||
connect(tab, &WebTab::playingChanged, this, std::bind(emitDataChanged, tab, AudioPlayingRole));
|
||||
connect(tab, &WebTab::mutedChanged, this, std::bind(emitDataChanged, tab, AudioMutedRole));
|
||||
}
|
||||
|
||||
void TabModel::tabRemoved(int index)
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
RestoredRole = Qt::UserRole + 5,
|
||||
CurrentTabRole = Qt::UserRole + 6,
|
||||
LoadingRole = Qt::UserRole + 7,
|
||||
AudioPlayingRole = Qt::UserRole + 8,
|
||||
AudioMutedRole = Qt::UserRole + 9
|
||||
};
|
||||
|
||||
explicit TabModel(BrowserWindow *window, QObject *parent = nullptr);
|
||||
|
|
|
@ -178,6 +178,13 @@ WebTab::WebTab(QWidget *parent)
|
|||
connect(m_webView, &TabbedWebView::loadStarted, this, std::bind(&WebTab::loadingChanged, this, true));
|
||||
connect(m_webView, &TabbedWebView::loadFinished, this, std::bind(&WebTab::loadingChanged, this, false));
|
||||
|
||||
auto pageChanged = [this](WebPage *page) {
|
||||
connect(page, &WebPage::audioMutedChanged, this, &WebTab::playingChanged);
|
||||
connect(page, &WebPage::recentlyAudibleChanged, this, &WebTab::mutedChanged);
|
||||
};
|
||||
pageChanged(m_webView->page());
|
||||
connect(m_webView, &TabbedWebView::pageChanged, this, pageChanged);
|
||||
|
||||
// Workaround QTabBar not immediately noticing resizing of tab buttons
|
||||
connect(m_tabIcon, &TabIcon::resized, this, [this]() {
|
||||
if (m_tabBar) {
|
||||
|
@ -397,6 +404,11 @@ bool WebTab::isMuted() const
|
|||
return m_webView->page()->isAudioMuted();
|
||||
}
|
||||
|
||||
bool WebTab::isPlaying() const
|
||||
{
|
||||
return m_webView->page()->recentlyAudible();
|
||||
}
|
||||
|
||||
void WebTab::setMuted(bool muted)
|
||||
{
|
||||
m_webView->page()->setAudioMuted(muted);
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
void togglePinned();
|
||||
|
||||
bool isMuted() const;
|
||||
bool isPlaying() const;
|
||||
void setMuted(bool muted);
|
||||
void toggleMuted();
|
||||
|
||||
|
@ -125,6 +126,8 @@ signals:
|
|||
void restoredChanged(bool restored);
|
||||
void currentTabChanged(bool current);
|
||||
void loadingChanged(bool loading);
|
||||
void mutedChanged(bool muted);
|
||||
void playingChanged(bool playing);
|
||||
void parentTabChanged(WebTab *tab);
|
||||
void childTabAdded(WebTab *tab, int index);
|
||||
void childTabRemoved(WebTab *tab, int index);
|
||||
|
|
Loading…
Reference in New Issue
Block a user