mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: remove redundant method in launcher applet
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
388f6f6bfc
commit
36381cb9ec
1 changed files with 13 additions and 19 deletions
|
@ -202,10 +202,9 @@ protected:
|
||||||
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) final;
|
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPropertyAnimation* animateHover(QPropertyAnimation *animation, const bool fadeout);
|
QPropertyAnimation* animateHover(QPropertyAnimation *animation, const bool fadein);
|
||||||
Plasma::Animation* animateButton(Plasma::Animation *animation, Plasma::ToolButton *toolbutton,
|
Plasma::Animation* animateButton(Plasma::Animation *animation, Plasma::ToolButton *toolbutton,
|
||||||
const bool fadeout);
|
const bool fadein);
|
||||||
void animateHoverAndButtons(const bool fadeout);
|
|
||||||
bool handleMouseEvent(QGraphicsSceneMouseEvent *event);
|
bool handleMouseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
QGraphicsLinearLayout* m_layout;
|
QGraphicsLinearLayout* m_layout;
|
||||||
|
@ -450,7 +449,11 @@ void LauncherWidget::removeAction(const int actionnumber)
|
||||||
|
|
||||||
void LauncherWidget::setUnderMouse(const bool undermouse)
|
void LauncherWidget::setUnderMouse(const bool undermouse)
|
||||||
{
|
{
|
||||||
animateHoverAndButtons(!undermouse);
|
m_hoveranimation = animateHover(m_hoveranimation, undermouse);
|
||||||
|
m_action1animation = animateButton(m_action1animation, m_action1widget, undermouse);
|
||||||
|
m_action2animation = animateButton(m_action2animation, m_action2widget, undermouse);
|
||||||
|
m_action3animation = animateButton(m_action3animation, m_action3widget, undermouse);
|
||||||
|
m_action4animation = animateButton(m_action4animation, m_action4widget, undermouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void LauncherWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
@ -471,13 +474,13 @@ void LauncherWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||||
void LauncherWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void LauncherWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
animateHoverAndButtons(false);
|
setUnderMouse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void LauncherWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
animateHoverAndButtons(true);
|
setUnderMouse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void LauncherWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
@ -516,7 +519,7 @@ QVariant LauncherWidget::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPropertyAnimation* LauncherWidget::animateHover(QPropertyAnimation *animation, const bool fadeout)
|
QPropertyAnimation* LauncherWidget::animateHover(QPropertyAnimation *animation, const bool fadein)
|
||||||
{
|
{
|
||||||
if (animation) {
|
if (animation) {
|
||||||
animation->stop();
|
animation->stop();
|
||||||
|
@ -525,14 +528,14 @@ QPropertyAnimation* LauncherWidget::animateHover(QPropertyAnimation *animation,
|
||||||
animation->setDuration(s_animationduration);
|
animation->setDuration(s_animationduration);
|
||||||
}
|
}
|
||||||
animation->setStartValue(m_hover);
|
animation->setStartValue(m_hover);
|
||||||
animation->setEndValue(fadeout ? 0.0 : 1.0);
|
animation->setEndValue(fadein ? 1.0 : 0.0);
|
||||||
animation->start(QAbstractAnimation::KeepWhenStopped);
|
animation->start(QAbstractAnimation::KeepWhenStopped);
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Animation* LauncherWidget::animateButton(Plasma::Animation *animation,
|
Plasma::Animation* LauncherWidget::animateButton(Plasma::Animation *animation,
|
||||||
Plasma::ToolButton *toolbutton,
|
Plasma::ToolButton *toolbutton,
|
||||||
const bool fadeout)
|
const bool fadein)
|
||||||
{
|
{
|
||||||
if (!toolbutton->isVisible()) {
|
if (!toolbutton->isVisible()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -545,20 +548,11 @@ Plasma::Animation* LauncherWidget::animateButton(Plasma::Animation *animation,
|
||||||
animation->setTargetWidget(toolbutton);
|
animation->setTargetWidget(toolbutton);
|
||||||
}
|
}
|
||||||
animation->setProperty("startOpacity", toolbutton->opacity());
|
animation->setProperty("startOpacity", toolbutton->opacity());
|
||||||
animation->setProperty("targetOpacity", fadeout ? 0.0 : 1.0);
|
animation->setProperty("targetOpacity", fadein ? 1.0 : 0.0);
|
||||||
animation->start(QAbstractAnimation::KeepWhenStopped);
|
animation->start(QAbstractAnimation::KeepWhenStopped);
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWidget::animateHoverAndButtons(const bool fadeout)
|
|
||||||
{
|
|
||||||
m_hoveranimation = animateHover(m_hoveranimation, fadeout);
|
|
||||||
m_action1animation = animateButton(m_action1animation, m_action1widget, fadeout);
|
|
||||||
m_action2animation = animateButton(m_action2animation, m_action2widget, fadeout);
|
|
||||||
m_action3animation = animateButton(m_action3animation, m_action3widget, fadeout);
|
|
||||||
m_action4animation = animateButton(m_action4animation, m_action4widget, fadeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LauncherWidget::handleMouseEvent(QGraphicsSceneMouseEvent *event)
|
bool LauncherWidget::handleMouseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton &&
|
if (event->buttons() & Qt::LeftButton &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue