mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-27 01:56:32 -05:00
Merge branch 'develop' into middle-mouse-click-status-icon
This commit is contained in:
commit
e9dd6e6c90
80 changed files with 14475 additions and 7097 deletions
|
|
@ -59,16 +59,16 @@ AboutDialog::AboutDialog(QWidget* parent)
|
|||
}
|
||||
|
||||
debugInfo.append(QString("%1\n- Qt %2\n- %3\n\n")
|
||||
.arg(tr("Libraries:"))
|
||||
.arg(QString::fromLocal8Bit(qVersion()))
|
||||
.arg(Crypto::backendVersion()));
|
||||
.arg(tr("Libraries:"),
|
||||
QString::fromLocal8Bit(qVersion()),
|
||||
Crypto::backendVersion()));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
debugInfo.append(tr("Operating system: %1\nCPU architecture: %2\nKernel: %3 %4")
|
||||
.arg(QSysInfo::prettyProductName())
|
||||
.arg(QSysInfo::currentCpuArchitecture())
|
||||
.arg(QSysInfo::kernelType())
|
||||
.arg(QSysInfo::kernelVersion()));
|
||||
.arg(QSysInfo::prettyProductName(),
|
||||
QSysInfo::currentCpuArchitecture(),
|
||||
QSysInfo::kernelType(),
|
||||
QSysInfo::kernelVersion()));
|
||||
|
||||
debugInfo.append("\n\n");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,14 +2,6 @@
|
|||
<ui version="4.0">
|
||||
<class>AboutDialog</class>
|
||||
<widget class="QDialog" name="AboutDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>652</width>
|
||||
<height>516</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About KeePassXC</string>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ Application::Application(int& argc, char** argv)
|
|||
#ifdef Q_OS_UNIX
|
||||
, m_unixSignalNotifier(nullptr)
|
||||
#endif
|
||||
, alreadyRunning(false)
|
||||
, lock(nullptr)
|
||||
, m_alreadyRunning(false)
|
||||
, m_lockFile(nullptr)
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
|
||||
installNativeEventFilter(new XcbEventFilter());
|
||||
|
|
@ -99,56 +99,72 @@ Application::Application(int& argc, char** argv)
|
|||
}
|
||||
QString identifier = "keepassxc";
|
||||
if (!userName.isEmpty()) {
|
||||
identifier.append("-");
|
||||
identifier.append(userName);
|
||||
#ifdef QT_DEBUG
|
||||
// In DEBUG mode don't interfere with Release instances
|
||||
identifier.append("-DEBUG");
|
||||
#endif
|
||||
identifier += "-" + userName;
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
// In DEBUG mode don't interfere with Release instances
|
||||
identifier += "-DEBUG";
|
||||
#endif
|
||||
QString socketName = identifier + ".socket";
|
||||
QString lockName = identifier + ".lock";
|
||||
|
||||
// According to documentation we should use RuntimeLocation on *nixes, but even Qt doesn't respect
|
||||
// this and creates sockets in TempLocation, so let's be consistent.
|
||||
lock = new QLockFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + lockName);
|
||||
lock->setStaleLockTime(0);
|
||||
lock->tryLock();
|
||||
switch (lock->error()) {
|
||||
m_lockFile = new QLockFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + lockName);
|
||||
m_lockFile->setStaleLockTime(0);
|
||||
m_lockFile->tryLock();
|
||||
|
||||
switch (m_lockFile->error()) {
|
||||
case QLockFile::NoError:
|
||||
server.setSocketOptions(QLocalServer::UserAccessOption);
|
||||
server.listen(socketName);
|
||||
connect(&server, SIGNAL(newConnection()), this, SIGNAL(anotherInstanceStarted()));
|
||||
// No existing lock was found, start listener
|
||||
m_lockServer.setSocketOptions(QLocalServer::UserAccessOption);
|
||||
m_lockServer.listen(socketName);
|
||||
connect(&m_lockServer, SIGNAL(newConnection()), this, SIGNAL(anotherInstanceStarted()));
|
||||
break;
|
||||
case QLockFile::LockFailedError: {
|
||||
alreadyRunning = true;
|
||||
// notify the other instance
|
||||
// try several times, in case the other instance is still starting up
|
||||
if (config()->get("SingleInstance").toBool()) {
|
||||
// Attempt to connect to the existing instance
|
||||
QLocalSocket client;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
client.connectToServer(socketName);
|
||||
if (client.waitForConnected(150)) {
|
||||
// Connection succeeded, this will raise the existing window if minimized
|
||||
client.abort();
|
||||
m_alreadyRunning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_alreadyRunning) {
|
||||
// If we get here then the original instance is likely dead
|
||||
qWarning() << QCoreApplication::translate("Main",
|
||||
"Existing single-instance lock file is invalid. Launching new instance.")
|
||||
.toUtf8().constData();
|
||||
|
||||
// forceably reset the lock file
|
||||
m_lockFile->removeStaleLockFile();
|
||||
m_lockFile->tryLock();
|
||||
// start the listen server
|
||||
m_lockServer.setSocketOptions(QLocalServer::UserAccessOption);
|
||||
m_lockServer.listen(socketName);
|
||||
connect(&m_lockServer, SIGNAL(newConnection()), this, SIGNAL(anotherInstanceStarted()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << QCoreApplication::translate("Main",
|
||||
"The lock file could not be created. Single-instance mode disabled.")
|
||||
.toUtf8().constData();
|
||||
"The lock file could not be created. Single-instance mode disabled.")
|
||||
.toUtf8().constData();
|
||||
}
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
server.close();
|
||||
if (lock) {
|
||||
lock->unlock();
|
||||
delete lock;
|
||||
m_lockServer.close();
|
||||
if (m_lockFile) {
|
||||
m_lockFile->unlock();
|
||||
delete m_lockFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -243,6 +259,6 @@ bool Application::isAlreadyRunning() const
|
|||
// In DEBUG mode we can run unlimited instances
|
||||
return false;
|
||||
#endif
|
||||
return config()->get("SingleInstance").toBool() && alreadyRunning;
|
||||
return config()->get("SingleInstance").toBool() && m_alreadyRunning;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ private:
|
|||
static void handleUnixSignal(int sig);
|
||||
static int unixSignalSocket[2];
|
||||
#endif
|
||||
bool alreadyRunning;
|
||||
QLockFile* lock;
|
||||
QLocalServer server;
|
||||
bool m_alreadyRunning;
|
||||
QLockFile* m_lockFile;
|
||||
QLocalServer m_lockServer;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_APPLICATION_H
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void CloneDialog::cloneEntry()
|
|||
Entry* entry = m_entry->clone(flags);
|
||||
entry->setGroup(m_entry->group());
|
||||
|
||||
emit m_parent->refreshSearch();
|
||||
m_parent->refreshSearch();
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,18 @@ void DatabaseOpenWidget::load(const QString& filename)
|
|||
m_ui->editPassword->setFocus();
|
||||
}
|
||||
|
||||
void DatabaseOpenWidget::clearForms()
|
||||
{
|
||||
m_ui->editPassword->clear();
|
||||
m_ui->comboKeyFile->clear();
|
||||
m_ui->checkPassword->setChecked(false);
|
||||
m_ui->checkKeyFile->setChecked(false);
|
||||
m_ui->checkChallengeResponse->setChecked(false);
|
||||
m_ui->buttonTogglePassword->setChecked(false);
|
||||
m_db = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Database* DatabaseOpenWidget::database()
|
||||
{
|
||||
return m_db;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
explicit DatabaseOpenWidget(QWidget* parent = nullptr);
|
||||
~DatabaseOpenWidget();
|
||||
void load(const QString& filename);
|
||||
void clearForms();
|
||||
void enterKey(const QString& pw, const QString& keyFile);
|
||||
Database* database();
|
||||
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
|
|||
lockFile->tryLock();
|
||||
}
|
||||
} else {
|
||||
delete lockFile;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -363,6 +364,8 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||
emit messageDismissTab();
|
||||
return true;
|
||||
} else {
|
||||
dbStruct.modified = true;
|
||||
updateTabName(db);
|
||||
emit messageTab(tr("Writing the database failed.").append("\n").append(errorMessage),
|
||||
MessageWidget::Error);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -813,6 +813,7 @@ void DatabaseWidget::mergeDatabase(bool accepted)
|
|||
m_db->merge(srcDb);
|
||||
}
|
||||
|
||||
m_databaseOpenMergeWidget->clearForms();
|
||||
setCurrentWidget(m_mainWidget);
|
||||
emit databaseMerged(m_db);
|
||||
}
|
||||
|
|
@ -918,6 +919,7 @@ void DatabaseWidget::switchToImportCsv(const QString& fileName)
|
|||
|
||||
void DatabaseWidget::switchToOpenMergeDatabase(const QString& fileName)
|
||||
{
|
||||
m_databaseOpenMergeWidget->clearForms();
|
||||
m_databaseOpenMergeWidget->load(fileName);
|
||||
setCurrentWidget(m_databaseOpenMergeWidget);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
|
|||
this, SLOT(updateWidgetsDefaultIcons(bool)));
|
||||
connect(m_ui->customIconsRadio, SIGNAL(toggled(bool)),
|
||||
this, SLOT(updateWidgetsCustomIcons(bool)));
|
||||
connect(m_ui->addButton, SIGNAL(clicked()), SLOT(addCustomIcon()));
|
||||
connect(m_ui->addButton, SIGNAL(clicked()), SLOT(addCustomIconFromFile()));
|
||||
connect(m_ui->deleteButton, SIGNAL(clicked()), SLOT(removeCustomIcon()));
|
||||
connect(m_ui->faviconButton, SIGNAL(clicked()), SLOT(downloadFavicon()));
|
||||
|
||||
|
|
@ -185,15 +185,7 @@ void EditWidgetIcons::fetchFavicon(const QUrl& url)
|
|||
image.loadFromData(response->collectedData());
|
||||
|
||||
if (!image.isNull()) {
|
||||
//Set the image
|
||||
Uuid uuid = Uuid::random();
|
||||
m_database->metadata()->addCustomIcon(uuid, image.scaled(16, 16));
|
||||
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||
m_database->metadata()->customIconsOrder());
|
||||
QModelIndex index = m_customIconModel->indexFromUuid(uuid);
|
||||
m_ui->customIconsView->setCurrentIndex(index);
|
||||
m_ui->customIconsRadio->setChecked(true);
|
||||
|
||||
addCustomIcon(image);
|
||||
resetFaviconDownload();
|
||||
} else {
|
||||
fetchFaviconFromGoogle(url.host());
|
||||
|
|
@ -226,7 +218,9 @@ void EditWidgetIcons::fetchFavicon(const QUrl& url)
|
|||
QUrl tempurl = QUrl(m_url);
|
||||
if (tempurl.scheme() == "http") {
|
||||
resetFaviconDownload();
|
||||
MessageBox::warning(this, tr("Error"), tr("Unable to fetch favicon.") + "\n" + tr("Hint: You can enable Google as a fallback under Tools>Settings>Security"));
|
||||
emit messageEditEntry(tr("Unable to fetch favicon.") + "\n" +
|
||||
tr("Hint: You can enable Google as a fallback under Tools>Settings>Security"),
|
||||
MessageWidget::Error);
|
||||
} else {
|
||||
tempurl.setScheme("http");
|
||||
m_url = tempurl.url();
|
||||
|
|
@ -248,7 +242,7 @@ void EditWidgetIcons::fetchFaviconFromGoogle(const QString& domain)
|
|||
fetchFavicon(faviconUrl);
|
||||
} else {
|
||||
resetFaviconDownload();
|
||||
MessageBox::warning(this, tr("Error"), tr("Unable to fetch favicon."));
|
||||
emit messageEditEntry(tr("Unable to fetch favicon."), MessageWidget::Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +263,7 @@ void EditWidgetIcons::resetFaviconDownload(bool clearRedirect)
|
|||
}
|
||||
#endif
|
||||
|
||||
void EditWidgetIcons::addCustomIcon()
|
||||
void EditWidgetIcons::addCustomIconFromFile()
|
||||
{
|
||||
if (m_database) {
|
||||
QString filter = QString("%1 (%2);;%3 (*)").arg(tr("Images"),
|
||||
|
|
@ -278,22 +272,41 @@ void EditWidgetIcons::addCustomIcon()
|
|||
QString filename = QFileDialog::getOpenFileName(
|
||||
this, tr("Select Image"), "", filter);
|
||||
if (!filename.isEmpty()) {
|
||||
QImage image(filename);
|
||||
if (!image.isNull()) {
|
||||
Uuid uuid = Uuid::random();
|
||||
m_database->metadata()->addCustomIcon(uuid, image.scaled(16, 16));
|
||||
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||
m_database->metadata()->customIconsOrder());
|
||||
QModelIndex index = m_customIconModel->indexFromUuid(uuid);
|
||||
m_ui->customIconsView->setCurrentIndex(index);
|
||||
}
|
||||
else {
|
||||
auto icon = QImage(filename);
|
||||
if (!icon.isNull()) {
|
||||
addCustomIcon(QImage(filename));
|
||||
} else {
|
||||
emit messageEditEntry(tr("Can't read icon"), MessageWidget::Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditWidgetIcons::addCustomIcon(const QImage &icon)
|
||||
{
|
||||
if (m_database) {
|
||||
Uuid uuid = m_database->metadata()->findCustomIcon(icon);
|
||||
if (uuid.isNull()) {
|
||||
uuid = Uuid::random();
|
||||
// Don't add an icon larger than 128x128, but retain original size if smaller
|
||||
if (icon.width() > 128 || icon.height() > 128) {
|
||||
m_database->metadata()->addCustomIcon(uuid, icon.scaled(128, 128));
|
||||
} else {
|
||||
m_database->metadata()->addCustomIcon(uuid, icon);
|
||||
}
|
||||
|
||||
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||
m_database->metadata()->customIconsOrder());
|
||||
} else {
|
||||
emit messageEditEntry(tr("Custom icon already exists"), MessageWidget::Information);
|
||||
}
|
||||
|
||||
// Select the new or existing icon
|
||||
QModelIndex index = m_customIconModel->indexFromUuid(uuid);
|
||||
m_ui->customIconsView->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void EditWidgetIcons::removeCustomIcon()
|
||||
{
|
||||
if (m_database) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ private slots:
|
|||
void fetchFaviconFromGoogle(const QString& domain);
|
||||
void resetFaviconDownload(bool clearRedirect = true);
|
||||
#endif
|
||||
void addCustomIcon();
|
||||
void addCustomIconFromFile();
|
||||
void addCustomIcon(const QImage& icon);
|
||||
void removeCustomIcon();
|
||||
void updateWidgetsDefaultIcons(bool checked);
|
||||
void updateWidgetsCustomIcons(bool checked);
|
||||
|
|
|
|||
|
|
@ -228,6 +228,15 @@ void SettingsWidget::saveSettings()
|
|||
config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
|
||||
config()->set("security/passwordsrepeat", m_secUi->passwordRepeatCheckBox->isChecked());
|
||||
|
||||
// Security: clear storage if related settings are disabled
|
||||
if (!config()->get("RememberLastDatabases").toBool()) {
|
||||
config()->set("LastDatabases", QVariant());
|
||||
}
|
||||
|
||||
if (!config()->get("RememberLastKeyFiles").toBool()) {
|
||||
config()->set("LastKeyFiles", QVariant());
|
||||
}
|
||||
|
||||
for (const ExtraPage& page: asConst(m_extraPages)) {
|
||||
page.saveSettings();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,3 @@ UnlockDatabaseWidget::UnlockDatabaseWidget(QWidget* parent)
|
|||
{
|
||||
m_ui->labelHeadline->setText(tr("Unlock database"));
|
||||
}
|
||||
|
||||
void UnlockDatabaseWidget::clearForms()
|
||||
{
|
||||
m_ui->editPassword->clear();
|
||||
m_ui->comboKeyFile->clear();
|
||||
m_ui->checkPassword->setChecked(false);
|
||||
m_ui->checkKeyFile->setChecked(false);
|
||||
m_ui->checkChallengeResponse->setChecked(false);
|
||||
m_ui->buttonTogglePassword->setChecked(false);
|
||||
m_db = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class UnlockDatabaseWidget : public DatabaseOpenWidget
|
|||
|
||||
public:
|
||||
explicit UnlockDatabaseWidget(QWidget* parent = nullptr);
|
||||
void clearForms();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_UNLOCKDATABASEWIDGET_H
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void CsvImportWizard::load(const QString& filename, Database* database)
|
|||
void CsvImportWizard::keyFinished(bool accepted)
|
||||
{
|
||||
if (!accepted) {
|
||||
emit(importFinished(false));
|
||||
emit importFinished(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -68,11 +68,11 @@ void CsvImportWizard::keyFinished(bool accepted)
|
|||
|
||||
if (!result) {
|
||||
MessageBox::critical(this, tr("Error"), tr("Unable to calculate master key"));
|
||||
emit(importFinished(false));
|
||||
emit importFinished(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CsvImportWizard::parseFinished(bool accepted)
|
||||
{
|
||||
emit(importFinished(accepted));
|
||||
emit importFinished(accepted);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,6 +429,7 @@ void EditEntryWidget::saveEntry()
|
|||
// must stand before beginUpdate()
|
||||
// we don't want to create a new history item, if only the history has changed
|
||||
m_entry->removeHistoryItems(m_historyModel->deletedEntries());
|
||||
m_historyModel->clearDeletedEntries();
|
||||
|
||||
m_autoTypeAssoc->removeEmpty();
|
||||
|
||||
|
|
@ -445,6 +446,12 @@ void EditEntryWidget::saveEntry()
|
|||
|
||||
void EditEntryWidget::acceptEntry()
|
||||
{
|
||||
// Check if passwords are mismatched first to prevent saving
|
||||
if (!passwordsEqual()) {
|
||||
showMessage(tr("Different passwords supplied."), MessageWidget::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
saveEntry();
|
||||
clear();
|
||||
emit editFinished(true);
|
||||
|
|
@ -912,8 +919,7 @@ void EditEntryWidget::deleteHistoryEntry()
|
|||
m_historyModel->deleteIndex(index);
|
||||
if (m_historyModel->rowCount() > 0) {
|
||||
m_historyUi->deleteAllButton->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m_historyUi->deleteAllButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ void EntryHistoryModel::clear()
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
void EntryHistoryModel::clearDeletedEntries()
|
||||
{
|
||||
m_deletedHistoryEntries.clear();
|
||||
}
|
||||
|
||||
QList<Entry*> EntryHistoryModel::deletedEntries()
|
||||
{
|
||||
return m_deletedHistoryEntries;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
void setEntries(const QList<Entry*>& entries);
|
||||
void clear();
|
||||
void clearDeletedEntries();
|
||||
QList<Entry*> deletedEntries();
|
||||
void deleteIndex(QModelIndex index);
|
||||
void deleteAll();
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||
}
|
||||
return result;
|
||||
case Url:
|
||||
result = entry->resolveMultiplePlaceholders(entry->url());
|
||||
result = entry->maskPasswordPlaceholders(entry->url());
|
||||
result = entry->resolveMultiplePlaceholders(result);
|
||||
if (attr->isReference(EntryAttributes::URLKey)) {
|
||||
result.prepend(tr("Ref: ","Reference abbreviation"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue