feat: 新增控制中心个性化插件

Merge remote-tracking branch 'origin/dev/11261'

Log: 新增控制中心个性化插件
Influence: 控制中心-个性化菜单下面的任务栏设置子菜单,任务栏右键菜单
Change-Id: If768e8a442e9a3b418e9da44207534f4ba28413a
This commit is contained in:
范朋程 2021-10-19 09:19:30 +08:00
commit 565ef80494
36 changed files with 1522 additions and 100 deletions

12
debian/control vendored
View File

@ -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/
@ -44,7 +45,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
Recommends:
dde-disk-mount-plugin,
dde-dock-onboard-plugin,
dde-dock-network-plugin
dde-dock-network-plugin,
dcc-dock-settings-plugin
Conflicts:
dde-workspace (<< 2.90.5),
dde-dock-applets,
@ -66,3 +68,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

View File

@ -0,0 +1 @@
usr/lib/dde-control-center/modules/libdcc-dock-settings-plugin.so

View File

@ -20,14 +20,53 @@
*/
#include "dbusdockadaptors.h"
#include "utils.h"
#include "dockitemmanager.h"
#include <QScreen>
#include <QDebug>
#include <QGSettings>
DBusDockAdaptors::DBusDockAdaptors(MainWindow* parent): QDBusAbstractAdaptor(parent)
DBusDockAdaptors::DBusDockAdaptors(MainWindow* parent)
: QDBusAbstractAdaptor(parent)
, m_gsettings(Utils::SettingsPtr("com.deepin.dde.dock.mainwindow", QByteArray(), this))
{
connect(parent, &MainWindow::panelGeometryChanged, this, [=] {
emit DBusDockAdaptors::geometryChanged(geometry());
});
if (m_gsettings) {
connect(m_gsettings, &QGSettings::changed, this, [ = ] (const QString &key) {
if (key == "onlyShowPrimary") {
Q_EMIT showInPrimaryChanged(m_gsettings->get(key).toBool());
}
});
}
connect(DockItemManager::instance(), &DockItemManager::itemInserted, this, [ = ] (const int index, DockItem *item) {
Q_UNUSED(index);
if (item->itemType() == DockItem::Plugins
|| item->itemType() == DockItem::FixedPlugin) {
PluginsItem *pluginItem = static_cast<PluginsItem *>(item);
for (auto *p : DockItemManager::instance()->pluginList()) {
if (p->pluginName() == pluginItem->pluginName()) {
Q_EMIT pluginVisibleChanged(p->pluginDisplayName(), getPluginVisible(p->pluginDisplayName()));
}
}
}
});
connect(DockItemManager::instance(), &DockItemManager::itemRemoved, this, [ = ] (DockItem *item) {
if (item->itemType() == DockItem::Plugins
|| item->itemType() == DockItem::FixedPlugin) {
PluginsItem *pluginItem = static_cast<PluginsItem *>(item);
for (auto *p : DockItemManager::instance()->pluginList()) {
if (p->pluginName() == pluginItem->pluginName()) {
Q_EMIT pluginVisibleChanged(p->pluginDisplayName(), getPluginVisible(p->pluginDisplayName()));
}
}
}
});
}
DBusDockAdaptors::~DBusDockAdaptors()
@ -50,7 +89,129 @@ void DBusDockAdaptors::ReloadPlugins()
return parent()->relaodPlugins();
}
QStringList DBusDockAdaptors::GetLoadedPlugins()
{
auto pluginList = DockItemManager::instance()->pluginList();
QStringList nameList;
QMap<QString, QString> map;
for (auto plugin : pluginList) {
// 托盘本身也是一个插件,这里去除掉这个特殊的插件,还有一些没有实际名字的插件
if (plugin->pluginName() == "tray"
|| plugin->pluginDisplayName().isEmpty()
|| !isPluginValid(plugin->pluginName()))
continue;
nameList << plugin->pluginName();
map.insert(plugin->pluginName(), plugin->pluginDisplayName());
}
// 排序,保持和原先任务栏右键菜单中的插件列表顺序一致
qSort(nameList.begin(), nameList.end(), [ = ] (const QString &name1, const QString &name2) {
return name1 > name2;
});
QStringList newList;
for (auto name : nameList) {
newList.push_back(map[name]);
}
return newList;
}
void DBusDockAdaptors::resizeDock(int offset)
{
parent()->resizeDock(offset);
}
// 返回每个插件的识别Key(所以此值应始终不变)供个性化插件根据key去匹配每个插件对应的图标
QString DBusDockAdaptors::getPluginKey(const QString &pluginName)
{
for (auto plugin : DockItemManager::instance()->pluginList()) {
if (plugin->pluginDisplayName() == pluginName)
return plugin->pluginName();
}
return QString();
}
bool DBusDockAdaptors::getPluginVisible(const QString &pluginName)
{
for (auto *p : DockItemManager::instance()->pluginList()) {
if (!p->pluginIsAllowDisable())
continue;
const QString &display = p->pluginDisplayName();
if (display != pluginName)
continue;
const QString &name = p->pluginName();
if (!isPluginValid(name))
continue;
return !p->pluginIsDisable();
}
qInfo() << "Unable to get information about this plugin";
return false;
}
void DBusDockAdaptors::setPluginVisible(const QString &pluginName, bool visible)
{
for (auto *p : DockItemManager::instance()->pluginList()) {
if (!p->pluginIsAllowDisable())
continue;
const QString &display = p->pluginDisplayName();
if (display != pluginName)
continue;
const QString &name = p->pluginName();
if (!isPluginValid(name))
continue;
if (p->pluginIsDisable() == visible) {
p->pluginStateSwitched();
Q_EMIT pluginVisibleChanged(pluginName, visible);
}
return;
}
qInfo() << "Unable to set information for this plugin";
}
QRect DBusDockAdaptors::geometry() const
{
return parent()->geometry();
}
bool DBusDockAdaptors::showInPrimary() const
{
return Utils::SettingValue("com.deepin.dde.dock.mainwindow", QByteArray(), "onlyShowPrimary", false).toBool();
}
void DBusDockAdaptors::setShowInPrimary(bool showInPrimary)
{
if (this->showInPrimary() == showInPrimary)
return;
if (Utils::SettingSaveValue("com.deepin.dde.dock.mainwindow", QByteArray(), "onlyShowPrimary", showInPrimary)) {
Q_EMIT showInPrimaryChanged(showInPrimary);
}
}
bool DBusDockAdaptors::isPluginValid(const QString &name)
{
// 插件被全局禁用时,理应获取不到此插件的任何信息
if (!Utils::SettingValue("com.deepin.dde.dock.module." + name, QByteArray(), "enable", false).toBool())
return false;
// 未开启窗口特效时,不显示多任务视图插件
if (name == "multitasking" && !DWindowManagerHelper::instance()->hasComposite())
return false;
// 录屏插件不显示,插件名如果有变化,建议发需求,避免任务栏反复适配
if (name == "deepin-screen-recorder-plugin")
return false;
return true;
}

