mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Consistency using filepath and minor code fixes
This commit is contained in:
parent
36e5377e6a
commit
1a7b874c60
@ -355,9 +355,9 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
} else {
|
} else {
|
||||||
oldFilePath = QDir::toNativeSeparators(QDir::homePath() + "/" + tr("Passwords").append(".kdbx"));
|
oldFilePath = QDir::toNativeSeparators(QDir::homePath() + "/" + tr("Passwords").append(".kdbx"));
|
||||||
}
|
}
|
||||||
QString newFilePath = fileDialog()->getSaveFileName(this, tr("Save database as"),
|
QString newFilePath = fileDialog()->getSaveFileName(this, tr("Save database as"), oldFilePath,
|
||||||
oldFilePath, tr("KeePass 2 Database").append(" (*.kdbx)"),
|
tr("KeePass 2 Database").append(" (*.kdbx)"),
|
||||||
nullptr, 0, "kdbx");
|
nullptr, 0, "kdbx");
|
||||||
if (!newFilePath.isEmpty()) {
|
if (!newFilePath.isEmpty()) {
|
||||||
// Ensure we don't recurse back into this function
|
// Ensure we don't recurse back into this function
|
||||||
dbStruct.readOnly = false;
|
dbStruct.readOnly = false;
|
||||||
@ -367,7 +367,7 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbStruct.dbWidget->updateFilename(dbStruct.fileInfo.absoluteFilePath());
|
dbStruct.dbWidget->updateFilePath(dbStruct.fileInfo.absoluteFilePath());
|
||||||
updateLastDatabases(dbStruct.fileInfo.absoluteFilePath());
|
updateLastDatabases(dbStruct.fileInfo.absoluteFilePath());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -669,7 +669,7 @@ void DatabaseTabWidget::lockDatabases()
|
|||||||
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(widget(i));
|
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(widget(i));
|
||||||
Database* db = databaseFromDatabaseWidget(dbWidget);
|
Database* db = databaseFromDatabaseWidget(dbWidget);
|
||||||
|
|
||||||
if (dbWidget->currentMode() == DatabaseWidget::LockedMode) {
|
if (dbWidget->currentMode() == DatabaseWidget::LockedMode || !dbWidget->dbHasKey()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,10 +839,10 @@ void DatabaseWidget::openDatabase(bool accepted)
|
|||||||
m_databaseOpenWidget = nullptr;
|
m_databaseOpenWidget = nullptr;
|
||||||
delete m_keepass1OpenWidget;
|
delete m_keepass1OpenWidget;
|
||||||
m_keepass1OpenWidget = nullptr;
|
m_keepass1OpenWidget = nullptr;
|
||||||
m_fileWatcher.addPath(m_filename);
|
m_fileWatcher.addPath(m_filePath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_fileWatcher.removePath(m_filename);
|
m_fileWatcher.removePath(m_filePath);
|
||||||
if (m_databaseOpenWidget->database()) {
|
if (m_databaseOpenWidget->database()) {
|
||||||
delete m_databaseOpenWidget->database();
|
delete m_databaseOpenWidget->database();
|
||||||
}
|
}
|
||||||
@ -950,23 +950,23 @@ void DatabaseWidget::switchToDatabaseSettings()
|
|||||||
setCurrentWidget(m_databaseSettingsWidget);
|
setCurrentWidget(m_databaseSettingsWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName)
|
void DatabaseWidget::switchToOpenDatabase(const QString& filePath)
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilePath(filePath);
|
||||||
if (m_databaseOpenWidget) {
|
if (m_databaseOpenWidget) {
|
||||||
m_databaseOpenWidget->load(fileName);
|
m_databaseOpenWidget->load(filePath);
|
||||||
setCurrentWidget(m_databaseOpenWidget);
|
setCurrentWidget(m_databaseOpenWidget);
|
||||||
} else if (m_unlockDatabaseWidget) {
|
} else if (m_unlockDatabaseWidget) {
|
||||||
m_unlockDatabaseWidget->load(fileName);
|
m_unlockDatabaseWidget->load(filePath);
|
||||||
setCurrentWidget(m_unlockDatabaseWidget);
|
setCurrentWidget(m_unlockDatabaseWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString& password,
|
void DatabaseWidget::switchToOpenDatabase(const QString& filePath, const QString& password,
|
||||||
const QString& keyFile)
|
const QString& keyFile)
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilePath(filePath);
|
||||||
switchToOpenDatabase(fileName);
|
switchToOpenDatabase(filePath);
|
||||||
if (m_databaseOpenWidget) {
|
if (m_databaseOpenWidget) {
|
||||||
m_databaseOpenWidget->enterKey(password, keyFile);
|
m_databaseOpenWidget->enterKey(password, keyFile);
|
||||||
} else if (m_unlockDatabaseWidget) {
|
} else if (m_unlockDatabaseWidget) {
|
||||||
@ -974,35 +974,35 @@ void DatabaseWidget::switchToOpenDatabase(const QString& fileName, const QString
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToImportCsv(const QString& fileName)
|
void DatabaseWidget::switchToImportCsv(const QString& filePath)
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilePath(filePath);
|
||||||
m_csvImportWizard->load(fileName, m_db);
|
m_csvImportWizard->load(filePath, m_db);
|
||||||
m_changeMasterKeyWidget->clearForms();
|
m_changeMasterKeyWidget->clearForms();
|
||||||
m_changeMasterKeyWidget->setCancelEnabled(false);
|
m_changeMasterKeyWidget->setCancelEnabled(false);
|
||||||
setCurrentWidget(m_changeMasterKeyWidget);
|
setCurrentWidget(m_changeMasterKeyWidget);
|
||||||
m_importingCsv = true;
|
m_importingCsv = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToOpenMergeDatabase(const QString& fileName)
|
void DatabaseWidget::switchToOpenMergeDatabase(const QString& filePath)
|
||||||
{
|
{
|
||||||
m_databaseOpenMergeWidget->clearForms();
|
m_databaseOpenMergeWidget->clearForms();
|
||||||
m_databaseOpenMergeWidget->load(fileName);
|
m_databaseOpenMergeWidget->load(filePath);
|
||||||
setCurrentWidget(m_databaseOpenMergeWidget);
|
setCurrentWidget(m_databaseOpenMergeWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DatabaseWidget::switchToOpenMergeDatabase(const QString& fileName, const QString& password,
|
void DatabaseWidget::switchToOpenMergeDatabase(const QString& filePath, const QString& password,
|
||||||
const QString& keyFile)
|
const QString& keyFile)
|
||||||
{
|
{
|
||||||
switchToOpenMergeDatabase(fileName);
|
switchToOpenMergeDatabase(filePath);
|
||||||
m_databaseOpenMergeWidget->enterKey(password, keyFile);
|
m_databaseOpenMergeWidget->enterKey(password, keyFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToImportKeepass1(const QString& fileName)
|
void DatabaseWidget::switchToImportKeepass1(const QString& filePath)
|
||||||
{
|
{
|
||||||
updateFilename(fileName);
|
updateFilePath(filePath);
|
||||||
m_keepass1OpenWidget->load(fileName);
|
m_keepass1OpenWidget->load(filePath);
|
||||||
setCurrentWidget(m_keepass1OpenWidget);
|
setCurrentWidget(m_keepass1OpenWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,21 +1172,21 @@ void DatabaseWidget::lock()
|
|||||||
|
|
||||||
endSearch();
|
endSearch();
|
||||||
clearAllWidgets();
|
clearAllWidgets();
|
||||||
m_unlockDatabaseWidget->load(m_filename);
|
m_unlockDatabaseWidget->load(m_filePath);
|
||||||
setCurrentWidget(m_unlockDatabaseWidget);
|
setCurrentWidget(m_unlockDatabaseWidget);
|
||||||
Database* newDb = new Database();
|
Database* newDb = new Database();
|
||||||
newDb->metadata()->setName(m_db->metadata()->name());
|
newDb->metadata()->setName(m_db->metadata()->name());
|
||||||
replaceDatabase(newDb);
|
replaceDatabase(newDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::updateFilename(const QString& fileName)
|
void DatabaseWidget::updateFilePath(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (!m_filename.isEmpty()) {
|
if (!m_filePath.isEmpty()) {
|
||||||
m_fileWatcher.removePath(m_filename);
|
m_fileWatcher.removePath(m_filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fileWatcher.addPath(fileName);
|
m_fileWatcher.addPath(filePath);
|
||||||
m_filename = fileName;
|
m_filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::blockAutoReload(bool block)
|
void DatabaseWidget::blockAutoReload(bool block)
|
||||||
@ -1202,7 +1202,7 @@ void DatabaseWidget::blockAutoReload(bool block)
|
|||||||
void DatabaseWidget::unblockAutoReload()
|
void DatabaseWidget::unblockAutoReload()
|
||||||
{
|
{
|
||||||
m_ignoreAutoReload = false;
|
m_ignoreAutoReload = false;
|
||||||
updateFilename(m_filename);
|
updateFilePath(m_filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::onWatchedFileChanged()
|
void DatabaseWidget::onWatchedFileChanged()
|
||||||
@ -1237,13 +1237,13 @@ void DatabaseWidget::reloadDatabaseFile()
|
|||||||
emit m_db->modified();
|
emit m_db->modified();
|
||||||
m_databaseModified = true;
|
m_databaseModified = true;
|
||||||
// Rewatch the database file
|
// Rewatch the database file
|
||||||
m_fileWatcher.addPath(m_filename);
|
m_fileWatcher.addPath(m_filePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeePass2Reader reader;
|
KeePass2Reader reader;
|
||||||
QFile file(m_filename);
|
QFile file(m_filePath);
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
Database* db = reader.readDatabase(&file, database()->key());
|
Database* db = reader.readDatabase(&file, database()->key());
|
||||||
if (db != nullptr) {
|
if (db != nullptr) {
|
||||||
@ -1293,7 +1293,7 @@ void DatabaseWidget::reloadDatabaseFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rewatch the database file
|
// Rewatch the database file
|
||||||
m_fileWatcher.addPath(m_filename);
|
m_fileWatcher.addPath(m_filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DatabaseWidget::numberOfSelectedEntries() const
|
int DatabaseWidget::numberOfSelectedEntries() const
|
||||||
@ -1417,7 +1417,7 @@ EntryView* DatabaseWidget::entryView() {
|
|||||||
void DatabaseWidget::showUnlockDialog()
|
void DatabaseWidget::showUnlockDialog()
|
||||||
{
|
{
|
||||||
m_unlockDatabaseDialog->clearForms();
|
m_unlockDatabaseDialog->clearForms();
|
||||||
m_unlockDatabaseDialog->setDBFilename(m_filename);
|
m_unlockDatabaseDialog->setFilePath(m_filePath);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
autoType()->raiseWindow();
|
autoType()->raiseWindow();
|
||||||
|
@ -82,7 +82,7 @@ public:
|
|||||||
void setCurrentWidget(QWidget* widget);
|
void setCurrentWidget(QWidget* widget);
|
||||||
DatabaseWidget::Mode currentMode() const;
|
DatabaseWidget::Mode currentMode() const;
|
||||||
void lock();
|
void lock();
|
||||||
void updateFilename(const QString& filename);
|
void updateFilePath(const QString &filePath);
|
||||||
int numberOfSelectedEntries() const;
|
int numberOfSelectedEntries() const;
|
||||||
QStringList customEntryAttributes() const;
|
QStringList customEntryAttributes() const;
|
||||||
bool isGroupSelected() const;
|
bool isGroupSelected() const;
|
||||||
@ -155,13 +155,13 @@ public slots:
|
|||||||
void switchToGroupEdit();
|
void switchToGroupEdit();
|
||||||
void switchToMasterKeyChange(bool disableCancel = false);
|
void switchToMasterKeyChange(bool disableCancel = false);
|
||||||
void switchToDatabaseSettings();
|
void switchToDatabaseSettings();
|
||||||
void switchToOpenDatabase(const QString& fileName);
|
void switchToOpenDatabase(const QString& filePath);
|
||||||
void switchToOpenDatabase(const QString& fileName, const QString& password, const QString& keyFile);
|
void switchToOpenDatabase(const QString& filePath, const QString& password, const QString& keyFile);
|
||||||
void switchToImportCsv(const QString& fileName);
|
void switchToImportCsv(const QString& filePath);
|
||||||
void csvImportFinished(bool accepted);
|
void csvImportFinished(bool accepted);
|
||||||
void switchToOpenMergeDatabase(const QString& fileName);
|
void switchToOpenMergeDatabase(const QString& filePath);
|
||||||
void switchToOpenMergeDatabase(const QString& fileName, const QString& password, const QString& keyFile);
|
void switchToOpenMergeDatabase(const QString& filePath, const QString& password, const QString& keyFile);
|
||||||
void switchToImportKeepass1(const QString& fileName);
|
void switchToImportKeepass1(const QString& filePath);
|
||||||
void databaseModified();
|
void databaseModified();
|
||||||
void databaseSaved();
|
void databaseSaved();
|
||||||
void emptyRecycleBin();
|
void emptyRecycleBin();
|
||||||
@ -225,7 +225,7 @@ private:
|
|||||||
Group* m_newGroup;
|
Group* m_newGroup;
|
||||||
Entry* m_newEntry;
|
Entry* m_newEntry;
|
||||||
Group* m_newParent;
|
Group* m_newParent;
|
||||||
QString m_filename;
|
QString m_filePath;
|
||||||
Uuid m_groupBeforeLock;
|
Uuid m_groupBeforeLock;
|
||||||
Uuid m_entryBeforeLock;
|
Uuid m_entryBeforeLock;
|
||||||
MessageWidget* m_messageWidget;
|
MessageWidget* m_messageWidget;
|
||||||
|
@ -30,9 +30,9 @@ UnlockDatabaseDialog::UnlockDatabaseDialog(QWidget* parent)
|
|||||||
connect(m_view, SIGNAL(editFinished(bool)), this, SLOT(complete(bool)));
|
connect(m_view, SIGNAL(editFinished(bool)), this, SLOT(complete(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlockDatabaseDialog::setDBFilename(const QString& filename)
|
void UnlockDatabaseDialog::setFilePath(const QString &filePath)
|
||||||
{
|
{
|
||||||
m_view->load(filename);
|
m_view->load(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlockDatabaseDialog::clearForms()
|
void UnlockDatabaseDialog::clearForms()
|
||||||
|
@ -32,7 +32,7 @@ class UnlockDatabaseDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit UnlockDatabaseDialog(QWidget* parent = nullptr);
|
explicit UnlockDatabaseDialog(QWidget* parent = nullptr);
|
||||||
void setDBFilename(const QString& filename);
|
void setFilePath(const QString &filePath);
|
||||||
void clearForms();
|
void clearForms();
|
||||||
Database* database();
|
Database* database();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user