diff --git a/cockatrice/resources/lock.svg b/cockatrice/resources/lock.svg
index 51f4ff8f..b7ebf1a5 100644
--- a/cockatrice/resources/lock.svg
+++ b/cockatrice/resources/lock.svg
@@ -1,16 +1,55 @@
-
diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp
index 8f6e0e4f..0f3a1087 100644
--- a/cockatrice/src/gamesmodel.cpp
+++ b/cockatrice/src/gamesmodel.cpp
@@ -151,7 +151,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
return result.join(", ");
}
case Qt::DecorationRole:{
- return g.with_password() ? QIcon(":/resources/lock.svg") : QVariant();
+ return g.with_password() ? QIcon(LockPixmapGenerator::generatePixmap(13)) : QVariant();
case Qt::TextAlignmentRole:
return Qt::AlignLeft;
default:
diff --git a/cockatrice/src/pixmapgenerator.cpp b/cockatrice/src/pixmapgenerator.cpp
index 4241a8f4..0ff25f57 100644
--- a/cockatrice/src/pixmapgenerator.cpp
+++ b/cockatrice/src/pixmapgenerator.cpp
@@ -166,3 +166,24 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
}
QMap UserLevelPixmapGenerator::pmCache;
+
+
+QPixmap LockPixmapGenerator::generatePixmap(int height)
+{
+
+ int key = height;
+ if (pmCache.contains(key))
+ return pmCache.value(key);
+
+ QSvgRenderer svg(QString(":/resources/lock.svg"));
+ int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
+ QPixmap pixmap(width, height);
+ pixmap.fill(Qt::transparent);
+ QPainter painter(&pixmap);
+ svg.render(&painter, QRectF(0, 0, width, height));
+
+ pmCache.insert(key, pixmap);
+ return pixmap;
+}
+
+QMap LockPixmapGenerator::pmCache;
diff --git a/cockatrice/src/pixmapgenerator.h b/cockatrice/src/pixmapgenerator.h
index 9caeece9..a4e8dfc0 100644
--- a/cockatrice/src/pixmapgenerator.h
+++ b/cockatrice/src/pixmapgenerator.h
@@ -54,4 +54,12 @@ public:
static void clear() { pmCache.clear(); }
};
+class LockPixmapGenerator {
+private:
+ static QMap pmCache;
+public:
+ static QPixmap generatePixmap(int height);
+ static void clear() { pmCache.clear(); }
+};
+
#endif