Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Vault] The set unlock methon UI show error. #1677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <DPasswordEdit>
#include <DLabel>
#include <DComboBox>
#ifdef DTKWIDGET_CLASS_DSizeMode
# include <DSizeMode>
#endif

#include <QDebug>
#include <QToolTip>
Expand All @@ -36,11 +39,8 @@ VaultActiveSetUnlockMethodView::VaultActiveSetUnlockMethodView(QWidget *parent)

void VaultActiveSetUnlockMethodView::initUi()
{
DLabel *pLabel = new DLabel(tr("Set Vault Password"), this);
QFont font = pLabel->font();
font.setPixelSize(18);
pLabel->setFont(font);
pLabel->setAlignment(Qt::AlignHCenter);
titleLabel = new DLabel(tr("Set Vault Password"), this);
titleLabel->setAlignment(Qt::AlignHCenter);

DLabel *pTypeLabel = new DLabel(tr("Encryption method"), this);
typeCombo = new DComboBox(this);
Expand Down Expand Up @@ -100,14 +100,16 @@ void VaultActiveSetUnlockMethodView::initUi()

QVBoxLayout *play = new QVBoxLayout(this);
play->setMargin(0);
play->addWidget(pLabel);
play->addWidget(titleLabel);
play->addSpacing(15);
play->addLayout(gridLayout);
play->addStretch();
play->addWidget(nextBtn);

initUiForSizeMode();

#ifdef ENABLE_TESTING
AddATTag(qobject_cast<QWidget *>(pLabel), AcName::kAcLabelVaultSetUnlockTitle);
AddATTag(qobject_cast<QWidget *>(titleLabel), AcName::kAcLabelVaultSetUnlockTitle);
AddATTag(qobject_cast<QWidget *>(pTypeLabel), AcName::kAcLabelVaultSetUnlcokMethod);
AddATTag(qobject_cast<QWidget *>(typeCombo), AcName::kAcComboVaultSetUnlockMethod);
AddATTag(qobject_cast<QWidget *>(passwordLabel), AcName::kAcLabelVaultSetUnlockPassword);
Expand All @@ -121,6 +123,19 @@ void VaultActiveSetUnlockMethodView::initUi()
#endif
}

void VaultActiveSetUnlockMethodView::initUiForSizeMode()
{
#ifdef DTKWIDGET_CLASS_DSizeMode
QFont font = titleLabel->font();
font.setPixelSize(DSizeModeHelper::element(13, 16));
titleLabel->setFont(font);
#else
QFont font = titleLabel->font();
font.setPixelSize(15);
titleLabel->setFont(font);
#endif
}

void VaultActiveSetUnlockMethodView::initConnect()
{
connect(typeCombo, SIGNAL(currentIndexChanged(int)),
Expand All @@ -143,6 +158,12 @@ void VaultActiveSetUnlockMethodView::initConnect()
this, &VaultActiveSetUnlockMethodView::slotRepeatPasswordEditFocusChanged);
connect(nextBtn, &DPushButton::clicked,
this, &VaultActiveSetUnlockMethodView::slotNextBtnClicked);

#ifdef DTKWIDGET_CLASS_DSizeMode
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [this]() {
initUiForSizeMode();
});
#endif
}

void VaultActiveSetUnlockMethodView::clearText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private slots:

private:
void initUi();
void initUiForSizeMode();
void initConnect();
//! 校验密码是否符合规则
bool checkPassword(const QString &passwordEdit);
Expand All @@ -71,6 +72,7 @@ private slots:
void showEvent(QShowEvent *event) override;

private:
DTK_WIDGET_NAMESPACE::DLabel *titleLabel { nullptr };
DTK_WIDGET_NAMESPACE::DComboBox *typeCombo { nullptr };

DTK_WIDGET_NAMESPACE::DLabel *passwordLabel { nullptr };
Expand Down