mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-19 03:28:25 -04:00
parent
38245aa2a9
commit
93585aded7
8 changed files with 25 additions and 14 deletions
|
@ -214,6 +214,17 @@ QHash<Uuid, QImage> Metadata::customIcons() const
|
||||||
return m_customIcons;
|
return m_customIcons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHash<Uuid, QPixmap> Metadata::customIconsScaledPixmaps() const
|
||||||
|
{
|
||||||
|
QHash<Uuid, QPixmap> result;
|
||||||
|
|
||||||
|
Q_FOREACH (const Uuid& uuid, m_customIconsOrder) {
|
||||||
|
result.insert(uuid, customIconScaledPixmap(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QList<Uuid> Metadata::customIconsOrder() const
|
QList<Uuid> Metadata::customIconsOrder() const
|
||||||
{
|
{
|
||||||
return m_customIconsOrder;
|
return m_customIconsOrder;
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
QHash<Uuid, QImage> customIcons() const;
|
QHash<Uuid, QImage> customIcons() const;
|
||||||
QList<Uuid> customIconsOrder() const;
|
QList<Uuid> customIconsOrder() const;
|
||||||
bool recycleBinEnabled() const;
|
bool recycleBinEnabled() const;
|
||||||
|
QHash<Uuid, QPixmap> customIconsScaledPixmaps() const;
|
||||||
Group* recycleBin();
|
Group* recycleBin();
|
||||||
const Group* recycleBin() const;
|
const Group* recycleBin() const;
|
||||||
QDateTime recycleBinChanged() const;
|
QDateTime recycleBinChanged() const;
|
||||||
|
|
|
@ -98,7 +98,7 @@ void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct icon
|
||||||
m_database = database;
|
m_database = database;
|
||||||
m_currentUuid = currentUuid;
|
m_currentUuid = currentUuid;
|
||||||
|
|
||||||
m_customIconModel->setIcons(database->metadata()->customIcons(),
|
m_customIconModel->setIcons(database->metadata()->customIconsScaledPixmaps(),
|
||||||
database->metadata()->customIconsOrder());
|
database->metadata()->customIconsOrder());
|
||||||
|
|
||||||
Uuid iconUuid = iconStruct.uuid;
|
Uuid iconUuid = iconStruct.uuid;
|
||||||
|
@ -133,7 +133,7 @@ void EditWidgetIcons::addCustomIcon()
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
Uuid uuid = Uuid::random();
|
Uuid uuid = Uuid::random();
|
||||||
m_database->metadata()->addCustomIconScaled(uuid, image);
|
m_database->metadata()->addCustomIconScaled(uuid, image);
|
||||||
m_customIconModel->setIcons(m_database->metadata()->customIcons(),
|
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||||
m_database->metadata()->customIconsOrder());
|
m_database->metadata()->customIconsOrder());
|
||||||
QModelIndex index = m_customIconModel->indexFromUuid(uuid);
|
QModelIndex index = m_customIconModel->indexFromUuid(uuid);
|
||||||
m_ui->customIconsView->setCurrentIndex(index);
|
m_ui->customIconsView->setCurrentIndex(index);
|
||||||
|
@ -183,7 +183,7 @@ void EditWidgetIcons::removeCustomIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_database->metadata()->removeCustomIcon(iconUuid);
|
m_database->metadata()->removeCustomIcon(iconUuid);
|
||||||
m_customIconModel->setIcons(m_database->metadata()->customIcons(),
|
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||||
m_database->metadata()->customIconsOrder());
|
m_database->metadata()->customIconsOrder());
|
||||||
if (m_customIconModel->rowCount() > 0) {
|
if (m_customIconModel->rowCount() > 0) {
|
||||||
m_ui->customIconsView->setCurrentIndex(m_customIconModel->index(0, 0));
|
m_ui->customIconsView->setCurrentIndex(m_customIconModel->index(0, 0));
|
||||||
|
|
|
@ -54,7 +54,7 @@ CustomIconModel::CustomIconModel(QObject* parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconModel::setIcons(const QHash<Uuid, QImage>& icons, const QList<Uuid>& iconsOrder)
|
void CustomIconModel::setIcons(const QHash<Uuid, QPixmap>& icons, const QList<Uuid>& iconsOrder)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#define KEEPASSX_ICONMODELS_H
|
#define KEEPASSX_ICONMODELS_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QImage>
|
#include <QPixmap>
|
||||||
|
|
||||||
#include "core/Global.h"
|
#include "core/Global.h"
|
||||||
#include "core/Uuid.h"
|
#include "core/Uuid.h"
|
||||||
|
@ -44,12 +44,12 @@ public:
|
||||||
|
|
||||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
||||||
void setIcons(const QHash<Uuid, QImage>& icons, const QList<Uuid>& iconsOrder);
|
void setIcons(const QHash<Uuid, QPixmap>& icons, const QList<Uuid>& iconsOrder);
|
||||||
Uuid uuidFromIndex(const QModelIndex& index) const;
|
Uuid uuidFromIndex(const QModelIndex& index) const;
|
||||||
QModelIndex indexFromUuid(const Uuid& uuid) const;
|
QModelIndex indexFromUuid(const Uuid& uuid) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<Uuid, QImage> m_icons;
|
QHash<Uuid, QPixmap> m_icons;
|
||||||
QList<Uuid> m_iconsOrder;
|
QList<Uuid> m_iconsOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case ParentGroup:
|
case ParentGroup:
|
||||||
if (entry->group()) {
|
if (entry->group()) {
|
||||||
return entry->group()->iconPixmap();
|
return entry->group()->iconScaledPixmap();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Title:
|
case Title:
|
||||||
|
@ -154,7 +154,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||||
return databaseIcons()->iconPixmap(DatabaseIcons::ExpiredIconIndex);
|
return databaseIcons()->iconPixmap(DatabaseIcons::ExpiredIconIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return entry->iconPixmap();
|
return entry->iconScaledPixmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ QVariant GroupModel::data(const QModelIndex& index, int role) const
|
||||||
return databaseIcons()->iconPixmap(DatabaseIcons::ExpiredIconIndex);
|
return databaseIcons()->iconPixmap(DatabaseIcons::ExpiredIconIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return group->iconPixmap();
|
return group->iconScaledPixmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (role == Qt::FontRole) {
|
else if (role == Qt::FontRole) {
|
||||||
|
|
|
@ -210,17 +210,16 @@ void TestEntryModel::testCustomIconModel()
|
||||||
|
|
||||||
QCOMPARE(model->rowCount(), 0);
|
QCOMPARE(model->rowCount(), 0);
|
||||||
|
|
||||||
QHash<Uuid, QImage> icons;
|
QHash<Uuid, QPixmap> icons;
|
||||||
QList<Uuid> iconsOrder;
|
QList<Uuid> iconsOrder;
|
||||||
|
|
||||||
Uuid iconUuid(QByteArray(16, '2'));
|
Uuid iconUuid(QByteArray(16, '2'));
|
||||||
QImage icon;
|
icons.insert(iconUuid, QPixmap());
|
||||||
icons.insert(iconUuid, icon);
|
|
||||||
iconsOrder << iconUuid;
|
iconsOrder << iconUuid;
|
||||||
|
|
||||||
Uuid iconUuid2(QByteArray(16, '1'));
|
Uuid iconUuid2(QByteArray(16, '1'));
|
||||||
QImage icon2;
|
QImage icon2;
|
||||||
icons.insert(iconUuid2, icon2);
|
icons.insert(iconUuid2, QPixmap());
|
||||||
iconsOrder << iconUuid2;
|
iconsOrder << iconUuid2;
|
||||||
|
|
||||||
model->setIcons(icons, iconsOrder);
|
model->setIcons(icons, iconsOrder);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue