Skip to content
Open
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions plugins/dde-dock/common/pluginitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ PluginItemWidget::PluginItemWidget(PluginStandardItem *item, QWidget *parent)
, m_spinner(nullptr)
, m_rightIconSpacerItem(new QSpacerItem(0, 0))
{
m_opacityEffect = new QGraphicsOpacityEffect(this);
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);

m_opacityAnim = new QPropertyAnimation(m_opacityEffect, "opacity", this);
m_opacityAnim->setDuration(kOpacityAnimDuration);
m_opacityAnim->setEasingCurve(QEasingCurve::OutCubic);

if (!m_item) {
QLabel *err = new QLabel(this);
err->setText("Unknown Item");
Expand Down Expand Up @@ -298,9 +306,24 @@ void PluginItemWidget::updateState(const PluginItemState state)
m_mainLayout->invalidate();
}

void PluginItemWidget::startHoverAnim()
{
m_opacityAnim->stop();
m_opacityAnim->setEndValue(kHoverOpacity);
m_opacityAnim->start();
}

bool PluginItemWidget::event(QEvent *e)
{
switch (e->type()) {
case QEvent::Enter:
startHoverAnim();
break;
case QEvent::Leave:
m_opacityAnim->stop();
m_opacityAnim->setEndValue(kNormalOpacity);
m_opacityAnim->start();
break;
case QEvent::PaletteChange: {
QLayout *layout = this->layout();
for (int i = 0; i < layout->count(); i++) {
Expand Down
12 changes: 11 additions & 1 deletion plugins/dde-dock/common/pluginitemdelegate.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// SPDX-FileCopyrightText: 2016 - 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2016 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#pragma once

#include "commoniconbutton.h"

#include <QGraphicsOpacityEffect>

Check warning on line 9 in plugins/dde-dock/common/pluginitemdelegate.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGraphicsOpacityEffect> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPropertyAnimation>

Check warning on line 10 in plugins/dde-dock/common/pluginitemdelegate.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPropertyAnimation> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DLabel>

Check warning on line 11 in plugins/dde-dock/common/pluginitemdelegate.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLabel> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DSpinner>

Check warning on line 12 in plugins/dde-dock/common/pluginitemdelegate.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSpinner> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QObject>
#include <QStyledItemDelegate>
Expand Down Expand Up @@ -118,6 +120,14 @@
bool event(QEvent *e) override;

private:
void startHoverAnim();

QGraphicsOpacityEffect *m_opacityEffect;
QPropertyAnimation *m_opacityAnim;
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;
static constexpr int kOpacityAnimDuration = 150;

PluginStandardItem *m_item;

QHBoxLayout *m_mainLayout;
Expand Down
15 changes: 15 additions & 0 deletions src/loader/pluginitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ PluginItem::PluginItem(PluginsItemInterface *pluginItemInterface, const QString
m_tooltipTimer->setSingleShot(true);
m_tooltipTimer->setInterval(200);

m_opacityEffect = new QGraphicsOpacityEffect(this);
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);

m_opacityAnim = new QPropertyAnimation(m_opacityEffect, "opacity", this);
m_opacityAnim->setDuration(kOpacityAnimDuration);
m_opacityAnim->setEasingCurve(QEasingCurve::OutCubic);
if (m_dbusProxy.isNull())
m_dbusProxy.reset(new DockDBusProxy);

Expand Down Expand Up @@ -176,6 +183,10 @@ void PluginItem::mouseReleaseEvent(QMouseEvent *e)

void PluginItem::enterEvent(QEnterEvent *event)
{
m_opacityAnim->stop();
m_opacityAnim->setEndValue(kHoverOpacity);
m_opacityAnim->start();

// panel popup existed, not show tooltip
if (panelPopupExisted()) {
return QWidget::enterEvent(event);
Expand Down Expand Up @@ -218,6 +229,10 @@ void PluginItem::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
closeToolTip();

m_opacityAnim->stop();
m_opacityAnim->setEndValue(kNormalOpacity);
m_opacityAnim->start();
}

// TODO: The reason we add this is because on openSUSE we can see render residue for those
Expand Down
12 changes: 10 additions & 2 deletions src/loader/pluginitem.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef PLUGINSITEM_H
#define PLUGINSITEM_H

#include "pluginsiteminterface_v2.h"

Check warning on line 8 in src/loader/pluginitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "pluginsiteminterface_v2.h" not found.
#include "dockdbusproxy.h"

#include <QGraphicsOpacityEffect>

Check warning on line 11 in src/loader/pluginitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGraphicsOpacityEffect> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPropertyAnimation>

Check warning on line 12 in src/loader/pluginitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPropertyAnimation> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWidget>

Check warning on line 13 in src/loader/pluginitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWidget> not found. Please note: Cppcheck does not need standard library headers to get proper results.

const int Attribute_ForceUnDock = 0x800000;

Expand Down Expand Up @@ -73,10 +75,16 @@
QMenu *m_menu;
QScopedPointer<DockDBusProxy> m_dbusProxy;

public:
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;
static constexpr int kOpacityAnimDuration = 150;

private:
QTimer* m_tooltipTimer;
QPointer<QWidget> m_tipsWidget;

QGraphicsOpacityEffect *m_opacityEffect;
QPropertyAnimation *m_opacityAnim;
QAction *m_unDockAction = nullptr;
int m_pluginFlags = 0;
int m_spacing = 0;
Expand Down
Loading