mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-05 21:47:38 +03:00
Store database icons as QImage instead of QIcon.
This has the advantage that they can be used without a running X server. Add methods to retrieve QPixmaps that are converted from the stored QImages and cached by QPixmapCache.
This commit is contained in:
parent
fdf600e09a
commit
00aafa69f5
15 changed files with 137 additions and 60 deletions
|
@ -52,10 +52,10 @@ Uuid Entry::uuid() const
|
|||
return m_uuid;
|
||||
}
|
||||
|
||||
QIcon Entry::icon() const
|
||||
QImage Entry::icon() const
|
||||
{
|
||||
if (m_customIcon.isNull()) {
|
||||
return DatabaseIcons::icon(m_iconNumber);
|
||||
return databaseIcons()->icon(m_iconNumber);
|
||||
}
|
||||
else {
|
||||
// TODO check if m_db is 0
|
||||
|
@ -63,6 +63,23 @@ QIcon Entry::icon() const
|
|||
}
|
||||
}
|
||||
|
||||
QPixmap Entry::iconPixmap() const
|
||||
{
|
||||
if (m_customIcon.isNull()) {
|
||||
return databaseIcons()->iconPixmap(m_iconNumber);
|
||||
}
|
||||
else {
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
// TODO check if m_db is 0
|
||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_customIcon));
|
||||
*const_cast<QPixmapCache::Key*>(&m_pixmapCacheKey) = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
}
|
||||
|
||||
int Entry::iconNumber() const
|
||||
{
|
||||
return m_iconNumber;
|
||||
|
@ -176,6 +193,8 @@ void Entry::setIcon(int iconNumber)
|
|||
|
||||
m_iconNumber = iconNumber;
|
||||
m_customIcon = Uuid();
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
}
|
||||
|
||||
void Entry::setIcon(const Uuid& uuid)
|
||||
|
@ -184,6 +203,8 @@ void Entry::setIcon(const Uuid& uuid)
|
|||
|
||||
m_iconNumber = 0;
|
||||
m_customIcon = uuid;
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
}
|
||||
|
||||
void Entry::setForegroundColor(const QColor& color)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue