fix: 为了将maintain/5.1分支合入uos,重新对任务栏图标点击、移动、拖动范围处理

由原来的提交的用鼠标当前坐标是否在图标范围内的判断方式修改为设置图标布局的边距的方式。以便于将maintain/5.1分支合入uos而不影响其他
功能

Log: 重新对任务栏图标可点击、移动或拖动范围进行处理
Change-Id: Icf6df593f468c247c6d4fc5c2ba0936d5135626b
Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/4271
Reviewed-by: <mailman@uniontech.com>
Reviewed-by: fanpengcheng <fanpengcheng@uniontech.com>
Tested-by: <mailman@uniontech.com>
This commit is contained in:
chenjun 2020-09-10 15:51:33 +08:00
parent e32e33de85
commit 88d52e28d1
20 changed files with 151 additions and 310 deletions

View File

@ -179,15 +179,9 @@ void DockItem::enterEvent(QEvent *e)
return;
}
if (containCursorPos()) {
m_hover = true;
m_hoverEffect->setHighlighting(true);
m_popupTipsDelayTimer->start();
} else {
m_hover = false;
m_hoverEffect->setHighlighting(false);
m_popupTipsDelayTimer->stop();
}
m_hover = true;
m_hoverEffect->setHighlighting(true);
m_popupTipsDelayTimer->start();
update();
@ -213,16 +207,9 @@ void DockItem::leaveEvent(QEvent *e)
void DockItem::mouseMoveEvent(QMouseEvent *e)
{
if (containCursorPos()) {
m_hover = true;
m_hoverEffect->setHighlighting(true);
m_popupTipsDelayTimer->start();
} else {
m_hover = false;
m_hoverEffect->setHighlighting(false);
m_popupTipsDelayTimer->stop();
hidePopup();
}
m_hover = true;
m_hoverEffect->setHighlighting(true);
m_popupTipsDelayTimer->start();
update();
@ -291,20 +278,6 @@ void DockItem::onContextMenuAccepted()
emit requestWindowAutoHide(true);
}
bool DockItem::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}
void DockItem::showHoverTips()
{
// another model popup window already exists

View File

@ -60,7 +60,6 @@ public:
QSize sizeHint() const override;
virtual QString accessibleName();
bool containCursorPos();
public slots:
virtual void refershIcon() {}

View File

@ -140,10 +140,6 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
return;
}
if (!containCursorPos()) {
return;
}
update();
if (PopupWindow->isVisible())
@ -164,10 +160,6 @@ void PluginsItem::mouseMoveEvent(QMouseEvent *e)
DockItem::mouseMoveEvent(e);
if (!containCursorPos()) {
return;
}
e->accept();
const QPoint distance = e->pos() - MousePressPoint;
@ -191,10 +183,6 @@ void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
e->accept();
if (!containCursorPos()) {
return;
}
const QPoint distance = e->pos() - MousePressPoint;
if (distance.manhattanLength() < PLUGIN_ITEM_DRAG_THRESHOLD)
mouseClicked();

View File

@ -255,8 +255,12 @@ void MainPanelControl::addTrayAreaItem(int index, QWidget *wdg)
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
{
m_pluginLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
resizeDockIcon();
//因为日期时间插件和其他插件的大小有异,为了方便设置边距,在插件区域布局再添加一层布局设置边距
//因此在处理插件图标时,需要通过两层布局判断是否为需要的插件,例如拖动插件位置等判断
QBoxLayout * boxLayout = new QBoxLayout(QBoxLayout::LeftToRight);
boxLayout->addWidget(wdg, 0, Qt::AlignCenter);
m_pluginLayout->insertLayout(index, boxLayout, 0);
resizeDockIcon();;
m_pluginAreaWidget->adjustSize();
}
@ -277,7 +281,16 @@ void MainPanelControl::removeTrayAreaItem(QWidget *wdg)
void MainPanelControl::removePluginAreaItem(QWidget *wdg)
{
m_pluginLayout->removeWidget(wdg);
//因为日期时间插件大小和其他插件有异,为了方便设置边距,各插件中增加一层布局
//因此remove插件图标时需要从多的一层布局中取widget进行判断是否需要移除的插件
for (int i = 0; i < m_pluginLayout->count(); ++i) {
QLayoutItem *layoutItem = m_pluginLayout->itemAt(i);
QLayout *boxLayout = layoutItem->layout();
if (boxLayout && boxLayout->itemAt(0)->widget() == wdg) {
boxLayout->removeWidget(wdg);
m_pluginLayout->removeItem(layoutItem);
}
}
}
void MainPanelControl::resizeEvent(QResizeEvent *event)
@ -375,9 +388,17 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
int idx = -1;
if (targetItem->itemType() == DockItem::App)
idx = m_appAreaSonLayout->indexOf(targetItem);
else if (targetItem->itemType() == DockItem::Plugins)
idx = m_pluginLayout->indexOf(targetItem);
else if (targetItem->itemType() == DockItem::FixedPlugin)
else if (targetItem->itemType() == DockItem::Plugins){
//因为日期时间插件大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
//因此有拖动图标时,需要从多的一层布局中判断是否相同插件而获取插件位置顺序
for (int i = 0; i < m_pluginLayout->count(); ++i) {
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
if (layout && layout->itemAt(0)->widget() == targetItem) {
idx = i;
break;
}
}
} else if (targetItem->itemType() == DockItem::FixedPlugin)
idx = m_fixedAreaLayout->indexOf(targetItem);
else
return;
@ -611,10 +632,6 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
if (item->itemType() != DockItem::App && item->itemType() != DockItem::Plugins && item->itemType() != DockItem::FixedPlugin)
return false;
if (!item->containCursorPos()) {
return false;
}
const QPoint pos = mouseEvent->globalPos();
const QPoint distance = pos - m_mousePressPos;
if (distance.manhattanLength() < QApplication::startDragDistance())
@ -720,22 +737,21 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
for (int i = 0 ; i < parentLayout->count(); ++i) {
QLayoutItem *layoutItem = parentLayout->itemAt(i);
DockItem *dockItem = qobject_cast<DockItem *>(layoutItem->widget());
DockItem *dockItem = nullptr;
if (parentWidget == m_pluginAreaWidget) {
QLayout *layout = layoutItem->layout();
if (layout) {
dockItem = qobject_cast<DockItem *>(layout->itemAt(0)->widget());
}
} else{
dockItem = qobject_cast<DockItem *>(layoutItem->widget());
}
if (!dockItem)
continue;
QRect rect;
rect.setTopLeft(dockItem->pos());
if (dockItem->itemType() == DockItem::Plugins) {
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
rect.setSize(QSize(PLUGIN_MAX_SIZE, height()));
} else {
rect.setSize(QSize(width(), PLUGIN_MAX_SIZE));
}
} else {
rect.setSize(dockItem->size());
}
QRect rect(dockItem->pos(), dockItem->size());
if (rect.contains(point)) {
targetItem = dockItem;
break;
@ -866,31 +882,39 @@ void MainPanelControl::paintEvent(QPaintEvent *event)
void MainPanelControl::resizeDockIcon()
{
if (!m_tray)
return;
// 插件有点特殊因为会引入第三方的插件并不会受dock的缩放影响我们只能限制我们自己的插件否则会导致显示错误。
// 以下是受控制的插件
PluginsItem *trashPlugin = nullptr;
PluginsItem *shutdownPlugin = nullptr;
PluginsItem *keyboardPlugin = nullptr;
PluginsItem *notificationPlugin = nullptr;
//因为日期时间大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
//因此需要通过多一层布局来获取各插件
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
if (w->pluginName() == "trash") {
trashPlugin = w;
} else if (w->pluginName() == "shutdown") {
shutdownPlugin = w;
} else if (w->pluginName() == "onboard") {
keyboardPlugin = w;
} else if (w->pluginName() == "notifications") {
notificationPlugin = w;
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
if (layout) {
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
if (w) {
if (w->pluginName() == "trash") {
trashPlugin = w;
} else if (w->pluginName() == "shutdown") {
shutdownPlugin = w;
} else if (w->pluginName() == "onboard") {
keyboardPlugin = w;
} else if (w->pluginName() == "notifications") {
notificationPlugin = w;
}
}
}
}
// 总宽度
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
// 减去托盘间隔区域
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
if (m_tray) {
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
}
// 减去3个分割线的宽度
totalLength -= 3 * SPLITER_SIZE;
@ -915,7 +939,12 @@ void MainPanelControl::resizeDockIcon()
return;
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
int pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
int pluginCount = 0;
if (m_tray) {
pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
} else {
pluginCount = (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
}
// icon个数
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
// 余数
@ -956,8 +985,10 @@ void MainPanelControl::resizeDockIcon()
void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin)
{
int appItemSize = qMin(w, h);
for (int i = 0; i < m_fixedAreaLayout->count(); ++i) {
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(w, h);
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(appItemSize, appItemSize);
}
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
@ -971,7 +1002,7 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
}
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(w, h);
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(appItemSize, appItemSize);
}
// 托盘上每个图标大小
@ -988,58 +1019,83 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
if (tray_item_size < 20)
return;
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
// 插件
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
if (shutdownPlugin)
shutdownPlugin->setFixedSize(tray_item_size, h - 20);
if (keyboardPlugin)
keyboardPlugin->setFixedSize(tray_item_size, h - 20);
if (notificationPlugin)
notificationPlugin->setFixedSize(tray_item_size, h - 20);
if (trashPlugin)
trashPlugin->setFixedSize(tray_item_size, h - 20);
} else {
if (shutdownPlugin)
shutdownPlugin->setFixedSize(w - 20, tray_item_size);
if (keyboardPlugin)
keyboardPlugin->setFixedSize(w - 20, tray_item_size);
if (notificationPlugin)
notificationPlugin->setFixedSize(w - 20, tray_item_size);
if (trashPlugin)
trashPlugin->setFixedSize(w - 20, tray_item_size);
if (m_tray) {
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
}
if (shutdownPlugin)
shutdownPlugin->setFixedSize(tray_item_size, tray_item_size);
if (keyboardPlugin)
keyboardPlugin->setFixedSize(tray_item_size, tray_item_size);
if (notificationPlugin)
notificationPlugin->setFixedSize(tray_item_size, tray_item_size);
if (trashPlugin)
trashPlugin->setFixedSize(tray_item_size, tray_item_size);
//因为日期时间大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
//因此需要通过多一层布局来获取各插件
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
// 三方插件
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
if (pItem->pluginName() == "datetime"){
pItem->setFixedSize(pItem->sizeHint().width(), h);
} else if (pItem->pluginName() == "AiAssistant"){
pItem->setFixedSize(tray_item_size, h - 20);
} else {
pItem->setFixedSize(pItem->sizeHint().width(), h - 20);
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
if (layout) {
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
if (pItem->pluginName() == "datetime") {
pItem->setFixedSize(pItem->sizeHint().width(), h);
} else {
pItem->setFixedSize(tray_item_size, tray_item_size);
}
}
}
}
} else {
// 三方插件
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
if (pItem->pluginName() == "datetime"){
pItem->setFixedSize(w, pItem->sizeHint().height());
} else if (pItem->pluginName() == "AiAssistant"){
pItem->setFixedSize(w - 20, tray_item_size);
} else {
pItem->setFixedSize(w - 20, pItem->sizeHint().height());
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
if (layout) {
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
if (pItem->pluginName() == "datetime") {
pItem->setFixedSize(w, pItem->sizeHint().height());
} else {
pItem->setFixedSize(tray_item_size, tray_item_size);
}
}
}
}
}
int appTopAndBottomMargin = 0;
int appLeftAndRightMargin = 0;
int trayTopAndBottomMargin = 0;
int trayLeftAndRightMargin = 0;
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
appTopAndBottomMargin = (m_fixedAreaWidget->height() - appItemSize) / 2;
trayTopAndBottomMargin = (m_trayAreaWidget->height() - tray_item_size) / 2;
} else {
appLeftAndRightMargin = (m_fixedAreaWidget->width() - appItemSize) / 2;
trayLeftAndRightMargin = (m_trayAreaWidget->width() - tray_item_size) / 2;
}
m_fixedAreaLayout->setContentsMargins(appLeftAndRightMargin, appTopAndBottomMargin, appLeftAndRightMargin, appTopAndBottomMargin);
m_appAreaSonLayout->setContentsMargins(appLeftAndRightMargin, appTopAndBottomMargin, appLeftAndRightMargin, appTopAndBottomMargin);
m_trayAreaLayout->setContentsMargins(trayLeftAndRightMargin, trayTopAndBottomMargin, trayLeftAndRightMargin, trayTopAndBottomMargin);
//因为日期时间插件大小和其他插件大小有异,需要单独设置各插件的边距
//而不对日期时间插件设置边距
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
if (layout) {
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
if (pItem && pItem->pluginName() != "datetime") {
layout->setContentsMargins(trayLeftAndRightMargin, trayTopAndBottomMargin, trayLeftAndRightMargin, trayTopAndBottomMargin);
}
}
}
}
void MainPanelControl::getTrayVisableItemCount()

