Skip to content

Commit 66744c6

Browse files
shule1987claude
andcommitted
feat: update fashion left dock, pinned popup, and task manager improvements
Continue the fashion mode dock series with task manager updates. Refine the left dock behavior and pinned popup interactions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 211c925 commit 66744c6

28 files changed

Lines changed: 909 additions & 184 deletions

applets/dde-appearance/appearanceapplet.cpp

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@
77
#include "pluginfactory.h"
88

99
#include <QDBusError>
10+
#include <QDBusMessage>
11+
#include <QDBusReply>
12+
#include <QDBusVariant>
1013
#include <QDebug>
1114
#include <QDBusServiceWatcher>
1215

1316
DCORE_USE_NAMESPACE
1417
DS_BEGIN_NAMESPACE
1518
namespace dde {
1619

20+
namespace {
21+
bool isOpacityChangeType(const QString &type)
22+
{
23+
return type.compare(QStringLiteral("opacity"), Qt::CaseInsensitive) == 0
24+
|| type.compare(QStringLiteral("windowopacity"), Qt::CaseInsensitive) == 0;
25+
}
26+
}
27+
1728
AppearanceApplet::AppearanceApplet(QObject *parent)
1829
: DApplet(parent)
1930
{
@@ -39,11 +50,11 @@ bool AppearanceApplet::load()
3950

4051
qreal AppearanceApplet::opacity() const
4152
{
42-
if (!m_interface)
53+
if (m_opacity < 0)
4354
return -1;
4455

4556
// The minimum opacity is 0.2
46-
return std::max(0.2, m_interface->opacity());
57+
return std::max(0.2, m_opacity);
4758
}
4859

4960
void AppearanceApplet::initDBusProxy()
@@ -61,19 +72,40 @@ void AppearanceApplet::initDBusProxy()
6172

6273
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::Changed, this,
6374
[this](const QString &type, const QString &) {
64-
if (type.compare(QStringLiteral("opacity"), Qt::CaseInsensitive) == 0) {
75+
if (isOpacityChangeType(type)) {
76+
refreshOpacity();
6577
Q_EMIT opacityChanged();
6678
}
6779
});
6880
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::Refreshed, this,
6981
[this](const QString &type) {
70-
if (type.compare(QStringLiteral("opacity"), Qt::CaseInsensitive) == 0) {
82+
if (isOpacityChangeType(type)) {
83+
refreshOpacity();
7184
Q_EMIT opacityChanged();
7285
}
7386
});
87+
refreshOpacity();
7488
Q_EMIT opacityChanged();
7589
}
7690

91+
void AppearanceApplet::refreshOpacity()
92+
{
93+
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.deepin.dde.Appearance1"),
94+
QStringLiteral("/org/deepin/dde/Appearance1"),
95+
QStringLiteral("org.freedesktop.DBus.Properties"),
96+
QStringLiteral("Get"));
97+
message << QStringLiteral("org.deepin.dde.Appearance1") << QStringLiteral("Opacity");
98+
99+
QDBusReply<QDBusVariant> reply = QDBusConnection::sessionBus().call(message);
100+
if (!reply.isValid()) {
101+
qWarning() << "Failed to get Appearance opacity, error:" << reply.error();
102+
m_opacity = -1;
103+
return;
104+
}
105+
106+
m_opacity = reply.value().variant().toReal();
107+
}
108+
77109
D_APPLET_CLASS(AppearanceApplet)
78110
}
79111
DS_END_NAMESPACE

applets/dde-appearance/appearanceapplet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ class AppearanceApplet : public DApplet
2424
void opacityChanged();
2525
private:
2626
void initDBusProxy();
27+
void refreshOpacity();
2728
private:
2829
QScopedPointer<org::deepin::dde::Appearance1> m_interface;
30+
qreal m_opacity = -1;
2931
};
3032

3133
}

