mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
ArrowRectangle add enterEvent and leaveEvent to control show and hide
This commit is contained in:
parent
61d09fb6c0
commit
e50feee224
@ -16,8 +16,6 @@ AppItem::AppItem(QWidget *parent) :
|
||||
QWidget *AppItem::getApplet()
|
||||
{
|
||||
AppPreviews *preview = new AppPreviews();
|
||||
connect(preview,&AppPreviews::mouseEntered,this,&AppItem::cancelHide);
|
||||
connect(preview,&AppPreviews::mouseExited,[=](){hidePreview();});
|
||||
connect(preview,&AppPreviews::sizeChanged,this,&AppItem::resizePreview);
|
||||
|
||||
QJsonArray tmpArray = QJsonDocument::fromJson(m_itemData.xidsJsonString.toUtf8()).array();
|
||||
|
@ -32,20 +32,17 @@ void AppPreviewFrame::mousePressEvent(QMouseEvent *)
|
||||
|
||||
void AppPreviewFrame::enterEvent(QEvent *)
|
||||
{
|
||||
emit mouseEntered();
|
||||
showCloseButton();
|
||||
}
|
||||
|
||||
void AppPreviewFrame::leaveEvent(QEvent *)
|
||||
{
|
||||
// emit mouseExited();
|
||||
hideCloseButton();
|
||||
}
|
||||
|
||||
void AppPreviewFrame::addCloseButton()
|
||||
{
|
||||
m_cb = new CloseButton(this);
|
||||
connect(m_cb,&CloseButton::hovered,this,&AppPreviewFrame::mouseEntered);
|
||||
connect(m_cb,&CloseButton::clicked,[=](){close(this->xidValue);});
|
||||
m_cb->resize(28,28);
|
||||
|
||||
@ -85,8 +82,6 @@ void AppPreviews::addItem(const QString &title, int xid)
|
||||
AppPreviewFrame *f = new AppPreviewFrame(preview,title,xid);
|
||||
connect(f,&AppPreviewFrame::close,this,&AppPreviews::removePreview);
|
||||
connect(f,&AppPreviewFrame::activate,this,&AppPreviews::activatePreview);
|
||||
connect(f,&AppPreviewFrame::mouseEntered,this,&AppPreviews::mouseEntered);
|
||||
connect(f,&AppPreviewFrame::mouseExited,this,&AppPreviews::mouseExited);
|
||||
|
||||
m_mainLayout->addWidget(f);
|
||||
|
||||
|
@ -27,8 +27,6 @@ protected:
|
||||
signals:
|
||||
void close(int xid);
|
||||
void activate(int xid);
|
||||
void mouseEntered();
|
||||
void mouseExited();
|
||||
|
||||
private:
|
||||
void addCloseButton();
|
||||
|
@ -78,6 +78,7 @@ void ArrowRectangle::showAtBottom(int x, int y)
|
||||
|
||||
void ArrowRectangle::delayHide(int interval)
|
||||
{
|
||||
m_delayHideInterval = interval;
|
||||
if (!m_destroyTimer)
|
||||
{
|
||||
m_destroyTimer = new QTimer(this);
|
||||
@ -263,6 +264,16 @@ void ArrowRectangle::paintEvent(QPaintEvent *)
|
||||
painter.fillPath(border, QBrush(backgroundColor == "" ? QColor(0,0,0,200) : QColor(backgroundColor)));
|
||||
}
|
||||
|
||||
void ArrowRectangle::enterEvent(QEvent *)
|
||||
{
|
||||
cancelHide();
|
||||
}
|
||||
|
||||
void ArrowRectangle::leaveEvent(QEvent *)
|
||||
{
|
||||
delayHide(m_delayHideInterval);
|
||||
}
|
||||
|
||||
void ArrowRectangle::slotHide()
|
||||
{
|
||||
destroyContent();
|
||||
|
@ -62,6 +62,8 @@ public slots:
|
||||
void slotCancelHide();
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
private:
|
||||
int radius = 3;
|
||||
@ -77,6 +79,7 @@ private:
|
||||
int shadowWidth = 2;
|
||||
QColor shadowColor = Qt::black;
|
||||
|
||||
int m_delayHideInterval = 0;
|
||||
ArrowDirection arrowDirection = ArrowRectangle::ArrowRight;
|
||||
|
||||
QWidget *m_content = NULL;
|
||||
|
@ -56,7 +56,7 @@ void PluginItemWrapper::leaveEvent(QEvent *)
|
||||
{
|
||||
emit mouseExited();
|
||||
|
||||
// hidePreview();
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user