Skip to content

Commit

Permalink
fix: [Vault] The set unlock methon UI show error.
Browse files Browse the repository at this point in the history
cause:
The title not adjust compact mode.
solution:
adjust the compact mode.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-237065.html
  • Loading branch information
GongHeng2017 committed Dec 28, 2023
1 parent daf5f26 commit b738261
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
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

0 comments on commit b738261

Please sign in to comment.