applets/dde-apps/appgroup.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ AppGroup::AppGroup(const QString &groupId, const QString &name, const QList<QStr
1919
{
2020
setItemsPerPage(m_itemsPage->maxItemCountPerPage());
2121
setAppName(m_itemsPage->name());
22+
QObject::connect(m_itemsPage, &ItemsPage::nameChanged, m_itemsPage, [this]() {
23+
setAppName(m_itemsPage->name());
24+
});
2225
// folder id is the numeric suffix of the normalized launcher group id.
2326
setFolderId(parseGroupId(groupId));
2427

applets/dde-apps/appgroupmanager.cpp

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212

1313
namespace apps {
1414

15+
static QString normalizeResolvableGroupId(const QString &groupId)
16+
{
17+
bool isNumericGroupId = false;
18+
groupId.toInt(&isNumericGroupId);
19+
20+
if (AppGroup::idIsFolder(groupId)) {
21+
return AppGroup::normalizeGroupId(groupId);
22+
}
23+
24+
if (isNumericGroupId) {
25+
return AppGroup::groupIdFromNumber(groupId.toInt());
26+
}
27+
28+
return {};
29+
}
30+
1531
AppGroupManager::AppGroupManager(AMAppItemModel * referenceModel, QObject *parent)
1632
: QStandardItemModel(parent)
1733
, m_referenceModel(referenceModel)
@@ -147,15 +163,8 @@ ItemsPage * AppGroupManager::groupPages(int groupId)
147163

148164
QStringList AppGroupManager::groupItems(const QString &groupId) const
149165
{
150-
QString normalizedGroupId = groupId;
151-
bool isNumericGroupId = false;
152-
groupId.toInt(&isNumericGroupId);
153-
154-
if (AppGroup::idIsFolder(groupId)) {
155-
normalizedGroupId = AppGroup::normalizeGroupId(groupId);
156-
} else if (isNumericGroupId) {
157-
normalizedGroupId = AppGroup::groupIdFromNumber(groupId.toInt());
158-
} else {
166+
const QString normalizedGroupId = normalizeResolvableGroupId(groupId);
167+
if (normalizedGroupId.isEmpty()) {
159168
return {};
160169
}
161170

@@ -171,6 +180,25 @@ QStringList AppGroupManager::groupItems(const QString &groupId) const
171180
return {};
172181
}
173182

183+
QString AppGroupManager::groupDisplayName(const QString &groupId) const
184+
{
185+
const QString normalizedGroupId = normalizeResolvableGroupId(groupId);
186+
if (normalizedGroupId.isEmpty()) {
187+
return {};
188+
}
189+
190+
for (int i = 0; i < rowCount(); ++i) {
191+
auto folder = static_cast<AppGroup *>(item(i));
192+
if (!folder || AppGroup::normalizeGroupId(folder->appId()) != normalizedGroupId) {
193+
continue;
194+
}
195+
196+
return folder->itemsPage() ? folder->itemsPage()->name() : folder->appName();
197+
}
198+
199+
return {};
200+
}
201+
174202
void AppGroupManager::bringToFromt(const QString & id)
175203
{
176204
const ItemPosition origPos = findItem(id);
@@ -411,7 +439,7 @@ void AppGroupManager::saveAppGroupInfo()
411439
for (int i = 0; i < rowCount(); i++) {
412440
auto folder = group(index(i, 0));
413441
QVariantMap valueMap;
414-
valueMap.insert("name", folder->data(AppItemModel::NameRole));
442+
valueMap.insert("name", folder->itemsPage() ? folder->itemsPage()->name() : folder->data(AppItemModel::NameRole));
415443
valueMap.insert("groupId", folder->appId());
416444
valueMap.insert("appItems", fromListOfStringList(folder->pages()));
417445
list << valueMap;

applets/dde-apps/appgroupmanager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class AppGroupManager : public QStandardItemModel
6565
AppGroup * group(QModelIndex idx);
6666
Q_INVOKABLE ItemsPage * groupPages(int groupId);
6767
Q_INVOKABLE QStringList groupItems(const QString &groupId) const;
68+
Q_INVOKABLE QString groupDisplayName(const QString &groupId) const;
6869
Q_INVOKABLE void bringToFromt(const QString & id);
6970
Q_INVOKABLE void commitRearrangeOperation(const QString & dragId, const QString & dropId, DndOperation operation, int pageHint = -1);
7071

frame/qml/PanelPopupWindow.qml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PopupWindow {
1515
property real yOffset: 0
1616
property int margins: 10
1717
property int windowThemeType: D.ApplicationHelper.LightType
18+
readonly property bool darkTheme: root.windowThemeType === D.ApplicationHelper.DarkType
1819
property Item currentItem
1920
property int requestedWidth: 10
2021
property int requestedHeight: 10
@@ -84,7 +85,7 @@ PopupWindow {
8485
D.DWindow.enableBlurWindow: true
8586
// TODO set shadowOffset maunally.
8687
D.DWindow.shadowOffset: Qt.point(0, 25)
87-
D.DWindow.shadowColor: root.windowThemeType === D.ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(0, 0, 0, 0.2)
88+
D.DWindow.shadowColor: root.darkTheme ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(0, 0, 0, 0.2)
8889
D.ColorSelector.family: D.Palette.CrystalColor
8990
color: "transparent"
9091

@@ -155,14 +156,15 @@ PopupWindow {
155156
return appearance.opacity
156157
}
157158
blendColor: {
159+
const isDark = root.darkTheme
158160
if (valid) {
159-
return DStyle.Style.control.selectColor(undefined,
160-
Qt.rgba(235 / 255.0, 235 / 255.0, 235 / 255.0, blendColorAlpha(0.6)),
161-
Qt.rgba(0, 0, 0, blendColorAlpha(85 / 255)))
161+
return isDark
162+
? Qt.rgba(0, 0, 0, blendColorAlpha(85 / 255))
163+
: Qt.rgba(235 / 255.0, 235 / 255.0, 235 / 255.0, blendColorAlpha(0.6))
162164
}
163-
return DStyle.Style.control.selectColor(undefined,
164-
DStyle.Style.behindWindowBlur.lightNoBlurColor,
165-
DStyle.Style.behindWindowBlur.darkNoBlurColor)
165+
return isDark
166+
? DStyle.Style.behindWindowBlur.darkNoBlurColor
167+
: DStyle.Style.behindWindowBlur.lightNoBlurColor
166168
}
167169
}
168170
}

frame/qml/PanelToolTip.qml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ Item {
1818
property int toolTipX: 0
1919
property int toolTipY: 0
2020
property bool readyBinding: false
21+
readonly property int toolTipTopFrameInset: 1
2122
// WM_NAME, used for kwin.
2223
property string windowTitle: "dde-shell/paneltooltip"
2324
width: toolTip.width
2425
height: toolTip.height
2526

2627
Binding {
2728
when: readyBinding
28-
target: toolTipWindow; property: "requestedWidth"
29+
target: toolTipWindow; property: "width"
2930
value: toolTip.width + toolTip.leftPadding + toolTip.rightPadding
3031
}
3132
Binding {
3233
when: readyBinding
33-
target: toolTipWindow; property: "requestedHeight"
34-
value: toolTip.height
34+
target: toolTipWindow; property: "height"
35+
value: toolTip.height + toolTipTopFrameInset
3536
}
3637
Binding {
3738
when: readyBinding
@@ -43,7 +44,7 @@ Item {
4344
when: readyBinding
4445
delayed: true
4546
target: toolTipWindow; property: "yOffset"
46-
value: control.toolTipY
47+
value: control.toolTipY - toolTipTopFrameInset
4748
}
4849

4950
function open()

frame/qml/PanelToolTipWindow.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ PanelPopupWindow {
1313
flags: Qt.ToolTip | Qt.WindowStaysOnTopHint
1414
D.DWindow.windowRadius: 8
1515
D.DWindow.shadowRadius: 8
16+
D.DWindow.shadowOffset: Qt.point(0, 8)
1617
}

panels/dock/dockpanel.cpp

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include <QLoggingCategory>
2323
#include <QGuiApplication>
2424
#include <QQuickItem>
25+
#include <QDBusInterface>
26+
#include <QDBusReply>
27+
#include <QDBusVariant>
2528
#include <DGuiApplicationHelper>
2629
#include <DPlatformTheme>
2730

@@ -31,6 +34,24 @@ Q_LOGGING_CATEGORY(dockLog, "org.deepin.dde.shell.dock")
3134

3235
namespace dock {
3336

37+
namespace {
38+
constexpr auto kAppearanceService = "org.deepin.dde.Appearance1";
39+
constexpr auto kAppearancePath = "/org/deepin/dde/Appearance1";
40+
constexpr auto kAppearanceInterface = "org.deepin.dde.Appearance1";
41+
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties";
42+
43+
ColorTheme colorThemeFromGlobalThemeName(const QString &themeName, const ColorTheme &fallbackTheme)
44+
{
45+
if (themeName.endsWith(QStringLiteral(".dark"), Qt::CaseInsensitive))
46+
return Dark;
47+
48+
if (themeName.endsWith(QStringLiteral(".light"), Qt::CaseInsensitive))
49+
return Light;
50+
51+
return fallbackTheme;
52+
}
53+
}
54+
3455
DockPanel::DockPanel(QObject *parent)
3556
: DPanel(parent)
3657
, m_theme(ColorTheme::Dark)
@@ -160,9 +181,13 @@ bool DockPanel::init()
160181
QObject::connect(guiHelper, &Dtk::Gui::DGuiApplicationHelper::themeTypeChanged,
161182
this, &DockPanel::syncColorThemeWithSystem);
162183
if (auto *platformTheme = guiHelper->applicationTheme()) {
163-
QObject::connect(platformTheme, &DPlatformTheme::themeNameChanged,
184+
QObject::connect(platformTheme, &Dtk::Gui::DPlatformTheme::themeNameChanged,
164185
this, &DockPanel::syncColorThemeWithSystem);
165186
}
187+
QDBusConnection::sessionBus().connect(kAppearanceService, kAppearancePath, kAppearanceInterface,
188+
"Changed", this, SLOT(onAppearanceChanged(QString,QString)));
189+
QDBusConnection::sessionBus().connect(kAppearanceService, kAppearancePath, kAppearanceInterface,
190+
"Refreshed", this, SLOT(onAppearanceRefreshed(QString)));
166191
syncColorThemeWithSystem();
167192

168193
auto platformName = QGuiApplication::platformName();
@@ -239,9 +264,41 @@ void DockPanel::setColorTheme(const ColorTheme& theme)
239264
Q_EMIT this->colorThemeChanged(theme);
240265
}
241266

267+
void DockPanel::onAppearanceChanged(const QString &type, const QString &value)
268+
{
269+
Q_UNUSED(value)
270+
if (type.compare(QStringLiteral("GlobalTheme"), Qt::CaseInsensitive) != 0)
271+
return;
272+
273+
syncColorThemeWithSystem();
274+
}
275+
276+
void DockPanel::onAppearanceRefreshed(const QString &type)
277+
{
278+
if (type.compare(QStringLiteral("GlobalTheme"), Qt::CaseInsensitive) != 0)
279+
return;
280+
281+
syncColorThemeWithSystem();
282+
}
283+
242284
void DockPanel::syncColorThemeWithSystem()
243285
{
244-
setColorTheme(static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType()));
286+
const auto fallbackTheme = static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType());
287+
QDBusInterface appearanceProperties(kAppearanceService,
288+
kAppearancePath,
289+
kPropertiesInterface,
290+
QDBusConnection::sessionBus());
291+
if (appearanceProperties.isValid()) {
292+
const QDBusReply<QDBusVariant> reply = appearanceProperties.call(QStringLiteral("Get"),
293+
QString::fromLatin1(kAppearanceInterface),
294+
QStringLiteral("GlobalTheme"));
295+
if (reply.isValid()) {
296+
setColorTheme(colorThemeFromGlobalThemeName(reply.value().variant().toString(), fallbackTheme));
297+
return;
298+
}
299+
}
300+
301+
setColorTheme(fallbackTheme);
245302
}
246303

247304
uint DockPanel::dockSize()

panels/dock/dockpanel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ private Q_SLOTS:
122122
void onWindowGeometryChanged();
123123
void launcherVisibleChanged(bool visible);
124124
void updateDockScreen();
125+
void onAppearanceChanged(const QString &type, const QString &value);
126+
void onAppearanceRefreshed(const QString &type);
125127
void syncColorThemeWithSystem();
126128

127129
Q_SIGNALS:

0 commit comments

Comments
 (0)