View File

@ -23,11 +23,13 @@
#define DBUSDOCKADAPTORS_H
#include <QtDBus/QtDBus>
#include "mainwindow.h"
/*
* Adaptor class for interface com.deepin.dde.Dock
*/
class QGSettings;
class DBusDockAdaptors: public QDBusAbstractAdaptor
{
Q_OBJECT
@ -35,13 +37,35 @@ class DBusDockAdaptors: public QDBusAbstractAdaptor
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"com.deepin.dde.Dock\">\n"
" <property access=\"read\" type=\"(iiii)\" name=\"geometry\"/>\n"
" <property access=\"readwrite\" type=\"b\" name=\"showInPrimary\"/>\n"
" <method name=\"callShow\"/>"
" <method name=\"ReloadPlugins\"/>"
" <signal name=\"geometryChanged\">"
"<arg name=\"geometry\" type=\"(iiii)\"/>"
"</signal>"
" <method name=\"GetLoadedPlugins\">"
" <arg name=\"list\" type=\"as\" direction=\"out\"/>"
" </method>"
" <method name=\"resizeDock\">"
" <arg name=\"offset\" type=\"i\" direction=\"in\"/>"
" </method>"
" <method name=\"getPluginKey\">"
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
" <arg name=\"key\" type=\"s\" direction=\"out\"/>"
" </method>"
" <method name=\"getPluginVisible\">"
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
" <arg name=\"visible\" type=\"b\" direction=\"out\"/>"
" </method>"
" <method name=\"setPluginVisible\">"
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
" <arg name=\"visible\" type=\"b\" direction=\"in\"/>"
" </method>"
" <signal name=\"pluginVisibleChanged\">"
" <arg type=\"s\"/>"
" <arg type=\"b\"/>"
" </signal>"
" </interface>\n"
"")
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged)
public:
explicit DBusDockAdaptors(MainWindow *parent);
@ -53,12 +77,31 @@ public Q_SLOTS: // METHODS
void callShow();
void ReloadPlugins();
QStringList GetLoadedPlugins();
void resizeDock(int offset);
QString getPluginKey(const QString &pluginName);
bool getPluginVisible(const QString &pluginName);
void setPluginVisible(const QString &pluginName, bool visible);
public: // PROPERTIES
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
QRect geometry() const;
bool showInPrimary() const;
void setShowInPrimary(bool showInPrimary);
signals:
void geometryChanged(QRect geometry);
void showInPrimaryChanged(bool);
void pluginVisibleChanged(const QString &pluginName, bool visible);
private:
bool isPluginValid(const QString &name);
private:
QGSettings *m_gsettings;
};
#endif //DBUSDOCKADAPTORS

View File

