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

chore: tweak menu animation #240

Open
wants to merge 1 commit into
base: dev/animation
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ inline static bool isTheClassObject(QObject *object)
ChameleonMovementAnimation::ChameleonMovementAnimation(QWidget *targetWidget)
: QVariantAnimation(targetWidget)
{
setDuration(150);
setDuration(50);

connect(this, &QVariantAnimation::valueChanged, targetWidget, [this] (const QVariant &value) {
if (!isRuning())
Expand Down Expand Up @@ -3064,6 +3064,12 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
if (selected)
animation->setTargetRect(option->rect);
}

if (type == QStyleOptionMenuItem::SubMenu) {
color = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType ?
QColor(0, 0, 0, 255 * 0.15): QColor(255, 255, 255, 255 * 0.2);
}

const int round = 6;
if (animation && animation->isRuning()) {
painter->save();
Expand All @@ -3072,15 +3078,19 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
painter->setOpacity(1.0);
painter->setBrush(color);
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawRoundedRect(animation->currentRect(), round, round);
painter->setOpacity(opacity);
painter->restore();

return animation;
} else if (selected) {
const QMargins &margins = frameExtentMargins();
drawShadow(painter, option->rect - margins, getColor(option, QPalette::Shadow));
painter->save();
painter->setBrush(color);
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawRoundedRect(option->rect, round, round);
painter->restore();
}
Expand Down
Loading