Add XML Export option to GUI. (#8524)

* Add XML Export option to GUI.

* Update database export screenshot.
This commit is contained in:
Patrick Klein 2022-10-03 05:04:21 +02:00 committed by GitHub
parent 9366c5c233
commit 54f9b25b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 126 KiB

View File

@ -55,7 +55,7 @@ To import a KeePass 1 database file in KeePassXC, perform the following steps:
6. The data from the `.kdb` file gets imported and converted to the new format, which is compatible with KeePassXC. You can now start using the new database file (`.kdbx`) in KeePassXC.
== Exporting Databases
KeePassXC supports multiple ways to export your database for transfer to another program or to print out and archive. To export your database into the KDB XML format, you must use the KeePassXC CLI: `keepassxc-cli export <database.kdbx>`.
KeePassXC supports multiple ways to export your database for transfer to another program or to print out and archive.
WARNING: Exporting your database will result in all of your passwords and sensitive information being stored in an unencrypted format. We do not recommend saving your exported database for long periods of time as that can cause a compromise of sensitive information.

View File

@ -2246,6 +2246,18 @@ This is definitely a bug, please report it to the developers.</source>
<comment>Database tab name modifier</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export database to XML file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XML file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Writing the XML file failed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseWidget</name>
@ -5434,6 +5446,14 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>Copy Password and TOTP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;XML File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XML File</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>

View File

@ -493,6 +493,40 @@ void DatabaseTabWidget::exportToHtml()
exportDialog->exec();
}
void DatabaseTabWidget::exportToXML()
{
auto db = databaseWidgetFromIndex(currentIndex())->database();
if (!db) {
Q_ASSERT(false);
return;
}
if (!warnOnExport()) {
return;
}
auto fileName = fileDialog()->getSaveFileName(
this, tr("Export database to XML file"), FileDialog::getLastDir("xml"), tr("XML file").append(" (*.xml)"));
if (fileName.isEmpty()) {
return;
}
FileDialog::saveLastDir("xml", fileName, true);
QByteArray xmlData;
QString err;
if (!db->extract(xmlData, &err)) {
emit messageGlobal(tr("Writing the XML file failed").append("\n").append(err), MessageWidget::Error);
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
emit messageGlobal(tr("Writing the XML file failed").append("\n").append(file.errorString()),
MessageWidget::Error);
}
file.write(xmlData);
}
bool DatabaseTabWidget::warnOnExport()
{
auto ans =

View File

@ -71,6 +71,7 @@ public slots:
bool saveDatabaseBackup(int index = -1);
void exportToCsv();
void exportToHtml();
void exportToXML();
bool lockDatabases();
void lockDatabasesDelayed();

View File

@ -485,6 +485,7 @@ MainWindow::MainWindow()
connect(m_ui->actionImportOpVault, SIGNAL(triggered()), m_ui->tabWidget, SLOT(importOpVaultDatabase()));
connect(m_ui->actionExportCsv, SIGNAL(triggered()), m_ui->tabWidget, SLOT(exportToCsv()));
connect(m_ui->actionExportHtml, SIGNAL(triggered()), m_ui->tabWidget, SLOT(exportToHtml()));
connect(m_ui->actionExportXML, SIGNAL(triggered()), m_ui->tabWidget, SLOT(exportToXML()));
connect(
m_ui->actionLockDatabase, SIGNAL(triggered()), m_ui->tabWidget, SLOT(lockAndSwitchToFirstUnlockedDatabase()));
connect(m_ui->actionLockDatabaseToolbar, SIGNAL(triggered()), m_ui->actionLockDatabase, SIGNAL(triggered()));
@ -973,6 +974,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->menuExport->setEnabled(true);
m_ui->actionExportCsv->setEnabled(true);
m_ui->actionExportHtml->setEnabled(true);
m_ui->actionExportXML->setEnabled(true);
m_ui->actionDatabaseMerge->setEnabled(m_ui->tabWidget->currentIndex() != -1);
#ifdef WITH_XC_SSHAGENT
bool singleEntryHasSshKey =

View File

@ -216,7 +216,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>25</height>
</rect>
</property>
<property name="contextMenuPolicy">
@ -245,6 +245,12 @@
</property>
<addaction name="actionExportCsv"/>
<addaction name="actionExportHtml"/>
<addaction name="actionExportXML"/>
</widget>
<widget class="QMenu" name="menu_Quit">
<property name="title">
<string>&amp;Quit</string>
</property>
</widget>
<addaction name="actionDatabaseNew"/>
<addaction name="actionDatabaseOpen"/>
@ -1101,6 +1107,17 @@
<string>&amp;Lock Database</string>
</property>
</action>
<action name="actionExportXML">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;XML File…</string>
</property>
<property name="toolTip">
<string>XML File…</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>