Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions panels/dock/api/dbus/org.deepin.ds.dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</property>
<property access="readwrite" type="i" name="position"/>
<property access="readwrite" type="b" name="showInPrimary"/>
<property access="readwrite" type="b" name="locked"/>
<method name="callShow"/>
<method name="ReloadPlugins"/>
</interface>
Expand Down
4 changes: 4 additions & 0 deletions panels/dock/api/old/org.deepin.dde.daemon.Dock1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<property access="readwrite" type="i" name="HideMode"/>
<property access="readwrite" type="i" name="Position"/>
<property access="read" type="i" name="HideState"/>
<property access="readwrite" type="b" name="Locked"/>
<property access="read" type="(iiii)" name="FrontendWindowRect">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QRect"/>
</property>
Expand All @@ -46,5 +47,8 @@
<signal name="HideModeChanged">
<arg name="hideMode" type="i" direction="out"/>
</signal>
<signal name="LockedChanged">
<arg name="locked" type="b" direction="out"/>
</signal>
</interface>
</node>
1 change: 1 addition & 0 deletions panels/dock/api/old/org.deepin.dde.dock1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QRect"/>
</property>
<property access="readwrite" type="b" name="showInPrimary"/>
<property access="readwrite" type="b" name="locked"/>
<method name="callShow"/>
<method name="ReloadPlugins"/>
<method name="GetLoadedPlugins">
Expand Down
40 changes: 25 additions & 15 deletions panels/dock/dconfig/org.deepin.ds.dock.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,34 @@
"visibility": "private"
},
"Plugins_Visible": {
"value": {},
"serial": 0,
"flags": [],
"name": "The visibilities of plugins",
"name[zh_CN]": "插件可见性",
"description": "The loaded plugin which is visible when dock is started.",
"permissions": "readwrite",
"visibility": "private"
"value": {},
"serial": 0,
"flags": [],
"name": "The visibilities of plugins",
"name[zh_CN]": "插件可见性",
"description": "The loaded plugin which is visible when dock is started.",
"permissions": "readwrite",
"visibility": "private"
},
"Show_In_Primary": {
"value": true,
"serial": 0,
"flags": [],
"name": "show_in_primary",
"name[zh_CN]": "任务栏显示在主屏幕",
"description": "show dock in primary screen",
"permissions": "readwrite",
"visibility": "private"
"serial": 0,
"flags": [],
"name": "show_in_primary",
"name[zh_CN]": "任务栏显示在主屏幕",
"description": "show dock in primary screen",
"permissions": "readwrite",
"visibility": "private"
},
"Locked": {
"value": false,
"serial": 0,
"flags": [],
"name": "locked",
"name[zh_CN]": "禁用自由调节",
"description": "lock dock to prevent dragging resize",
"permissions": "readwrite",
"visibility": "private"
}
}
}
13 changes: 13 additions & 0 deletions panels/dock/dockdbusproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,18 @@ void DockDBusProxy::setShowInPrimary(bool newShowInPrimary)
parent()->setShowInPrimary(newShowInPrimary);
}

bool DockDBusProxy::locked() const
{
return parent()->locked();
}

void DockDBusProxy::setLocked(bool newLocked)
{
if (parent()->locked() == newLocked)
return;

parent()->setLocked(newLocked);
}

}

4 changes: 4 additions & 0 deletions panels/dock/dockdbusproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DockDBusProxy final: public QObject, public QDBusContext
Q_PROPERTY(uint WindowSizeFashion READ windowSizeFashion WRITE setWindowSizeFashion)
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode FINAL)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary FINAL)
Q_PROPERTY(bool locked READ locked WRITE setLocked FINAL)


public:
Expand Down Expand Up @@ -74,6 +75,9 @@ class DockDBusProxy final: public QObject, public QDBusContext
bool showInPrimary() const;
void setShowInPrimary(bool newShowInPrimary);

bool locked() const;
void setLocked(bool newLocked);

Q_SIGNALS:
void pluginVisibleChanged(const QString &pluginName, bool visible) const;

Expand Down
14 changes: 14 additions & 0 deletions panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ bool DockPanel::init()
connect(SETTINGS, &DockSettings::hideModeChanged, this, &DockPanel::hideModeChanged);
connect(SETTINGS, &DockSettings::itemAlignmentChanged, this, &DockPanel::itemAlignmentChanged);
connect(SETTINGS, &DockSettings::indicatorStyleChanged, this, &DockPanel::indicatorStyleChanged);
connect(SETTINGS, &DockSettings::lockedChanged, this, &DockPanel::lockedChanged);

