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
34 changes: 34 additions & 0 deletions plugins/dde-dock/bluetooth/quickpanelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ QuickPanelWidget::QuickPanelWidget(QWidget *parent)
, m_nameLabel(new DLabel(this))
, m_stateLabel(new DLabel(this))
, m_expandLabel(new DIconButton(this))
, m_iconEffect(new QGraphicsOpacityEffect(m_iconWidget))
, m_nameEffect(new QGraphicsOpacityEffect(m_nameLabel))
, m_stateEffect(new QGraphicsOpacityEffect(m_stateLabel))
{
initUi();
initConnection();
Expand All @@ -90,7 +93,9 @@ void QuickPanelWidget::setDescription(const QString &description)

void QuickPanelWidget::setActive(bool active)
{
m_active = active;
m_iconWidget->setBackgroundRole(active ? QPalette::Highlight : QPalette::BrightText);
updateOpacity(m_hovered);
}

void QuickPanelWidget::mousePressEvent(QMouseEvent *event)
Expand Down Expand Up @@ -128,10 +133,14 @@ void QuickPanelWidget::initUi()
m_nameLabel->setElideMode(Qt::ElideRight);
m_nameLabel->setContentsMargins(0, 2, 0, 0);
m_nameLabel->setForegroundRole(QPalette::BrightText);
m_nameEffect->setOpacity(kNormalOpacity);
m_nameLabel->setGraphicsEffect(m_nameEffect);

DFontSizeManager::instance()->bind(m_stateLabel, DFontSizeManager::T10);
DToolTip::setToolTipShowMode(m_stateLabel, DToolTip::ShowWhenElided);
m_stateLabel->setElideMode(Qt::ElideRight);
m_stateEffect->setOpacity(kNormalOpacity);
m_stateLabel->setGraphicsEffect(m_stateEffect);

QVBoxLayout *layout = new QVBoxLayout(labelWidget);
layout->setContentsMargins(0, 8, 0, 8);
Expand All @@ -143,6 +152,8 @@ void QuickPanelWidget::initUi()
m_iconWidget->setEnabledCircle(true);
m_iconWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_iconWidget->setIconSize(IconSize);
m_iconEffect->setOpacity(kNormalOpacity);
m_iconWidget->setGraphicsEffect(m_iconEffect);
m_iconWidget->setCheckable(false);
m_iconWidget->setFixedSize(QSize(40, 40));
m_iconWidget->setFocusPolicy(Qt::NoFocus);
Expand Down Expand Up @@ -171,3 +182,26 @@ void QuickPanelWidget::initConnection()
{
connect(m_iconWidget, &DFloatingButton::clicked, this, &QuickPanelWidget::iconClicked);
}

void QuickPanelWidget::updateOpacity(bool hover)
{
// icon: when active, always 1.0; otherwise follow hover
m_iconEffect->setOpacity((m_active || hover) ? kHoverOpacity : kNormalOpacity);
// text: always follow hover regardless of active state
m_nameEffect->setOpacity(hover ? kHoverOpacity : kNormalOpacity);
m_stateEffect->setOpacity(hover ? kHoverOpacity : kNormalOpacity);
}

void QuickPanelWidget::enterEvent(QEnterEvent *event)
{
m_hovered = true;
updateOpacity(true);
QWidget::enterEvent(event);
}

void QuickPanelWidget::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
m_hovered = false;
updateOpacity(false);
}
13 changes: 13 additions & 0 deletions plugins/dde-dock/bluetooth/quickpanelwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#ifndef QUICKPANELWIDGET_H
#define QUICKPANELWIDGET_H

#include <QGraphicsOpacityEffect>

Check warning on line 9 in plugins/dde-dock/bluetooth/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.

#include <DFloatingButton>

Check warning on line 11 in plugins/dde-dock/bluetooth/quickpanelwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in plugins/dde-dock/bluetooth/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>

Expand Down Expand Up @@ -35,17 +37,28 @@
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;

private:
void initUi();
void initConnection();
void updateOpacity(bool hover);

private:
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;

QuickButton *m_iconWidget;
Dtk::Widget::DLabel *m_nameLabel;
Dtk::Widget::DLabel *m_stateLabel;
Dtk::Widget::DIconButton *m_expandLabel;
QPoint m_clickPoint;
bool m_active = false;
bool m_hovered = false;
QGraphicsOpacityEffect *m_iconEffect;
QGraphicsOpacityEffect *m_nameEffect;
QGraphicsOpacityEffect *m_stateEffect;
};

