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
38 changes: 37 additions & 1 deletion dock-network-plugin/quickpanelwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
// Copyright (C) 2022 ~ 2026 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down Expand Up @@ -68,6 +68,11 @@ QuickPanelWidget::QuickPanelWidget(QWidget *parent)
, m_nameLabel(new DLabel(this))
, m_stateLabel(new DLabel(this))
, m_expandLabel(new DIconButton(this))
, m_iconOpacityEffect(new QGraphicsOpacityEffect(this))
, m_nameOpacityEffect(new QGraphicsOpacityEffect(this))
, m_stateOpacityEffect(new QGraphicsOpacityEffect(this))
, m_hover(false)
, m_active(true)
{
initUi();
initConnection();
Expand Down Expand Up @@ -98,7 +103,9 @@ void QuickPanelWidget::setDescription(const QString &description)

void QuickPanelWidget::setActive(bool active)
{
m_active = active;
m_iconWidget->setBackgroundRole(active ? QPalette::Highlight : QPalette::BrightText);
m_iconOpacityEffect->setOpacity(active ? 1.0 : (m_hover ? kHoverOpacity : kNormalOpacity));
}

void QuickPanelWidget::mousePressEvent(QMouseEvent *event)
Expand Down Expand Up @@ -126,6 +133,26 @@ void QuickPanelWidget::mouseReleaseEvent(QMouseEvent *event)
m_clickPoint = QPoint();
return QWidget::mouseReleaseEvent(event);
}

void QuickPanelWidget::enterEvent(QEnterEvent *event)
{
m_hover = true;
m_nameOpacityEffect->setOpacity(kHoverOpacity);
m_stateOpacityEffect->setOpacity(kHoverOpacity);
if (!m_active)
m_iconOpacityEffect->setOpacity(kHoverOpacity);
QWidget::enterEvent(event);
}

void QuickPanelWidget::leaveEvent(QEvent *event)
{
m_hover = false;
m_nameOpacityEffect->setOpacity(kNormalOpacity);
m_stateOpacityEffect->setOpacity(kNormalOpacity);
if (!m_active)
m_iconOpacityEffect->setOpacity(kNormalOpacity);
QWidget::leaveEvent(event);
}

