Skip to content

Commit 85e06cf

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
feat: Lock the height of dock.
add dbus for control-center add lock interface. Log:
1 parent 5723329 commit 85e06cf

13 files changed

+137
-33
lines changed

panels/dock/api/dbus/org.deepin.ds.dock.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</property>
88
<property access="readwrite" type="i" name="position"/>
99
<property access="readwrite" type="b" name="showInPrimary"/>
10+
<property access="readwrite" type="b" name="locked"/>
1011
<method name="callShow"/>
1112
<method name="ReloadPlugins"/>
1213
</interface>

panels/dock/api/old/org.deepin.dde.daemon.Dock1.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<property access="readwrite" type="i" name="HideMode"/>
2525
<property access="readwrite" type="i" name="Position"/>
2626
<property access="read" type="i" name="HideState"/>
27+
<property access="readwrite" type="b" name="Locked"/>
2728
<property access="read" type="(iiii)" name="FrontendWindowRect">
2829
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QRect"/>
2930
</property>
@@ -46,5 +47,8 @@
4647
<signal name="HideModeChanged">
4748
<arg name="hideMode" type="i" direction="out"/>
4849
</signal>
50+
<signal name="LockedChanged">
51+
<arg name="locked" type="b" direction="out"/>
52+
</signal>
4953
</interface>
5054
</node>

panels/dock/api/old/org.deepin.dde.dock1.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QRect"/>
77
</property>
88
<property access="readwrite" type="b" name="showInPrimary"/>
9+
<property access="readwrite" type="b" name="locked"/>
910
<method name="callShow"/>
1011
<method name="ReloadPlugins"/>
1112
<method name="GetLoadedPlugins">

panels/dock/dconfig/org.deepin.ds.dock.json

100644100755
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,34 @@
5353
"visibility": "private"
5454
},
5555
"Plugins_Visible": {
56-
"value": {},
57-
"serial": 0,
58-
"flags": [],
59-
"name": "The visibilities of plugins",
60-
"name[zh_CN]": "插件可见性",
61-
"description": "The loaded plugin which is visible when dock is started.",
62-
"permissions": "readwrite",
63-
"visibility": "private"
56+
"value": {},
57+
"serial": 0,
58+
"flags": [],
59+
"name": "The visibilities of plugins",
60+
"name[zh_CN]": "插件可见性",
61+
"description": "The loaded plugin which is visible when dock is started.",
62+
"permissions": "readwrite",
63+
"visibility": "private"
6464
},
6565
"Show_In_Primary": {
6666
"value": true,
67-
"serial": 0,
68-
"flags": [],
69-
"name": "show_in_primary",
70-
"name[zh_CN]": "任务栏显示在主屏幕",
71-
"description": "show dock in primary screen",
72-
"permissions": "readwrite",
73-
"visibility": "private"
67+
"serial": 0,
68+
"flags": [],
69+
"name": "show_in_primary",
70+
"name[zh_CN]": "任务栏显示在主屏幕",
71+
"description": "show dock in primary screen",
72+
"permissions": "readwrite",
73+
"visibility": "private"
74+
},
75+
"Locked": {
76+
"value": false,
77+
"serial": 0,
78+
"flags": [],
79+
"name": "locked",
80+
"name[zh_CN]": "禁用自由调节",
81+
"description": "lock dock to prevent dragging resize",
82+
"permissions": "readwrite",
83+
"visibility": "private"
7484
}
7585
}
7686
}

panels/dock/dockdbusproxy.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,18 @@ void DockDBusProxy::setShowInPrimary(bool newShowInPrimary)
281281
parent()->setShowInPrimary(newShowInPrimary);
282282
}
283283

284+
bool DockDBusProxy::locked() const
285+
{
286+
return parent()->locked();
287+
}
288+
289+
void DockDBusProxy::setLocked(bool newLocked)
290+
{
291+
if (parent()->locked() == newLocked)
292+
return;
293+
294+
parent()->setLocked(newLocked);
295+
}
296+
284297
}
285298

panels/dock/dockdbusproxy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class DockDBusProxy final: public QObject, public QDBusContext
3232
Q_PROPERTY(uint WindowSizeFashion READ windowSizeFashion WRITE setWindowSizeFashion)
3333
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode FINAL)
3434
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary FINAL)
35+
Q_PROPERTY(bool locked READ locked WRITE setLocked FINAL)
3536

3637

3738
public:
@@ -74,6 +75,9 @@ class DockDBusProxy final: public QObject, public QDBusContext
7475
bool showInPrimary() const;
7576
void setShowInPrimary(bool newShowInPrimary);
7677

78+
bool locked() const;
79+
void setLocked(bool newLocked);
80+
7781
Q_SIGNALS:
7882
void pluginVisibleChanged(const QString &pluginName, bool visible) const;
7983

panels/dock/dockpanel.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ bool DockPanel::init()
109109
connect(SETTINGS, &DockSettings::hideModeChanged, this, &DockPanel::hideModeChanged);
110110
connect(SETTINGS, &DockSettings::itemAlignmentChanged, this, &DockPanel::itemAlignmentChanged);
111111
connect(SETTINGS, &DockSettings::indicatorStyleChanged, this, &DockPanel::indicatorStyleChanged);
112+
connect(SETTINGS, &DockSettings::lockedChanged, this, &DockPanel::lockedChanged);
112113

