diff --git a/debian/control b/debian/control
index 13318f603..8f68895d7 100644
--- a/debian/control
+++ b/debian/control
@@ -24,7 +24,8 @@ Build-Depends: debhelper (>= 8.0.0),
libgsettings-qt-dev,
libdbusmenu-qt5-dev,
libgtest-dev,
- libgmock-dev
+ libgmock-dev,
+ dde-control-center-dev
Standards-Version: 3.9.8
Homepage: http://www.deepin.org/
@@ -66,3 +67,9 @@ Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, onboard
Description: deepin desktop-environment - dock plugin for onboard
Dock plugin for onboard of deepin desktop-environment
+
+Package: dcc-dock-settings-plugin
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, onboard
+Description: deepin desktop-environment - dcc plugin for dock settings
+ Dcc plugin for dock settings of deepin desktop-environment
\ No newline at end of file
diff --git a/debian/dcc-dock-settings-plugin.install b/debian/dcc-dock-settings-plugin.install
new file mode 100644
index 000000000..732740dd0
--- /dev/null
+++ b/debian/dcc-dock-settings-plugin.install
@@ -0,0 +1 @@
+usr/lib/dde-control-center/modules/libdcc-dock-settings-plugin.so
\ No newline at end of file
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 245f1ee0f..db8eb428b 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -11,3 +11,4 @@ add_subdirectory("overlay-warning")
add_subdirectory("show-desktop")
add_subdirectory("multitasking")
add_subdirectory("bluetooth")
+add_subdirectory("dcc-dock-settings-plugin")
diff --git a/plugins/dcc-dock-settings-plugin/CMakeLists.txt b/plugins/dcc-dock-settings-plugin/CMakeLists.txt
new file mode 100644
index 000000000..13632ee10
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/CMakeLists.txt
@@ -0,0 +1,46 @@
+cmake_minimum_required(VERSION 3.7)
+
+set(PLUGIN_NAME "dcc-dock-settings-plugin")
+
+project(${PLUGIN_NAME})
+
+set(CMAKE_AUTOMOC ON)
+
+file(GLOB_RECURSE SRCS
+ "*.h"
+ "*.cpp")
+
+find_package(Qt5 COMPONENTS Core Widgets DBus REQUIRED)
+find_package(DdeControlCenter REQUIRED)
+find_package(PkgConfig REQUIRED)
+find_package(DtkWidget REQUIRED)
+
+pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
+pkg_check_modules(QGSettings REQUIRED gsettings-qt)
+
+add_library(${PLUGIN_NAME} SHARED ${SRCS})
+set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
+target_include_directories(${PLUGIN_NAME} PUBLIC
+ ../src
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${DtkWidget_INCLUDE_DIRS}
+ ${DdeControlCenter_INCLUDE_DIR}
+ ${DFrameworkDBus_INCLUDE_DIRS}
+ ${QGSettings_INCLUDE_DIRS}
+ ${Qt5DBus_INCLUDE_DIRS}
+ )
+target_link_libraries(${PLUGIN_NAME} PRIVATE
+ ${Qt5Widgets_LIBRARIES}
+ ${DtkWidget_LIBRARIES}
+ ${DdeControlCenter_LIBRARIES}
+ ${DFrameworkDBus_LIBRARIES}
+ ${QGSettings_LIBRARIES}
+ ${Qt5DBus_LIBRARIES}
+ )
+
+set(CMAKE_INSTALL_PREFIX "/usr")
+
+install(FILES com.deepin.dde.control-center.dock-settings.gschema.xml
+ DESTINATION share/glib-2.0/schemas)
+
+install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-control-center/modules)
diff --git a/plugins/dcc-dock-settings-plugin/com.deepin.dde.control-center.dock-settings.gschema.xml b/plugins/dcc-dock-settings-plugin/com.deepin.dde.control-center.dock-settings.gschema.xml
new file mode 100644
index 000000000..5751cbd19
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/com.deepin.dde.control-center.dock-settings.gschema.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+ 'Enabled'
+
+
+
+ 'Enabled'
+
+
+
+ 'Enabled'
+
+
+
+ 'Enabled'
+
+
+
+ 'Enabled'
+
+
+
+ 'Enabled'
+
+
+
+
diff --git a/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.cpp b/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.cpp
new file mode 100644
index 000000000..8264d12e9
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.cpp
@@ -0,0 +1,123 @@
+/*
+ * This file was generated by qdbusxml2cpp-fix version 0.8
+ * Command line was: qdbusxml2cpp-fix -c Dock -p generated/com_deepin_dde_dock ../xml/com.deepin.dde.Dock.xml
+ *
+ * qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "com_deepin_dde_dock.h"
+
+/*
+ * Implementation of interface class _Dock
+ */
+
+class _DockPrivate
+{
+public:
+ _DockPrivate() = default;
+
+ // begin member variables
+ QRect geometry;
+ int showInPrimary;
+
+public:
+ QMap m_processingCalls;
+ QMap> m_waittingCalls;
+};
+
+_Dock::_Dock(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+ , d_ptr(new _DockPrivate)
+{
+ connect(this, &_Dock::propertyChanged, this, &_Dock::onPropertyChanged);
+
+ if (QMetaType::type("QRect") == QMetaType::UnknownType) {
+ qRegisterMetaType("QRect");
+ qDBusRegisterMetaType();
+ }
+}
+
+_Dock::~_Dock()
+{
+ qDeleteAll(d_ptr->m_processingCalls.values());
+ delete d_ptr;
+}
+
+void _Dock::onPropertyChanged(const QString &propName, const QVariant &value)
+{
+ if (propName == QStringLiteral("geometry"))
+ {
+ const QRect &geometry = qvariant_cast(value);
+ if (d_ptr->geometry != geometry)
+ {
+ d_ptr->geometry = geometry;
+ Q_EMIT GeometryChanged(d_ptr->geometry);
+ }
+ return;
+ }
+
+ if (propName == QStringLiteral("showInPrimary"))
+ {
+ const int &showInPrimary = qvariant_cast(value);
+ if (d_ptr->showInPrimary != showInPrimary)
+ {
+ d_ptr->showInPrimary = showInPrimary;
+ Q_EMIT ShowInPrimaryChanged(d_ptr->showInPrimary);
+ }
+ return;
+ }
+
+ qWarning() << "property not handle: " << propName;
+ return;
+}
+
+QRect _Dock::geometry()
+{
+ return qvariant_cast(internalPropGet("geometry", &d_ptr->geometry));
+}
+
+bool _Dock::showInPrimary()
+{
+ return qvariant_cast(internalPropGet("showInPrimary", &d_ptr->showInPrimary));
+}
+
+void _Dock::setShowInPrimary(bool value)
+{
+
+ internalPropSet("showInPrimary", QVariant::fromValue(value), &d_ptr->showInPrimary);
+}
+
+void _Dock::CallQueued(const QString &callName, const QList &args)
+{
+ if (d_ptr->m_waittingCalls.contains(callName))
+ {
+ d_ptr->m_waittingCalls[callName] = args;
+ return;
+ }
+ if (d_ptr->m_processingCalls.contains(callName))
+ {
+ d_ptr->m_waittingCalls.insert(callName, args);
+ } else {
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
+ connect(watcher, &QDBusPendingCallWatcher::finished, this, &_Dock::onPendingCallFinished);
+ d_ptr->m_processingCalls.insert(callName, watcher);
+ }
+}
+
+void _Dock::onPendingCallFinished(QDBusPendingCallWatcher *w)
+{
+ w->deleteLater();
+ const auto callName = d_ptr->m_processingCalls.key(w);
+ Q_ASSERT(!callName.isEmpty());
+ if (callName.isEmpty())
+ return;
+ d_ptr->m_processingCalls.remove(callName);
+ if (!d_ptr->m_waittingCalls.contains(callName))
+ return;
+ const auto args = d_ptr->m_waittingCalls.take(callName);
+ CallQueued(callName, args);
+}
diff --git a/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.h b/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.h
new file mode 100644
index 000000000..10cdbe142
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.h
@@ -0,0 +1,137 @@
+/*
+ * This file was generated by qdbusxml2cpp-fix version 0.8
+ * Command line was: qdbusxml2cpp-fix -c Dock -p generated/com_deepin_dde_dock ../xml/com.deepin.dde.Dock.xml
+ *
+ * qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef COM_DEEPIN_DDE_DOCK_H
+#define COM_DEEPIN_DDE_DOCK_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+/*
+ * Proxy class for interface com.deepin.dde.Dock
+ */
+class _DockPrivate;
+class _Dock : public DBusExtendedAbstractInterface
+{
+ Q_OBJECT
+
+public:
+ static inline const char *staticInterfaceName()
+ { return "com.deepin.dde.Dock"; }
+
+public:
+ explicit _Dock(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~_Dock();
+
+ Q_PROPERTY(QRect geometry READ geometry NOTIFY GeometryChanged)
+ QRect geometry();
+
+ Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY ShowInPrimaryChanged)
+ bool showInPrimary();
+ void setShowInPrimary(bool value);
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply GetLoadedPlugins()
+ {
+ QList argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetLoadedPlugins"), argumentList);
+ }
+
+
+
+ inline QDBusPendingReply<> ReloadPlugins()
+ {
+ QList argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("ReloadPlugins"), argumentList);
+ }
+
+ inline void ReloadPluginsQueued()
+ {
+ QList argumentList;
+
+ CallQueued(QStringLiteral("ReloadPlugins"), argumentList);
+ }
+
+
+ inline QDBusPendingReply<> callShow()
+ {
+ QList argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("callShow"), argumentList);
+ }
+
+ inline void callShowQueued()
+ {
+ QList argumentList;
+
+ CallQueued(QStringLiteral("callShow"), argumentList);
+ }
+
+
+ inline QDBusPendingReply getPluginVisible(const QString &pluginName)
+ {
+ QList argumentList;
+ argumentList << QVariant::fromValue(pluginName);
+ return asyncCallWithArgumentList(QStringLiteral("getPluginVisible"), argumentList);
+ }
+
+
+
+ inline QDBusPendingReply<> setPluginVisible(const QString &pluginName, bool visible)
+ {
+ QList argumentList;
+ argumentList << QVariant::fromValue(pluginName) << QVariant::fromValue(visible);
+ return asyncCallWithArgumentList(QStringLiteral("setPluginVisible"), argumentList);
+ }
+
+ inline void setPluginVisibleQueued(const QString &pluginName, bool visible)
+ {
+ QList argumentList;
+ argumentList << QVariant::fromValue(pluginName) << QVariant::fromValue(visible);
+
+ CallQueued(QStringLiteral("setPluginVisible"), argumentList);
+ }
+
+
+
+Q_SIGNALS: // SIGNALS
+ void pluginVisibleChanged(const QString &in0, bool in1);
+ // begin property changed signals
+ void GeometryChanged(const QRect & value) const;
+ void ShowInPrimaryChanged(int value) const;
+
+public Q_SLOTS:
+ void CallQueued(const QString &callName, const QList &args);
+
+private Q_SLOTS:
+ void onPendingCallFinished(QDBusPendingCallWatcher *w);
+ void onPropertyChanged(const QString &propName, const QVariant &value);
+
+private:
+ _DockPrivate *d_ptr;
+};
+
+namespace com {
+ namespace deepin {
+ namespace dde {
+ typedef ::_Dock Dock;
+ }
+ }
+}
+#endif
diff --git a/plugins/dcc-dock-settings-plugin/dock_settings.json b/plugins/dcc-dock-settings-plugin/dock_settings.json
new file mode 100644
index 000000000..dbc6b7b2e
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/dock_settings.json
@@ -0,0 +1,3 @@
+{
+ "api" : "1.0.0"
+}
\ No newline at end of file
diff --git a/plugins/dcc-dock-settings-plugin/gsetting_watcher.cpp b/plugins/dcc-dock-settings-plugin/gsetting_watcher.cpp
new file mode 100644
index 000000000..93ad21d7b
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/gsetting_watcher.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include "gsetting_watcher.h"
+#include "utils.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * @brief GSettingWatcher::GSettingWatcher 用于监听处于 \a baseSchemasId + "." + \a module 配置下的配置项内容变化,并将变化应用到绑定的控件上
+ */
+GSettingWatcher::GSettingWatcher(const QString &baseSchemasId, const QString &module, QObject *parent)
+ : QObject(parent)
+ , m_gsettings(Utils::SettingsPtr(baseSchemasId + "." + module, QByteArray(), this))
+{
+ if (m_gsettings) {
+ connect(m_gsettings, &QGSettings::changed, this, &GSettingWatcher::onStatusModeChanged);
+ }
+}
+
+GSettingWatcher::~GSettingWatcher()
+{
+ m_map.clear();
+}
+
+void GSettingWatcher::bind(const QString &key, QWidget *binder)
+{
+ m_map.insert(key, binder);
+
+ setStatus(key, binder);
+
+ // 自动解绑
+ connect(binder, &QObject::destroyed, this, [=] {
+ m_map.remove(m_map.key(binder), binder);
+ });
+}
+
+void GSettingWatcher::setStatus(const QString &key, QWidget *binder)
+{
+ if (!binder || !m_gsettings || !m_gsettings->keys().contains(key))
+ return;
+
+ const QString setting = m_gsettings->get(key).toString();
+
+ if ("Enabled" == setting) {
+ binder->setEnabled(true);
+ } else if ("Disabled" == setting) {
+ binder->setEnabled(false);
+ }
+
+ binder->setVisible("Hidden" != setting);
+}
+
+void GSettingWatcher::onStatusModeChanged(const QString &key)
+{
+ if (!m_map.isEmpty() && m_map.contains(key)) {
+ for (auto it = m_map.begin(); it != m_map.end(); ++it) {
+ if (key == it.key()) {
+ setStatus(key, it.value());
+ }
+ }
+ }
+}
diff --git a/plugins/dcc-dock-settings-plugin/gsetting_watcher.h b/plugins/dcc-dock-settings-plugin/gsetting_watcher.h
new file mode 100644
index 000000000..7a8fb1ad9
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/gsetting_watcher.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#ifndef GSETTINGWATCHER_H
+#define GSETTINGWATCHER_H
+
+#include
+#include
+#include
+
+class QGSettings;
+class QListView;
+class QStandardItem;
+class GSettingWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ GSettingWatcher(const QString &baseSchemasId, const QString &module, QObject *parent = nullptr);
+ ~GSettingWatcher();
+
+ void bind(const QString &key, QWidget *binder);
+
+private:
+ void setStatus(const QString &key, QWidget *binder);
+ void onStatusModeChanged(const QString &key);
+
+private:
+ QMultiHash m_map;
+ QGSettings *m_gsettings;
+};
+
+#endif // GSETTINGWATCHER_H
diff --git a/plugins/dcc-dock-settings-plugin/module_widget.cpp b/plugins/dcc-dock-settings-plugin/module_widget.cpp
new file mode 100644
index 000000000..3d1320fa7
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/module_widget.cpp
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include "module_widget.h"
+#include "gsetting_watcher.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+DWIDGET_USE_NAMESPACE
+
+enum DisplayMode {
+ Fashion = 0,
+ Efficient = 1,
+};
+
+enum HideMode {
+ KeepShowing = 0,
+ KeepHidden = 1,
+ SmartHide = 3,
+};
+
+enum Position {
+ Top = 0,
+ Right = 1,
+ Bottom = 2,
+ Left = 3,
+};
+
+ModuleWidget::ModuleWidget(QWidget *parent)
+ : QScrollArea(parent)
+ , m_modeComboxWidget(new ComboxWidget)
+ , m_positionComboxWidget(new ComboxWidget)
+ , m_stateComboxWidget(new ComboxWidget)
+ , m_sizeSlider(new TitledSliderItem(tr("Size")))
+ , m_screenSettingTitle(new TitleLabel(tr("Multi screen config")))
+ , m_screenSettingComboxWidget(new ComboxWidget)
+ , m_pluginAreaTitle(new TitleLabel(tr("Plugin area")))
+ , m_daemonDockInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
+ , m_dockInter(new DBusInter("com.deepin.dde.Dock", "/com/deepin/dde/Dock", QDBusConnection::sessionBus(), this))
+ , m_gsettingsWatcher(new GSettingWatcher("com.deepin.dde.control-center", "personalization", this))
+{
+ initUI();
+}
+
+ModuleWidget::~ModuleWidget()
+{
+ delete m_modeComboxWidget;
+ delete m_positionComboxWidget;
+ delete m_stateComboxWidget;
+ delete m_sizeSlider;
+ delete m_screenSettingTitle;
+ delete m_screenSettingComboxWidget;
+ delete m_pluginAreaTitle;
+}
+
+void ModuleWidget::initUI()
+{
+ setFrameShape(QFrame::NoFrame);
+ setWidgetResizable(true);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins(10, 10, 10, 10);
+ layout->setSpacing(10);
+
+ static QMap g_modeMap = {{tr("Fashion mode"), Fashion}
+ , {tr("Efficient mode"), Efficient}};
+ // 模式
+ m_modeComboxWidget->setTitle(tr("Mode"));
+ m_modeComboxWidget->addBackground();
+ m_modeComboxWidget->setComboxOption(QStringList() << tr("Fashion mode") << tr("Efficient mode"));
+ m_modeComboxWidget->setCurrentText(g_modeMap.key(m_daemonDockInter->displayMode()));
+ connect(m_modeComboxWidget, &ComboxWidget::onSelectChanged, this, [ = ] (const QString &text) {
+ m_daemonDockInter->setDisplayMode(g_modeMap.value(text));
+ });
+ layout->addWidget(m_modeComboxWidget);
+ m_gsettingsWatcher->bind("displayMode", m_modeComboxWidget);// 转换settingName?
+
+ static QMap g_positionMap = {{tr("Top"), Top}
+ , {tr("Bottom"), Bottom}
+ , {tr("Left"), Left}
+ , {tr("Right"), Right}};
+ // 位置
+ m_positionComboxWidget->setTitle(tr("Position"));
+ m_positionComboxWidget->addBackground();
+ m_positionComboxWidget->setComboxOption(QStringList() << tr("Top") << tr("Bottom") << tr("Left") << tr("Right"));
+ m_positionComboxWidget->setCurrentText(g_positionMap.key(m_daemonDockInter->position()));
+ connect(m_positionComboxWidget, &ComboxWidget::onSelectChanged, this, [ = ] (const QString &text) {
+ m_daemonDockInter->setPosition(g_positionMap.value(text));
+ });
+ layout->addWidget(m_positionComboxWidget);
+ m_gsettingsWatcher->bind("position", m_positionComboxWidget);
+
+ static QMap g_stateMap = {{tr("Always show"), KeepShowing}
+ , {tr("Always hide"), KeepHidden}
+ , {tr("Smart hide"), SmartHide}};
+ // 状态
+ m_stateComboxWidget->setTitle(tr("State"));
+ m_stateComboxWidget->addBackground();
+ m_stateComboxWidget->setComboxOption(QStringList() << tr("Always show") << tr("Always hide") << tr("Smart hide"));
+ m_stateComboxWidget->setCurrentText(g_stateMap.key(m_daemonDockInter->hideMode()));
+ connect(m_stateComboxWidget, &ComboxWidget::onSelectChanged, this, [ = ] (const QString &text) {
+ m_daemonDockInter->setHideMode(g_stateMap.value(text));
+ });
+ layout->addWidget(m_stateComboxWidget);
+ m_gsettingsWatcher->bind("hideMode", m_stateComboxWidget);
+
+ // 高度调整控件
+ m_sizeSlider->addBackground();
+ m_sizeSlider->slider()->setRange(40, 100);
+ QStringList ranges;
+ ranges << tr("Small") << tr("Big");
+ m_sizeSlider->setAnnotations(ranges);
+ connect(m_daemonDockInter, &DBusDock::DisplayModeChanged, this, &ModuleWidget::updateSliderValue);
+ connect(m_sizeSlider->slider(), &DSlider::valueChanged, this, [ = ] (int value) {
+ if (m_daemonDockInter->displayMode() == DisplayMode::Fashion) {
+ m_daemonDockInter->setWindowSizeFashion(uint(value));
+ } else if (m_daemonDockInter->displayMode() == DisplayMode::Efficient) {
+ m_daemonDockInter->setWindowSizeEfficient(uint(value));
+ }
+ });
+ updateSliderValue(m_daemonDockInter->displayMode());
+ m_gsettingsWatcher->bind("sizeSlider", m_sizeSlider);
+
+ layout->addWidget(m_sizeSlider);
+
+ // 多屏显示设置
+ if (QDBusConnection::sessionBus().interface()->isServiceRegistered("com.deepin.dde.Dock")) {
+ static QMap g_screenSettingMap = {{tr("Follow the mouse"), false}
+ , {tr("Only show in primary"), true}};
+
+ layout->addSpacing(10);
+ layout->addWidget(m_screenSettingTitle);
+ m_screenSettingComboxWidget->setTitle(tr("Dock position"));
+ m_screenSettingComboxWidget->addBackground();
+ m_screenSettingComboxWidget->setComboxOption(QStringList() << tr("Follow the mouse") << tr("Only show in primary"));
+ m_screenSettingComboxWidget->setCurrentText(g_screenSettingMap.key(m_dockInter->showInPrimary()));
+ connect(m_screenSettingComboxWidget, &ComboxWidget::onSelectChanged, this, [ = ] (const QString &text) {
+ m_dockInter->setShowInPrimary(g_screenSettingMap.value(text));
+ });
+ connect(m_dockInter, &DBusInter::ShowInPrimaryChanged, m_screenSettingComboxWidget, &ComboxWidget::setCurrentIndex);
+ layout->addWidget(m_screenSettingComboxWidget);
+ m_gsettingsWatcher->bind("multiScreenArea", m_screenSettingTitle);
+ m_gsettingsWatcher->bind("multiScreenArea", m_screenSettingComboxWidget);
+ }
+
+ // 插件区域
+ QDBusPendingReply reply = m_dockInter->GetLoadedPlugins();
+ QStringList plugins = reply.value();
+ if (reply.error().type() != QDBusError::ErrorType::NoError) {
+ qWarning() << "dbus call failed, method: 'GetLoadedPlugins()'";
+ } else {
+ if (plugins.size() != 0) {
+ layout->addSpacing(10);
+ layout->addWidget(m_pluginAreaTitle);
+ m_gsettingsWatcher->bind("pluginArea", m_pluginAreaTitle);
+ for (auto name : plugins) {
+ SwitchWidget *widget = new SwitchWidget(this);
+ widget->setTitle(name);
+ widget->addBackground();
+ widget->setChecked(m_dockInter->getPluginVisible(name));
+ connect(widget, &SwitchWidget::checkedChanged, this, [ = ] (const bool checked) {
+ m_dockInter->setPluginVisible(widget->title(), checked);
+ });
+ connect(m_dockInter, &DBusInter::pluginVisibleChanged, this, [ = ] (const QString &pluginName, bool visible) {
+ if (pluginName == widget->title()) {
+ widget->setChecked(visible);
+ }
+ });
+
+ layout->addWidget(widget);
+ m_gsettingsWatcher->bind("pluginArea", widget);
+ m_pluginWidgetList.append(widget);
+ }
+ }
+ }
+
+ // 保持内容正常铺满
+ layout->addStretch();
+
+ // 界面内容过多时可滚动查看
+ QWidget *widget = new QWidget;
+ widget->setLayout(layout);
+ setWidget(widget);
+}
+
+void ModuleWidget::updateSliderValue(int displayMode)
+{
+ if (displayMode == DisplayMode::Fashion) {
+ m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeFashion()));
+ } else if (displayMode == DisplayMode::Efficient) {
+ m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeEfficient()));
+ }
+}
diff --git a/plugins/dcc-dock-settings-plugin/module_widget.h b/plugins/dcc-dock-settings-plugin/module_widget.h
new file mode 100644
index 000000000..7232b28a3
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/module_widget.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#ifndef MODULE_WIDGET_H
+#define MODULE_WIDGET_H
+
+#include
+
+#include
+
+#include "com_deepin_dde_dock.h"
+
+namespace dcc {
+namespace widgets {
+class ComboxWidget;
+class TitledSliderItem;
+class SwitchWidget;
+}
+}
+
+class TitleLabel;
+class GSettingWatcher;
+using namespace dcc::widgets;
+using DBusDock = com::deepin::dde::daemon::Dock;
+using DBusInter = com::deepin::dde::Dock;
+
+class ModuleWidget : public QScrollArea
+{
+ Q_OBJECT
+public:
+ explicit ModuleWidget(QWidget *parent = nullptr);
+ ~ ModuleWidget();
+
+ void initUI();
+
+private Q_SLOTS:
+ void updateSliderValue(int displayMode);
+
+private:
+ ComboxWidget *m_modeComboxWidget;
+ ComboxWidget *m_positionComboxWidget;
+ ComboxWidget *m_stateComboxWidget;
+
+ TitledSliderItem *m_sizeSlider;
+
+ TitleLabel *m_screenSettingTitle;
+ ComboxWidget *m_screenSettingComboxWidget;
+
+ TitleLabel *m_pluginAreaTitle;
+ QList m_pluginWidgetList;
+
+ DBusDock *m_daemonDockInter;
+ DBusInter *m_dockInter;
+ GSettingWatcher *m_gsettingsWatcher;
+};
+
+#endif // MODULE_WIDGET_H
diff --git a/plugins/dcc-dock-settings-plugin/settings_module.cpp b/plugins/dcc-dock-settings-plugin/settings_module.cpp
new file mode 100644
index 000000000..29de209c4
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/settings_module.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include "settings_module.h"
+#include "module_widget.h"
+
+#include
+
+SettingsModule::SettingsModule()
+ : QObject()
+ , ModuleInterface()
+ , m_moduleWidget(nullptr)
+{
+
+}
+
+SettingsModule::~SettingsModule()
+{
+ delete m_moduleWidget;
+}
+
+void SettingsModule::initialize()
+{
+
+}
+
+void SettingsModule::active()
+{
+ m_moduleWidget = new ModuleWidget;
+
+ m_frameProxy->pushWidget(this, m_moduleWidget);
+ m_moduleWidget->setVisible(true);
+}
+
+QStringList SettingsModule::availPage() const
+{
+ return QStringList() << tr("Dock");
+}
+
+const QString SettingsModule::displayName() const
+{
+ return tr("Dock");
+}
+
+QIcon SettingsModule::icon() const
+{
+ return QIcon::fromTheme("unknown");
+}
+
+QString SettingsModule::translationPath() const
+{
+ return QString("/usr/share/dde-dock/translations");
+}
+
+QString SettingsModule::path() const
+{
+ return PERSONALIZATION;
+}
+
+QString SettingsModule::follow() const
+{
+ return "10";
+}
+
+const QString SettingsModule::name() const
+{
+ return tr("Dock");
+}
+
+void SettingsModule::showPage(const QString &pageName)
+{
+ Q_UNUSED(pageName);
+}
diff --git a/plugins/dcc-dock-settings-plugin/settings_module.h b/plugins/dcc-dock-settings-plugin/settings_module.h
new file mode 100644
index 000000000..f459277a5
--- /dev/null
+++ b/plugins/dcc-dock-settings-plugin/settings_module.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
+ *
+ * Author: fanpengcheng
+ *
+ * Maintainer: fanpengcheng
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#ifndef SETTINGSMODULE_H
+#define SETTINGSMODULE_H
+
+#include
+
+#include "interface/namespace.h"
+#include "interface/moduleinterface.h"
+#include "interface/frameproxyinterface.h"
+
+namespace DCC_NAMESPACE {
+ class ModuleInterface;
+ class FrameProxyInterface;
+}
+
+using namespace DCC_NAMESPACE;
+
+class ModuleWidget;
+class SettingsModule : public QObject, public ModuleInterface
+{
+ Q_OBJECT
+
+ Q_PLUGIN_METADATA(IID ModuleInterface_iid FILE "dock_settings.json")
+ Q_INTERFACES(DCC_NAMESPACE::ModuleInterface)
+
+public:
+ explicit SettingsModule();
+
+ ~SettingsModule() Q_DECL_OVERRIDE;
+
+ void initialize() Q_DECL_OVERRIDE;
+
+ QStringList availPage() const Q_DECL_OVERRIDE;
+
+ const QString displayName() const Q_DECL_OVERRIDE;
+
+ QIcon icon() const Q_DECL_OVERRIDE;
+
+ QString translationPath() const Q_DECL_OVERRIDE;
+
+ QString path() const Q_DECL_OVERRIDE;
+
+ QString follow() const Q_DECL_OVERRIDE;
+
+ const QString name() const Q_DECL_OVERRIDE;
+
+ void showPage(const QString &pageName) Q_DECL_OVERRIDE;
+
+public Q_SLOTS:
+ void active() Q_DECL_OVERRIDE;
+
+private:
+ ModuleWidget *m_moduleWidget;
+};
+
+#endif // SETTINGSMODULE_H