feat: 更新插件页面UI

按照设计图更新UI

Log:
Task: https://pms.uniontech.com/zentao/task-view-86359.html
Change-Id: I90f16bc2d39bbbc49f245e6ef76ac833e660e6b5
This commit is contained in:
范朋程 2021-10-11 11:14:40 +08:00
parent 644f6166b9
commit 8d8eac0262
19 changed files with 244 additions and 40 deletions

View File

@ -118,6 +118,17 @@ QStringList DBusDockAdaptors::GetLoadedPlugins()
return newList;
}
// 返回每个插件的识别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()) {

View File

@ -43,6 +43,9 @@ class DBusDockAdaptors: public QDBusAbstractAdaptor
" <method name=\"GetLoadedPlugins\">"
" <arg name=\"list\" type=\"as\" direction=\"out\"/>"
" </method>"
" <method name=\"getPluginKey\">"
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
" </method>"
" <method name=\"getPluginVisible\">"
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
" <arg name=\"visible\" type=\"b\" direction=\"out\"/>"
@ -72,6 +75,8 @@ public Q_SLOTS: // METHODS
QStringList GetLoadedPlugins();
QString getPluginKey(const QString &pluginName);
bool getPluginVisible(const QString &pluginName);
void setPluginVisible(const QString &pluginName, bool visible);

View File

@ -18,7 +18,7 @@ find_package(DtkWidget REQUIRED)
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
add_library(${PLUGIN_NAME} SHARED ${SRCS})
add_library(${PLUGIN_NAME} SHARED ${SRCS} resources.qrc)
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ./)
target_include_directories(${PLUGIN_NAME} PUBLIC
../src

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

@ -54,6 +54,12 @@ public Q_SLOTS: // METHODS
return asyncCallWithArgumentList(QStringLiteral("GetLoadedPlugins"), argumentList);
}
inline QDBusPendingReply<QString> getPluginKey(const QString &pluginName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(pluginName);
return asyncCallWithArgumentList(QStringLiteral("getPluginKey"), argumentList);
}
inline QDBusPendingReply<> ReloadPlugins()

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

@ -25,9 +25,10 @@
#include <widgets/titledslideritem.h>
#include <widgets/dccslider.h>
#include <widgets/titlelabel.h>
#include <widgets/switchwidget.h>
#include <DSlider>
#include <DListView>
#include <DTipLabel>
#include <QLabel>
#include <QVBoxLayout>
@ -36,6 +37,7 @@
#include <QDBusError>
#include <QMap>
#include <QScrollArea>
#include <QScroller>
DWIDGET_USE_NAMESPACE
@ -66,11 +68,16 @@ ModuleWidget::ModuleWidget(QWidget *parent)
, m_screenSettingTitle(new TitleLabel(tr("Multi screen config")))
, m_screenSettingComboxWidget(new ComboxWidget)
, m_pluginAreaTitle(new TitleLabel(tr("Plugin area")))
, m_pluginTips(new DTipLabel(tr("Select the icon that needs to be displayed in the plug-in area of the taskbar")))
, 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()
@ -82,6 +89,7 @@ ModuleWidget::~ModuleWidget()
delete m_screenSettingTitle;
delete m_screenSettingComboxWidget;
delete m_pluginAreaTitle;
delete m_pluginTips;
}
void ModuleWidget::initUI()
@ -140,17 +148,21 @@ void ModuleWidget::initUI()
m_sizeSlider->addBackground();
m_sizeSlider->slider()->setRange(40, 100);
QStringList ranges;
ranges << tr("Small") << tr("Big");
ranges << tr("Small") << "" << tr("Big");
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, 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();
});
updateSliderValue(m_daemonDockInter->displayMode());
updateSliderValue();
m_gsettingsWatcher->bind("sizeSlider", m_sizeSlider);
layout->addWidget(m_sizeSlider);
@ -181,28 +193,76 @@ void ModuleWidget::initUI()
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);
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);
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);
}
}
@ -215,13 +275,32 @@ void ModuleWidget::initUI()
setWidget(widget);
}
void ModuleWidget::updateSliderValue(int displayMode)
void ModuleWidget::updateSliderValue()
{
auto displayMode = m_daemonDockInter->displayMode();
m_sizeSlider->blockSignals(true);
if (displayMode == DisplayMode::Fashion) {
m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeFashion()));
m_sizeSlider->slider()->setValue(int(m_daemonDockInter->windowSizeFashion()));
} else if (displayMode == DisplayMode::Efficient) {
m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeEfficient()));
m_sizeSlider->slider()->setValue(int(m_daemonDockInter->windowSizeEfficient()));
} else {
Q_ASSERT_X(false, __FILE__, "not supported");
}
m_sizeSlider->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

@ -23,6 +23,8 @@
#include <QScrollArea>
#include <dtkwidget_global.h>
#include <com_deepin_dde_daemon_dock.h>
#include "com_deepin_dde_dock.h"
@ -31,12 +33,18 @@ namespace dcc {
namespace widgets {
class ComboxWidget;
class TitledSliderItem;
class SwitchWidget;
}
}
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;
@ -48,10 +56,12 @@ public:
explicit ModuleWidget(QWidget *parent = nullptr);
~ ModuleWidget();
private:
void initUI();
private Q_SLOTS:
void updateSliderValue(int displayMode);
void updateSliderValue();
void updateItemCheckStatus(const QString &name, bool visible);
private:
ComboxWidget *m_modeComboxWidget;
@ -64,7 +74,9 @@ private:
ComboxWidget *m_screenSettingComboxWidget;
TitleLabel *m_pluginAreaTitle;
QList<SwitchWidget *> m_pluginWidgetList;
DTK_WIDGET_NAMESPACE::DTipLabel *m_pluginTips;
DTK_WIDGET_NAMESPACE::DListView *m_pluginView;
QStandardItemModel *m_pluginModel;
DBusDock *m_daemonDockInter;
DBusInter *m_dockInter;

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

@ -61,7 +61,7 @@ const QString SettingsModule::displayName() const
QIcon SettingsModule::icon() const
{
return QIcon::fromTheme("unknown");
return QIcon::fromTheme("icon_dock");
}
QString SettingsModule::translationPath() const

View File

@ -7,18 +7,9 @@
class Test_ModuleWidget : public QObject, public ::testing::Test
{};
TEST(Test_ModuleWidget_DeathTest, updateSliderValue)
{
ModuleWidget widget;
#ifdef QT_DEBUG
EXPECT_DEBUG_DEATH({widget.updateSliderValue(-1);}, "");
#endif
}
TEST_F(Test_ModuleWidget, updateSliderValue)
{
ModuleWidget widget;
widget.updateSliderValue(0);
widget.updateSliderValue(1);
widget.updateSliderValue();
}