113114
connect(SETTINGS, &DockSettings::dockSizeChanged, this, [this, dockDaemonAdaptor](){
114115
Q_EMIT dockDaemonAdaptor->WindowSizeEfficientChanged(dockSize());
@@ -121,6 +122,9 @@ bool DockPanel::init()
121122
connect(SETTINGS, &DockSettings::itemAlignmentChanged, this, [this, dockDaemonAdaptor](){
122123
Q_EMIT dockDaemonAdaptor->DisplayModeChanged(itemAlignment());
123124
});
125+
connect(SETTINGS, &DockSettings::lockedChanged, this, [this, dockDaemonAdaptor](){
126+
Q_EMIT dockDaemonAdaptor->LockedChanged(locked());
127+
});
124128

125129
DPanel::init();
126130

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

375+
bool DockPanel::locked() const
376+
{
377+
return SETTINGS->locked();
378+
}
379+
380+
void DockPanel::setLocked(bool newLocked)
381+
{
382+
SETTINGS->setLocked(newLocked);
383+
}
384+
371385
D_APPLET_CLASS(DockPanel)
372386

373387
void DockPanel::setHideState(HideState newHideState)

panels/dock/dockpanel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
3232
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
3333
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
3434
Q_PROPERTY(QString screenName READ screenName NOTIFY screenNameChanged FINAL)
35+
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)
3536

3637
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged FINAL)
3738

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

85+
bool locked() const;
86+
void setLocked(bool newLocked);
87+
8488
void setHideState(HideState newHideState);
8589
QScreen* dockScreen();
8690
void setDockScreen(QScreen *screen);
@@ -116,6 +120,7 @@ private Q_SLOTS:
116120
void screenNameChanged();
117121
void requestClosePopup();
118122
void devicePixelRatioChanged(qreal ratio);
123+
void lockedChanged(bool locked);
119124

120125
void contextDraggingChanged();
121126

panels/dock/docksettings.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const static QString keyItemAlignment = "Item_Alignment";
1818
const static QString keyIndicatorStyle = "Indicator_Style";
1919
const static QString keyPluginsVisible = "Plugins_Visible";
2020
const static QString keyShowInPrimary = "Show_In_Primary";
21+
const static QString keyLocked = "Locked";
2122

2223
namespace dock {
2324

@@ -131,6 +132,7 @@ DockSettings::DockSettings(QObject* parent)
131132
, m_dockPosition(dock::Bottom)
132133
, m_alignment(dock::CenterAlignment)
133134
, m_style(dock::Fashion)
135+
, m_locked(false)
134136
{
135137
m_writeTimer->setSingleShot(true);
136138
m_writeTimer->setInterval(1000);
@@ -147,6 +149,7 @@ void DockSettings::init()
147149
m_style = string2IndicatorStyle(m_dockConfig->value(keyIndicatorStyle).toString());
148150
m_pluginsVisible = m_dockConfig->value(keyPluginsVisible).toMap();
149151
m_showInPrimary = m_dockConfig->value(keyShowInPrimary).toBool();
152+
m_locked = m_dockConfig->value(keyLocked).toBool();
150153

151154
connect(m_dockConfig.data(), &DConfig::valueChanged, this, [this](const QString& key){
152155
if (keyDockSize == key) {
@@ -182,6 +185,11 @@ void DockSettings::init()
182185
if (showInPrimary == m_showInPrimary) return;
183186
m_showInPrimary = showInPrimary;
184187
Q_EMIT showInPrimaryChanged(m_showInPrimary);
188+
} else if (keyLocked == key) {
189+
auto locked = m_dockConfig->value(keyLocked).toBool();
190+
if (locked == m_locked) return;
191+
m_locked = locked;
192+
Q_EMIT lockedChanged(m_locked);
185193
}
186194
});
187195
} else {
@@ -289,6 +297,21 @@ bool DockSettings::showInPrimary() const
289297
return m_showInPrimary;
290298
}
291299

300+
bool DockSettings::locked() const
301+
{
302+
return m_locked;
303+
}
304+
305+
void DockSettings::setLocked(bool newLocked)
306+
{
307+
if (m_locked == newLocked) {
308+
return;
309+
}
310+
m_locked = newLocked;
311+
m_dockConfig->setValue(keyLocked, m_locked);
312+
Q_EMIT lockedChanged(m_locked);
313+
}
314+
292315
void DockSettings::addWriteJob(WriteJob job)
293316
{
294317
if (m_writeJob.contains(job)) return;
@@ -346,5 +369,4 @@ void DockSettings::checkWriteJob()
346369
m_writeTimer->start();
347370
}
348371

349-
350372
}

panels/dock/docksettings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class DockSettings : public QObject
2626
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
2727
Q_PROPERTY(QVariantMap pluginsVisible READ pluginsVisible WRITE setPluginsVisible NOTIFY pluginsVisibleChanged FINAL)
2828
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
29+
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)
2930

3031
public:
3132
static DockSettings* instance();
@@ -37,6 +38,7 @@ class DockSettings : public QObject
3738
IndicatorStyle indicatorStyle();
3839
QVariantMap pluginsVisible();
3940
bool showInPrimary() const;
41+
bool locked() const;
4042

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

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

7275
void showInPrimaryChanged(bool showInPrimary);
76+
void lockedChanged(bool locked);
7377

7478
private:
7579
QScopedPointer<DConfig> m_dockConfig;
@@ -83,5 +87,6 @@ class DockSettings : public QObject
8387
IndicatorStyle m_style;
8488
QVariantMap m_pluginsVisible;
8589
bool m_showInPrimary;
90+
bool m_locked;
8691
};
8792
}

0 commit comments

Comments
 (0)