Complete overhaul of the implementation

This commit is contained in:
Jonathan White 2025-11-02 12:25:28 -05:00
parent bd05bf05fc
commit 27a50d8fa5
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
7 changed files with 36 additions and 21 deletions

View file

@ -3720,7 +3720,11 @@ Supported extensions are: %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Share recursively</source>
<source>Maintain group structure with shared database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Keep Group Structure</source>
<translation type="unfinished"></translation>
</message>
</context>

View file

@ -213,7 +213,7 @@ namespace KeeShareSettings
}
}
} else {
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement();
}
}
@ -253,7 +253,7 @@ namespace KeeShareSettings
} else if (reader.name() == "PublicKey") {
own.certificate = Certificate::deserialize(reader);
} else {
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement();
}
}
@ -262,8 +262,7 @@ namespace KeeShareSettings
}
Reference::Reference()
: type(Inactive)
, uuid(QUuid::createUuid())
: uuid(QUuid::createUuid())
{
}
@ -320,15 +319,21 @@ namespace KeeShareSettings
writer.writeStartElement("Password");
writer.writeCharacters(reference.password.toUtf8().toBase64());
writer.writeEndElement();
writer.writeStartElement("Recurse");
writer.writeCharacters(reference.recurse ? "True" : "False");
writer.writeStartElement("KeepGroups");
writer.writeCharacters(reference.keepGroups ? "True" : "False");
writer.writeEndElement();
});
}
Reference Reference::deserialize(const QString& raw)
{
if (raw.isEmpty()) {
return {};
}
Reference reference;
// If KeepGroups is not present, default to false for backward compatibility
reference.keepGroups = false;
xmlDeserialize(raw, [&](QXmlStreamReader& reader) {
while (!reader.error() && reader.readNextStartElement()) {
if (reader.name() == "Type") {
@ -349,10 +354,10 @@ namespace KeeShareSettings
reference.path = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
} else if (reader.name() == "Password") {
reference.password = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
} else if (reader.name() == "Recurse") {
reference.recurse = reader.readElementText().compare("True") == 0;
} else if (reader.name() == "KeepGroups") {
reference.keepGroups = reader.readElementText().compare("True") == 0;
} else {
qWarning("Unknown Reference element %s", qPrintable(reader.name().toString()));
qDebug("Unknown Reference element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement();
}
}

View file

@ -122,11 +122,11 @@ namespace KeeShareSettings
struct Reference
{
Type type;
Type type = Inactive;
QUuid uuid;
QString path;
QString password;
bool recurse;
bool keepGroups = true;
Reference();
bool isNull() const;

View file

@ -110,7 +110,7 @@ namespace
targetRoot->setUpdateTimeinfo(updateTimeinfo);
cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid());
cloneEntries(targetMetadata, sourceRoot, targetRoot);
if (reference.recurse) {
if (reference.keepGroups) {
cloneChildren(targetMetadata, sourceRoot, targetRoot);
}

View file

@ -43,7 +43,7 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
connect(m_ui->pathEdit, SIGNAL(editingFinished()), SLOT(selectPath()));
connect(m_ui->pathSelectionButton, SIGNAL(pressed()), SLOT(launchPathSelectionDialog()));
connect(m_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(selectType()));
connect(m_ui->recurseIntoGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(recurseIntoGroupsToggled(bool)));
connect(m_ui->keepGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(keepGroupsToggled(bool)));
connect(m_ui->clearButton, SIGNAL(clicked(bool)), SLOT(clearInputs()));
connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(updateSharingState()));
@ -98,7 +98,7 @@ void EditGroupWidgetKeeShare::updateSharingState()
m_ui->pathEdit->setEnabled(isEnabled);
m_ui->pathSelectionButton->setEnabled(isEnabled);
m_ui->passwordEdit->setEnabled(isEnabled);
m_ui->recurseIntoGroupsCheckbox->setEnabled(isEnabled);
m_ui->keepGroupsCheckbox->setEnabled(isEnabled);
if (!m_temporaryGroup || !isEnabled) {
m_ui->messageWidget->hideMessage();
@ -190,7 +190,7 @@ void EditGroupWidgetKeeShare::update()
m_ui->typeComboBox->setCurrentIndex(reference.type);
m_ui->passwordEdit->setText(reference.password);
m_ui->pathEdit->setText(reference.path);
m_ui->recurseIntoGroupsCheckbox->setChecked(reference.recurse);
m_ui->keepGroupsCheckbox->setChecked(reference.keepGroups);
}
updateSharingState();
@ -295,12 +295,12 @@ void EditGroupWidgetKeeShare::selectType()
updateSharingState();
}
void EditGroupWidgetKeeShare::recurseIntoGroupsToggled(bool toggled)
void EditGroupWidgetKeeShare::keepGroupsToggled(bool toggled)
{
if (!m_temporaryGroup) {
return;
}
auto reference = KeeShare::referenceOf(m_temporaryGroup);
reference.recurse = toggled;
reference.keepGroups = toggled;
KeeShare::setReferenceTo(m_temporaryGroup, reference);
}

View file

@ -48,7 +48,7 @@ private slots:
void selectPassword();
void launchPathSelectionDialog();
void selectPath();
void recurseIntoGroupsToggled(bool);
void keepGroupsToggled(bool);
private:
QScopedPointer<Ui::EditGroupWidgetKeeShare> m_ui;

View file

@ -185,9 +185,15 @@
</spacer>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="recurseIntoGroupsCheckbox">
<widget class="QCheckBox" name="keepGroupsCheckbox">
<property name="toolTip">
<string>Maintain group structure with shared database</string>
</property>
<property name="text">
<string>Share recursively</string>
<string>Keep Group Structure</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>