Disable entry level Auto-Type

This commit is contained in:
varjolintu 2023-07-29 09:20:47 +03:00 committed by Jonathan White
parent b8f9ac85ec
commit 3f78e5f7a2
8 changed files with 58 additions and 11 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -205,6 +205,11 @@ bool Entry::autoTypeEnabled() const
return m_data.autoTypeEnabled;
}
bool Entry::groupAutoTypeEnabled() const
{
return group() && group()->resolveAutoTypeEnabled();
}
int Entry::autoTypeObfuscation() const
{
return m_data.autoTypeObfuscation;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -91,6 +91,7 @@ public:
QStringList tagList() const;
const TimeInfo& timeInfo() const;
bool autoTypeEnabled() const;
bool groupAutoTypeEnabled() const;
int autoTypeObfuscation() const;
QString defaultAutoTypeSequence() const;
QString effectiveAutoTypeSequence() const;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1977,6 +1977,16 @@ bool DatabaseWidget::currentEntryHasNotes()
return !currentEntry->resolveMultiplePlaceholders(currentEntry->notes()).isEmpty();
}
bool DatabaseWidget::currentEntryHasAutoTypeEnabled()
{
auto currentEntry = currentSelectedEntry();
if (!currentEntry) {
return false;
}
return currentEntry->autoTypeEnabled() && currentEntry->groupAutoTypeEnabled();
}
GroupView* DatabaseWidget::groupView()
{
return m_groupView;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -116,6 +116,7 @@ public:
#ifdef WITH_XC_SSHAGENT
bool currentEntryHasSshKey();
#endif
bool currentEntryHasAutoTypeEnabled();
QByteArray entryViewState() const;
bool setEntryViewState(const QByteArray& state) const;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -468,7 +468,9 @@ void EntryPreviewWidget::updateEntryAutotypeTab()
}
m_ui->entryAutotypeTree->addTopLevelItems(items);
setTabEnabled(m_ui->entryTabWidget, m_ui->entryAutotypeTab, m_currentEntry->autoTypeEnabled());
setTabEnabled(m_ui->entryTabWidget,
m_ui->entryAutotypeTab,
m_currentEntry->autoTypeEnabled() && m_currentEntry->groupAutoTypeEnabled());
}
void EntryPreviewWidget::updateGroupHeaderLine()

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -929,8 +929,9 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->menuEntryCopyAttribute->setEnabled(singleEntrySelected);
m_ui->menuEntryTotp->setEnabled(singleEntrySelected);
m_ui->menuTags->setEnabled(entriesSelected);
m_ui->actionEntryAutoType->setEnabled(singleEntrySelected);
m_ui->actionEntryAutoType->menu()->setEnabled(singleEntrySelected);
m_ui->actionEntryAutoType->setEnabled(singleEntrySelected && dbWidget->currentEntryHasAutoTypeEnabled());
m_ui->actionEntryAutoType->menu()->setEnabled(singleEntrySelected
&& dbWidget->currentEntryHasAutoTypeEnabled());
m_ui->actionEntryAutoTypeSequence->setText(
singleEntrySelected ? dbWidget->currentSelectedEntry()->effectiveAutoTypeSequence()
: Group::RootAutoTypeSequence);

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1293,3 +1293,29 @@ void TestGroup::testPreviousParentGroup()
QVERIFY(group1->previousParentGroupUuid() == group2->uuid());
QVERIFY(group1->previousParentGroup() == group2);
}
void TestGroup::testAutoTypeState()
{
Database db;
auto* root = db.rootGroup();
auto* entry1 = new Entry();
entry1->setGroup(root);
auto subGroup = new Group();
subGroup->setParent(root);
auto* entry2 = new Entry();
entry2->setGroup(subGroup);
// Disable Auto-Type from root group
root->setAutoTypeEnabled(Group::TriState::Disable);
QVERIFY(!entry1->groupAutoTypeEnabled());
QVERIFY(!entry2->groupAutoTypeEnabled());
// Enable Auto-Type for sub group
subGroup->setAutoTypeEnabled(Group::TriState::Enable);
QVERIFY(root->autoTypeEnabled() == Group::TriState::Disable);
QVERIFY(subGroup->autoTypeEnabled() == Group::TriState::Enable);
QVERIFY(!entry1->groupAutoTypeEnabled());
QVERIFY(entry2->groupAutoTypeEnabled());
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +49,7 @@ private slots:
void testUsernamesRecursive();
void testMoveUpDown();
void testPreviousParentGroup();
void testAutoTypeState();
};
#endif // KEEPASSX_TESTGROUP_H