View File

@ -121,11 +121,7 @@ const QPixmap OnboardItem::loadSvg(const QString &fileName, const QSize &size) c
void OnboardItem::mousePressEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_pressed = true;
} else {
m_pressed = false;
}
m_pressed = true;
update();
@ -143,11 +139,7 @@ void OnboardItem::mouseReleaseEvent(QMouseEvent *event)
void OnboardItem::mouseMoveEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
m_hover = true;
update();
@ -167,17 +159,3 @@ void OnboardItem::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
}
bool OnboardItem::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}

View File

@ -44,7 +44,6 @@ private:
void mouseMoveEvent(QMouseEvent *event) override;
void leaveEvent(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
bool containCursorPos();
private:
Dock::DisplayMode m_displayMode;

View File

@ -122,27 +122,9 @@ const QPixmap ShutdownWidget::loadSvg(const QString &fileName, const QSize &size
return pixmap;
}
bool ShutdownWidget::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}
void ShutdownWidget::mousePressEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_pressed = true;
} else {
m_pressed = false;
}
m_pressed = true;
update();
@ -160,11 +142,7 @@ void ShutdownWidget::mouseReleaseEvent(QMouseEvent *event)
void ShutdownWidget::mouseMoveEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
m_hover = true;
update();

View File

@ -43,7 +43,6 @@ protected:
private:
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
bool containCursorPos();
private:
Dock::DisplayMode m_displayMode;

