mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
refactor: 修改显示桌面插件,让其在任何模式都显示
This commit is contained in:
parent
4ac6a85b3b
commit
5f0ea1692c
@ -28,10 +28,11 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
ShowDesktopItem::ShowDesktopItem(QWidget *parent)
|
||||
: QLabel(parent),
|
||||
m_isHovered(false),
|
||||
m_isPressed(false)
|
||||
: DockItem(parent)
|
||||
, m_isHovered(false)
|
||||
, m_isPressed(false)
|
||||
{
|
||||
setAccessibleName("ShowDesktop");
|
||||
}
|
||||
|
||||
ShowDesktopItem::~ShowDesktopItem()
|
||||
@ -43,7 +44,7 @@ void ShowDesktopItem::enterEvent(QEvent *event)
|
||||
m_isHovered = true;
|
||||
update();
|
||||
|
||||
QLabel::enterEvent(event);
|
||||
DockItem::enterEvent(event);
|
||||
}
|
||||
|
||||
void ShowDesktopItem::leaveEvent(QEvent *event)
|
||||
@ -51,13 +52,13 @@ void ShowDesktopItem::leaveEvent(QEvent *event)
|
||||
m_isHovered = false;
|
||||
update();
|
||||
|
||||
QLabel::leaveEvent(event);
|
||||
DockItem::leaveEvent(event);
|
||||
}
|
||||
|
||||
void ShowDesktopItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
return QLabel::mousePressEvent(event);
|
||||
return DockItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
m_isPressed = true;
|
||||
@ -69,7 +70,7 @@ void ShowDesktopItem::mousePressEvent(QMouseEvent *event)
|
||||
void ShowDesktopItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
return QLabel::mouseReleaseEvent(event);
|
||||
return DockItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
m_isPressed = false;
|
||||
@ -91,7 +92,7 @@ void ShowDesktopItem::paintEvent(QPaintEvent *event)
|
||||
|
||||
if (m_isPressed) {
|
||||
painter.fillRect(destRect, "#2ca7f8");
|
||||
} else if(m_isHovered){
|
||||
} else if (m_isHovered) {
|
||||
painter.fillRect(destRect, QColor(255, 255, 255, 51));
|
||||
} else {
|
||||
painter.fillRect(destRect, QColor(255, 255, 255, 26));
|
||||
|
@ -22,15 +22,19 @@
|
||||
#ifndef SHOWDESKTOPITEM_H
|
||||
#define SHOWDESKTOPITEM_H
|
||||
|
||||
#include <QLabel>
|
||||
#include "dockitem.h"
|
||||
|
||||
class ShowDesktopItem : public QLabel
|
||||
class ShowDesktopItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShowDesktopItem(QWidget *parent = 0);
|
||||
virtual ~ShowDesktopItem();
|
||||
explicit ShowDesktopItem(QWidget *parent = nullptr);
|
||||
virtual ~ShowDesktopItem() override;
|
||||
inline ItemType itemType() const override
|
||||
{
|
||||
return Launcher;
|
||||
}
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
@ -168,8 +168,8 @@ void TrashPlugin::displayModeChanged(const Dock::DisplayMode displayMode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (displayMode == Dock::Fashion)
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
// if (displayMode == Dock::Fashion)
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
// else
|
||||
// m_proxyInter->itemRemoved(this, pluginName());
|
||||
}
|
||||
|
@ -72,8 +72,7 @@ const QString TrashWidget::contextMenu() const
|
||||
open["isActive"] = true;
|
||||
items.push_back(open);
|
||||
|
||||
if (!m_popupApplet->empty())
|
||||
{
|
||||
if (!m_popupApplet->empty()) {
|
||||
QMap<QString, QVariant> empty;
|
||||
empty["itemId"] = "empty";
|
||||
empty["itemText"] = tr("Empty");
|
||||
@ -182,7 +181,8 @@ void TrashWidget::resizeEvent(QResizeEvent *e)
|
||||
|
||||
void TrashWidget::updateIcon()
|
||||
{
|
||||
const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
// Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
Dock::DisplayMode displayMode = displayMode = Dock::Fashion;
|
||||
|
||||
QString iconString = "user-trash";
|
||||
if (!m_popupApplet->empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user