#endif // QUICKPANELWIDGET_H
17 changes: 17 additions & 0 deletions plugins/dde-dock/brightness/brightnessquickpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ BrightnessQuickPanel::BrightnessQuickPanel(QWidget* parent)
: QWidget(parent)
, m_sliderContainer(new SliderContainer(this))
, m_currentMonitor(nullptr)
, m_opacityEffect(new QGraphicsOpacityEffect(this))
{
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);
initUi();
initConnection();

m_sliderContainer->setRange(BrightnessModel::ref().minBrightness(), BrightnessModel::ref().maxBrightness());
UpdateDisplayStatus();
}


BrightnessQuickPanel::~BrightnessQuickPanel()
{
}
Expand Down Expand Up @@ -110,3 +114,16 @@ void BrightnessQuickPanel::refreshWidget()
m_sliderContainer->updateSliderValue(m_currentMonitor->brightness() * 100);
}
}

void BrightnessQuickPanel::enterEvent(QEnterEvent *event)
{
m_opacityEffect->setOpacity(kHoverOpacity);
QWidget::enterEvent(event);
}

void BrightnessQuickPanel::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
m_opacityEffect->setOpacity(kNormalOpacity);
}

7 changes: 7 additions & 0 deletions plugins/dde-dock/brightness/brightnessquickpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include "brightnesscontroller.h"
#include "monitor.h"

#include <DBlurEffectWidget>

Check warning on line 11 in plugins/dde-dock/brightness/brightnessquickpanel.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in plugins/dde-dock/brightness/brightnessquickpanel.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 <QWidget>

Check warning on line 13 in plugins/dde-dock/brightness/brightnessquickpanel.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 <QPointer>

Check warning on line 14 in plugins/dde-dock/brightness/brightnessquickpanel.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

class QDBusMessage;
class SliderContainer;
Expand All @@ -32,12 +33,18 @@
protected:
void initUi();
void initConnection();
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;

private Q_SLOTS:
void refreshWidget();
void UpdateDisplayStatus();

private:
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;

SliderContainer *m_sliderContainer;
QPointer<Monitor> m_currentMonitor;
QGraphicsOpacityEffect *m_opacityEffect;
};
20 changes: 20 additions & 0 deletions plugins/dde-dock/common/jumpsettingbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,24 @@ JumpSettingButton::JumpSettingButton(QWidget *parent)
, m_autoShowPage(true)
, m_iconButton(new CommonIconButton(this))
, m_descriptionLabel(new DLabel(this))
, m_opacityEffect(new QGraphicsOpacityEffect(this))
{
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);
initUI();
}


JumpSettingButton::JumpSettingButton(const QIcon& icon, const QString& description, QWidget* parent)
: QFrame(parent)
, m_hover(false)
, m_autoShowPage(true)
, m_iconButton(new CommonIconButton(this))
, m_descriptionLabel(new DLabel(this))
, m_opacityEffect(new QGraphicsOpacityEffect(this))
{
m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);
initUI();

m_iconButton->setIcon(icon);
Expand Down Expand Up @@ -143,3 +150,16 @@ void JumpSettingButton::setDccPage(const QString &first, const QString &second)
m_fistPage = first;
m_secondPage = second;
}

void JumpSettingButton::enterEvent(QEnterEvent *event)
{
m_opacityEffect->setOpacity(kHoverOpacity);
QFrame::enterEvent(event);
}

void JumpSettingButton::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
m_opacityEffect->setOpacity(kNormalOpacity);
}

8 changes: 8 additions & 0 deletions plugins/dde-dock/common/jumpsettingbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

#include "commoniconbutton.h"

#include <QGraphicsOpacityEffect>

Check warning on line 10 in plugins/dde-dock/common/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 <QFrame>

Check warning on line 12 in plugins/dde-dock/common/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 13 in plugins/dde-dock/common/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 <DLabel>

Expand All @@ -33,17 +35,23 @@
bool event(QEvent* e) override;
void paintEvent(QPaintEvent* e) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;

private:
void initUI();

private:
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;

bool m_hover;
bool m_autoShowPage;
QString m_fistPage;
QString m_secondPage;
CommonIconButton *m_iconButton;
Dtk::Widget::DLabel *m_descriptionLabel;
QGraphicsOpacityEffect *m_opacityEffect;
};

