Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/DatabaseTabWidget.cpp')
-rw-r--r--src/gui/DatabaseTabWidget.cpp80
1 files changed, 72 insertions, 8 deletions
diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp
index 92d706b6e..4c8458e52 100644
--- a/src/gui/DatabaseTabWidget.cpp
+++ b/src/gui/DatabaseTabWidget.cpp
@@ -30,6 +30,7 @@
#include "core/Metadata.h"
#include "core/Tools.h"
#include "format/CsvExporter.h"
+#include "format/HtmlExporter.h"
#include "gui/Clipboard.h"
#include "gui/DatabaseOpenDialog.h"
#include "gui/DatabaseWidget.h"
@@ -116,15 +117,17 @@ QSharedPointer<Database> DatabaseTabWidget::execNewDatabaseWizard()
return db;
}
-void DatabaseTabWidget::newDatabase()
+DatabaseWidget* DatabaseTabWidget::newDatabase()
{
auto db = execNewDatabaseWizard();
if (!db) {
- return;
+ return nullptr;
}
- addDatabaseTab(new DatabaseWidget(db, this));
+ auto dbWidget = new DatabaseWidget(db, this);
+ addDatabaseTab(dbWidget);
db->markAsModified();
+ return dbWidget;
}
void DatabaseTabWidget::openDatabase()
@@ -187,18 +190,24 @@ void DatabaseTabWidget::addDatabaseTab(DatabaseWidget* dbWidget, bool inBackgrou
{
Q_ASSERT(dbWidget->database());
+ // emit before index change
+ emit databaseOpened(dbWidget);
+
int index = addTab(dbWidget, "");
updateTabName(index);
toggleTabbar();
-
if (!inBackground) {
setCurrentIndex(index);
}
+ connect(dbWidget,
+ SIGNAL(requestOpenDatabase(QString, bool, QString, QString)),
+ SLOT(addDatabaseTab(QString, bool, QString, QString)));
connect(dbWidget, SIGNAL(databaseFilePathChanged(QString, QString)), SLOT(updateTabName()));
- connect(
- dbWidget, SIGNAL(requestOpenDatabase(QString, bool, QString)), SLOT(addDatabaseTab(QString, bool, QString)));
connect(dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseTabFromSender()));
+ connect(dbWidget,
+ SIGNAL(databaseReplaced(const QSharedPointer<Database>&, const QSharedPointer<Database>&)),
+ SLOT(updateTabName()));
connect(dbWidget, SIGNAL(databaseModified()), SLOT(updateTabName()));
connect(dbWidget, SIGNAL(databaseSaved()), SLOT(updateTabName()));
connect(dbWidget, SIGNAL(databaseUnlocked()), SLOT(updateTabName()));
@@ -258,6 +267,20 @@ void DatabaseTabWidget::importKeePass1Database()
dbWidget->switchToImportKeepass1(fileName);
}
+void DatabaseTabWidget::importOpVaultDatabase()
+{
+ QString fileName = fileDialog()->getExistingDirectory(this, "Open .opvault database");
+
+ if (fileName.isEmpty()) {
+ return;
+ }
+
+ auto db = QSharedPointer<Database>::create();
+ auto* dbWidget = new DatabaseWidget(db, this);
+ addDatabaseTab(dbWidget);
+ dbWidget->switchToImportOpVault(fileName);
+}
+
/**
* Attempt to close the current database and remove its tab afterwards.
*
@@ -371,8 +394,12 @@ void DatabaseTabWidget::exportToCsv()
return;
}
- QString fileName = fileDialog()->getSaveFileName(
- this, tr("Export database to CSV file"), QString(), tr("CSV file").append(" (*.csv)"), nullptr, nullptr, "csv");
+ if (!warnOnExport()) {
+ return;
+ }
+
+ const QString fileName = fileDialog()->getSaveFileName(
+ this, tr("Export database to CSV file"), QString(), tr("CSV file").append(" (*.csv)"), nullptr, nullptr);
if (fileName.isEmpty()) {
return;
}
@@ -384,6 +411,43 @@ void DatabaseTabWidget::exportToCsv()
}
}
+void DatabaseTabWidget::exportToHtml()
+{
+ auto db = databaseWidgetFromIndex(currentIndex())->database();
+ if (!db) {
+ Q_ASSERT(false);
+ return;
+ }
+
+ if (!warnOnExport()) {
+ return;
+ }
+
+ const QString fileName = fileDialog()->getSaveFileName(
+ this, tr("Export database to HTML file"), QString(), tr("HTML file").append(" (*.html)"), nullptr, nullptr);
+ if (fileName.isEmpty()) {
+ return;
+ }
+
+ HtmlExporter htmlExporter;
+ if (!htmlExporter.exportDatabase(fileName, db)) {
+ emit messageGlobal(tr("Writing the HTML file failed.").append("\n").append(htmlExporter.errorString()),
+ MessageWidget::Error);
+ }
+}
+
+bool DatabaseTabWidget::warnOnExport()
+{
+ auto ans =
+ MessageBox::question(this,
+ tr("Export Confirmation"),
+ tr("You are about to export your database to an unencrypted file. This will leave your "
+ "passwords and sensitive information vulnerable! Are you sure you want to continue?"),
+ MessageBox::Yes | MessageBox::No,
+ MessageBox::No);
+ return ans == MessageBox::Yes;
+}
+
void DatabaseTabWidget::changeMasterKey()
{
currentDatabaseWidget()->switchToMasterKeyChange();