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

feat: 增加dock栏鼠标悬停item背景加深 #874

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
25 changes: 25 additions & 0 deletions frame/item/dockitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ QPointer<DockPopupWindow> DockItem::PopupWindow(nullptr);
DockItem::DockItem(QWidget *parent)
: QWidget(parent)
, m_hover(false)
, m_pressed(false)
, m_popupShown(false)
, m_tapAndHold(false)
, m_draging(false)
Expand Down Expand Up @@ -134,12 +135,28 @@ void DockItem::updatePopupPosition()

void DockItem::paintEvent(QPaintEvent *e)
{
if(m_hover && !m_pressed)
{
Comment on lines +138 to +139
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(m_hover && !m_pressed)
{
if (m_hover && !m_pressed) {

QPainter painter(this);
painter.setBrush(QBrush(QColor(248, 248, 255)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个颜色无论亮色与暗色主题均保持同一个颜色吗?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,这个颜色是固定的,无论主题是否变化

painter.setPen(Qt::NoPen);
QRect tempRect = rect();
painter.drawRect(tempRect.x(), tempRect.y(), tempRect.width(), tempRect.height());
}else if(m_hover && m_pressed)
{
Comment on lines +145 to +146
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else if(m_hover && m_pressed)
{
} else if (m_hover && m_pressed) {

QPainter painter(this);
painter.setBrush(Qt::gray);
painter.setPen(Qt::NoPen);
QRect tempRect = rect();
painter.drawRect(tempRect.x(), tempRect.y(), tempRect.width(), tempRect.height());
}
QWidget::paintEvent(e);
}

void DockItem::mousePressEvent(QMouseEvent *e)
{
m_popupTipsDelayTimer->stop();
m_pressed = true;
hideNonModel();

if (e->button() == Qt::RightButton) {
Expand Down Expand Up @@ -178,6 +195,7 @@ void DockItem::leaveEvent(QEvent *e)
QWidget::leaveEvent(e);

m_hover = false;
m_pressed = false;
//FIXME: 可能是qt的bug,概率性导致崩溃,待修复
// m_hoverEffect->setHighlighting(false);
m_popupTipsDelayTimer->stop();
Expand All @@ -189,6 +207,13 @@ void DockItem::leaveEvent(QEvent *e)
update();
}

void DockItem::mouseReleaseEvent(QMouseEvent *event)
{
m_pressed = false;
QWidget::mouseReleaseEvent(event);
update();
}

const QRect DockItem::perfectIconRect() const
{
const QRect itemRect = rect();
Expand Down
2 changes: 2 additions & 0 deletions frame/item/dockitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public slots:
void mousePressEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
void mouseReleaseEvent(QMouseEvent *event) override;

const QRect perfectIconRect() const;
const QPoint popupMarkPoint() ;
Expand All @@ -95,6 +96,7 @@ protected slots:

protected:
bool m_hover;
bool m_pressed;
bool m_popupShown;
bool m_tapAndHold;
bool m_draging;
Expand Down