Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
06accd51
Commit
06accd51
authored
Apr 11, 2015
by
Matt Lowe
Browse files
Fixed main chat room lag
parent
19e86c61
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
cockatrice/resources/lock.svg
View file @
06accd51
This diff is collapsed.
Click to expand it.
cockatrice/src/gamesmodel.cpp
View file @
06accd51
...
@@ -151,7 +151,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
...
@@ -151,7 +151,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
return
result
.
join
(
", "
);
return
result
.
join
(
", "
);
}
}
case
Qt
::
DecorationRole
:{
case
Qt
::
DecorationRole
:{
return
g
.
with_password
()
?
QIcon
(
":/resources/lock.svg"
)
:
QVariant
();
return
g
.
with_password
()
?
QIcon
(
LockPixmapGenerator
::
generatePixmap
(
13
)
)
:
QVariant
();
case
Qt
::
TextAlignmentRole
:
case
Qt
::
TextAlignmentRole
:
return
Qt
::
AlignLeft
;
return
Qt
::
AlignLeft
;
default:
default:
...
...
cockatrice/src/pixmapgenerator.cpp
View file @
06accd51
...
@@ -166,3 +166,24 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
...
@@ -166,3 +166,24 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
}
}
QMap
<
int
,
QPixmap
>
UserLevelPixmapGenerator
::
pmCache
;
QMap
<
int
,
QPixmap
>
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
<
int
,
QPixmap
>
LockPixmapGenerator
::
pmCache
;
cockatrice/src/pixmapgenerator.h
View file @
06accd51
...
@@ -54,4 +54,12 @@ public:
...
@@ -54,4 +54,12 @@ public:
static
void
clear
()
{
pmCache
.
clear
();
}
static
void
clear
()
{
pmCache
.
clear
();
}
};
};
class
LockPixmapGenerator
{
private:
static
QMap
<
int
,
QPixmap
>
pmCache
;
public:
static
QPixmap
generatePixmap
(
int
height
);
static
void
clear
()
{
pmCache
.
clear
();
}
};
#endif
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment