From dc496fd1d9c6fa700ddc24a898dc7a24bd62e59a Mon Sep 17 00:00:00 2001 From: Martin Mokrejs Date: Sun, 11 Apr 2021 22:48:35 +0200 Subject: [PATCH] Better description text for Key File change dialog --- src/gui/databasekey/KeyFileEditWidget.cpp | 10 +-- src/gui/databasekey/KeyFileEditWidget.ui | 83 ++++++++++++----------- tests/gui/TestGui.cpp | 12 ++-- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/gui/databasekey/KeyFileEditWidget.cpp b/src/gui/databasekey/KeyFileEditWidget.cpp index 17348b8f9..4a183b721 100644 --- a/src/gui/databasekey/KeyFileEditWidget.cpp +++ b/src/gui/databasekey/KeyFileEditWidget.cpp @@ -40,7 +40,7 @@ KeyFileEditWidget::~KeyFileEditWidget() bool KeyFileEditWidget::addToCompositeKey(QSharedPointer key) { auto fileKey = QSharedPointer::create(); - QString fileKeyName = m_compUi->keyFileCombo->currentText(); + QString fileKeyName = m_compUi->keyFileLineEdit->text(); if (!fileKey->load(fileKeyName, nullptr)) { return false; } @@ -62,7 +62,7 @@ bool KeyFileEditWidget::validate(QString& errorMessage) const { FileKey fileKey; QString fileKeyError; - QString fileKeyName = m_compUi->keyFileCombo->currentText(); + QString fileKeyName = m_compUi->keyFileLineEdit->text(); if (!fileKey.load(fileKeyName, &fileKeyError)) { errorMessage = tr("Error loading the key file '%1'\nMessage: %2").arg(fileKeyName, fileKeyError); return false; @@ -85,7 +85,7 @@ void KeyFileEditWidget::initComponentEditWidget(QWidget* widget) { Q_UNUSED(widget); Q_ASSERT(m_compEditWidget); - m_compUi->keyFileCombo->setFocus(); + m_compUi->keyFileLineEdit->setFocus(); } void KeyFileEditWidget::initComponent() @@ -120,7 +120,7 @@ void KeyFileEditWidget::createKeyFile() tr("Unable to create key file: %1").arg(errorMsg), QMessageBox::Button::Ok); } else { - m_compUi->keyFileCombo->setEditText(fileName); + m_compUi->keyFileLineEdit->setText(fileName); } } } @@ -155,6 +155,6 @@ void KeyFileEditWidget::browseKeyFile() } if (!fileName.isEmpty()) { - m_compUi->keyFileCombo->setEditText(fileName); + m_compUi->keyFileLineEdit->setText(fileName); } } diff --git a/src/gui/databasekey/KeyFileEditWidget.ui b/src/gui/databasekey/KeyFileEditWidget.ui index 23b4e528b..3c83a55d3 100644 --- a/src/gui/databasekey/KeyFileEditWidget.ui +++ b/src/gui/databasekey/KeyFileEditWidget.ui @@ -6,8 +6,8 @@ 0 0 - 370 - 76 + 566 + 94 @@ -23,33 +23,7 @@ 0 - - - - - 0 - 0 - - - - Key file selection - - - true - - - - - - Browse for key file - - - Browse… - - - - Generate a new key file @@ -59,34 +33,61 @@ - - - - Qt::Vertical + + + + Generate a new key file or choose an existing one to protect your database. - - - 20 - 0 - + + true - + - - + + true - Note: Do not use a file that may change as that will prevent you from unlocking your database! + Note: Do NOT use a file that may change as that will prevent you from unlocking your database. true + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + true + + + + + + + Browse for key file + + + Browse… + + + diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index f65090044..65f9e3b8d 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -278,15 +278,15 @@ void TestGui::testCreateDatabase() QTRY_VERIFY(!additionalOptionsButton->isVisible()); QCOMPARE(passwordWidget->visiblePage(), KeyFileEditWidget::Page::Edit); QTest::mouseClick(keyFileWidget->findChild("addButton"), Qt::MouseButton::LeftButton); - auto* fileCombo = keyFileWidget->findChild("keyFileCombo"); - QTRY_VERIFY(fileCombo); - QTRY_VERIFY(fileCombo->isVisible()); + auto* fileEdit = keyFileWidget->findChild("keyFileLineEdit"); + QTRY_VERIFY(fileEdit); + QTRY_VERIFY(fileEdit->isVisible()); fileDialog()->setNextFileName(QString("%1/%2").arg(QString(KEEPASSX_TEST_DATA_DIR), "FileKeyHashed.key")); QTest::keyClick(keyFileWidget->findChild("addButton"), Qt::Key::Key_Enter); - QVERIFY(fileCombo->hasFocus()); + QVERIFY(fileEdit->hasFocus()); auto* browseButton = keyFileWidget->findChild("browseKeyFileButton"); QTest::keyClick(browseButton, Qt::Key::Key_Enter); - QCOMPARE(fileCombo->currentText(), QString("%1/%2").arg(QString(KEEPASSX_TEST_DATA_DIR), "FileKeyHashed.key")); + QCOMPARE(fileEdit->text(), QString("%1/%2").arg(QString(KEEPASSX_TEST_DATA_DIR), "FileKeyHashed.key")); // save database to temporary file TemporaryFile tmpFile; @@ -294,7 +294,7 @@ void TestGui::testCreateDatabase() tmpFile.close(); fileDialog()->setNextFileName(tmpFile.fileName()); - QTest::keyClick(fileCombo, Qt::Key::Key_Enter); + QTest::keyClick(fileEdit, Qt::Key::Key_Enter); tmpFile.remove();); triggerAction("actionDatabaseNew");