connect(SETTINGS, &DockSettings::dockSizeChanged, this, [this, dockDaemonAdaptor](){
Q_EMIT dockDaemonAdaptor->WindowSizeEfficientChanged(dockSize());
Expand All @@ -121,6 +122,9 @@ bool DockPanel::init()
connect(SETTINGS, &DockSettings::itemAlignmentChanged, this, [this, dockDaemonAdaptor](){
Q_EMIT dockDaemonAdaptor->DisplayModeChanged(itemAlignment());
});
connect(SETTINGS, &DockSettings::lockedChanged, this, [this, dockDaemonAdaptor](){
Q_EMIT dockDaemonAdaptor->LockedChanged(locked());
});

DPanel::init();

Expand Down Expand Up @@ -368,6 +372,16 @@ void DockPanel::setShowInPrimary(bool newShowInPrimary)
disconnect(qApp, &QGuiApplication::primaryScreenChanged, this, &DockPanel::updateDockScreen);
}

bool DockPanel::locked() const
{
return SETTINGS->locked();
}

void DockPanel::setLocked(bool newLocked)
{
SETTINGS->setLocked(newLocked);
}

D_APPLET_CLASS(DockPanel)

void DockPanel::setHideState(HideState newHideState)
Expand Down
5 changes: 5 additions & 0 deletions panels/dock/dockpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
Q_PROPERTY(QString screenName READ screenName NOTIFY screenNameChanged FINAL)
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)

Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged FINAL)

Expand Down Expand Up @@ -81,6 +82,9 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
bool showInPrimary() const;
void setShowInPrimary(bool newShowInPrimary);

bool locked() const;
void setLocked(bool newLocked);

void setHideState(HideState newHideState);
QScreen* dockScreen();
void setDockScreen(QScreen *screen);
Expand Down Expand Up @@ -116,6 +120,7 @@ private Q_SLOTS:
void screenNameChanged();
void requestClosePopup();
void devicePixelRatioChanged(qreal ratio);
void lockedChanged(bool locked);

void contextDraggingChanged();

Expand Down
24 changes: 23 additions & 1 deletion panels/dock/docksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const static QString keyItemAlignment = "Item_Alignment";
const static QString keyIndicatorStyle = "Indicator_Style";
const static QString keyPluginsVisible = "Plugins_Visible";
const static QString keyShowInPrimary = "Show_In_Primary";
const static QString keyLocked = "Locked";

namespace dock {

Expand Down Expand Up @@ -131,6 +132,7 @@ DockSettings::DockSettings(QObject* parent)
, m_dockPosition(dock::Bottom)
, m_alignment(dock::CenterAlignment)
, m_style(dock::Fashion)
, m_locked(false)
{
m_writeTimer->setSingleShot(true);
m_writeTimer->setInterval(1000);
Expand All @@ -147,6 +149,7 @@ void DockSettings::init()
m_style = string2IndicatorStyle(m_dockConfig->value(keyIndicatorStyle).toString());
m_pluginsVisible = m_dockConfig->value(keyPluginsVisible).toMap();
m_showInPrimary = m_dockConfig->value(keyShowInPrimary).toBool();
m_locked = m_dockConfig->value(keyLocked).toBool();

connect(m_dockConfig.data(), &DConfig::valueChanged, this, [this](const QString& key){
if (keyDockSize == key) {
Expand Down Expand Up @@ -182,6 +185,11 @@ void DockSettings::init()
if (showInPrimary == m_showInPrimary) return;
m_showInPrimary = showInPrimary;
Q_EMIT showInPrimaryChanged(m_showInPrimary);
} else if (keyLocked == key) {
auto locked = m_dockConfig->value(keyLocked).toBool();
if (locked == m_locked) return;
m_locked = locked;
Q_EMIT lockedChanged(m_locked);
}
});
} else {
Expand Down Expand Up @@ -289,6 +297,21 @@ bool DockSettings::showInPrimary() const
return m_showInPrimary;
}

bool DockSettings::locked() const
{
return m_locked;
}

void DockSettings::setLocked(bool newLocked)
{
if (m_locked == newLocked) {
return;
}
m_locked = newLocked;
m_dockConfig->setValue(keyLocked, m_locked);
Q_EMIT lockedChanged(m_locked);
Comment on lines +310 to +312
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Batch config writes via WriteJob instead of immediate setValue

Use addWriteJob(WriteJob::Locked) and rely on checkWriteJob() to handle the write, ensuring consistency with other setters.

Suggested change
m_locked = newLocked;
m_dockConfig->setValue(keyLocked, m_locked);
Q_EMIT lockedChanged(m_locked);
m_locked = newLocked;
addWriteJob(WriteJob::Locked);
Q_EMIT lockedChanged(m_locked);

}

void DockSettings::addWriteJob(WriteJob job)
{
if (m_writeJob.contains(job)) return;
Expand Down Expand Up @@ -346,5 +369,4 @@ void DockSettings::checkWriteJob()
m_writeTimer->start();
}


}
5 changes: 5 additions & 0 deletions panels/dock/docksettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DockSettings : public QObject
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
Q_PROPERTY(QVariantMap pluginsVisible READ pluginsVisible WRITE setPluginsVisible NOTIFY pluginsVisibleChanged FINAL)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)

