mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: 新增任务栏配置的控制中心插件
新增任务栏配置的控制中心插件 Log: 支持在控制中心中对任务栏的配置进行修改 Task: https://pms.uniontech.com/zentao/task-view-86359.html Change-Id: Ic55390c9ad98ec9513cb8f3f59d910d54c946008
This commit is contained in:
parent
b7b3451735
commit
bd244e8f3d
9
debian/control
vendored
9
debian/control
vendored
@ -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
|
1
debian/dcc-dock-settings-plugin.install
vendored
Normal file
1
debian/dcc-dock-settings-plugin.install
vendored
Normal file
@ -0,0 +1 @@
|
||||
usr/lib/dde-control-center/modules/libdcc-dock-settings-plugin.so
|
@ -11,3 +11,4 @@ add_subdirectory("overlay-warning")
|
||||
add_subdirectory("show-desktop")
|
||||
add_subdirectory("multitasking")
|
||||
add_subdirectory("bluetooth")
|
||||
add_subdirectory("dcc-dock-settings-plugin")
|
||||
|
46
plugins/dcc-dock-settings-plugin/CMakeLists.txt
Normal file
46
plugins/dcc-dock-settings-plugin/CMakeLists.txt
Normal file
@ -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)
|
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
<enum id="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<value value="0" nick="Enabled" />
|
||||
<value value="1" nick="Disabled" />
|
||||
<value value="2" nick="Hidden" />
|
||||
</enum>
|
||||
<schema path="/com/deepin/dde/control-center/personalization/" id="com.deepin.dde.control-center.personalization">
|
||||
<key name="display-mode" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
<key name="position" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
<key name="hide-mode" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
<key name="size-slider" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
<key name="multi-screen-area" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
<key name="plugin-area" enum="com.deepin.dde.control-center.personalization.StatusMode">
|
||||
<default>'Enabled'</default>
|
||||
<summary></summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
123
plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.cpp
Normal file
123
plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.cpp
Normal file
@ -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<QString, QDBusPendingCallWatcher *> m_processingCalls;
|
||||
QMap<QString, QList<QVariant>> 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>("QRect");
|
||||
qDBusRegisterMetaType<QRect>();
|
||||
}
|
||||
}
|
||||
|
||||
_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<QRect>(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<int>(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<QRect>(internalPropGet("geometry", &d_ptr->geometry));
|
||||
}
|
||||
|
||||
bool _Dock::showInPrimary()
|
||||
{
|
||||
return qvariant_cast<bool>(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<QVariant> &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);
|
||||
}
|
137
plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.h
Normal file
137
plugins/dcc-dock-settings-plugin/com_deepin_dde_dock.h
Normal file
@ -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 <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include <DBusExtendedAbstractInterface>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QRect>
|
||||
|
||||
/*
|
||||
* 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<QStringList> GetLoadedPlugins()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("GetLoadedPlugins"), argumentList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline QDBusPendingReply<> ReloadPlugins()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("ReloadPlugins"), argumentList);
|
||||
}
|
||||
|
||||
inline void ReloadPluginsQueued()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
|
||||
CallQueued(QStringLiteral("ReloadPlugins"), argumentList);
|
||||
}
|
||||
|
||||
|
||||
inline QDBusPendingReply<> callShow()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("callShow"), argumentList);
|
||||
}
|
||||
|
||||
inline void callShowQueued()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
|
||||
CallQueued(QStringLiteral("callShow"), argumentList);
|
||||
}
|
||||
|
||||
|
||||
inline QDBusPendingReply<bool> getPluginVisible(const QString &pluginName)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(pluginName);
|
||||
return asyncCallWithArgumentList(QStringLiteral("getPluginVisible"), argumentList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline QDBusPendingReply<> setPluginVisible(const QString &pluginName, bool visible)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(pluginName) << QVariant::fromValue(visible);
|
||||
return asyncCallWithArgumentList(QStringLiteral("setPluginVisible"), argumentList);
|
||||
}
|
||||
|
||||
inline void setPluginVisibleQueued(const QString &pluginName, bool visible)
|
||||
{
|
||||
QList<QVariant> 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<QVariant> &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
|
3
plugins/dcc-dock-settings-plugin/dock_settings.json
Normal file
3
plugins/dcc-dock-settings-plugin/dock_settings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"api" : "1.0.0"
|
||||
}
|
85
plugins/dcc-dock-settings-plugin/gsetting_watcher.cpp
Normal file
85
plugins/dcc-dock-settings-plugin/gsetting_watcher.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "gsetting_watcher.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QGSettings>
|
||||
#include <QListView>
|
||||
#include <QStandardItem>
|
||||
#include <QStandardItemModel>
|
||||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
plugins/dcc-dock-settings-plugin/gsetting_watcher.h
Normal file
49
plugins/dcc-dock-settings-plugin/gsetting_watcher.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef GSETTINGWATCHER_H
|
||||
#define GSETTINGWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
|
||||
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<QString, QWidget *> m_map;
|
||||
QGSettings *m_gsettings;
|
||||
};
|
||||
|
||||
#endif // GSETTINGWATCHER_H
|
225
plugins/dcc-dock-settings-plugin/module_widget.cpp
Normal file
225
plugins/dcc-dock-settings-plugin/module_widget.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "module_widget.h"
|
||||
#include "gsetting_watcher.h"
|
||||
|
||||
#include <widgets/comboxwidget.h>
|
||||
#include <widgets/titledslideritem.h>
|
||||
#include <widgets/dccslider.h>
|
||||
#include <widgets/titlelabel.h>
|
||||
#include <widgets/switchwidget.h>
|
||||
|
||||
#include <DSlider>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusError>
|
||||
#include <QMap>
|
||||
#include <QScrollArea>
|
||||
|
||||
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<QString, int> 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<QString, int> 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<QString, int> 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<QString, bool> 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<QStringList> 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()));
|
||||
}
|
||||
}
|
74
plugins/dcc-dock-settings-plugin/module_widget.h
Normal file
74
plugins/dcc-dock-settings-plugin/module_widget.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef MODULE_WIDGET_H
|
||||
#define MODULE_WIDGET_H
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
#include <com_deepin_dde_daemon_dock.h>
|
||||
|
||||
#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<SwitchWidget *> m_pluginWidgetList;
|
||||
|
||||
DBusDock *m_daemonDockInter;
|
||||
DBusInter *m_dockInter;
|
||||
GSettingWatcher *m_gsettingsWatcher;
|
||||
};
|
||||
|
||||
#endif // MODULE_WIDGET_H
|
90
plugins/dcc-dock-settings-plugin/settings_module.cpp
Normal file
90
plugins/dcc-dock-settings-plugin/settings_module.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "settings_module.h"
|
||||
#include "module_widget.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
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);
|
||||
}
|
75
plugins/dcc-dock-settings-plugin/settings_module.h
Normal file
75
plugins/dcc-dock-settings-plugin/settings_module.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2021 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef SETTINGSMODULE_H
|
||||
#define SETTINGSMODULE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#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
|
Loading…
x
Reference in New Issue
Block a user