mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-22 02:02:10 +02:00
TabIcon: Replace the favicon with audio icon when tab is playing audio
Also add tooltip to the audio icon
This commit is contained in:
parent
208e08a914
commit
fcc47ea914
|
@ -37,8 +37,8 @@ TabIcon::TabIcon(QWidget* parent)
|
||||||
m_animationPixmap = QIcon(QSL(":icons/other/loading.png")).pixmap(288, 16);
|
m_animationPixmap = QIcon(QSL(":icons/other/loading.png")).pixmap(288, 16);
|
||||||
m_framesCount = m_animationPixmap.width() / m_animationPixmap.height();
|
m_framesCount = m_animationPixmap.width() / m_animationPixmap.height();
|
||||||
|
|
||||||
m_audioPlayingPixmap = QIcon(QSL(":icons/other/audioplaying.png")).pixmap(15, 15);
|
m_audioPlayingPixmap = QIcon::fromTheme(QSL("audio-volume-high"), QIcon(QSL(":icons/other/audioplaying.png"))).pixmap(16);
|
||||||
m_audioMutedPixmap = QIcon(QSL(":icons/other/audiomuted.png")).pixmap(15, 15);
|
m_audioMutedPixmap = QIcon::fromTheme(QSL("audio-volume-muted"), QIcon(QSL(":icons/other/audiomuted.png"))).pixmap(16);
|
||||||
|
|
||||||
m_updateTimer = new QTimer(this);
|
m_updateTimer = new QTimer(this);
|
||||||
m_updateTimer->setInterval(ANIMATION_INTERVAL);
|
m_updateTimer->setInterval(ANIMATION_INTERVAL);
|
||||||
|
@ -100,10 +100,13 @@ void TabIcon::updateAnimationFrame()
|
||||||
|
|
||||||
void TabIcon::updateAudioIcon(bool recentlyAudible)
|
void TabIcon::updateAudioIcon(bool recentlyAudible)
|
||||||
{
|
{
|
||||||
if (m_tab->isMuted() || (!m_tab->isMuted() && recentlyAudible))
|
if (m_tab->isMuted() || (!m_tab->isMuted() && recentlyAudible)) {
|
||||||
|
setToolTip(m_tab->isMuted() ? tr("Unmute Tab") : tr("Mute Tab"));
|
||||||
m_audioIconDisplayed = true;
|
m_audioIconDisplayed = true;
|
||||||
else
|
} else {
|
||||||
|
setToolTip(QString());
|
||||||
m_audioIconDisplayed = false;
|
m_audioIconDisplayed = false;
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -124,25 +127,23 @@ void TabIcon::paintEvent(QPaintEvent* event)
|
||||||
r.setWidth(size);
|
r.setWidth(size);
|
||||||
r.setHeight(size);
|
r.setHeight(size);
|
||||||
|
|
||||||
|
if (m_audioIconDisplayed) {
|
||||||
|
if (m_tab->isMuted())
|
||||||
|
p.drawPixmap(r, m_audioMutedPixmap);
|
||||||
|
else
|
||||||
|
p.drawPixmap(r, m_audioPlayingPixmap);
|
||||||
|
} else {
|
||||||
if (m_animationRunning)
|
if (m_animationRunning)
|
||||||
p.drawPixmap(r, m_animationPixmap, QRect(m_currentFrame * pixmapSize, 0, pixmapSize, pixmapSize));
|
p.drawPixmap(r, m_animationPixmap, QRect(m_currentFrame * pixmapSize, 0, pixmapSize, pixmapSize));
|
||||||
else
|
else
|
||||||
p.drawPixmap(r, m_sitePixmap);
|
p.drawPixmap(r, m_sitePixmap);
|
||||||
|
|
||||||
if (m_audioIconDisplayed) {
|
|
||||||
if (m_tab->isMuted())
|
|
||||||
p.drawPixmap(QPointF(width() * 0.25, 0), m_audioMutedPixmap);
|
|
||||||
else
|
|
||||||
p.drawPixmap(QPointF(width() * 0.25, 0), m_audioPlayingPixmap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabIcon::mousePressEvent(QMouseEvent *event)
|
void TabIcon::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
qreal x = event->localPos().x();
|
// If audio icon is clicked - we don't propagate mouse press to the tab
|
||||||
qreal y = event->localPos().y();
|
if (m_audioIconDisplayed && event->button() == Qt::LeftButton)
|
||||||
// if audio icon is clicked - we don't propagate mouse press to the tab
|
|
||||||
if (m_audioIconDisplayed && x >= width() * 0.25 && y < height() * 0.75)
|
|
||||||
m_tab->toggleMuted();
|
m_tab->toggleMuted();
|
||||||
else
|
else
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user