public:
static DockSettings* instance();
Expand All @@ -37,6 +38,7 @@ class DockSettings : public QObject
IndicatorStyle indicatorStyle();
QVariantMap pluginsVisible();
bool showInPrimary() const;
bool locked() const;

void setDockSize(const uint& size);
void setHideMode(const HideMode& mode);
Expand All @@ -45,6 +47,7 @@ class DockSettings : public QObject
void setIndicatorStyle(const IndicatorStyle& style);
void setPluginsVisible(const QVariantMap & pluginsVisible);
void setShowInPrimary(bool newShowInPrimary);
void setLocked(bool newLocked);

private:
enum WriteJob {
Expand All @@ -70,6 +73,7 @@ class DockSettings : public QObject
void pluginsVisibleChanged(const QVariantMap &pluginsVisible);

void showInPrimaryChanged(bool showInPrimary);
void lockedChanged(bool locked);

private:
QScopedPointer<DConfig> m_dockConfig;
Expand All @@ -83,5 +87,6 @@ class DockSettings : public QObject
IndicatorStyle m_style;
QVariantMap m_pluginsVisible;
bool m_showInPrimary;
bool m_locked;
};
}
15 changes: 13 additions & 2 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ Window {
value: Dock.SmartHide
}
}

LP.MenuItem {
text: qsTr("Lock the Dock")
checked: Panel.locked
onTriggered: {
Panel.locked = !Panel.locked
}
}
LP.MenuItem {
text: qsTr("Dock Settings")
onTriggered: {
Expand Down Expand Up @@ -481,13 +487,17 @@ Window {
propagateComposedEvents: true

cursorShape: {
if (Panel.locked) {
return Qt.ArrowCursor
}
if (Panel.position == Dock.Top || Panel.position == Dock.Bottom) {
return Qt.SizeVerCursor
}
return Qt.SizeHorCursor
}

onPressed: function(mouse) {
if (Panel.locked) return
dock.isDragging = true
oldMousePos = mapToGlobal(mouse.x, mouse.y)
oldDockSize = dockSize
Expand All @@ -500,7 +510,7 @@ Window {
onClicked: {}

onPositionChanged: function(mouse) {
if (!dock.isDragging) return
if (Panel.locked || !dock.isDragging) return
var newPos = mapToGlobal(mouse.x, mouse.y)
var xChange = newPos.x - oldMousePos.x
var yChange = newPos.y - oldMousePos.y
Expand Down Expand Up @@ -536,6 +546,7 @@ Window {
}

onReleased: function(mouse) {
if (Panel.locked) return
dock.isDragging = false
Applet.dockSize = dockSize
itemIconSizeBase = dockItemMaxSize
Expand Down
18 changes: 15 additions & 3 deletions toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp ./dde-shell/panels/dock/api/old/org.deepin.dde.daemon.Dock1.xml -a ./dde-shell/toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor -i ./dde-shell/toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1.h
* Source file was org.deepin.dde.daemon.Dock1.xml
*
* qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd.
* qdbusxml2cpp is Copyright (C) The Qt Company Ltd. and other contributors.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/

#include "./dde-shell/toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.h"
#include "./toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.h"

Check warning on line 11 in toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "./toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.h" not found.
#include <QtCore/QMetaObject>

Check warning on line 12 in toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QByteArray>

Check warning on line 13 in toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QList>

Check warning on line 14 in toolGenerate/qdbusxml2cpp/org.deepin.dde.daemon.Dock1Adaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
Expand Down Expand Up @@ -69,6 +69,18 @@
return qvariant_cast< int >(parent()->property("HideState"));
}

bool Dock1Adaptor::locked() const
{
// get the value of property Locked
return qvariant_cast< bool >(parent()->property("Locked"));
}

void Dock1Adaptor::setLocked(bool value)
{
// set the value of property Locked
parent()->setProperty("Locked", QVariant::fromValue(value));
}

int Dock1Adaptor::position() const
{
// get the value of property Position
Expand Down
Loading