feat(decoration): resize window buttons

main
kate 3 years ago
parent b5198d1588
commit 20f907f623

@ -74,10 +74,14 @@ void Button::paint(QPainter *painter, const QRect &repaintRegion)
painter->setRenderHint(QPainter::SmoothPixmapTransform, false); painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
painter->setRenderHints(QPainter::Antialiasing, true); painter->setRenderHints(QPainter::Antialiasing, true);
QRect btnRect(0, 0, 28 * decoration->devicePixelRatio(), QRect btnRect(0, 0, 26 * decoration->devicePixelRatio(),
28 * decoration->devicePixelRatio()); 26 * decoration->devicePixelRatio());
btnRect.moveCenter(rect.center()); btnRect.moveCenter(rect.center());
QRect imgRect(0, 0, 24 * decoration->devicePixelRatio(),
24 * decoration->devicePixelRatio());
imgRect.moveCenter(rect.center());
if (isHovered() || isPressed()) { if (isHovered() || isPressed()) {
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
painter->setBrush(isDarkMode ? isPressed() ? QColor(255, 255, 255, 255 * 0.1) : QColor(255, 255, 255, 255 * 0.15) painter->setBrush(isDarkMode ? isPressed() ? QColor(255, 255, 255, 255 * 0.1) : QColor(255, 255, 255, 255 * 0.15)
@ -94,18 +98,18 @@ void Button::paint(QPainter *painter, const QRect &repaintRegion)
break; break;
} }
case KDecoration2::DecorationButtonType::Minimize: { case KDecoration2::DecorationButtonType::Minimize: {
painter->drawPixmap(btnRect, decoration->minimizeBtnPixmap()); painter->drawPixmap(imgRect, decoration->minimizeBtnPixmap());
break; break;
} }
case KDecoration2::DecorationButtonType::Maximize: { case KDecoration2::DecorationButtonType::Maximize: {
if (isChecked()) if (isChecked())
painter->drawPixmap(btnRect, decoration->restoreBtnPixmap()); painter->drawPixmap(imgRect, decoration->restoreBtnPixmap());
else else
painter->drawPixmap(btnRect, decoration->maximizeBtnPixmap()); painter->drawPixmap(imgRect, decoration->maximizeBtnPixmap());
break; break;
} }
case KDecoration2::DecorationButtonType::Close: { case KDecoration2::DecorationButtonType::Close: {
painter->drawPixmap(btnRect, decoration->closeBtnPixmap()); painter->drawPixmap(imgRect, decoration->closeBtnPixmap());
break; break;
} }
default: default:

@ -329,7 +329,7 @@ void Decoration::updateShadow()
void Decoration::updateBtnPixmap() void Decoration::updateBtnPixmap()
{ {
int size = 28; int size = 24;
QString dirName = darkMode() ? "dark" : "light"; QString dirName = darkMode() ? "dark" : "light";
m_closeBtnPixmap = fromSvgToPixmap(QString(":/images/%1/close_normal.svg").arg(dirName), QSize(size, size)); m_closeBtnPixmap = fromSvgToPixmap(QString(":/images/%1/close_normal.svg").arg(dirName), QSize(size, size));

@ -46,6 +46,7 @@ static QStringList allowList = { "netease-cloud-music netease-cloud-music",
"bytedance-feishu bytedance-feishu", "bytedance-feishu bytedance-feishu",
"xmind xmind", "xmind xmind",
"mtxx mtxx", "mtxx mtxx",
"ynote-desktop ynote-desktop",
// Open source software // Open source software
"code code", "code code",

Loading…
Cancel
Save