View File

@ -134,17 +134,3 @@ void AbstractTrayWidget::resizeEvent(QResizeEvent *event)
setMaximumWidth(QWIDGETSIZE_MAX);
}
}
bool AbstractTrayWidget::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}

View File

@ -60,7 +60,6 @@ protected:
void handleMouseRelease();
const QRect perfectIconRect() const;
void resizeEvent(QResizeEvent *event) override;
bool containCursorPos();
private:
QTimer *m_handleMouseReleaseTimer;

View File

@ -149,11 +149,6 @@ void AbstractContainer::setExpand(const bool expand)
refreshVisible();
}
//QSize AbstractContainer::sizeHint() const
//{
// return totalSize();
//}
void AbstractContainer::setItemSize(int itemSize)
{
m_itemSize = itemSize;

View File

@ -149,9 +149,8 @@ void FashionTrayControlWidget::mouseReleaseEvent(QMouseEvent *event)
if (event->button() == Qt::LeftButton) {
event->accept();
if (containCursorPos()) {
setExpanded(!m_expanded);
}
setExpanded(!m_expanded);
return;
}
@ -165,11 +164,7 @@ void FashionTrayControlWidget::mousePressEvent(QMouseEvent *event)
return QWidget::mousePressEvent(event);
}
if (containCursorPos()) {
m_pressed = true;
} else {
m_pressed = false;
}
m_pressed = true;
update();
@ -178,11 +173,7 @@ void FashionTrayControlWidget::mousePressEvent(QMouseEvent *event)
void FashionTrayControlWidget::enterEvent(QEvent *event)
{
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
m_hover = true;
update();
@ -203,19 +194,6 @@ void FashionTrayControlWidget::resizeEvent(QResizeEvent *event)
QWidget::resizeEvent(event);
}
void FashionTrayControlWidget::mouseMoveEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
update();
QWidget::mouseMoveEvent(event);
}
void FashionTrayControlWidget::refreshArrowPixmap()
{
QString iconPath;
@ -238,17 +216,3 @@ void FashionTrayControlWidget::refreshArrowPixmap()
const auto ratio = devicePixelRatioF();
m_arrowPix = ImageUtil::loadSvg(iconPath, ":/icons/resources/", PLUGIN_ICON_MAX_SIZE, ratio);
}
bool FashionTrayControlWidget::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}

View File

@ -48,11 +48,9 @@ protected:
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
void refreshArrowPixmap();
bool containCursorPos();
private:
QTimer *m_expandDelayTimer;

View File