void QuickPanelWidget::initUi()
{
Expand Down Expand Up @@ -154,6 +181,15 @@ void QuickPanelWidget::initUi()
m_iconWidget->setCheckable(false);
m_iconWidget->setFixedSize(QSize(40, 40));
m_iconWidget->setFocusPolicy(Qt::NoFocus);

m_iconOpacityEffect->setOpacity(kNormalOpacity);
m_iconWidget->setGraphicsEffect(m_iconOpacityEffect);

m_nameOpacityEffect->setOpacity(kNormalOpacity);
m_nameLabel->setGraphicsEffect(m_nameOpacityEffect);

m_stateOpacityEffect->setOpacity(kNormalOpacity);
m_stateLabel->setGraphicsEffect(m_stateOpacityEffect);

// 进入图标
m_expandLabel->setIcon(DStyle::standardIcon(style(), DStyle::SP_ArrowEnter));
Expand Down
12 changes: 11 additions & 1 deletion dock-network-plugin/quickpanelwidget.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
// Copyright (C) 2022 ~ 2026 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
Expand All @@ -7,9 +7,10 @@
#define QUICKPANELWIDGET_H

#include <DFloatingButton>
#include <DLabel>

Check warning on line 10 in dock-network-plugin/quickpanelwidget.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 <QWidget>

Check warning on line 12 in dock-network-plugin/quickpanelwidget.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.
#include <QGraphicsOpacityEffect>

Check warning on line 13 in dock-network-plugin/quickpanelwidget.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.

class QLabel;

Expand All @@ -36,6 +37,8 @@
void iconClicked();

protected:
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;

Expand All @@ -48,6 +51,13 @@
Dtk::Widget::DLabel *m_nameLabel;
Dtk::Widget::DLabel *m_stateLabel;
Dtk::Widget::DIconButton *m_expandLabel;
QGraphicsOpacityEffect *m_iconOpacityEffect;
QGraphicsOpacityEffect *m_nameOpacityEffect;
QGraphicsOpacityEffect *m_stateOpacityEffect;
bool m_hover;
bool m_active;
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;
QPoint m_clickPoint;
};
} // namespace network
Expand Down
20 changes: 18 additions & 2 deletions dock-network-plugin/widget/jumpsettingbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ JumpSettingButton::JumpSettingButton(QWidget *parent)
, m_autoShowPage(true)
, m_iconButton(new CommonIconButton(this))
, m_descriptionLabel(new DLabel(this))
, m_iconOpacityEffect(new QGraphicsOpacityEffect(this))
, m_descOpacityEffect(new QGraphicsOpacityEffect(this))
{
initUI();
}
Expand All @@ -32,6 +34,8 @@ JumpSettingButton::JumpSettingButton(const QIcon& icon, const QString& descripti
, m_autoShowPage(true)
, m_iconButton(new CommonIconButton(this))
, m_descriptionLabel(new DLabel(this))
, m_iconOpacityEffect(new QGraphicsOpacityEffect(this))
, m_descOpacityEffect(new QGraphicsOpacityEffect(this))
{
initUI();

Expand Down Expand Up @@ -59,6 +63,13 @@ void JumpSettingButton::initUI()
layout->setContentsMargins(10, 0, 10, 0);
layout->addWidget(m_iconButton);
layout->addWidget(m_descriptionLabel);

m_iconOpacityEffect->setOpacity(kNormalOpacity);
m_iconButton->setGraphicsEffect(m_iconOpacityEffect);

m_descOpacityEffect->setOpacity(kNormalOpacity);
m_descriptionLabel->setGraphicsEffect(m_descOpacityEffect);

layout->addStretch();
}

Expand All @@ -76,11 +87,16 @@ bool JumpSettingButton::event(QEvent* e)
{
switch (e->type()) {
case QEvent::Leave:
case QEvent::Enter:
case QEvent::Enter: {
m_hover = e->type() == QEvent::Enter;
qreal opacity = m_hover ? kHoverOpacity : kNormalOpacity;
m_iconOpacityEffect->setOpacity(opacity);
m_descOpacityEffect->setOpacity(opacity);
update();
break;
} break;
case QEvent::Hide:
m_iconOpacityEffect->setOpacity(kNormalOpacity);
m_descOpacityEffect->setOpacity(kNormalOpacity);
m_hover = false;
update();
break;
Expand Down
7 changes: 6 additions & 1 deletion dock-network-plugin/widget/jumpsettingbutton.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand All @@ -7,10 +7,11 @@

#include "commoniconbutton.h"

#include <QFrame>

Check warning on line 10 in dock-network-plugin/widget/jumpsettingbutton.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in dock-network-plugin/widget/jumpsettingbutton.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in dock-network-plugin/widget/jumpsettingbutton.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 <DLabel>

Check warning on line 14 in dock-network-plugin/widget/jumpsettingbutton.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.

class JumpSettingButton : public QFrame
{
Expand Down Expand Up @@ -44,6 +45,10 @@
QString m_secondPage;
CommonIconButton *m_iconButton;
Dtk::Widget::DLabel *m_descriptionLabel;
QGraphicsOpacityEffect *m_iconOpacityEffect;
QGraphicsOpacityEffect *m_descOpacityEffect;
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;
};

#endif
6 changes: 6 additions & 0 deletions net-view/window/private/netdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
#include <QTextLine>
#include <QTimer>
#include <QToolButton>
#include <QTextLine>

Check warning on line 28 in net-view/window/private/netdelegate.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 29 in net-view/window/private/netdelegate.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 30 in net-view/window/private/netdelegate.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

DWIDGET_USE_NAMESPACE

Expand Down Expand Up @@ -891,7 +892,10 @@
: NetWidget (item, parent)
, m_portalLabel (nullptr)
, m_isEnter(false)
, m_opacityEffect(new QGraphicsOpacityEffect(this))
{
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);
}

void NetItemWidget::removePasswordWidget()
Expand All @@ -912,6 +916,8 @@

void NetItemWidget::setHover(bool isHover)
{
m_opacityEffect->setOpacity(isHover ? kHoverOpacity : kNormalOpacity);

if (!m_portalLabel)
return;

Expand Down
4 changes: 4 additions & 0 deletions net-view/window/private/netdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class QSortFilterProxyModel;
class QVBoxLayout;
class QGraphicsOpacityEffect;
class QLabel;

namespace Dtk {
Expand Down Expand Up @@ -181,6 +182,9 @@ protected slots:
QLabel *m_portalLabel;
NetType::NetManagerFlags m_flag;
bool m_isEnter;
QGraphicsOpacityEffect *m_opacityEffect;
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;
};

class NetWirelessWidget : public NetItemWidget
Expand Down
Loading