diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 82b928219..924eec067 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -331,6 +331,15 @@ void Database::emptyRecycleBin() void Database::merge(const Database* other) { 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(); } diff --git a/src/core/Metadata.cpp b/src/core/Metadata.cpp index eb976d0e5..9fd0ce02f 100644 --- a/src/core/Metadata.cpp +++ b/src/core/Metadata.cpp @@ -41,7 +41,6 @@ Metadata::Metadata(QObject* parent) m_data.protectPassword = true; m_data.protectUrl = false; m_data.protectNotes = false; - // m_data.autoEnableVisualHiding = false; QDateTime now = QDateTime::currentDateTimeUtc(); m_data.nameChanged = now; @@ -158,11 +157,6 @@ bool Metadata::protectNotes() const return m_data.protectNotes; } -/*bool Metadata::autoEnableVisualHiding() const -{ - return m_autoEnableVisualHiding; -}*/ - QImage Metadata::customIcon(const Uuid& uuid) const { return m_customIcons.value(uuid); @@ -376,11 +370,6 @@ void Metadata::setProtectNotes(bool value) set(m_data.protectNotes, value); } -/*void Metadata::setAutoEnableVisualHiding(bool value) -{ - set(m_autoEnableVisualHiding, value); -}*/ - void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon) { Q_ASSERT(!uuid.isNull()); diff --git a/src/core/Metadata.h b/src/core/Metadata.h index 2104868c2..1e972fd5a 100644 --- a/src/core/Metadata.h +++ b/src/core/Metadata.h @@ -60,7 +60,6 @@ public: bool protectPassword; bool protectUrl; bool protectNotes; - // bool autoEnableVisualHiding; }; QString generator() const; @@ -77,7 +76,6 @@ public: bool protectPassword() const; bool protectUrl() const; bool protectNotes() const; - // bool autoEnableVisualHiding() const; QImage customIcon(const Uuid& uuid) const; QPixmap customIconPixmap(const Uuid& uuid) const; QPixmap customIconScaledPixmap(const Uuid& uuid) const; @@ -117,7 +115,6 @@ public: void setProtectPassword(bool value); void setProtectUrl(bool value); void setProtectNotes(bool value); - // void setAutoEnableVisualHiding(bool value); void addCustomIcon(const Uuid& uuid, const QImage& icon); void addCustomIconScaled(const Uuid& uuid, const QImage& icon); void removeCustomIcon(const Uuid& uuid); diff --git a/src/format/KeePass2XmlReader.cpp b/src/format/KeePass2XmlReader.cpp index e4ceb1762..de7ca6d79 100644 --- a/src/format/KeePass2XmlReader.cpp +++ b/src/format/KeePass2XmlReader.cpp @@ -323,9 +323,6 @@ void KeePass2XmlReader::parseMemoryProtection() else if (m_xml.name() == "ProtectNotes") { m_meta->setProtectNotes(readBool()); } - /*else if (m_xml.name() == "AutoEnableVisualHiding") { - m_meta->setAutoEnableVisualHiding(readBool()); - }*/ else { skipCurrentElement(); } diff --git a/src/format/KeePass2XmlWriter.cpp b/src/format/KeePass2XmlWriter.cpp index 8f1d9231d..fa67ece93 100644 --- a/src/format/KeePass2XmlWriter.cpp +++ b/src/format/KeePass2XmlWriter.cpp @@ -141,7 +141,6 @@ void KeePass2XmlWriter::writeMemoryProtection() writeBool("ProtectPassword", m_meta->protectPassword()); writeBool("ProtectURL", m_meta->protectUrl()); writeBool("ProtectNotes", m_meta->protectNotes()); - // writeBool("AutoEnableVisualHiding", m_meta->autoEnableVisualHiding()); m_xml.writeEndElement(); } diff --git a/tests/TestMerge.cpp b/tests/TestMerge.cpp index 48f228b41..c8f15f29b 100644 --- a/tests/TestMerge.cpp +++ b/tests/TestMerge.cpp @@ -420,6 +420,29 @@ void TestMerge::testMergeAndSync() 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* db = new Database(); diff --git a/tests/TestMerge.h b/tests/TestMerge.h index bfb18c305..0b3ec618e 100644 --- a/tests/TestMerge.h +++ b/tests/TestMerge.h @@ -38,6 +38,7 @@ private slots: void testCreateNewGroups(); void testUpdateEntryDifferentLocation(); void testMergeAndSync(); + void testMergeCustomIcons(); private: Database* createTestDatabase();