Skip to content

Commit 27a50d8

Browse files
committed
Complete overhaul of the implementation
1 parent bd05bf0 commit 27a50d8

File tree

7 files changed

+36
-21
lines changed

7 files changed

+36
-21
lines changed

share/translations/keepassxc_en.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3720,7 +3720,11 @@ Supported extensions are: %1.</source>
37203720
<translation type="unfinished"></translation>
37213721
</message>
37223722
<message>
3723-
<source>Share recursively</source>
3723+
<source>Maintain group structure with shared database</source>
3724+
<translation type="unfinished"></translation>
3725+
</message>
3726+
<message>
3727+
<source>Keep Group Structure</source>
37243728
<translation type="unfinished"></translation>
37253729
</message>
37263730
</context>

src/keeshare/KeeShareSettings.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace KeeShareSettings
213213
}
214214
}
215215
} else {
216-
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
216+
qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
217217
reader.skipCurrentElement();
218218
}
219219
}
@@ -253,7 +253,7 @@ namespace KeeShareSettings
253253
} else if (reader.name() == "PublicKey") {
254254
own.certificate = Certificate::deserialize(reader);
255255
} else {
256-
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
256+
qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
257257
reader.skipCurrentElement();
258258
}
259259
}
@@ -262,8 +262,7 @@ namespace KeeShareSettings
262262
}
263263

264264
Reference::Reference()
265-
: type(Inactive)
266-
, uuid(QUuid::createUuid())
265+
: uuid(QUuid::createUuid())
267266
{
268267
}
269268

@@ -320,15 +319,21 @@ namespace KeeShareSettings
320319
writer.writeStartElement("Password");
321320
writer.writeCharacters(reference.password.toUtf8().toBase64());
322321
writer.writeEndElement();
323-
writer.writeStartElement("Recurse");
324-
writer.writeCharacters(reference.recurse ? "True" : "False");
322+
writer.writeStartElement("KeepGroups");
323+
writer.writeCharacters(reference.keepGroups ? "True" : "False");
325324
writer.writeEndElement();
326325
});
327326
}
328327

329328
Reference Reference::deserialize(const QString& raw)
330329
{
330+
if (raw.isEmpty()) {
331+
return {};
332+
}
333+
331334
Reference reference;
335+
// If KeepGroups is not present, default to false for backward compatibility
336+
reference.keepGroups = false;
332337
xmlDeserialize(raw, [&](QXmlStreamReader& reader) {
333338
while (!reader.error() && reader.readNextStartElement()) {
334339
if (reader.name() == "Type") {
@@ -349,10 +354,10 @@ namespace KeeShareSettings
349354
reference.path = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
350355
} else if (reader.name() == "Password") {
351356
reference.password = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
352-
} else if (reader.name() == "Recurse") {
353-
reference.recurse = reader.readElementText().compare("True") == 0;
357+
} else if (reader.name() == "KeepGroups") {
358+
reference.keepGroups = reader.readElementText().compare("True") == 0;
354359
} else {
355-
qWarning("Unknown Reference element %s", qPrintable(reader.name().toString()));
360+
qDebug("Unknown Reference element %s", qPrintable(reader.name().toString()));
356361
reader.skipCurrentElement();
357362
}
358363
}

src/keeshare/KeeShareSettings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ namespace KeeShareSettings
122122

123123
struct Reference
124124
{
125-
Type type;
125+
Type type = Inactive;
126126
QUuid uuid;
127127
QString path;
128128
QString password;
129-
bool recurse;
129+
bool keepGroups = true;
130130

131131
Reference();
132132
bool isNull() const;

src/keeshare/ShareExport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace
110110
targetRoot->setUpdateTimeinfo(updateTimeinfo);
111111
cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid());
112112
cloneEntries(targetMetadata, sourceRoot, targetRoot);
113-
if (reference.recurse) {
113+
if (reference.keepGroups) {
114114
cloneChildren(targetMetadata, sourceRoot, targetRoot);
115115
}
116116

src/keeshare/group/EditGroupWidgetKeeShare.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
4343
connect(m_ui->pathEdit, SIGNAL(editingFinished()), SLOT(selectPath()));
4444
connect(m_ui->pathSelectionButton, SIGNAL(pressed()), SLOT(launchPathSelectionDialog()));
4545
connect(m_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(selectType()));
46-
connect(m_ui->recurseIntoGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(recurseIntoGroupsToggled(bool)));
46+
connect(m_ui->keepGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(keepGroupsToggled(bool)));
4747
connect(m_ui->clearButton, SIGNAL(clicked(bool)), SLOT(clearInputs()));
4848

4949
connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(updateSharingState()));
@@ -98,7 +98,7 @@ void EditGroupWidgetKeeShare::updateSharingState()
9898
m_ui->pathEdit->setEnabled(isEnabled);
9999
m_ui->pathSelectionButton->setEnabled(isEnabled);
100100
m_ui->passwordEdit->setEnabled(isEnabled);
101-
m_ui->recurseIntoGroupsCheckbox->setEnabled(isEnabled);
101+
m_ui->keepGroupsCheckbox->setEnabled(isEnabled);
102102

103103
if (!m_temporaryGroup || !isEnabled) {
104104
m_ui->messageWidget->hideMessage();
@@ -190,7 +190,7 @@ void EditGroupWidgetKeeShare::update()
190190
m_ui->typeComboBox->setCurrentIndex(reference.type);
191191
m_ui->passwordEdit->setText(reference.password);
192192
m_ui->pathEdit->setText(reference.path);
193-
m_ui->recurseIntoGroupsCheckbox->setChecked(reference.recurse);
193+
m_ui->keepGroupsCheckbox->setChecked(reference.keepGroups);
194194
}
195195

196196
updateSharingState();
@@ -295,12 +295,12 @@ void EditGroupWidgetKeeShare::selectType()
295295
updateSharingState();
296296
}
297297

298-
void EditGroupWidgetKeeShare::recurseIntoGroupsToggled(bool toggled)
298+
void EditGroupWidgetKeeShare::keepGroupsToggled(bool toggled)
299299
{
300300
if (!m_temporaryGroup) {
301301
return;
302302
}
303303
auto reference = KeeShare::referenceOf(m_temporaryGroup);
304-
reference.recurse = toggled;
304+
reference.keepGroups = toggled;
305305
KeeShare::setReferenceTo(m_temporaryGroup, reference);
306306
}

src/keeshare/group/EditGroupWidgetKeeShare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private slots:
4848
void selectPassword();
4949
void launchPathSelectionDialog();
5050
void selectPath();
51-
void recurseIntoGroupsToggled(bool);
51+
void keepGroupsToggled(bool);
5252

5353
private:
5454
QScopedPointer<Ui::EditGroupWidgetKeeShare> m_ui;

src/keeshare/group/EditGroupWidgetKeeShare.ui

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,15 @@
185185
</spacer>
186186
</item>
187187
<item row="3" column="1">
188-
<widget class="QCheckBox" name="recurseIntoGroupsCheckbox">
188+
<widget class="QCheckBox" name="keepGroupsCheckbox">
189+
<property name="toolTip">
190+
<string>Maintain group structure with shared database</string>
191+
</property>
189192
<property name="text">
190-
<string>Share recursively</string>
193+
<string>Keep Group Structure</string>
194+
</property>
195+
<property name="checked">
196+
<bool>true</bool>
191197
</property>
192198
</widget>
193199
</item>

0 commit comments

Comments
 (0)