mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-12 07:49:55 -05:00
Add "Apply" button to entry and group edit windows (#624)
This commit is contained in:
parent
107684e393
commit
6ffca842e6
@ -18,6 +18,7 @@
|
|||||||
#include "EditWidget.h"
|
#include "EditWidget.h"
|
||||||
#include "ui_EditWidget.h"
|
#include "ui_EditWidget.h"
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "core/FilePath.h"
|
#include "core/FilePath.h"
|
||||||
|
|
||||||
@ -102,7 +103,10 @@ void EditWidget::setReadOnly(bool readOnly)
|
|||||||
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
|
||||||
|
// Find and connect the apply button
|
||||||
|
QPushButton* applyButton = m_ui->buttonBox->button(QDialogButtonBox::Apply);
|
||||||
|
connect(applyButton, SIGNAL(clicked()), SIGNAL(apply()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
bool readOnly() const;
|
bool readOnly() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void apply();
|
||||||
void accepted();
|
void accepted();
|
||||||
void rejected();
|
void rejected();
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -75,8 +75,9 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
|||||||
setupProperties();
|
setupProperties();
|
||||||
setupHistory();
|
setupHistory();
|
||||||
|
|
||||||
connect(this, SIGNAL(accepted()), SLOT(saveEntry()));
|
connect(this, SIGNAL(accepted()), SLOT(acceptEntry()));
|
||||||
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
||||||
|
connect(this, SIGNAL(apply()), SLOT(saveEntry()));
|
||||||
connect(m_iconsWidget, SIGNAL(messageEditEntry(QString, MessageWidget::MessageType)), SLOT(showMessage(QString, MessageWidget::MessageType)));
|
connect(m_iconsWidget, SIGNAL(messageEditEntry(QString, MessageWidget::MessageType)), SLOT(showMessage(QString, MessageWidget::MessageType)));
|
||||||
connect(m_iconsWidget, SIGNAL(messageEditEntryDismiss()), SLOT(hideMessage()));
|
connect(m_iconsWidget, SIGNAL(messageEditEntryDismiss()), SLOT(hideMessage()));
|
||||||
|
|
||||||
@ -439,9 +440,12 @@ void EditEntryWidget::saveEntry()
|
|||||||
if (!m_create) {
|
if (!m_create) {
|
||||||
m_entry->endUpdate();
|
m_entry->endUpdate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditEntryWidget::acceptEntry()
|
||||||
|
{
|
||||||
|
saveEntry();
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
emit editFinished(true);
|
emit editFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ signals:
|
|||||||
void historyEntryActivated(Entry* entry);
|
void historyEntryActivated(Entry* entry);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void acceptEntry();
|
||||||
void saveEntry();
|
void saveEntry();
|
||||||
void cancel();
|
void cancel();
|
||||||
void togglePasswordGeneratorButton(bool checked);
|
void togglePasswordGeneratorButton(bool checked);
|
||||||
|
@ -42,6 +42,7 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
|
|||||||
connect(m_mainUi->autoTypeSequenceCustomRadio, SIGNAL(toggled(bool)),
|
connect(m_mainUi->autoTypeSequenceCustomRadio, SIGNAL(toggled(bool)),
|
||||||
m_mainUi->autoTypeSequenceCustomEdit, SLOT(setEnabled(bool)));
|
m_mainUi->autoTypeSequenceCustomEdit, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(apply()), SLOT(apply()));
|
||||||
connect(this, SIGNAL(accepted()), SLOT(save()));
|
connect(this, SIGNAL(accepted()), SLOT(save()));
|
||||||
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
||||||
|
|
||||||
@ -101,6 +102,13 @@ void EditGroupWidget::loadGroup(Group* group, bool create, Database* database)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditGroupWidget::save()
|
void EditGroupWidget::save()
|
||||||
|
{
|
||||||
|
apply();
|
||||||
|
clear();
|
||||||
|
emit editFinished(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditGroupWidget::apply()
|
||||||
{
|
{
|
||||||
m_group->setName(m_mainUi->editName->text());
|
m_group->setName(m_mainUi->editName->text());
|
||||||
m_group->setNotes(m_mainUi->editNotes->toPlainText());
|
m_group->setNotes(m_mainUi->editNotes->toPlainText());
|
||||||
@ -128,9 +136,6 @@ void EditGroupWidget::save()
|
|||||||
else {
|
else {
|
||||||
m_group->setIcon(iconStruct.uuid);
|
m_group->setIcon(iconStruct.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
|
||||||
emit editFinished(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditGroupWidget::cancel()
|
void EditGroupWidget::cancel()
|
||||||
|
@ -49,6 +49,7 @@ signals:
|
|||||||
void messageEditEntryDismiss();
|
void messageEditEntryDismiss();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void apply();
|
||||||
void save();
|
void save();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
|
@ -230,6 +230,7 @@ void TestGui::testEditEntry()
|
|||||||
// Select the first entry in the database
|
// Select the first entry in the database
|
||||||
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
||||||
QModelIndex entryItem = entryView->model()->index(0, 1);
|
QModelIndex entryItem = entryView->model()->index(0, 1);
|
||||||
|
Entry* entry = entryView->entryFromIndex(entryItem);
|
||||||
clickIndex(entryItem, entryView, Qt::LeftButton);
|
clickIndex(entryItem, entryView, Qt::LeftButton);
|
||||||
|
|
||||||
// Confirm the edit action button is enabled
|
// Confirm the edit action button is enabled
|
||||||
@ -246,6 +247,13 @@ void TestGui::testEditEntry()
|
|||||||
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
|
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
|
||||||
QTest::keyClicks(titleEdit, "_test");
|
QTest::keyClicks(titleEdit, "_test");
|
||||||
|
|
||||||
|
// Apply the edit
|
||||||
|
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||||
|
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
|
||||||
|
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
||||||
|
QCOMPARE(entry->historyItems().size(), 1);
|
||||||
|
|
||||||
// Test protected attributes
|
// Test protected attributes
|
||||||
editEntryWidget->setCurrentPage(1);
|
editEntryWidget->setCurrentPage(1);
|
||||||
QPlainTextEdit* attrTextEdit = editEntryWidget->findChild<QPlainTextEdit*>("attributesEdit");
|
QPlainTextEdit* attrTextEdit = editEntryWidget->findChild<QPlainTextEdit*>("attributesEdit");
|
||||||
@ -259,15 +267,13 @@ void TestGui::testEditEntry()
|
|||||||
QCOMPARE(attrTextEdit->toPlainText(), attrText);
|
QCOMPARE(attrTextEdit->toPlainText(), attrText);
|
||||||
editEntryWidget->setCurrentPage(0);
|
editEntryWidget->setCurrentPage(0);
|
||||||
|
|
||||||
// Save the edit
|
// Save the edit (press OK)
|
||||||
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
|
||||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
|
||||||
// Confirm edit was made
|
// Confirm edit was made
|
||||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
|
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
|
||||||
Entry* entry = entryView->entryFromIndex(entryItem);
|
|
||||||
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
||||||
QCOMPARE(entry->historyItems().size(), 1);
|
QCOMPARE(entry->historyItems().size(), 2);
|
||||||
|
|
||||||
// Confirm modified indicator is showing
|
// Confirm modified indicator is showing
|
||||||
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_dbFileName));
|
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_dbFileName));
|
||||||
|
Loading…
Reference in New Issue
Block a user