diff --git a/src/lib/data/icons.qrc b/src/lib/data/icons.qrc index 37b928527..0333f3404 100644 --- a/src/lib/data/icons.qrc +++ b/src/lib/data/icons.qrc @@ -60,6 +60,7 @@ icons/sites/startpage.png icons/sites/w3.png icons/other/loading.png + icons/other/loading@2x.png icons/other/empty-page.png icons/menu/privatebrowsing.png icons/menu/settings.png diff --git a/src/lib/data/icons/other/loading@2x.png b/src/lib/data/icons/other/loading@2x.png new file mode 100644 index 000000000..7fa5a3434 Binary files /dev/null and b/src/lib/data/icons/other/loading@2x.png differ diff --git a/src/lib/tabwidget/tabicon.cpp b/src/lib/tabwidget/tabicon.cpp index 9345c8bfd..0eeb44856 100644 --- a/src/lib/tabwidget/tabicon.cpp +++ b/src/lib/tabwidget/tabicon.cpp @@ -32,8 +32,8 @@ TabIcon::TabIcon(QWidget* parent) { setObjectName(QSL("tab-icon")); - m_animationImage = QImage(QSL(":icons/other/loading.png")); - m_framesCount = m_animationImage.width() / 16; + m_animationPixmap = QIcon(QSL(":icons/other/loading.png")).pixmap(288, 16); + m_framesCount = m_animationPixmap.width() / m_animationPixmap.height(); m_updateTimer = new QTimer(this); m_updateTimer->setInterval(ANIMATION_INTERVAL); @@ -57,7 +57,7 @@ void TabIcon::setWebTab(WebTab* tab) void TabIcon::setIcon(const QIcon &icon) { - m_siteImage = icon.pixmap(16).toImage(); + m_sitePixmap = icon.pixmap(16); update(); } @@ -80,7 +80,7 @@ void TabIcon::hideLoadingAnimation() void TabIcon::showIcon() { - m_siteImage = m_tab->icon().pixmap(16).toImage(); + m_sitePixmap = m_tab->icon().pixmap(16); update(); } @@ -101,10 +101,10 @@ void TabIcon::paintEvent(QPaintEvent* event) QPainter p(this); - if (m_animationRunning) { - p.drawImage(0, 0, m_animationImage, m_currentFrame * 16, 0, 16, 16); - } - else { - p.drawImage(0, 0, m_siteImage); - } + const int width = 16 * m_animationPixmap.devicePixelRatio(); + + if (m_animationRunning) + p.drawPixmap(rect(), m_animationPixmap, QRect(m_currentFrame * width, 0, width, width)); + else + p.drawPixmap(rect(), m_sitePixmap); } diff --git a/src/lib/tabwidget/tabicon.h b/src/lib/tabwidget/tabicon.h index b3eb8c745..8340c4a9b 100644 --- a/src/lib/tabwidget/tabicon.h +++ b/src/lib/tabwidget/tabicon.h @@ -50,8 +50,8 @@ private: WebTab* m_tab; QTimer* m_updateTimer; - QImage m_siteImage; - QImage m_animationImage; + QPixmap m_sitePixmap; + QPixmap m_animationPixmap; int m_currentFrame; int m_framesCount; bool m_animationRunning;