mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Final fixes
This commit is contained in:
committed by
Janek Bevendorff
parent
fc5f504509
commit
66ff42c78b
@@ -1799,6 +1799,10 @@ Are you sure you want to continue with this file?.</source>
|
||||
<source>Press ESC again to close this database</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>The database file does not exist or is not accessible.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DatabaseSettingWidgetMetaData</name>
|
||||
@@ -2608,10 +2612,6 @@ This is definitely a bug, please report it to the developers.</source>
|
||||
<source>Open database</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Failed to open %1. It either does not exist or is not accessible.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
namespace
|
||||
{
|
||||
constexpr int clearFormsDelay = 30000;
|
||||
constexpr int fileExistsCheckInterval = 5000;
|
||||
|
||||
bool isQuickUnlockAvailable()
|
||||
{
|
||||
@@ -68,6 +69,16 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
||||
m_ui->editPassword->setShowPassword(false);
|
||||
});
|
||||
|
||||
m_fileExistsTimer.setInterval(fileExistsCheckInterval);
|
||||
m_fileExistsTimer.setSingleShot(false);
|
||||
connect(&m_fileExistsTimer, &QTimer::timeout, this, [this] {
|
||||
if (!QFile::exists(m_filename)) {
|
||||
m_ui->messageWidget->showMessage(tr("The database file does not exist or is not accessible."),
|
||||
MessageWidget::Warning,
|
||||
fileExistsCheckInterval + 500);
|
||||
}
|
||||
});
|
||||
|
||||
QFont font;
|
||||
font.setPointSize(font.pointSize() + 4);
|
||||
font.setBold(true);
|
||||
@@ -215,6 +226,7 @@ bool DatabaseOpenWidget::event(QEvent* event)
|
||||
}
|
||||
|
||||
if (isVisible()) {
|
||||
m_fileExistsTimer.start();
|
||||
m_hideTimer.stop();
|
||||
pollHardwareKey();
|
||||
}
|
||||
@@ -226,6 +238,8 @@ bool DatabaseOpenWidget::event(QEvent* event)
|
||||
m_hideTimer.start();
|
||||
}
|
||||
|
||||
m_fileExistsTimer.stop();
|
||||
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
if (type == QEvent::Hide) {
|
||||
m_deviceListener->deregisterAllHotplugCallbacks();
|
||||
@@ -257,12 +271,7 @@ void DatabaseOpenWidget::load(const QString& filename)
|
||||
// Read public headers
|
||||
QString error;
|
||||
m_db.reset(new Database());
|
||||
bool openSuccess = m_db->open(m_filename, nullptr, &error);
|
||||
|
||||
// If opening failed (e.g., file doesn't exist), show an informative message
|
||||
if (!openSuccess && !error.isEmpty()) {
|
||||
m_ui->messageWidget->showMessage(error, MessageWidget::MessageType::Warning);
|
||||
}
|
||||
m_db->open(m_filename, nullptr, &error);
|
||||
|
||||
m_ui->fileNameLabel->setRawText(m_filename);
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ private:
|
||||
bool m_triedToQuit = false;
|
||||
QTimer m_hideTimer;
|
||||
QTimer m_hideNoHardwareKeysFoundTimer;
|
||||
QTimer m_fileExistsTimer;
|
||||
|
||||
Q_DISABLE_COPY(DatabaseOpenWidget)
|
||||
};
|
||||
|
||||
@@ -163,26 +163,31 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
|
||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||
|
||||
if (canonicalFilePath.isEmpty()) {
|
||||
// Don't return early - continue to show unlock dialog even if file is missing
|
||||
// This allows user to retry when file becomes available (e.g., cloud storage mounting)
|
||||
emit messageGlobal(tr("Failed to open %1. It either does not exist or is not accessible.").arg(cleanFilePath),
|
||||
MessageWidget::Error);
|
||||
canonicalFilePath = cleanFilePath; // Use the original path for comparison
|
||||
// The file does not exist, revert back to the cleaned path for comparison
|
||||
canonicalFilePath = cleanFilePath;
|
||||
}
|
||||
|
||||
// Try to find an existing tab with the same file path
|
||||
for (int i = 0, c = count(); i < c; ++i) {
|
||||
auto* dbWidget = databaseWidgetFromIndex(i);
|
||||
Q_ASSERT(dbWidget);
|
||||
if (dbWidget
|
||||
&& dbWidget->database()->canonicalFilePath().compare(canonicalFilePath, FILE_CASE_SENSITIVE) == 0) {
|
||||
if (dbWidget) {
|
||||
auto dbFilePath = dbWidget->database()->canonicalFilePath();
|
||||
if (dbFilePath.isEmpty()) {
|
||||
// The file does not exist, revert back to the cleaned path for comparison
|
||||
dbFilePath = QDir::toNativeSeparators(dbWidget->database()->filePath());
|
||||
}
|
||||
if (dbFilePath.compare(canonicalFilePath, FILE_CASE_SENSITIVE) == 0) {
|
||||
// Attempt to unlock the database if password and/or keyfile is provided
|
||||
dbWidget->performUnlockDatabase(password, keyfile);
|
||||
if (!inBackground) {
|
||||
// switch to existing tab if file is already open
|
||||
setCurrentIndex(indexOf(dbWidget));
|
||||
}
|
||||
// Prevent opening a new tab for this file
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto* dbWidget = new DatabaseWidget(QSharedPointer<Database>::create(cleanFilePath), this);
|
||||
addDatabaseTab(dbWidget, inBackground);
|
||||
|
||||
@@ -714,7 +714,7 @@ void MainWindow::restoreConfigState()
|
||||
if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
|
||||
const QStringList fileNames = config()->get(Config::LastOpenedDatabases).toStringList();
|
||||
for (const QString& filename : fileNames) {
|
||||
if (!filename.isEmpty() && QFile::exists(filename)) {
|
||||
if (!filename.isEmpty()) {
|
||||
openDatabase(filename);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user