1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

TabIcon: Draw audio icon in topright corner for pinned tabs

This commit is contained in:
David Rosca 2017-01-02 13:31:22 +01:00
parent 9bceb3f8b3
commit 20abaaf9f9
2 changed files with 19 additions and 7 deletions

View File

@ -175,7 +175,8 @@ void TabIcon::paintEvent(QPaintEvent* event)
if (m_animationRunning) {
p.drawPixmap(r, s_data->animationPixmap, QRect(m_currentFrame * pixmapSize, 0, pixmapSize, pixmapSize));
} else if (m_audioIconDisplayed && (!m_tab || !m_tab->isPinned())) {
} else if (m_audioIconDisplayed && !m_tab->isPinned()) {
m_audioIconRect = r;
p.drawPixmap(r, m_tab->isMuted() ? s_data->audioMutedPixmap : s_data->audioPlayingPixmap);
} else if (!m_sitePixmap.isNull()) {
p.drawPixmap(r, m_sitePixmap);
@ -184,7 +185,15 @@ void TabIcon::paintEvent(QPaintEvent* event)
}
// Draw audio icon on top of site icon for pinned tabs
if (!m_animationRunning && m_audioIconDisplayed && m_tab && m_tab->isPinned()) {
if (!m_animationRunning && m_audioIconDisplayed && m_tab->isPinned()) {
const int s = size - 4;
const QRect r(width() - s, 0, s, s);
m_audioIconRect = r;
QColor c = palette().color(QPalette::Window);
c.setAlpha(180);
p.setPen(c);
p.setBrush(c);
p.drawEllipse(r);
p.drawPixmap(r, m_tab->isMuted() ? s_data->audioMutedPixmap : s_data->audioPlayingPixmap);
}
}
@ -192,8 +201,10 @@ void TabIcon::paintEvent(QPaintEvent* event)
void TabIcon::mousePressEvent(QMouseEvent *event)
{
// If audio icon is clicked - we don't propagate mouse press to the tab
if (m_audioIconDisplayed && event->button() == Qt::LeftButton)
if (m_audioIconDisplayed && event->button() == Qt::LeftButton && m_audioIconRect.contains(event->pos())) {
m_tab->toggleMuted();
else
return;
}
QWidget::mousePressEvent(event);
}

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2014-2016 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,6 +62,7 @@ private:
int m_currentFrame;
bool m_animationRunning;
bool m_audioIconDisplayed;
QRect m_audioIconRect;
struct Data {
int framesCount;