From 1d99b3e5daf1cfd9c215eab611396c9641394e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E6=9C=8B=E7=A8=8B?= Date: Wed, 3 Feb 2021 14:49:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=81=E8=AE=B8=E9=94=81=E5=AE=9A?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=A0=8F=E4=B8=8A=E7=9A=84=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E8=A2=AB=E6=8B=96=E6=8B=BD=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 需要通过命令设置gsettings set com.deepin.dde.dock.module.app removeable false Log: Task: https://pms.uniontech.com/zentao/task-view-60374.html Issue: Fixes #338 Change-Id: Idb76a8e28bbd4fae7db5870d07d3432fe4029029 --- frame/item/appitem.cpp | 7 +++++++ frame/panel/mainpanelcontrol.cpp | 11 +++++++++-- gschema/com.deepin.dde.dock.module.gschema.xml | 7 +++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 31c9745ff..9a101a234 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -122,6 +122,8 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent) connect(GSettingsByApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged); connect(GSettingsByDockApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged); + connect(GSettingsByActiveApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged); + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &AppItem::onThemeTypeChanged); connect(m_refershIconTimer, &QTimer::timeout, this, [ = ]() { @@ -305,6 +307,11 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e) m_lastclickTimes = curTimestamp; + // 鼠标在图标外边松开时,没必要响应点击操作 + const QRect rect { QPoint(0, 0), size()}; + if (!rect.contains(mapFromGlobal(QCursor::pos()))) + return; + if (e->button() == Qt::MiddleButton) { m_itemEntryInter->NewInstance(QX11Info::getTimestamp()); diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 935ab509a..1771a5910 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -54,6 +54,12 @@ static QGSettings *GSettingsByLaunch() return &settings; } +static QGSettings *GSettingsByApp() +{ + static QGSettings settings("com.deepin.dde.dock.module.app"); + return &settings; +} + MainPanelControl::MainPanelControl(QWidget *parent) : QWidget(parent) , m_mainPanelLayout(new QBoxLayout(QBoxLayout::LeftToRight, this)) @@ -652,7 +658,8 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event) return false; } - startDrag(item); + if (!GSettingsByApp()->keys().contains("removeable") || GSettingsByApp()->get("removeable").toBool()) + startDrag(item); return QWidget::eventFilter(watched, event); } @@ -724,7 +731,7 @@ void MainPanelControl::startDrag(DockItem *item) static_cast(m_appDragWidget)->viewport()->installEventFilter(this); } else { appDrag->QDrag::setPixmap(dragPix); - } + } drag = appDrag; drag->setHotSpot(dragPix.rect().center() / dragPix.devicePixelRatioF()); diff --git a/gschema/com.deepin.dde.dock.module.gschema.xml b/gschema/com.deepin.dde.dock.module.gschema.xml index ca02ac67d..8b5568288 100644 --- a/gschema/com.deepin.dde.dock.module.gschema.xml +++ b/gschema/com.deepin.dde.dock.module.gschema.xml @@ -14,6 +14,13 @@ Control Module Enable + + + true + App Removeable + + Control App Removeable +