mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04: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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -38,6 +38,7 @@ private slots:
|
||||
void testCreateNewGroups();
|
||||
void testUpdateEntryDifferentLocation();
|
||||
void testMergeAndSync();
|
||||
void testMergeCustomIcons();
|
||||
|
||||
private:
|
||||
Database* createTestDatabase();
|
||||
|
Loading…
Reference in New Issue
Block a user