Commit ce5f0a39 authored by Jens Bache-Wiig's avatar Jens Bache-Wiig
Browse files

Cache the welcomemode background

I now cache the scaled welcomemode background so it feels more
responsive when toggeling back and forth between modes.

Reviewed-by: joao
parent 77bd9e29
......@@ -43,6 +43,7 @@
#include <QtGui/QScrollArea>
#include <QtGui/QDesktopServices>
#include <QtGui/QToolButton>
#include <QtGui/QPainter>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
......@@ -56,6 +57,24 @@ static const char currentPageSettingsKeyC[] = "General/WelcomeTab";
namespace Welcome {
// Helper class introduced to cache the scaled background image
// so we avoid re-scaling for every repaint.
class ImageWidget : public QWidget
ImageWidget(const QPixmap &bg, QWidget *parent) : QWidget(parent), m_bg(bg) {}
void paintEvent(QPaintEvent *e) {
QPainter painter(this);
if (m_stretch.size() != size())
m_stretch = m_bg.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
painter.drawPixmap(rect(), m_stretch);
QPixmap m_bg;
QPixmap m_stretch;
struct WelcomeModePrivate
typedef QMap<QToolButton*, QWidget*> ToolButtonWidgetMap;
......@@ -64,7 +83,7 @@ struct WelcomeModePrivate
QScrollArea *m_scrollArea;
QWidget *m_widget;
QWidget *m_welcomePage;
ImageWidget *m_welcomePage;
ToolButtonWidgetMap buttonMap;
QHBoxLayout * buttonLayout;
Ui::WelcomeMode ui;
......@@ -79,7 +98,7 @@ WelcomeMode::WelcomeMode() :
l->addWidget(new Utils::StyledBar(m_d->m_widget));
m_d->m_welcomePage = new QWidget(m_d->m_widget);
m_d->m_welcomePage = new ImageWidget(QPixmap(":/welcome/images/welcomebg.png"), m_d->m_widget);
......@@ -75,12 +75,6 @@ QToolButton:pressed, QPushButton:pressed{
<widget class="QWidget" name="gradientWidget" native="true">
<property name="styleSheet">
<string notr="true">#gradientWidget {
border-image: url(:/welcome/images/welcomebg.png) 0;
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment