Add XML Export option to GUI. (#8524)
* Add XML Export option to GUI. * Update database export screenshot.
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -71,6 +71,7 @@ public slots:
|
||||
bool saveDatabaseBackup(int index = -1);
|
||||
void exportToCsv();
|
||||
void exportToHtml();
|
||||
void exportToXML();
|
||||
|
||||
bool lockDatabases();
|
||||
void lockDatabasesDelayed();
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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>&Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="actionDatabaseNew"/>
|
||||
<addaction name="actionDatabaseOpen"/>
|
||||
@@ -1101,6 +1107,17 @@
|
||||
<string>&Lock Database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportXML">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&XML File…</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>XML File…</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user