mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-25 08:51:21 -05:00
Add custom icons when merging. (#1008)
* Adding missing custom icons on merge. * qDebug when adding icon * Adding test for merge custom icons.
This commit is contained in:
parent
0d5fec6dfc
commit
242faa138b
@ -331,6 +331,15 @@ void Database::emptyRecycleBin()
|
|||||||
void Database::merge(const Database* other)
|
void Database::merge(const Database* other)
|
||||||
{
|
{
|
||||||
m_rootGroup->merge(other->rootGroup());
|
m_rootGroup->merge(other->rootGroup());
|
||||||
|
|
||||||
|
for (Uuid customIconId : other->metadata()->customIcons().keys()) {
|
||||||
|
QImage customIcon = other->metadata()->customIcon(customIconId);
|
||||||
|
if (!this->metadata()->containsCustomIcon(customIconId)) {
|
||||||
|
qDebug("Adding custom icon %s to database.", qPrintable(customIconId.toHex()));
|
||||||
|
this->metadata()->addCustomIcon(customIconId, customIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ Metadata::Metadata(QObject* parent)
|
|||||||
m_data.protectPassword = true;
|
m_data.protectPassword = true;
|
||||||
m_data.protectUrl = false;
|
m_data.protectUrl = false;
|
||||||
m_data.protectNotes = false;
|
m_data.protectNotes = false;
|
||||||
// m_data.autoEnableVisualHiding = false;
|
|
||||||
|
|
||||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||||
m_data.nameChanged = now;
|
m_data.nameChanged = now;
|
||||||
@ -158,11 +157,6 @@ bool Metadata::protectNotes() const
|
|||||||
return m_data.protectNotes;
|
return m_data.protectNotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*bool Metadata::autoEnableVisualHiding() const
|
|
||||||
{
|
|
||||||
return m_autoEnableVisualHiding;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
QImage Metadata::customIcon(const Uuid& uuid) const
|
QImage Metadata::customIcon(const Uuid& uuid) const
|
||||||
{
|
{
|
||||||
return m_customIcons.value(uuid);
|
return m_customIcons.value(uuid);
|
||||||
@ -376,11 +370,6 @@ void Metadata::setProtectNotes(bool value)
|
|||||||
set(m_data.protectNotes, value);
|
set(m_data.protectNotes, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void Metadata::setAutoEnableVisualHiding(bool value)
|
|
||||||
{
|
|
||||||
set(m_autoEnableVisualHiding, value);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
|
void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!uuid.isNull());
|
Q_ASSERT(!uuid.isNull());
|
||||||
|
@ -60,7 +60,6 @@ public:
|
|||||||
bool protectPassword;
|
bool protectPassword;
|
||||||
bool protectUrl;
|
bool protectUrl;
|
||||||
bool protectNotes;
|
bool protectNotes;
|
||||||
// bool autoEnableVisualHiding;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QString generator() const;
|
QString generator() const;
|
||||||
@ -77,7 +76,6 @@ public:
|
|||||||
bool protectPassword() const;
|
bool protectPassword() const;
|
||||||
bool protectUrl() const;
|
bool protectUrl() const;
|
||||||
bool protectNotes() const;
|
bool protectNotes() const;
|
||||||
// bool autoEnableVisualHiding() const;
|
|
||||||
QImage customIcon(const Uuid& uuid) const;
|
QImage customIcon(const Uuid& uuid) const;
|
||||||
QPixmap customIconPixmap(const Uuid& uuid) const;
|
QPixmap customIconPixmap(const Uuid& uuid) const;
|
||||||
QPixmap customIconScaledPixmap(const Uuid& uuid) const;
|
QPixmap customIconScaledPixmap(const Uuid& uuid) const;
|
||||||
@ -117,7 +115,6 @@ public:
|
|||||||
void setProtectPassword(bool value);
|
void setProtectPassword(bool value);
|
||||||
void setProtectUrl(bool value);
|
void setProtectUrl(bool value);
|
||||||
void setProtectNotes(bool value);
|
void setProtectNotes(bool value);
|
||||||
// void setAutoEnableVisualHiding(bool value);
|
|
||||||
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
||||||
void addCustomIconScaled(const Uuid& uuid, const QImage& icon);
|
void addCustomIconScaled(const Uuid& uuid, const QImage& icon);
|
||||||
void removeCustomIcon(const Uuid& uuid);
|
void removeCustomIcon(const Uuid& uuid);
|
||||||
|
@ -323,9 +323,6 @@ void KeePass2XmlReader::parseMemoryProtection()
|
|||||||
else if (m_xml.name() == "ProtectNotes") {
|
else if (m_xml.name() == "ProtectNotes") {
|
||||||
m_meta->setProtectNotes(readBool());
|
m_meta->setProtectNotes(readBool());
|
||||||
}
|
}
|
||||||
/*else if (m_xml.name() == "AutoEnableVisualHiding") {
|
|
||||||
m_meta->setAutoEnableVisualHiding(readBool());
|
|
||||||
}*/
|
|
||||||
else {
|
else {
|
||||||
skipCurrentElement();
|
skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,6 @@ void KeePass2XmlWriter::writeMemoryProtection()
|
|||||||
writeBool("ProtectPassword", m_meta->protectPassword());
|
writeBool("ProtectPassword", m_meta->protectPassword());
|
||||||
writeBool("ProtectURL", m_meta->protectUrl());
|
writeBool("ProtectURL", m_meta->protectUrl());
|
||||||
writeBool("ProtectNotes", m_meta->protectNotes());
|
writeBool("ProtectNotes", m_meta->protectNotes());
|
||||||
// writeBool("AutoEnableVisualHiding", m_meta->autoEnableVisualHiding());
|
|
||||||
|
|
||||||
m_xml.writeEndElement();
|
m_xml.writeEndElement();
|
||||||
}
|
}
|
||||||
|
@ -420,6 +420,29 @@ void TestMerge::testMergeAndSync()
|
|||||||
delete dbSource;
|
delete dbSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom icons should be brought over when merging.
|
||||||
|
*/
|
||||||
|
void TestMerge::testMergeCustomIcons()
|
||||||
|
{
|
||||||
|
Database* dbDestination = new Database();
|
||||||
|
Database* dbSource = createTestDatabase();
|
||||||
|
|
||||||
|
Uuid customIconId = Uuid::random();
|
||||||
|
QImage customIcon;
|
||||||
|
|
||||||
|
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
||||||
|
// Sanity check.
|
||||||
|
QVERIFY(dbSource->metadata()->containsCustomIcon(customIconId));
|
||||||
|
|
||||||
|
dbDestination->merge(dbSource);
|
||||||
|
|
||||||
|
QVERIFY(dbDestination->metadata()->containsCustomIcon(customIconId));
|
||||||
|
|
||||||
|
delete dbDestination;
|
||||||
|
delete dbSource;
|
||||||
|
}
|
||||||
|
|
||||||
Database* TestMerge::createTestDatabase()
|
Database* TestMerge::createTestDatabase()
|
||||||
{
|
{
|
||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
|
@ -38,6 +38,7 @@ private slots:
|
|||||||
void testCreateNewGroups();
|
void testCreateNewGroups();
|
||||||
void testUpdateEntryDifferentLocation();
|
void testUpdateEntryDifferentLocation();
|
||||||
void testMergeAndSync();
|
void testMergeAndSync();
|
||||||
|
void testMergeCustomIcons();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Database* createTestDatabase();
|
Database* createTestDatabase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user