feat: 允许锁定任务栏上的图标防止被拖拽删除

需要通过命令设置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
This commit is contained in:
范朋程 2021-02-03 14:49:02 +08:00 committed by fanpengcheng
parent 7bd1bf6572
commit 1d99b3e5da
3 changed files with 23 additions and 2 deletions

View File

@ -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());

View File

@ -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<QGraphicsView *>(m_appDragWidget)->viewport()->installEventFilter(this);
} else {
appDrag->QDrag::setPixmap(dragPix);
}
}
drag = appDrag;
drag->setHotSpot(dragPix.rect().center() / dragPix.devicePixelRatioF());

View File

@ -14,6 +14,13 @@
<description>
Control Module Enable
</description>
</key>
<key type="b" name="removeable">
<default>true</default>
<summary>App Removeable</summary>
<description>
Control App Removeable
</description>
</key>
</schema>
<schema path="/com/deepin/dde/dock/disableplugins/" id="com.deepin.dde.dock.disableplugins" gettext-domain="DDE">