#endif
18 changes: 18 additions & 0 deletions plugins/dde-dock/common/pluginitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ PluginItemWidget::PluginItemWidget(PluginStandardItem *item, QWidget *parent)
, m_connBtn(nullptr)
, m_spinner(nullptr)
, m_rightIconSpacerItem(new QSpacerItem(0, 0))
, m_opacityEffect(new QGraphicsOpacityEffect(this))
{
if (!m_item) {
QLabel *err = new QLabel(this);
Expand Down Expand Up @@ -242,8 +243,12 @@ PluginItemWidget::PluginItemWidget(PluginStandardItem *item, QWidget *parent)
connect(m_item, &PluginStandardItem::stateChanged, this, &PluginItemWidget::updateState);

connect(m_connBtn, &CommonIconButton::clicked, m_item, &PluginStandardItem::connectBtnClicked);

m_opacityEffect->setOpacity(kNormalOpacity);
setGraphicsEffect(m_opacityEffect);
}


PluginItemWidget::~PluginItemWidget()
{
}
Expand Down Expand Up @@ -315,3 +320,16 @@ bool PluginItemWidget::event(QEvent *e)
}
return QWidget::event(e);
}

void PluginItemWidget::enterEvent(QEnterEvent *event)
{
m_opacityEffect->setOpacity(kHoverOpacity);
QWidget::enterEvent(event);
}

void PluginItemWidget::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
m_opacityEffect->setOpacity(kNormalOpacity);
}

8 changes: 8 additions & 0 deletions plugins/dde-dock/common/pluginitemdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <DLabel>
#include <DSpinner>

#include <QGraphicsOpacityEffect>

#include <QObject>
#include <QStyledItemDelegate>
#include <QStandardItem>
Expand Down Expand Up @@ -116,8 +118,13 @@ public Q_SLOTS:

protected:
bool event(QEvent *e) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;

private:
static constexpr qreal kNormalOpacity = 0.7;
static constexpr qreal kHoverOpacity = 1.0;

PluginStandardItem *m_item;

QHBoxLayout *m_mainLayout;
Expand All @@ -126,4 +133,5 @@ public Q_SLOTS:
CommonIconButton *m_connBtn;
DSpinner *m_spinner;
QSpacerItem *m_rightIconSpacerItem;
QGraphicsOpacityEffect *m_opacityEffect;
};
31 changes: 31 additions & 0 deletions plugins/dde-dock/common/singlequickpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SignalQuickPanel::SignalQuickPanel(QWidget *parent)
, m_icon(new CommonIconButton(this))
, m_description(new DLabel(this))
, m_active(false)
, m_iconEffect(new QGraphicsOpacityEffect(m_icon))
, m_descEffect(new QGraphicsOpacityEffect(m_description))
{
initUI();
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SignalQuickPanel::refreshBg);
Expand All @@ -34,10 +36,16 @@ void SignalQuickPanel::initUI()
{
m_icon->setFixedSize(QSize(24, 24));

m_iconEffect->setOpacity(kNormalOpacity);
m_icon->setGraphicsEffect(m_iconEffect);

m_description->setElideMode(Qt::ElideRight);
DToolTip::setToolTipShowMode(m_description, DToolTip::ShowWhenElided);
DFontSizeManager::instance()->bind(m_description, DFontSizeManager::T10);

m_descEffect->setOpacity(kNormalOpacity);
m_description->setGraphicsEffect(m_descEffect);

auto layout = new QVBoxLayout;
layout->setContentsMargins(8, 8, 8, 8);
layout->setSpacing(0);
Expand Down Expand Up @@ -68,6 +76,29 @@ void SignalQuickPanel::setWidgetState(WidgetState state)
m_active = (WS_ACTIVE == state);

refreshBg();
updateOpacity(m_hovered);
}

void SignalQuickPanel::updateOpacity(bool hover)
{
// icon: when active, always 1.0; otherwise follow hover
m_iconEffect->setOpacity((m_active || hover) ? kHoverOpacity : kNormalOpacity);
// text: always follow hover regardless of active state
m_descEffect->setOpacity(hover ? kHoverOpacity : kNormalOpacity);
}

void SignalQuickPanel::enterEvent(QEnterEvent *event)
{
m_hovered = true;
updateOpacity(true);
QWidget::enterEvent(event);
}

void SignalQuickPanel::leaveEvent(QEvent *event)
{
Q_UNUSED(event)
m_hovered = false;
updateOpacity(false);
}

void SignalQuickPanel::mouseReleaseEvent(QMouseEvent *event)
Expand Down
Loading
Loading