mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 15:59:50 -05:00
Better description text for Key File change dialog
This commit is contained in:
parent
01d86760e0
commit
dc496fd1d9
@ -40,7 +40,7 @@ KeyFileEditWidget::~KeyFileEditWidget()
|
|||||||
bool KeyFileEditWidget::addToCompositeKey(QSharedPointer<CompositeKey> key)
|
bool KeyFileEditWidget::addToCompositeKey(QSharedPointer<CompositeKey> key)
|
||||||
{
|
{
|
||||||
auto fileKey = QSharedPointer<FileKey>::create();
|
auto fileKey = QSharedPointer<FileKey>::create();
|
||||||
QString fileKeyName = m_compUi->keyFileCombo->currentText();
|
QString fileKeyName = m_compUi->keyFileLineEdit->text();
|
||||||
if (!fileKey->load(fileKeyName, nullptr)) {
|
if (!fileKey->load(fileKeyName, nullptr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ bool KeyFileEditWidget::validate(QString& errorMessage) const
|
|||||||
{
|
{
|
||||||
FileKey fileKey;
|
FileKey fileKey;
|
||||||
QString fileKeyError;
|
QString fileKeyError;
|
||||||
QString fileKeyName = m_compUi->keyFileCombo->currentText();
|
QString fileKeyName = m_compUi->keyFileLineEdit->text();
|
||||||
if (!fileKey.load(fileKeyName, &fileKeyError)) {
|
if (!fileKey.load(fileKeyName, &fileKeyError)) {
|
||||||
errorMessage = tr("Error loading the key file '%1'\nMessage: %2").arg(fileKeyName, fileKeyError);
|
errorMessage = tr("Error loading the key file '%1'\nMessage: %2").arg(fileKeyName, fileKeyError);
|
||||||
return false;
|
return false;
|
||||||
@ -85,7 +85,7 @@ void KeyFileEditWidget::initComponentEditWidget(QWidget* widget)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
Q_ASSERT(m_compEditWidget);
|
Q_ASSERT(m_compEditWidget);
|
||||||
m_compUi->keyFileCombo->setFocus();
|
m_compUi->keyFileLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyFileEditWidget::initComponent()
|
void KeyFileEditWidget::initComponent()
|
||||||
@ -120,7 +120,7 @@ void KeyFileEditWidget::createKeyFile()
|
|||||||
tr("Unable to create key file: %1").arg(errorMsg),
|
tr("Unable to create key file: %1").arg(errorMsg),
|
||||||
QMessageBox::Button::Ok);
|
QMessageBox::Button::Ok);
|
||||||
} else {
|
} else {
|
||||||
m_compUi->keyFileCombo->setEditText(fileName);
|
m_compUi->keyFileLineEdit->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,6 +155,6 @@ void KeyFileEditWidget::browseKeyFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
m_compUi->keyFileCombo->setEditText(fileName);
|
m_compUi->keyFileLineEdit->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>370</width>
|
<width>566</width>
|
||||||
<height>76</height>
|
<height>94</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@ -23,33 +23,7 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="keyFileCombo">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="accessibleName">
|
|
||||||
<string>Key file selection</string>
|
|
||||||
</property>
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="browseKeyFileButton">
|
|
||||||
<property name="accessibleName">
|
|
||||||
<string>Browse for key file</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Browse…</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPushButton" name="createKeyFileButton">
|
<widget class="QPushButton" name="createKeyFileButton">
|
||||||
<property name="accessibleName">
|
<property name="accessibleName">
|
||||||
<string>Generate a new key file</string>
|
<string>Generate a new key file</string>
|
||||||
@ -59,34 +33,61 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="0" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<widget class="QLabel" name="instructions">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Vertical</enum>
|
<string>Generate a new key file or choose an existing one to protect your database.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="wordWrap">
|
||||||
<size>
|
<bool>true</bool>
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="instructions_2">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<italic>true</italic>
|
<italic>true</italic>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Note: Do not use a file that may change as that will prevent you from unlocking your database!</string>
|
<string>Note: Do NOT use a file that may change as that will prevent you from unlocking your database.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLineEdit" name="keyFileLineEdit">
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="browseKeyFileButton">
|
||||||
|
<property name="accessibleName">
|
||||||
|
<string>Browse for key file</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse…</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -278,15 +278,15 @@ void TestGui::testCreateDatabase()
|
|||||||
QTRY_VERIFY(!additionalOptionsButton->isVisible());
|
QTRY_VERIFY(!additionalOptionsButton->isVisible());
|
||||||
QCOMPARE(passwordWidget->visiblePage(), KeyFileEditWidget::Page::Edit);
|
QCOMPARE(passwordWidget->visiblePage(), KeyFileEditWidget::Page::Edit);
|
||||||
QTest::mouseClick(keyFileWidget->findChild<QPushButton*>("addButton"), Qt::MouseButton::LeftButton);
|
QTest::mouseClick(keyFileWidget->findChild<QPushButton*>("addButton"), Qt::MouseButton::LeftButton);
|
||||||
auto* fileCombo = keyFileWidget->findChild<QComboBox*>("keyFileCombo");
|
auto* fileEdit = keyFileWidget->findChild<QLineEdit*>("keyFileLineEdit");
|
||||||
QTRY_VERIFY(fileCombo);
|
QTRY_VERIFY(fileEdit);
|
||||||
QTRY_VERIFY(fileCombo->isVisible());
|
QTRY_VERIFY(fileEdit->isVisible());
|
||||||
fileDialog()->setNextFileName(QString("%1/%2").arg(QString(KEEPASSX_TEST_DATA_DIR), "FileKeyHashed.key"));
|
fileDialog()->setNextFileName(QString("%1/%2").arg(QString(KEEPASSX_TEST_DATA_DIR), "FileKeyHashed.key"));
|
||||||
QTest::keyClick(keyFileWidget->findChild<QPushButton*>("addButton"), Qt::Key::Key_Enter);
|
QTest::keyClick(keyFileWidget->findChild<QPushButton*>("addButton"), Qt::Key::Key_Enter);
|
||||||
QVERIFY(fileCombo->hasFocus());
|
QVERIFY(fileEdit->hasFocus());
|
||||||
auto* browseButton = keyFileWidget->findChild<QPushButton*>("browseKeyFileButton");
|
auto* browseButton = keyFileWidget->findChild<QPushButton*>("browseKeyFileButton");
|
||||||
QTest::keyClick(browseButton, Qt::Key::Key_Enter);
|
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
|
// save database to temporary file
|
||||||
TemporaryFile tmpFile;
|
TemporaryFile tmpFile;
|
||||||
@ -294,7 +294,7 @@ void TestGui::testCreateDatabase()
|
|||||||
tmpFile.close();
|
tmpFile.close();
|
||||||
fileDialog()->setNextFileName(tmpFile.fileName());
|
fileDialog()->setNextFileName(tmpFile.fileName());
|
||||||
|
|
||||||
QTest::keyClick(fileCombo, Qt::Key::Key_Enter);
|
QTest::keyClick(fileEdit, Qt::Key::Key_Enter);
|
||||||
tmpFile.remove(););
|
tmpFile.remove(););
|
||||||
|
|
||||||
triggerAction("actionDatabaseNew");
|
triggerAction("actionDatabaseNew");
|
||||||
|
Loading…
Reference in New Issue
Block a user