mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-28 09:14:18 -04:00
Merge branch '2.0'
This commit is contained in:
commit
c78822f6e6
12 changed files with 120 additions and 14 deletions
|
@ -384,14 +384,22 @@ bool AutoTypePlatformX11::isTopLevelWindow(Window window)
|
|||
int format;
|
||||
unsigned long nitems;
|
||||
unsigned long after;
|
||||
unsigned char* data = nullptr;
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 0, False, AnyPropertyType, &type, &format,
|
||||
unsigned char* data = Q_NULLPTR;
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 2, False, m_atomWmState, &type, &format,
|
||||
&nitems, &after, &data);
|
||||
if (data) {
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (retVal == 0 && data) {
|
||||
if (type == m_atomWmState && format == 32 && nitems > 0) {
|
||||
qint32 state = static_cast<qint32>(*data);
|
||||
result = (state != WithdrawnState);
|
||||
}
|
||||
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
return (retVal == 0) && type;
|
||||
return result;
|
||||
}
|
||||
|
||||
KeySym AutoTypePlatformX11::charToKeySym(const QChar& ch)
|
||||
|
|
|
@ -371,7 +371,6 @@ const QList<Entry*>& Entry::historyItems() const
|
|||
void Entry::addHistoryItem(Entry* entry)
|
||||
{
|
||||
Q_ASSERT(!entry->parent());
|
||||
Q_ASSERT(entry->uuid() == uuid());
|
||||
|
||||
m_history.append(entry);
|
||||
Q_EMIT modified();
|
||||
|
|
|
@ -192,7 +192,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
QByteArray headerHash = CryptoHash::hash(headerStream.storedData(), CryptoHash::Sha256);
|
||||
if (headerHash != xmlReader.headerHash()) {
|
||||
raiseError("Header doesn't match hash");
|
||||
return nullptr;
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -778,6 +778,13 @@ Entry* KeePass2XmlReader::parseEntry(bool history)
|
|||
}
|
||||
|
||||
Q_FOREACH (Entry* historyItem, historyItems) {
|
||||
if (historyItem->uuid() != entry->uuid()) {
|
||||
if (m_strictMode) {
|
||||
raiseError("History element with different uuid");
|
||||
} else {
|
||||
historyItem->setUuid(entry->uuid());
|
||||
}
|
||||
}
|
||||
entry->addHistoryItem(historyItem);
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||
|
||||
if (dbStruct.saveToFilename) {
|
||||
QSaveFile saveFile(dbStruct.filePath);
|
||||
QSaveFile saveFile(dbStruct.canonicalFilePath);
|
||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||
m_writer.writeDatabase(&saveFile, db);
|
||||
if (m_writer.hasError()) {
|
||||
|
@ -310,6 +310,11 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
dbStruct.modified = false;
|
||||
updateTabName(db);
|
||||
|
|
|
@ -493,7 +493,9 @@ void DatabaseWidget::deleteGroup()
|
|||
}
|
||||
|
||||
bool inRecylceBin = Tools::hasChild(m_db->metadata()->recycleBin(), currentGroup);
|
||||
if (inRecylceBin || !m_db->metadata()->recycleBinEnabled()) {
|
||||
bool isRecycleBin = (currentGroup == m_db->metadata()->recycleBin());
|
||||
bool isRecycleBinSubgroup = Tools::hasChild(currentGroup, m_db->metadata()->recycleBin());
|
||||
if (inRecylceBin || isRecycleBin || isRecycleBinSubgroup || !m_db->metadata()->recycleBinEnabled()) {
|
||||
QMessageBox::StandardButton result = MessageBox::question(
|
||||
this, tr("Delete group?"),
|
||||
tr("Do you really want to delete the group \"%1\" for good?")
|
||||
|
@ -871,8 +873,7 @@ bool DatabaseWidget::dbHasKey() const
|
|||
bool DatabaseWidget::canDeleteCurrentGroup() const
|
||||
{
|
||||
bool isRootGroup = m_db->rootGroup() == m_groupView->currentGroup();
|
||||
bool isRecycleBin = m_db->metadata()->recycleBin() == m_groupView->currentGroup();
|
||||
return !isRootGroup && !isRecycleBin;
|
||||
return !isRootGroup;
|
||||
}
|
||||
|
||||
bool DatabaseWidget::isInSearchMode() const
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "ui_EditWidgetIcons.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QImageReader>
|
||||
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
|
@ -129,7 +130,10 @@ void EditWidgetIcons::addCustomIcon()
|
|||
QString filename = QFileDialog::getOpenFileName(
|
||||
this, tr("Select Image"), "", filter);
|
||||
if (!filename.isEmpty()) {
|
||||
QImage image(filename);
|
||||
QImageReader imageReader(filename);
|
||||
// detect from content, otherwise reading fails if file extension is wrong
|
||||
imageReader.setDecideFormatFromContent(true);
|
||||
QImage image = imageReader.read();
|
||||
if (!image.isNull()) {
|
||||
Uuid uuid = Uuid::random();
|
||||
m_database->metadata()->addCustomIconScaled(uuid, image);
|
||||
|
@ -139,7 +143,8 @@ void EditWidgetIcons::addCustomIcon()
|
|||
m_ui->customIconsView->setCurrentIndex(index);
|
||||
}
|
||||
else {
|
||||
// TODO: show error
|
||||
MessageBox::critical(this, tr("Error"),
|
||||
tr("Can't read icon:").append("\n").append(imageReader.errorString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,10 @@ void PasswordGeneratorWidget::sliderMoved()
|
|||
|
||||
void PasswordGeneratorWidget::spinBoxChanged()
|
||||
{
|
||||
if (m_updatingSpinBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Interlock so that we don't update twice - this causes issues as the spinbox can go higher than slider
|
||||
m_updatingSpinBox = true;
|
||||
|
||||
|
@ -161,9 +165,39 @@ PasswordGenerator::GeneratorFlags PasswordGeneratorWidget::generatorFlags()
|
|||
|
||||
void PasswordGeneratorWidget::updateGenerator()
|
||||
{
|
||||
PasswordGenerator::CharClasses classes = charClasses();
|
||||
PasswordGenerator::GeneratorFlags flags = generatorFlags();
|
||||
|
||||
int minLength = 0;
|
||||
if (flags.testFlag(PasswordGenerator::CharFromEveryGroup)) {
|
||||
if (classes.testFlag(PasswordGenerator::LowerLetters)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::UpperLetters)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::Numbers)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::SpecialCharacters)) {
|
||||
minLength++;
|
||||
}
|
||||
}
|
||||
minLength = qMax(minLength, 1);
|
||||
|
||||
if (m_ui->spinBoxLength->value() < minLength) {
|
||||
m_updatingSpinBox = true;
|
||||
m_ui->spinBoxLength->setValue(minLength);
|
||||
m_ui->sliderLength->setValue(minLength);
|
||||
m_updatingSpinBox = false;
|
||||
}
|
||||
|
||||
m_ui->spinBoxLength->setMinimum(minLength);
|
||||
m_ui->sliderLength->setMinimum(minLength);
|
||||
|
||||
m_generator->setLength(m_ui->spinBoxLength->value());
|
||||
m_generator->setCharClasses(charClasses());
|
||||
m_generator->setFlags(generatorFlags());
|
||||
m_generator->setCharClasses(classes);
|
||||
m_generator->setFlags(flags);
|
||||
|
||||
if (m_generator->isValid()) {
|
||||
QString password = m_generator->generatePassword();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue