fix(scale): Remove part of the zoom and retain the zoom of the user avatar to solve the problem that the display is abnormal under the zoom setting

Description: 去除部分缩放,保留用户头像的缩放,解决设置缩放下显示异常的问题

Log: issue#I8W9Q9【次要】【锁屏】【缩放率】更改缩放率(非100%),锁屏界面,点击右下角电源键,各功能图标未显示全
     issue#I8W6X3 【次要】【锁屏】【登录】【分辨率】修改分辨率或缩放率后,锁屏和登录界面用户名称显示不全、网络图标大小异常
     issue#I8M96N  【需求24962】【X】【网络】锁屏界面网络图标异常
This commit is contained in:
liuyuanpeng 2024-03-11 11:27:27 +08:00
parent 60adb99618
commit bc08b3440a
4 changed files with 40 additions and 40 deletions

View File

@ -36,14 +36,14 @@
#include "../lock-dialog/pam-tally.h"
#include "global_utils.h"
#define WIDGET_HEIGHT_HEADTIP (40 * scale)
#define WIDGET_HEIGHT_HEADTIP (40)
#define WIDGET_HEIGHT_HEADIMAGE (154 * scale)
#define WIDGET_HEIGHT_USERNAME (40 * scale)
#define WIDGET_HEIGHT_PASSWDEDIT (80 * scale)
#define WIDGET_HEIGHT_USERNAME (40)
#define WIDGET_HEIGHT_PASSWDEDIT (80)
#define WIDGET_HEIGHT_SPACING (16 * scale)
#define WIDGET_HEIGHT_CUSTOM \
(WIDGET_HEIGHT_HEADIMAGE + WIDGET_HEIGHT_USERNAME + WIDGET_HEIGHT_PASSWDEDIT + WIDGET_HEIGHT_SPACING * 2)
#define WIDGET_HEIGHT_LOGINOPTS (104 * scale)
#define WIDGET_HEIGHT_LOGINOPTS (104)
AuthDialog::AuthDialog(LockDialogModel *model, UserInfoPtr userInfo, QWidget *parent)
: QWidget(parent)
@ -188,25 +188,25 @@ void AuthDialog::updateAuthSize()
m_nameLabel->setFontSize((24 + m_curFontSize) * m_ptToPx);
}
if (m_passwordEdit) {
m_passwordEdit->setFixedSize(240 * scale, 40 * scale);
m_passwordEdit->setFixedSize(240, 40);
m_passwordEdit->updateUI();
}
if (m_messageLabel) {
m_messageLabel->setFixedSize(this->width(), 40 * scale);
m_messageLabel->setFixedSize(this->width(), 40);
m_messageLabel->setFontSize((14 + m_curFontSize) * m_ptToPx);
}
if (m_messageButton) {
m_messageButton->setFixedSize(200 * scale, 40 * scale);
m_messageButton->setFixedSize(200, 40);
QFont font = m_messageButton->font();
font.setPointSize((14 + m_curFontSize) * m_ptToPx);
m_messageButton->setFont(font);
}
if (m_ukeyPasswordEdit) {
m_ukeyPasswordEdit->setFixedSize(240 * scale, 40 * scale);
m_ukeyPasswordEdit->setFixedSize(240, 40);
m_ukeyPasswordEdit->updateUI();
}
if (m_ukeyMessageLabel) {
m_ukeyMessageLabel->setFixedSize(this->width(), 40 * scale);
m_ukeyMessageLabel->setFixedSize(this->width(), 40);
m_ukeyMessageLabel->setFontSize((14 + m_curFontSize) * m_ptToPx);
}
if (bottomListWidget) {
@ -215,7 +215,7 @@ void AuthDialog::updateAuthSize()
bottomListWidget->updateUI();
}
if (m_tipWidget && bottomListWidget)
m_optionTip->setFixedSize(bottomListWidget->width(), 32 * scale);
m_optionTip->setFixedSize(bottomListWidget->width(), 32);
if (m_customWidget)
m_customWidget->setFixedSize(width(), WIDGET_HEIGHT_CUSTOM);
updateUI();
@ -318,7 +318,7 @@ void AuthDialog::initHeaderWidget()
m_labelQRCode->setLayout(layoutQRCode);
m_labelQRCodeTip = new QLabel();
layoutQRCode->addWidget(m_labelQRCodeTip, 0, Qt::AlignHCenter);
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22 * scale, 22 * scale)));
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22, 22)));
m_labelQRCodeTip->show();
m_labelQRCodeMsg = new KLabel();
m_labelQRCodeMsg->setStyleSheet("QLabel{background-color:rgba(255,255,255,0);color:rgb(255,0,0)}");
@ -691,7 +691,7 @@ void AuthDialog::setQRCodeMsg(QString strMsg)
}
m_labelQRCodeMsg->setTipText(strMsg);
m_labelQRCodeMsg->show();
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22 * scale, 22 * scale)));
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22, 22)));
m_labelQRCodeTip->show();
}
}
@ -1640,7 +1640,7 @@ void AuthDialog::onLoadingImage()
w_timer->setInterval(150);
connect(w_timer, &QTimer::timeout, this, &AuthDialog::updatePixmap);
}
m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24 * scale, 24 * scale);
m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24, 24);
m_labelFace->setAlignment(Qt::AlignCenter);
if (m_uCurLoginOptType == LOGINOPT_TYPE_FACE) {
m_labelFace->setPixmap(m_waitingPixmap);

View File

@ -61,7 +61,7 @@ IconEdit::IconEdit(LockDialogModel *model, QWidget *parent) : QWidget(parent), m
m_iconButton = new QPushButton(this);
m_iconButton->installEventFilter(this);
m_iconButton->setFixedSize(24 * scale, 24 * scale);
m_iconButton->setFixedSize(24, 24);
m_iconButton->setProperty("isRoundButton", true);
m_iconButton->setProperty("isImportant", true);
@ -137,9 +137,9 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
void IconEdit::setIcon(const QIcon &icon, const QSize &size)
{
QPixmap pixmap = icon.pixmap(size.width() * scale, size.height() * scale);
QPixmap pixmap = icon.pixmap(size.width(), size.height());
m_iconButton->setIcon(pixmap);
m_iconButton->setIconSize(QSize(size.width() * scale, size.height() * scale));
m_iconButton->setIconSize(QSize(size.width(), size.height()));
m_iconButton->setText("");
m_sizeIconBtn = size;
m_icon = icon;
@ -211,9 +211,9 @@ void IconEdit::startWaiting()
// 更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致?
// QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16).scaled(16,16, Qt::IgnoreAspectRatio,
// Qt::SmoothTransformation);
m_waitingPixmap = getLoadingIcon(16 * scale);
m_waitingPixmap = getLoadingIcon(16);
m_iconButton->setIcon(m_waitingPixmap);
m_iconButton->setIconSize(QSize(16 * scale, 16 * scale));
m_iconButton->setIconSize(QSize(16, 16));
m_timer->start();
}
@ -225,9 +225,9 @@ void IconEdit::stopWaiting()
m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, false);
m_edit->setReadOnly(false);
if (!m_icon.isNull()) {
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale);
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width(), m_sizeIconBtn.height());
m_iconButton->setIcon(pixmap);
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale));
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width(), m_sizeIconBtn.height()));
} else {
m_iconButton->setText(m_iconText);
}
@ -235,17 +235,17 @@ void IconEdit::stopWaiting()
void IconEdit::updateUI()
{
m_iconButton->setFixedSize(QSize(24 * scale, 24 * scale));
m_iconButton->setFixedSize(QSize(24, 24));
if (!m_icon.isNull()) {
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale);
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width(), m_sizeIconBtn.height());
m_iconButton->setIcon(pixmap);
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale));
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width(), m_sizeIconBtn.height()));
} else {
m_iconButton->setText(m_iconText);
}
m_modeButton->setFixedSize(QSize(24 * scale, 24 * scale));
m_modeButton->setIconSize(QSize(16 * scale, 16 * scale));
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16 * scale, 16 * scale)));
m_modeButton->setFixedSize(QSize(24, 24));
m_modeButton->setIconSize(QSize(16, 16));
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16, 16)));
}
void IconEdit::updatePixmap()
@ -256,7 +256,7 @@ void IconEdit::updatePixmap()
matrix.rotate(90.0);
m_waitingPixmap = m_waitingPixmap.transformed(matrix, Qt::FastTransformation);
m_iconButton->setIcon(QIcon(m_waitingPixmap));
m_iconButton->setIconSize(QSize(16 * scale, 16 * scale));
m_iconButton->setIconSize(QSize(16, 16));
}
void IconEdit::clicked_cb()

View File

@ -415,8 +415,8 @@ void LockWidget::initButtonWidget()
}
QPixmap ssIcon(strCurSession);
ssIcon = scaledPixmap(ssIcon);
ssIcon = ssIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ssIcon = PixmapToRound(ssIcon, 16);
ssIcon = ssIcon.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ssIcon = PixmapToRound(ssIcon, 24);
m_sessionButton->setIcon(ssIcon);
connect(m_sessionButton, &StatusButton::clicked, this, [this]() { onShowSessionListWidget(); });
}
@ -544,17 +544,17 @@ void LockWidget::updateBottomButton()
QList<StatusButton *> statusButton = this->findChildren<StatusButton *>();
for (auto button : statusButton) {
if (button->getButtonTyoe() == POWERBUTTON) {
button->setFixedSize(130 * scale, 130 * scale);
button->setIconSize(QSize(130 * scale, 130 * scale));
button->setFixedSize(130, 130);
button->setIconSize(QSize(130, 130));
} else {
button->setFixedSize(48 * scale, 48 * scale);
button->setIconSize(QSize(24 * scale, 24 * scale));
button->setFixedSize(48, 48);
button->setIconSize(QSize(24, 24));
}
}
QList<NetWorkButton *> networkButton = this->findChildren<NetWorkButton *>();
for (auto button : networkButton) {
button->setFixedSize(48 * scale, 48 * scale);
button->setIconSize(QSize(24 * scale, 24 * scale));
button->setFixedSize(48, 48);
button->setIconSize(QSize(24, 24));
}
}
@ -726,8 +726,8 @@ void LockWidget::onSessionChanged(const QString &strSession)
}
QPixmap ssIcon(strCurSession);
ssIcon = scaledPixmap(ssIcon);
ssIcon = ssIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ssIcon = PixmapToRound(ssIcon, 16);
ssIcon = ssIcon.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ssIcon = PixmapToRound(ssIcon, 24);
sButton->setIcon(ssIcon);
}
}

View File

@ -17,7 +17,7 @@
**/
#include "statusbutton.h"
#include <QDebug>
#include <QApplication>
#include <QMouseEvent>
StatusButton::StatusButton(QWidget *parent, int type) : QPushButton(parent)
@ -161,8 +161,8 @@ void StatusButton::paintEvent(QPaintEvent *e)
QRect buttonRect(0, 0, buttonWidget, buttonHeight);
QPixmap pixmap = option.icon.pixmap(option.iconSize, QIcon::Active);
int pixmapWidth = static_cast<int>(pixmap.width());
int pixmapHeight = static_cast<int>(pixmap.height());
int pixmapWidth = static_cast<int>(pixmap.width() / qApp->devicePixelRatio());
int pixmapHeight = static_cast<int>(pixmap.height() / qApp->devicePixelRatio());
QRect pixmapRect(0, 0, pixmapWidth, pixmapHeight);
int deltaX = 0;