@ -28,6 +28,7 @@
#include <QGSettings>
#include <DApplication>
#include <DDBusSender>
#define DIS_INS DisplayManager::instance()
@ -145,98 +146,10 @@ QMenu *MenuWorker::createMenu()
settingsMenu->addAction(act);
}
// 插件
if (!menuSettings || !menuSettings->keys().contains("hideVisible") || menuSettings->get("hideVisible").toBool()) {
QMenu *hideSubMenu = new QMenu(settingsMenu);
hideSubMenu->setAccessibleName("pluginsmenu");
QAction *hideSubMenuAct = new QAction(tr("Plugins"), this);
hideSubMenuAct->setMenu(hideSubMenu);
// create actions
QList<QAction *> actions;
for (auto *p : DockItemManager::instance()->pluginList()) {
if (!p->pluginIsAllowDisable())
continue;
const bool enable = !p->pluginIsDisable();
const QString &name = p->pluginName();
const QString &display = p->pluginDisplayName();
// 模块和菜单均需要响应enable配置的变化
const QGSettings *setting = Utils::ModuleSettingsPtr(name);
if (setting && setting->keys().contains("enable") && !setting->get("enable").toBool()) {
continue;
}
delete setting;
setting = nullptr;
// 未开启窗口特效时,同样不显示多任务视图插件
if (name == "multitasking" && !DWindowManagerHelper::instance()->hasComposite()) {
continue;
}
if (name == "deepin-screen-recorder-plugin") {
continue;
}
QAction *act = new QAction(display, this);
act->setCheckable(true);
act->setChecked(enable);
act->setData(name);
connect(act, &QAction::triggered, this, [ p ]{p->pluginStateSwitched();});
// check plugin hide menu.
const QGSettings *pluginSettings = Utils::ModuleSettingsPtr(name);
if (pluginSettings && (!pluginSettings->keys().contains("visible") || pluginSettings->get("visible").toBool()))
actions << act;
}
// sort by name
std::sort(actions.begin(), actions.end(), [](QAction * a, QAction * b) -> bool {
return a->data().toString() > b->data().toString();
});
// add plugins actions
qDeleteAll(hideSubMenu->actions());
for (auto act : actions)
hideSubMenu->addAction(act);
// add plugins menu
settingsMenu->addAction(hideSubMenuAct);
}
// 多屏显示设置 仅多屏扩展模式显示菜单
if ((!menuSettings || !menuSettings->keys().contains("multiscreenVisible") || menuSettings->get("multiscreenVisible").toBool())
&& (QApplication::screens().size() > 1) && !DIS_INS->isCopyMode()) {
bool onlyShowPrimary = Utils::SettingValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", false).toBool();
QMenu *displaySubMenu = new QMenu(settingsMenu);
displaySubMenu->setAccessibleName("displaysubmenu");
QAction *onlyPrimaryScreenModeAct = new QAction(tr("Only on main screen"), this);
QAction *followMouseModeAct = new QAction(tr("On screen where the cursor is"), this);
onlyPrimaryScreenModeAct->setCheckable(true);
followMouseModeAct->setCheckable(true);
onlyPrimaryScreenModeAct->setChecked(onlyShowPrimary);
followMouseModeAct->setChecked(!onlyShowPrimary);
connect(onlyPrimaryScreenModeAct, &QAction::triggered, this, [ = ]{
Utils::SettingSaveValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", true);
});
connect(followMouseModeAct, &QAction::triggered, this, [ = ]{
Utils::SettingSaveValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", false);
});
displaySubMenu->addAction(onlyPrimaryScreenModeAct);
displaySubMenu->addAction(followMouseModeAct);
QAction *act = new QAction(tr("Show the Dock"), this);
act->setMenu(displaySubMenu);
// 任务栏配置
if (!menuSettings || !menuSettings->keys().contains("settingVisible") || menuSettings->get("settingVisible").toBool()) {
QAction *act = new QAction(tr("Dock settings"), this);
connect(act, &QAction::triggered, this, &MenuWorker::onDockSettingsTriggered);
settingsMenu->addAction(act);
}
@ -245,6 +158,17 @@ QMenu *MenuWorker::createMenu()
return settingsMenu;
}
void MenuWorker::onDockSettingsTriggered()
{
DDBusSender().service("com.deepin.dde.ControlCenter")
.path("/com/deepin/dde/ControlCenter")
.interface("com.deepin.dde.ControlCenter")
.method("ShowPage")
.arg(QString("personalization"))
.arg(QString("Dock"))
.call();
}
void MenuWorker::showDockSettingsMenu()
{
// 菜单功能被禁用

View File

@ -49,6 +49,9 @@ public slots:
private:
QMenu *createMenu();
private slots:
void onDockSettingsTriggered();
private:
DBusDock *m_dockInter;
bool m_autoHide;

View File

@ -210,6 +210,7 @@ void MultiScreenWorker::onRegionMonitorChanged(int x, int y, const QString &key)
// 鼠标在任务栏之外移动时,任务栏该响应隐藏时需要隐藏
void MultiScreenWorker::onExtralRegionMonitorChanged(int x, int y, const QString &key)
{
// TODO 后续可以考虑去掉这部分的处理不用一直监听外部区域的移动xeventmonitor有一个CursorInto和CursorOut的信号使用这个也可以替代但要做好测试工作
Q_UNUSED(x);
Q_UNUSED(y);
if (m_extralRegisterKey != key || testState(MousePress))

View File

@ -465,6 +465,38 @@ void MainWindow::resetDragWindow()
}
}
void MainWindow::resizeDock(int offset)
{
const QRect &rect = m_multiScreenWorker->dockRect(m_multiScreenWorker->deskScreen()
, m_multiScreenWorker->position()
, HideMode::KeepShowing,
m_multiScreenWorker->displayMode());
QRect newRect;
switch (m_multiScreenWorker->position()) {
case Top:
case Bottom: {
newRect.setX(rect.x());
newRect.setY(rect.y() + rect.height() - qBound(MAINWINDOW_MIN_SIZE, rect.height() + offset, MAINWINDOW_MAX_SIZE));
newRect.setWidth(rect.width());
newRect.setHeight(qBound(MAINWINDOW_MIN_SIZE, rect.height() + offset, MAINWINDOW_MAX_SIZE));
}
break;
case Left:
case Right: {
newRect.setX(rect.x() + rect.width() - qBound(MAINWINDOW_MIN_SIZE, rect.width() + offset, MAINWINDOW_MAX_SIZE));
newRect.setY(rect.y());
newRect.setWidth(qBound(MAINWINDOW_MIN_SIZE, rect.width() - offset, MAINWINDOW_MAX_SIZE));
newRect.setHeight(rect.height());
}
break;
}
// 更新界面大小
m_mainPanel->setFixedSize(newRect.size());
setFixedSize(newRect.size());
move(newRect.topLeft());
}
/**
* @brief MainWindow::onMainWindowSizeChanged
* @param offset

View File

@ -166,6 +166,7 @@ signals:
public slots:
void RegisterDdeSession();
void resizeDock(int offset);
void resetDragWindow(); // 任务栏调整高度或宽度后需调用此函数
private slots:

View File

@ -426,6 +426,14 @@
Control Module Visible
</description>
</key>
<key type="b" name="setting-visible">
<default>true</default>
<summary>Module Visible</summary>
<description>
Control Setting Menu Visible
</description>
</key>
<!-- start 以下配置不再起作用,对应的菜单已经被删除,为了防止定制化场景调用出错,暂时保留-->
<key type="b" name="hide-visible">
<default>true</default>
<summary>Module Visible</summary>
@ -440,7 +448,7 @@
Control Multiscreen Visible
</description>
</key>
<!-- end -->
</schema>
<schema path="/com/deepin/dde/dock/module/AiAssistant/" id="com.deepin.dde.dock.module.AiAssistant" gettext-domain="DDE">
<key type="b" name="control">

View File

@ -11,3 +11,4 @@ add_subdirectory("overlay-warning")
add_subdirectory("show-desktop")
add_subdirectory("multitasking")
add_subdirectory("bluetooth")
add_subdirectory("dcc-dock-settings-plugin")

View 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} resources.qrc)
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)

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>list2_icon/dock/normal</title>
<g id="list2_icon/dock/normal" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M24,8 C25.6568542,8 27,9.34314575 27,11 L27,21 C27,22.6568542 25.6568542,24 24,24 L8,24 C6.34314575,24 5,22.6568542 5,21 L5,11 C5,9.34314575 6.34314575,8 8,8 L24,8 Z M9.5,19 L7.5,19 C7.22385763,19 7,19.2238576 7,19.5 L7,19.5 L7,21.5 C7,21.7761424 7.22385763,22 7.5,22 L7.5,22 L9.5,22 C9.77614237,22 10,21.7761424 10,21.5 L10,21.5 L10,19.5 C10,19.2238576 9.77614237,19 9.5,19 L9.5,19 Z M14.5,19 L12.5,19 C12.2238576,19 12,19.2238576 12,19.5 L12,19.5 L12,21.5 C12,21.7761424 12.2238576,22 12.5,22 L12.5,22 L14.5,22 C14.7761424,22 15,21.7761424 15,21.5 L15,21.5 L15,19.5 C15,19.2238576 14.7761424,19 14.5,19 L14.5,19 Z M19.5,19 L17.5,19 C17.2238576,19 17,19.2238576 17,19.5 L17,19.5 L17,21.5 C17,21.7761424 17.2238576,22 17.5,22 L17.5,22 L19.5,22 C19.7761424,22 20,21.7761424 20,21.5 L20,21.5 L20,19.5 C20,19.2238576 19.7761424,19 19.5,19 L19.5,19 Z M24.5,19 L22.5,19 C22.2238576,19 22,19.2238576 22,19.5 L22,19.5 L22,21.5 C22,21.7761424 22.2238576,22 22.5,22 L22.5,22 L24.5,22 C24.7761424,22 25,21.7761424 25,21.5 L25,21.5 L25,19.5 C25,19.2238576 24.7761424,19 24.5,19 L24.5,19 Z" id="形状结合" fill="#29B2DC"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -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>

View File

@ -0,0 +1,102 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Dock -p com_deepin_dde_dock 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
bool 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);
}
_Dock::~_Dock()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void _Dock::onPropertyChanged(const QString &propName, const QVariant &value)
{
if (propName == QStringLiteral("showInPrimary"))
{
const bool &showInPrimary = qvariant_cast<bool>(value);
if (d_ptr->showInPrimary != showInPrimary)
{
d_ptr->showInPrimary = showInPrimary;
Q_EMIT ShowInPrimaryChanged(d_ptr->showInPrimary);
}
return;
}
qWarning() << "property not handle: " << propName;
return;
}
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);
}

View File

@ -0,0 +1,158 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Dock -p com_deepin_dde_dock 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>
/*
* 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(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<QString> getPluginKey(const QString &pluginName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(pluginName);
return asyncCallWithArgumentList(QStringLiteral("getPluginKey"), argumentList);
}
inline QDBusPendingReply<bool> getPluginVisible(const QString &pluginName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(pluginName);
return asyncCallWithArgumentList(QStringLiteral("getPluginVisible"), argumentList);
}
inline QDBusPendingReply<> resizeDock(int offset)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(offset);
return asyncCallWithArgumentList(QStringLiteral("resizeDock"), argumentList);
}
inline void resizeDockQueued(int offset)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(offset);
CallQueued(QStringLiteral("resizeDock"), 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 ShowInPrimaryChanged(bool 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

View File

@ -0,0 +1,3 @@
{
"api" : "1.0.0"
}

View 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());
}
}
}
}

View 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

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/assistant</title>
<defs>
<path d="M7,0 C10.8659932,0 14,3.13400675 14,7 C14,10.8659932 10.8659932,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 Z M7.5,4 C7.22385763,4 7,4.22385763 7,4.5 L7,4.5 L7,9.5 C7,9.77614237 7.22385763,10 7.5,10 C7.77614237,10 8,9.77614237 8,9.5 L8,9.5 L8,4.5 C8,4.22385763 7.77614237,4 7.5,4 Z M5.5,5 C5.22385763,5 5,5.22385763 5,5.5 L5,5.5 L5,8.5 C5,8.77614237 5.22385763,9 5.5,9 C5.77614237,9 6,8.77614237 6,8.5 L6,8.5 L6,5.5 C6,5.22385763 5.77614237,5 5.5,5 Z M9.5,5 C9.22385763,5 9,5.22385763 9,5.5 L9,5.5 L9,8.5 C9,8.77614237 9.22385763,9 9.5,9 C9.77614237,9 10,8.77614237 10,8.5 L10,8.5 L10,5.5 C10,5.22385763 9.77614237,5 9.5,5 Z M3.5,6 C3.22385763,6 3,6.22385763 3,6.5 L3,6.5 L3,7.5 C3,7.77614237 3.22385763,8 3.5,8 C3.77614237,8 4,7.77614237 4,7.5 L4,7.5 L4,6.5 C4,6.22385763 3.77614237,6 3.5,6 Z M11.5,6 C11.2238576,6 11,6.22385763 11,6.5 L11,6.5 L11,7.5 C11,7.77614237 11.2238576,8 11.5,8 C11.7761424,8 12,7.77614237 12,7.5 L12,7.5 L12,6.5 C12,6.22385763 11.7761424,6 11.5,6 Z" id="path-1"></path>
</defs>
<g id="icon/dock/assistant" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="路径-5" transform="translate(1.000000, 1.000000)">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#536076" xlink:href="#path-1"></use>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/desktop</title>
<g id="icon/dock/desktop" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M13,2 C14.1045695,2 15,2.8954305 15,4 L15,12 C15,13.1045695 14.1045695,14 13,14 L3,14 C1.8954305,14 1,13.1045695 1,12 L1,4 C1,2.8954305 1.8954305,2 3,2 L13,2 Z M12.5,11 L3.5,11 C3.22385763,11 3,11.2238576 3,11.5 L3,11.5 L3,12.5 C3,12.7761424 3.22385763,13 3.5,13 L3.5,13 L12.5,13 C12.7761424,13 13,12.7761424 13,12.5 L13,12.5 L13,11.5 C13,11.2238576 12.7761424,11 12.5,11 L12.5,11 Z M4.5,7 L3.5,7 C3.22385763,7 3,7.22385763 3,7.5 L3,7.5 L3,8.5 C3,8.77614237 3.22385763,9 3.5,9 L3.5,9 L4.5,9 C4.77614237,9 5,8.77614237 5,8.5 L5,8.5 L5,7.5 C5,7.22385763 4.77614237,7 4.5,7 L4.5,7 Z M4.5,4 L3.5,4 C3.22385763,4 3,4.22385763 3,4.5 L3,4.5 L3,5.5 C3,5.77614237 3.22385763,6 3.5,6 L3.5,6 L4.5,6 C4.77614237,6 5,5.77614237 5,5.5 L5,5.5 L5,4.5 C5,4.22385763 4.77614237,4 4.5,4 L4.5,4 Z" id="形状结合" fill="#536076"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/keyboard</title>
<g id="icon/dock/keyboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M14,2 C15.1045695,2 16,2.8954305 16,4 L16,12 C16,13.1045695 15.1045695,14 14,14 L2,14 C0.8954305,14 1.3527075e-16,13.1045695 0,12 L0,4 C-1.3527075e-16,2.8954305 0.8954305,2 2,2 L14,2 Z M13.9931545,3 L2.00684547,3 C1.45078007,3 1,3.4556644 1,3.99539757 L1,12.0046024 C1,12.5543453 1.44994876,13 2.00684547,13 L13.9931545,13 C14.5492199,13 15,12.5443356 15,12.0046024 L15,3.99539757 C15,3.44565467 14.5500512,3 13.9931545,3 Z M5,10 L5,12 L2,12 L2,10 L5,10 Z M11,10 L11,12 L6,12 L6,10 L11,10 Z M14,10 L14,12 L12,12 L12,10 L14,10 Z M6,7 L6,9 L2,9 L2,7 L6,7 Z M9,7 L9,9 L7,9 L7,7 L9,7 Z M14,7 L14,9 L10,9 L10,7 L14,7 Z M5,4 L5,6 L2,6 L2,4 L5,4 Z M8,4 L8,6 L6,6 L6,4 L8,4 Z M11,4 L11,6 L9,6 L9,4 L11,4 Z M14,4 L14,6 L12,6 L12,4 L14,4 Z" id="形状结合" fill="#536076"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/notify</title>
<g id="icon/dock/notify" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M10,13 C10,14.1045695 9.1045695,15 8,15 C6.9456382,15 6.08183488,14.1841222 6.00548574,13.1492623 L6,13 L10,13 Z M8.37736851,0.580039239 C10.8942381,0.580039239 12.0585627,2.6474214 12.2115228,5.19766654 L12.2344541,5.57999124 C12.4012564,8.36102233 13.0559216,9.54402205 14.7140591,12 L1.41306267,12 C3.07120014,9.54402205 3.59874356,8.36102233 3.76554589,5.57999124 L3.78847718,5.19766654 C3.94143729,2.6474214 5.1057619,0.580039239 7.62263149,0.580039239 L8.37736851,0.580039239 Z" id="Combined-Shape" fill="#536076"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 873 B

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/plug-in2</title>
<g id="icon/dock/plug-in2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M7.5,1 C8.6045695,1 9.5,1.8954305 9.5,3 C9.5,3.364732 9.4023677,3.70666076 9.23181186,4.0010775 L12,4 C12.5522847,4 13,4.44771525 13,5 L12.9996679,7.26775657 C13.2939163,7.09746762 13.6355757,7 14,7 C15.1045695,7 16,7.8954305 16,9 C16,10.1045695 15.1045695,11 14,11 C13.6355757,11 13.2939163,10.9025324 12.9996679,10.7322434 L13,13 C13,13.5522847 12.5522847,14 12,14 L3,14 C2.44771525,14 2,13.5522847 2,13 L1.99858626,10.5809198 C2.22625932,10.6893264 2.48104412,10.75 2.75,10.75 C3.71649831,10.75 4.5,9.96649831 4.5,9 C4.5,8.03350169 3.71649831,7.25 2.75,7.25 C2.48104412,7.25 2.22625932,7.31067361 1.99858626,7.41908017 L2,5 C2,4.44771525 2.44771525,4 3,4 L5.76818814,4.0010775 C5.5976323,3.70666076 5.5,3.364732 5.5,3 C5.5,1.8954305 6.3954305,1 7.5,1 Z" id="形状结合" fill="#536076"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/power</title>
<g id="icon/dock/power" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="path-1-link" transform="translate(0.000000, 3.000000)" fill="#536076">
<path d="M11.6666667,0 C12.9553311,0 14,1.11928813 14,2.5 L14,7.5 C14,8.88071187 12.9553311,10 11.6666667,10 L2.33333333,10 C1.04466892,10 0,8.88071187 0,7.5 L0,2.5 C0,1.11928813 1.04466892,0 2.33333333,0 L11.6666667,0 Z M11.5,1 L2.5,1 C1.67157288,1 1,1.7163444 1,2.6 L1,7.4 C1,8.2836556 1.67157288,9 2.5,9 L11.5,9 C12.3284271,9 13,8.2836556 13,7.4 L13,2.6 C13,1.7163444 12.3284271,1 11.5,1 Z M10,2 L10,8 L3,8 C2.44771525,8 2,7.55228475 2,7 L2,3 C2,2.44771525 2.44771525,2 3,2 L10,2 Z M16,2 L16,8 L15,8 L15,2 L16,2 Z" id="形状结合"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 981 B

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/task</title>
<g id="icon/dock/task" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M13,2 C14.1045695,2 15,2.8954305 15,4 L15,12 C15,13.1045695 14.1045695,14 13,14 L3,14 C1.8954305,14 1,13.1045695 1,12 L1,4 C1,2.8954305 1.8954305,2 3,2 L13,2 Z M5.5,9 L3.5,9 C3.22385763,9 3,9.22385763 3,9.5 L3,9.5 L3,11.5 C3,11.7761424 3.22385763,12 3.5,12 L3.5,12 L5.5,12 C5.77614237,12 6,11.7761424 6,11.5 L6,11.5 L6,9.5 C6,9.22385763 5.77614237,9 5.5,9 L5.5,9 Z M12.5,9 L8.5,9 C8.22385763,9 8,9.22385763 8,9.5 L8,9.5 L8,11.5 C8,11.7761424 8.22385763,12 8.5,12 L8.5,12 L12.5,12 C12.7761424,12 13,11.7761424 13,11.5 L13,11.5 L13,9.5 C13,9.22385763 12.7761424,9 12.5,9 L12.5,9 Z M7.5,4 L3.5,4 C3.22385763,4 3,4.22385763 3,4.5 L3,4.5 L3,6.5 C3,6.77614237 3.22385763,7 3.5,7 L3.5,7 L7.5,7 C7.77614237,7 8,6.77614237 8,6.5 L8,6.5 L8,4.5 C8,4.22385763 7.77614237,4 7.5,4 L7.5,4 Z M12.5,4 L10.5,4 C10.2238576,4 10,4.22385763 10,4.5 L10,4.5 L10,6.5 C10,6.77614237 10.2238576,7 10.5,7 L10.5,7 L12.5,7 C12.7761424,7 13,6.77614237 13,6.5 L13,6.5 L13,4.5 C13,4.22385763 12.7761424,4 12.5,4 L12.5,4 Z" id="形状结合" fill="#536076"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/time</title>
<g id="icon/dock/time" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ICON-/-Place-/-Recent" transform="translate(1.000000, 1.000000)" fill="#536076">
<path d="M7,0 C10.8659932,0 14,3.13400675 14,7 C14,10.8659932 10.8659932,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 Z M6.5,2.5 C6.22385763,2.5 6,2.72385763 6,3 L6,7.5 C6,7.77614237 6.22385763,8 6.5,8 L11,8 C11.2761424,8 11.5,7.77614237 11.5,7.5 C11.5,7.22385763 11.2761424,7 11,7 L7,7 L7,3 C7,2.72385763 6.77614237,2.5 6.5,2.5 Z" id="Combined-Shape"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 831 B

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon/dock/trash</title>
<g id="icon/dock/trash" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ICON-/-Action-/-Delete" transform="translate(2.000000, 1.000000)" fill="#536076">
<path d="M6,0 C9.3137085,0 12,0.927517607 12,2.33333333 C12,2.36106207 11.953792,2.58428654 11.8613761,3.00300675 L11.8113175,3.22865817 C11.5058314,4.59966698 10.8293981,7.54007214 9.78201742,12.0498737 L9.68861237,12.451864 C9.6289802,12.7085364 9.47044588,12.9312968 9.24747157,13.0717216 C8.26482407,13.6905739 7.18233355,14 6,14 C4.91617954,14 3.91625723,13.739989 3.00023307,13.2199671 L2.75248331,13.0717045 C2.52951762,12.9312828 2.37098512,12.7085342 2.31134306,12.4518733 C0.770447686,5.82085682 0,2.44801015 0,2.33333333 C0,0.927517607 2.6862915,0 6,0 Z M6,1.16666667 C3.3490332,1.16666667 1.2,1.68900113 1.2,2.33333333 C1.2,2.97766554 3.3490332,3.5 6,3.5 C8.6509668,3.5 10.8,2.97766554 10.8,2.33333333 C10.8,1.68900113 8.6509668,1.16666667 6,1.16666667 Z" id="形状结合"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,347 @@
/*
* 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 <DSlider>
#include <DListView>
#include <DTipLabel>
#include <QLabel>
#include <QVBoxLayout>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusError>
#include <QMap>
#include <QScrollArea>
#include <QScroller>
#include <QComboBox>
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("Multiple Displays")))
, m_screenSettingComboxWidget(new ComboxWidget)
, m_pluginAreaTitle(new TitleLabel(tr("Plugin Area")))
, m_pluginTips(new DTipLabel(tr("Select which icons appear in the Dock")))
, m_pluginView(new DListView(this))
, m_pluginModel(new QStandardItemModel(this))
, 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();
connect(m_dockInter, &DBusInter::pluginVisibleChanged, this, &ModuleWidget::updateItemCheckStatus);
}
ModuleWidget::~ModuleWidget()
{
delete m_modeComboxWidget;
delete m_positionComboxWidget;
delete m_stateComboxWidget;
delete m_sizeSlider;
delete m_screenSettingTitle;
delete m_screenSettingComboxWidget;
delete m_pluginAreaTitle;
delete m_pluginTips;
}
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));
});
connect(m_daemonDockInter, &DBusDock::DisplayModeChanged, this, [ = ] (int value) {
DisplayMode mode = static_cast<DisplayMode>(value);
if (g_modeMap.key(mode) == m_modeComboxWidget->comboBox()->currentText())
return;
m_modeComboxWidget->setCurrentText(g_modeMap.key(mode));
});
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("Location"));
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));
});
connect(m_daemonDockInter, &DBusDock::PositionChanged, this, [ = ] (int position) {
Position pos = static_cast<Position>(position);
if (g_positionMap.key(pos) == m_positionComboxWidget->comboBox()->currentText())
return;
m_positionComboxWidget->setCurrentText(g_positionMap.key(pos));
});
layout->addWidget(m_positionComboxWidget);
m_gsettingsWatcher->bind("position", m_positionComboxWidget);
static QMap<QString, int> g_stateMap = {{tr("Keep shown"), KeepShowing}
, {tr("Keep hidden"), KeepHidden}
, {tr("Smart hide"), SmartHide}};
// 状态
m_stateComboxWidget->setTitle(tr("Status"));
m_stateComboxWidget->addBackground();
m_stateComboxWidget->setComboxOption(QStringList() << tr("Keep shown") << tr("Keep hidden") << 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));
});
connect(m_daemonDockInter, &DBusDock::HideModeChanged, this, [ = ] (int value) {
HideMode mode = static_cast<HideMode>(value);
if (g_stateMap.key(mode) == m_stateComboxWidget->comboBox()->currentText())
return;
m_stateComboxWidget->setCurrentText(g_stateMap.key(mode));
});
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("Large");
m_sizeSlider->setAnnotations(ranges);
connect(m_daemonDockInter, &DBusDock::DisplayModeChanged, this, &ModuleWidget::updateSliderValue);
connect(m_daemonDockInter, &DBusDock::WindowSizeFashionChanged, this, &ModuleWidget::updateSliderValue);
connect(m_daemonDockInter, &DBusDock::WindowSizeEfficientChanged, this, &ModuleWidget::updateSliderValue);
connect(m_sizeSlider->slider(), &DSlider::valueChanged, m_sizeSlider->slider(), &DSlider::sliderMoved);
connect(m_sizeSlider->slider(), &DSlider::sliderMoved, this, [ = ] (int value) {
int lastValue = 0;
if (m_daemonDockInter->displayMode() == DisplayMode::Fashion) {
lastValue = int(m_daemonDockInter->windowSizeFashion());
} else if (m_daemonDockInter->displayMode() == DisplayMode::Efficient) {
lastValue = int(m_daemonDockInter->windowSizeEfficient());
} else {
Q_ASSERT_X(false, __FILE__, "not supported");
}
// 得到绝对偏移值
int offset = value - lastValue;
m_dockInter->resizeDock(offset);
});
updateSliderValue();
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("Show Dock"));
m_screenSettingComboxWidget->addBackground();
m_screenSettingComboxWidget->setComboxOption(QStringList() << tr("On screen where the cursor is") << tr("Only on main screen"));
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, this, [ = ] (bool showInPrimary) {
if (m_screenSettingComboxWidget->comboBox()->currentText() == g_screenSettingMap.key(showInPrimary))
return;
m_screenSettingComboxWidget->blockSignals(true);
m_screenSettingComboxWidget->setCurrentText(g_screenSettingMap.key(showInPrimary));
m_screenSettingComboxWidget->blockSignals(false);
});
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 {
const QMap<QString, QString> &pluginIconMap = {{"assistant", ":/icons/plugins/assistant.svg"}
, {"show-desktop", ":/icons/plugins/desktop.svg"}
, {"onboard", ":/icons/plugins/keyboard.svg"}
, {"notifications", ":/icons/plugins/notify.svg"}
, {"shutdown", ":/icons/plugins/power.svg"}
, {"multitasking", ":/icons/plugins/task.svg"}
, {"datetime", ":/icons/plugins/time.svg"}
, {"trash", ":/icons/plugins/trash.svg"}};
if (plugins.size() != 0) {
layout->addSpacing(10);
layout->addWidget(m_pluginAreaTitle);
m_gsettingsWatcher->bind("pluginArea", m_pluginAreaTitle);
DFontSizeManager::instance()->bind(m_pluginTips, DFontSizeManager::T8);
m_pluginTips->adjustSize();
m_pluginTips->setWordWrap(true);
m_pluginTips->setContentsMargins(10, 5, 10, 5);
m_pluginTips->setAlignment(Qt::AlignLeft);
layout->addWidget(m_pluginTips);
m_pluginView->setAccessibleName("pluginList");
m_pluginView->setBackgroundType(DStyledItemDelegate::BackgroundType::ClipCornerBackground);
m_pluginView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_pluginView->setSelectionMode(QListView::SelectionMode::NoSelection);
m_pluginView->setEditTriggers(DListView::NoEditTriggers);
m_pluginView->setFrameShape(DListView::NoFrame);
m_pluginView->setViewportMargins(0, 0, 0, 0);
m_pluginView->setItemSpacing(1);
QMargins itemMargins(m_pluginView->itemMargins());
itemMargins.setLeft(14);
m_pluginView->setItemMargins(itemMargins);
m_pluginView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
QScroller *scroller = QScroller::scroller(m_pluginView->viewport());
QScrollerProperties sp;
sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
scroller->setScrollerProperties(sp);
m_pluginView->setModel(m_pluginModel);
layout->addWidget(m_pluginView);
m_gsettingsWatcher->bind("pluginArea", m_pluginView);
for (auto name : plugins) {
DStandardItem *item = new DStandardItem(name);
item->setFontSize(DFontSizeManager::T8);
QSize size(16, 16);
// 插件图标
auto leftAction = new DViewItemAction(Qt::AlignVCenter, size, size, true);
leftAction->setIcon(QIcon::fromTheme(pluginIconMap.value(m_dockInter->getPluginKey(name), ":/icons/plugins/plug-in2.svg")));
item->setActionList(Qt::Edge::LeftEdge, {leftAction});
auto rightAction = new DViewItemAction(Qt::AlignVCenter, size, size, true);
bool visible = m_dockInter->getPluginVisible(name);
auto checkstatus = visible ? DStyle::SP_IndicatorChecked : DStyle::SP_IndicatorUnchecked ;
auto checkIcon = qobject_cast<DStyle *>(style())->standardIcon(checkstatus);
rightAction->setIcon(checkIcon);
item->setActionList(Qt::Edge::RightEdge, {rightAction});
m_pluginModel->appendRow(item);
connect(rightAction, &DViewItemAction::triggered, this, [ = ] {
bool checked = m_dockInter->getPluginVisible(name);
m_dockInter->setPluginVisible(name, !checked);
updateItemCheckStatus(name, !checked);
});
}
// 固定大小,防止滚动
int lineHeight = m_pluginView->visualRect(m_pluginView->indexAt(QPoint(0, 0))).height();
m_pluginView->setMinimumHeight(lineHeight * plugins.size() + 10);
}
}
// 保持内容正常铺满
layout->addStretch();
// 界面内容过多时可滚动查看
QWidget *widget = new QWidget;
widget->setLayout(layout);
setWidget(widget);
}
void ModuleWidget::updateSliderValue()
{
auto displayMode = m_daemonDockInter->displayMode();
m_sizeSlider->slider()->blockSignals(true);
if (displayMode == DisplayMode::Fashion) {
if (int(m_daemonDockInter->windowSizeFashion()) != m_sizeSlider->slider()->value())
m_sizeSlider->slider()->setValue(int(m_daemonDockInter->windowSizeFashion()));
} else if (displayMode == DisplayMode::Efficient) {
if (int(m_daemonDockInter->windowSizeEfficient()) != m_sizeSlider->slider()->value())
m_sizeSlider->slider()->setValue(int(m_daemonDockInter->windowSizeEfficient()));
} else {
Q_ASSERT_X(false, __FILE__, "not supported");
}
m_sizeSlider->slider()->blockSignals(false);
}
void ModuleWidget::updateItemCheckStatus(const QString &name, bool visible)
{
for (int i = 0; i < m_pluginModel->rowCount(); ++i) {
auto item = static_cast<DStandardItem *>(m_pluginModel->item(i));
if (item->text() != name || item->actionList(Qt::Edge::RightEdge).size() < 1)
continue;
auto action = item->actionList(Qt::Edge::RightEdge).first();
auto checkstatus = visible ? DStyle::SP_IndicatorChecked : DStyle::SP_IndicatorUnchecked ;
auto icon = qobject_cast<DStyle *>(style())->standardIcon(checkstatus);
action->setIcon(icon);
m_pluginView->update(item->index());
break;
}
}

View File

@ -0,0 +1,86 @@
/*
* 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 <dtkwidget_global.h>
#include <com_deepin_dde_daemon_dock.h>
#include "com_deepin_dde_dock.h"
namespace dcc {
namespace widgets {
class ComboxWidget;
class TitledSliderItem;
}
}
DWIDGET_BEGIN_NAMESPACE
class DListView;
class DTipLabel;
DWIDGET_END_NAMESPACE
class TitleLabel;
class GSettingWatcher;
class QStandardItemModel;
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();
private:
void initUI();
private Q_SLOTS:
void updateSliderValue();
void updateItemCheckStatus(const QString &name, bool visible);
private:
ComboxWidget *m_modeComboxWidget;
ComboxWidget *m_positionComboxWidget;
ComboxWidget *m_stateComboxWidget;
TitledSliderItem *m_sizeSlider;
TitleLabel *m_screenSettingTitle;
ComboxWidget *m_screenSettingComboxWidget;
TitleLabel *m_pluginAreaTitle;
DTK_WIDGET_NAMESPACE::DTipLabel *m_pluginTips;
DTK_WIDGET_NAMESPACE::DListView *m_pluginView;
QStandardItemModel *m_pluginModel;
DBusDock *m_daemonDockInter;
DBusInter *m_dockInter;
GSettingWatcher *m_gsettingsWatcher;
};
#endif // MODULE_WIDGET_H

View File

@ -0,0 +1,16 @@
<RCC>
<qresource prefix="/icons/deepin/builtin">
<file>actions/icon_dock_32px.svg</file>
</qresource>
<qresource prefix="/">
<file>icons/plugins/time.svg</file>
<file>icons/plugins/assistant.svg</file>
<file>icons/plugins/desktop.svg</file>
<file>icons/plugins/keyboard.svg</file>
<file>icons/plugins/notify.svg</file>
<file>icons/plugins/plug-in2.svg</file>
<file>icons/plugins/power.svg</file>
<file>icons/plugins/task.svg</file>
<file>icons/plugins/trash.svg</file>
</qresource>
</RCC>

View 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()
{
}
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() << "Dock";
}
const QString SettingsModule::displayName() const
{
return tr("Dock");
}
QIcon SettingsModule::icon() const
{
return QIcon::fromTheme("icon_dock");
}
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);
}

View 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

View File

@ -20,9 +20,14 @@ file(GLOB_RECURSE PLUGIN_SRCS
"../plugins/bluetooth/*.cpp"
"../plugins/bluetooth/componments/*.h"
"../plugins/bluetooth/componments/*.cpp"
"../plugins/dcc-dock-settings-plugin/*.h"
"../plugins/dcc-dock-settings-plugin/*.cpp"
"../frame/util/horizontalseperator.h"
"../frame/util/horizontalseperator.cpp")
# "interface/moduleinterface.h"ModuleInterface_iidinterface
list(FILTER PLUGIN_SRCS EXCLUDE REGEX "../plugins/dcc-dock-settings-plugin/settings_module.*")
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
@ -43,6 +48,7 @@ find_package(Qt5DBus REQUIRED)
find_package(DtkWidget REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5 COMPONENTS Test REQUIRED)
find_package(DdeControlCenter REQUIRED)
find_package(GTest REQUIRED)
find_package(GMock REQUIRED)
@ -66,10 +72,12 @@ target_include_directories(${BIN_NAME} PUBLIC
${DFrameworkDBus_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${QGSettings_INCLUDE_DIRS}
${DdeControlCenter_INCLUDE_DIR}
../interfaces
fakedbus
../plugins/bluetooth
../plugins/bluetooth/componments
../plugins/dcc-dock-settings-plugin
)
#
@ -84,6 +92,7 @@ target_link_libraries(${BIN_NAME} PRIVATE
${Qt5DBus_LIBRARIES}
${QGSettings_LIBRARIES}
${Qt5Svg_LIBRARIES}
${DdeControlCenter_LIBRARIES}
${GTEST_LIBRARIES}
${GMOCK_LIBRARIES}
-lpthread

View File

@ -0,0 +1,40 @@
#include "gsetting_watcher.h"
#include <QWidget>
#include <gtest/gtest.h>
class Test_GSettingWatcher : public QObject, public ::testing::Test
{};
TEST_F(Test_GSettingWatcher, bind)
{
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
QWidget widget;
watcher.bind("displayMode", &widget);
watcher.bind("displayMode", nullptr);
watcher.bind("invalid", &widget);
watcher.bind("", &widget);
watcher.bind("", nullptr);
}
TEST_F(Test_GSettingWatcher, setStatus)
{
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
QWidget widget;
watcher.bind("displayMode", &widget);
watcher.setStatus("displayMode", &widget);
}
TEST_F(Test_GSettingWatcher, onStatusModeChanged)
{
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
QWidget widget;
watcher.bind("displayMode", &widget);
watcher.onStatusModeChanged("displayMode");
watcher.onStatusModeChanged("invalid");
watcher.onStatusModeChanged("");
}

View File

@ -0,0 +1,15 @@
#include "module_widget.h"
#include <QWidget>
#include <gtest/gtest.h>
class Test_ModuleWidget : public QObject, public ::testing::Test
{};
TEST_F(Test_ModuleWidget, updateSliderValue)
{
ModuleWidget widget;
widget.updateSliderValue();
}