@ -141,11 +141,7 @@ void FashionTrayWidgetWrapper::mousePressEvent(QMouseEvent *event)
MousePressPoint = event->pos();
}
if (containCursorPos()) {
m_pressed = true;
} else {
m_pressed = false;
}
m_pressed = true;
update();
@ -179,11 +175,7 @@ void FashionTrayWidgetWrapper::dragEnterEvent(QDragEnterEvent *event)
void FashionTrayWidgetWrapper::enterEvent(QEvent *event)
{
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
m_hover = true;
update();
@ -228,11 +220,7 @@ void FashionTrayWidgetWrapper::handleMouseMove(QMouseEvent *event)
if(m_absTrayWidget.isNull())
return;
if (containCursorPos()) {
m_hover = true;
} else {
m_hover = false;
}
m_hover = true;
update();
@ -244,10 +232,6 @@ void FashionTrayWidgetWrapper::handleMouseMove(QMouseEvent *event)
return;
}
if (!containCursorPos()) {
return;
}
event->accept();
QDrag drag(this);
@ -283,20 +267,6 @@ void FashionTrayWidgetWrapper::onTrayWidgetClicked()
setAttention(false);
}
bool FashionTrayWidgetWrapper::containCursorPos()
{
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
QRect rect(this->rect());
int iconSize = qMin(rect.width(), rect.height());
int w = (rect.width() - iconSize) / 2;
int h = (rect.height() - iconSize) / 2;
rect = rect.adjusted(w, h, -w, -h);
return rect.contains(cursorPos);
}
bool FashionTrayWidgetWrapper::attention() const
{
return m_attention;

View File

@ -64,7 +64,6 @@ private:
void handleMouseMove(QMouseEvent *event);
void onTrayWidgetNeedAttention();
void onTrayWidgetClicked();
bool containCursorPos();
private:
QPointer<AbstractTrayWidget> m_absTrayWidget;

View File

@ -560,12 +560,7 @@ QPixmap SNITrayWidget::newIconPixmap(IconType iconType)
void SNITrayWidget::enterEvent(QEvent *event)
{
if (containCursorPos()) {
m_popupTipsDelayTimer->start();
} else {
m_popupTipsDelayTimer->stop();
hidePopup();
}
m_popupTipsDelayTimer->start();
AbstractTrayWidget::enterEvent(event);
}
@ -581,18 +576,6 @@ void SNITrayWidget::leaveEvent(QEvent *event)
AbstractTrayWidget::leaveEvent(event);
}
void SNITrayWidget::mouseMoveEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_popupTipsDelayTimer->start();
} else {
m_popupTipsDelayTimer->stop();
hidePopup();
}
AbstractTrayWidget::mouseMoveEvent(event);
}
void SNITrayWidget::showHoverTips()
{
if (PopupWindow->model())

View File

@ -101,7 +101,6 @@ private Q_SLOTS:
void popupWindowAccept();
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
void paintEvent(QPaintEvent *e) override;

View File

@ -203,12 +203,7 @@ void SystemTrayItem::enterEvent(QEvent *event)
return;
}
if (containCursorPos()) {
m_popupTipsDelayTimer->start();
} else {
m_popupTipsDelayTimer->stop();
hidePopup();
}
m_popupTipsDelayTimer->start();
update();
@ -294,18 +289,6 @@ void SystemTrayItem::showEvent(QShowEvent *event)
return AbstractTrayWidget::showEvent(event);
}
void SystemTrayItem::mouseMoveEvent(QMouseEvent *event)
{
if (containCursorPos()) {
m_popupTipsDelayTimer->start();
} else {
m_popupTipsDelayTimer->stop();
hidePopup();
}
AbstractTrayWidget::mouseMoveEvent(event);
}
const QPoint SystemTrayItem::popupMarkPoint() const
{
QPoint p(topleftPoint());

View File

@ -72,7 +72,6 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void showEvent(QShowEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
protected:
const QPoint popupMarkPoint() const;

View File

@ -147,11 +147,7 @@ void XEmbedTrayWidget::mouseMoveEvent(QMouseEvent *e)
return;
}
if (containCursorPos()) {
m_sendHoverEvent->start();;
} else {
m_sendHoverEvent->stop();
}
m_sendHoverEvent->start();
}
void XEmbedTrayWidget::configContainerPosition()