1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 02:02:10 +02:00

HighDpi: Fix TabIcon

This commit is contained in:
David Rosca 2015-10-24 12:35:53 +02:00
parent c06fb1ee0a
commit 374af4277a
4 changed files with 13 additions and 12 deletions

View File

@ -60,6 +60,7 @@
<file>icons/sites/startpage.png</file> <file>icons/sites/startpage.png</file>
<file>icons/sites/w3.png</file> <file>icons/sites/w3.png</file>
<file>icons/other/loading.png</file> <file>icons/other/loading.png</file>
<file>icons/other/loading@2x.png</file>
<file>icons/other/empty-page.png</file> <file>icons/other/empty-page.png</file>
<file>icons/menu/privatebrowsing.png</file> <file>icons/menu/privatebrowsing.png</file>
<file>icons/menu/settings.png</file> <file>icons/menu/settings.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -32,8 +32,8 @@ TabIcon::TabIcon(QWidget* parent)
{ {
setObjectName(QSL("tab-icon")); setObjectName(QSL("tab-icon"));
m_animationImage = QImage(QSL(":icons/other/loading.png")); m_animationPixmap = QIcon(QSL(":icons/other/loading.png")).pixmap(288, 16);
m_framesCount = m_animationImage.width() / 16; m_framesCount = m_animationPixmap.width() / m_animationPixmap.height();
m_updateTimer = new QTimer(this); m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(ANIMATION_INTERVAL); m_updateTimer->setInterval(ANIMATION_INTERVAL);
@ -57,7 +57,7 @@ void TabIcon::setWebTab(WebTab* tab)
void TabIcon::setIcon(const QIcon &icon) void TabIcon::setIcon(const QIcon &icon)
{ {
m_siteImage = icon.pixmap(16).toImage(); m_sitePixmap = icon.pixmap(16);
update(); update();
} }
@ -80,7 +80,7 @@ void TabIcon::hideLoadingAnimation()
void TabIcon::showIcon() void TabIcon::showIcon()
{ {
m_siteImage = m_tab->icon().pixmap(16).toImage(); m_sitePixmap = m_tab->icon().pixmap(16);
update(); update();
} }
@ -101,10 +101,10 @@ void TabIcon::paintEvent(QPaintEvent* event)
QPainter p(this); QPainter p(this);
if (m_animationRunning) { const int width = 16 * m_animationPixmap.devicePixelRatio();
p.drawImage(0, 0, m_animationImage, m_currentFrame * 16, 0, 16, 16);
} if (m_animationRunning)
else { p.drawPixmap(rect(), m_animationPixmap, QRect(m_currentFrame * width, 0, width, width));
p.drawImage(0, 0, m_siteImage); else
} p.drawPixmap(rect(), m_sitePixmap);
} }

View File

@ -50,8 +50,8 @@ private:
WebTab* m_tab; WebTab* m_tab;
QTimer* m_updateTimer; QTimer* m_updateTimer;
QImage m_siteImage; QPixmap m_sitePixmap;
QImage m_animationImage; QPixmap m_animationPixmap;
int m_currentFrame; int m_currentFrame;
int m_framesCount; int m_framesCount;
bool m_animationRunning; bool m_animationRunning;