Skip to content

Commit 211c925

Browse files
shule1987claude
andcommitted
feat: add fashion left dock, pinned popup, and various dock improvements
Add the first fashion mode dock implementation pieces. Introduce the left dock area, pinned popup support, and related dock updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 61b4c67 commit 211c925

46 files changed

Lines changed: 7512 additions & 306 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

applets/dde-appearance/appearanceapplet.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,18 @@ void AppearanceApplet::initDBusProxy()
5959
return;
6060
}
6161

62-
m_interface->setSync(false);
63-
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::OpacityChanged, this, &AppearanceApplet::opacityChanged);
62+
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::Changed, this,
63+
[this](const QString &type, const QString &) {
64+
if (type.compare(QStringLiteral("opacity"), Qt::CaseInsensitive) == 0) {
65+
Q_EMIT opacityChanged();
66+
}
67+
});
68+
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::Refreshed, this,
69+
[this](const QString &type) {
70+
if (type.compare(QStringLiteral("opacity"), Qt::CaseInsensitive) == 0) {
71+
Q_EMIT opacityChanged();
72+
}
73+
});
6474
Q_EMIT opacityChanged();
6575
}
6676

applets/dde-apps/CMakeLists.txt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,46 @@ find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS DB
66
find_package(DDEApplicationManager REQUIRED)
77
find_package(yaml-cpp REQUIRED)
88

9+
set(DDE_APPS_DBUS_API_FALLBACK_DIR "${PROJECT_SOURCE_DIR}/panels/dock/taskmanager/api/amdbus")
10+
set(DDE_APPS_APPLICATION_XML "${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.Application.xml")
11+
set(DDE_APPS_APPLICATION_MANAGER_XML "${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.xml")
12+
set(DDE_APPS_OBJECT_MANAGER_XML "${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ObjectManager1.xml")
13+
14+
if (NOT EXISTS "${DDE_APPS_APPLICATION_XML}")
15+
set(DDE_APPS_APPLICATION_XML "${DDE_APPS_DBUS_API_FALLBACK_DIR}/org.desktopspec.ApplicationManager1.Application.xml")
16+
endif()
17+
18+
if (NOT EXISTS "${DDE_APPS_APPLICATION_MANAGER_XML}")
19+
set(DDE_APPS_APPLICATION_MANAGER_XML "${DDE_APPS_DBUS_API_FALLBACK_DIR}/org.desktopspec.ApplicationManager1.xml")
20+
endif()
21+
22+
if (NOT EXISTS "${DDE_APPS_OBJECT_MANAGER_XML}")
23+
set(DDE_APPS_OBJECT_MANAGER_XML "${DDE_APPS_DBUS_API_FALLBACK_DIR}/org.desktopspec.ObjectManager1.xml")
24+
endif()
25+
926
set_source_files_properties(
10-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.Application.xml
27+
${DDE_APPS_APPLICATION_XML}
1128
PROPERTIES INCLUDE api/types/am.h
1229
CLASSNAME Application
1330
)
1431

1532
set_source_files_properties(
16-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.xml
33+
${DDE_APPS_APPLICATION_MANAGER_XML}
1734
PROPERTIES INCLUDE api/types/am.h
1835
CLASSNAME ApplicationManager
1936
)
2037

2138
set_source_files_properties(
22-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ObjectManager1.xml
39+
${DDE_APPS_OBJECT_MANAGER_XML}
2340
PROPERTIES INCLUDE api/types/am.h
2441
CLASSNAME ObjectManager
2542
)
2643

2744
qt_add_dbus_interfaces(
2845
DBUS_INTERFACES
29-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.Application.xml
30-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ApplicationManager1.xml
31-
${DDE_APPLICATION_MANAGER_DBUS_API_DIR}/org.desktopspec.ObjectManager1.xml
46+
${DDE_APPS_APPLICATION_XML}
47+
${DDE_APPS_APPLICATION_MANAGER_XML}
48+
${DDE_APPS_OBJECT_MANAGER_XML}
3249
)
3350

3451

applets/dde-apps/appgroup.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Q_LOGGING_CATEGORY(appGroupLog, "org.deepin.dde.shell.dde-apps.appgroup")
1414

1515
namespace apps {
1616
AppGroup::AppGroup(const QString &groupId, const QString &name, const QList<QStringList> &appIDs)
17-
: AppItem(groupId, AppItemModel::FolderItemType)
18-
, m_itemsPage(new ItemsPage(name, groupId == QStringLiteral("internal/folder/0") ? (4 * 8) : (3 * 4)))
17+
: AppItem(normalizeGroupId(groupId), AppItemModel::FolderItemType)
18+
, m_itemsPage(new ItemsPage(name, parseGroupId(groupId) == 0 ? (4 * 8) : (3 * 4)))
1919
{
2020
setItemsPerPage(m_itemsPage->maxItemCountPerPage());
2121
setAppName(m_itemsPage->name());
22-
// folder id is a part of its groupId: "internal/folder/{folderId}"
22+
// folder id is the numeric suffix of the normalized launcher group id.
2323
setFolderId(parseGroupId(groupId));
2424

2525
for (const QStringList &items : appIDs) {
@@ -49,19 +49,38 @@ ItemsPage *AppGroup::itemsPage()
4949

5050
bool AppGroup::idIsFolder(const QString & id)
5151
{
52-
return id.startsWith(QStringLiteral("internal/folder/"));
52+
bool isNumericId = false;
53+
id.toInt(&isNumericId);
54+
55+
return isNumericId ||
56+
id.startsWith(QStringLiteral("internal/folder/")) ||
57+
id.startsWith(QStringLiteral("internal/folders/")) ||
58+
id.startsWith(QStringLiteral("internal/group/"));
59+
}
60+
61+
QString AppGroup::normalizeGroupId(const QString &id)
62+
{
63+
bool isNumericId = false;
64+
const int numericId = id.toInt(&isNumericId);
65+
if (isNumericId) {
66+
return groupIdFromNumber(numericId);
67+
}
68+
69+
if (!idIsFolder(id)) {
70+
return id;
71+
}
72+
73+
return QStringLiteral("internal/folders/%1").arg(parseGroupId(id));
5374
}
5475

5576
QString AppGroup::groupIdFromNumber(int groupId)
5677
{
57-
return QStringLiteral("internal/folder/%1").arg(groupId);
78+
return QStringLiteral("internal/folders/%1").arg(groupId);
5879
}
5980

6081
int AppGroup::parseGroupId(const QString & id)
6182
{
62-
using namespace std::string_view_literals;
63-
constexpr size_t len = "internal/folder/"sv.size();
64-
return QStringView{id}.mid(len + 1).toInt();
83+
return id.section(QLatin1Char('/'), -1).toInt();
6584
}
6685

6786
void AppGroup::setItemsPerPage(int number)
@@ -75,4 +94,3 @@ void AppGroup::setFolderId(int folderId)
7594
}
7695

7796
}
78-

applets/dde-apps/appgroup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AppGroup : public AppItem
1919
ItemsPage * itemsPage();
2020

2121
static bool idIsFolder(const QString & id);
22+
static QString normalizeGroupId(const QString &id);
2223
static QString groupIdFromNumber(int groupId);
2324
static int parseGroupId(const QString & id);
2425

applets/dde-apps/appgroupmanager.cpp

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,37 @@ QVariant AppGroupManager::data(const QModelIndex &index, int role) const
4343
if (!index.isValid())
4444
return QVariant();
4545

46-
if (role == GroupIdRole) {
47-
return index.row();
48-
}
49-
5046
return QStandardItemModel::data(index, role);
5147
}
5248

49+
QHash<int, QByteArray> AppGroupManager::roleNames() const
50+
{
51+
return {
52+
{GroupIdRole, QByteArrayLiteral("groupId")},
53+
{GroupItemsPerPageRole, QByteArrayLiteral("groupItemsPerPage")},
54+
{AppItemModel::DesktopIdRole, QByteArrayLiteral("desktopId")},
55+
{AppItemModel::NameRole, QByteArrayLiteral("name")},
56+
{AppItemModel::IconNameRole, QByteArrayLiteral("iconName")},
57+
{AppItemModel::StartUpWMClassRole, QByteArrayLiteral("startupWMClass")},
58+
{AppItemModel::NoDisplayRole, QByteArrayLiteral("noDisplay")},
59+
{AppItemModel::ActionsRole, QByteArrayLiteral("actions")},
60+
{AppItemModel::DDECategoryRole, QByteArrayLiteral("ddeCategory")},
61+
{AppItemModel::CategoriesRole, QByteArrayLiteral("categories")},
62+
{AppItemModel::InstalledTimeRole, QByteArrayLiteral("installedTime")},
63+
{AppItemModel::LastLaunchedTimeRole, QByteArrayLiteral("lastLaunchedTime")},
64+
{AppItemModel::LaunchedTimesRole, QByteArrayLiteral("launchedTimes")},
65+
{AppItemModel::DockedRole, QByteArrayLiteral("docked")},
66+
{AppItemModel::OnDesktopRole, QByteArrayLiteral("onDesktop")},
67+
{AppItemModel::AutoStartRole, QByteArrayLiteral("autoStart")},
68+
{AppItemModel::AppTypeRole, QByteArrayLiteral("appType")},
69+
{AppItemModel::XLingLongRole, QByteArrayLiteral("isLingLong")},
70+
{AppItemModel::IdRole, QByteArrayLiteral("id")},
71+
{AppItemModel::XCreatedByRole, QByteArrayLiteral("xCreatedBy")},
72+
{AppItemModel::ExecsRole, QByteArrayLiteral("execs")},
73+
{AppItemModel::DesktopSourcePathRole, QByteArrayLiteral("desktopSourcePath")},
74+
};
75+
}
76+
5377
// Find the item's location. If folderId is -1, search all folders.
5478
ItemPosition AppGroupManager::findItem(const QString &appId, int folderId)
5579
{
@@ -121,6 +145,32 @@ ItemsPage * AppGroupManager::groupPages(int groupId)
121145
return folder->itemsPage();
122146
}
123147

148+
QStringList AppGroupManager::groupItems(const QString &groupId) const
149+
{
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 {
159+
return {};
160+
}
161+
162+
for (int i = 0; i < rowCount(); ++i) {
163+
auto folder = static_cast<AppGroup *>(item(i));
164+
if (!folder || AppGroup::normalizeGroupId(folder->appId()) != normalizedGroupId) {
165+
continue;
166+
}
167+
168+
return folder->itemsPage()->allArrangedItems();
169+
}
170+
171+
return {};
172+
}
173+
124174
void AppGroupManager::bringToFromt(const QString & id)
125175
{
126176
const ItemPosition origPos = findItem(id);
@@ -342,6 +392,8 @@ void AppGroupManager::loadAppGroupInfo()
342392

343393
if (groupId.isEmpty()) {
344394
groupId = assignGroupId();
395+
} else {
396+
groupId = AppGroup::normalizeGroupId(groupId);
345397
}
346398
appendGroup(groupId, name, items);
347399
}
@@ -373,15 +425,15 @@ QString AppGroupManager::assignGroupId() const
373425
QStringList knownGroupIds;
374426
for (int i = 0; i < rowCount(); i++) {
375427
auto group = index(i, 0);
376-
knownGroupIds.append(group.data(AppItemModel::DesktopIdRole).toString());
428+
knownGroupIds.append(AppGroup::normalizeGroupId(group.data(AppItemModel::DesktopIdRole).toString()));
377429
}
378430

379431
int idNumber = 0;
380-
while (knownGroupIds.contains(QString("internal/group/%1").arg(idNumber))) {
432+
while (knownGroupIds.contains(AppGroup::groupIdFromNumber(idNumber))) {
381433
idNumber++;
382434
}
383435

384-
return QString("internal/group/%1").arg(idNumber);
436+
return AppGroup::groupIdFromNumber(idNumber);
385437
}
386438

387439
AppGroup * AppGroupManager::appendGroup(int groupId, QString groupName, const QList<QStringList> &appItemIDs)
@@ -392,7 +444,7 @@ AppGroup * AppGroupManager::appendGroup(int groupId, QString groupName, const QL
392444

393445
AppGroup * AppGroupManager::appendGroup(QString groupId, QString groupName, const QList<QStringList> &appItemIDs)
394446
{
395-
auto p = new AppGroup(groupId, groupName, appItemIDs);
447+
auto p = new AppGroup(AppGroup::normalizeGroupId(groupId), groupName, appItemIDs);
396448
appendRow(p);
397449
return p;
398450
}

applets/dde-apps/appgroupmanager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class AppGroupManager : public QStandardItemModel
5555
explicit AppGroupManager(AMAppItemModel * referenceModel, QObject* parent = nullptr);
5656

5757
QVariant data(const QModelIndex &index, int role = GroupIdRole) const override;
58+
QHash<int, QByteArray> roleNames() const override;
5859

5960
Q_INVOKABLE ItemPosition findItem(const QString &appId, int folderId = -1);
6061
Q_INVOKABLE void appendItemToGroup(const QString &appId, int groupId);
@@ -63,6 +64,7 @@ class AppGroupManager : public QStandardItemModel
6364
AppGroup * group(int groupId);
6465
AppGroup * group(QModelIndex idx);
6566
Q_INVOKABLE ItemsPage * groupPages(int groupId);
67+
Q_INVOKABLE QStringList groupItems(const QString &groupId) const;
6668
Q_INVOKABLE void bringToFromt(const QString & id);
6769
Q_INVOKABLE void commitRearrangeOperation(const QString & dragId, const QString & dropId, DndOperation operation, int pageHint = -1);
6870

frame/pluginloader.cpp

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,33 +130,67 @@ class DPluginLoaderPrivate : public DObjectPrivate
130130

131131
result << DDE_SHELL_PLUGIN_INSTALL_DIR;
132132

133+
QStringList librarySubdirs {QStringLiteral("lib/dde-shell")};
134+
const QString installPluginDir = QString::fromLocal8Bit(DDE_SHELL_PLUGIN_INSTALL_DIR);
135+
const int installLibIndex = installPluginDir.lastIndexOf(QStringLiteral("/lib"));
136+
if (installLibIndex >= 0) {
137+
const QString libSubdir = installPluginDir.mid(installLibIndex + 1, installPluginDir.size() - installLibIndex - 1 - QStringLiteral("/dde-shell").size());
138+
if (!libSubdir.isEmpty()) {
139+
const QString resolvedSubdir = libSubdir + QStringLiteral("/dde-shell");
140+
if (!librarySubdirs.contains(resolvedSubdir)) {
141+
librarySubdirs.prepend(resolvedSubdir);
142+
}
143+
}
144+
}
145+
146+
for (const auto &dataDir : QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) {
147+
if (!dataDir.endsWith(QStringLiteral("/share"))) {
148+
continue;
149+
}
150+
151+
const QString prefix = dataDir.left(dataDir.size() - QStringLiteral("/share").size());
152+
for (const auto &librarySubdir : librarySubdirs) {
153+
const QString pluginDir = QDir(prefix).absoluteFilePath(librarySubdir);
154+
if (QDir(pluginDir).exists() && !result.contains(pluginDir)) {
155+
result << pluginDir;
156+
}
157+
}
158+
}
159+
133160
qCDebug(dsLog()) << "Builtin plugin paths" << result;
134161
return result;
135162
}
136163

137-
bool existPlugin(const DPluginMetaData &data) const
164+
QString pluginFilePath(const DPluginMetaData &data) const
138165
{
139166
const QString fileName = data.pluginId();
140167
D_QC(DPluginLoader);
141168
for (const auto &item : q->pluginDirs()) {
142169
const QDir dir(item);
143-
if (dir.exists(fileName + PluginSuffix))
144-
return true;
170+
const QString absoluteFilePath = dir.absoluteFilePath(fileName + PluginSuffix);
171+
if (QFileInfo::exists(absoluteFilePath))
172+
return absoluteFilePath;
145173
}
146-
return false;
174+
return {};
175+
}
176+
177+
bool existPlugin(const DPluginMetaData &data) const
178+
{
179+
return !pluginFilePath(data).isEmpty();
147180
}
148181

149182
DAppletFactory *appletFactory(const DPluginMetaData &data)
150183
{
151-
if (!existPlugin(data))
184+
const QString pluginPath = pluginFilePath(data);
185+
if (pluginPath.isEmpty()) {
152186
return nullptr;
187+
}
153188

154189
DAppletFactory *factory = nullptr;
155-
const QString fileName = data.pluginId();
156-
QPluginLoader loader(fileName);
190+
QPluginLoader loader(pluginPath);
157191
loader.load();
158192
if (!loader.isLoaded()) {
159-
qCWarning(dsLog) << "Load the plugin failed." << loader.errorString();
193+
qCWarning(dsLog) << "Load the plugin failed." << pluginPath << loader.errorString();
160194
return factory;
161195
}
162196

@@ -171,12 +205,12 @@ class DPluginLoaderPrivate : public DObjectPrivate
171205
break;
172206

173207
if (!loader.instance()) {
174-
qWarning(dsLog) << "Load the plugin failed." << loader.errorString();
208+
qWarning(dsLog) << "Load the plugin failed." << pluginPath << loader.errorString();
175209
break;
176210
}
177211
factory = qobject_cast<DAppletFactory *>(loader.instance());
178212
if (!factory) {
179-
qWarning(dsLog) << "The plugin isn't a DAppletFactory." << fileName;
213+
qWarning(dsLog) << "The plugin isn't a DAppletFactory." << pluginPath;
180214
break;
181215
}
182216
} while (false);

frame/qml/PanelPopupWindow.qml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PopupWindow {
1414
property real xOffset: 0
1515
property real yOffset: 0
1616
property int margins: 10
17+
property int windowThemeType: D.ApplicationHelper.LightType
1718
property Item currentItem
1819
property int requestedWidth: 10
1920
property int requestedHeight: 10
@@ -76,13 +77,14 @@ PopupWindow {
7677
flags: (Qt.platform.pluginName === "xcb" ? (Qt.Tool | Qt.WindowStaysOnTopHint) : Qt.Popup)
7778
font: D.DTK.fontManager.t6
7879
D.DWindow.enabled: true
80+
D.DWindow.themeType: root.windowThemeType
7981
D.DWindow.windowRadius: D.DTK.platformTheme.windowRadius < 0 ? 4 : D.DTK.platformTheme.windowRadius
8082
D.DWindow.enableSystemResize: false
8183
D.DWindow.enableSystemMove: false
8284
D.DWindow.enableBlurWindow: true
8385
// TODO set shadowOffset maunally.
8486
D.DWindow.shadowOffset: Qt.point(0, 25)
85-
D.DWindow.shadowColor: D.DTK.themeType === D.ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(0, 0, 0, 0.2)
87+
D.DWindow.shadowColor: root.windowThemeType === D.ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(0, 0, 0, 0.2)
8688
D.ColorSelector.family: D.Palette.CrystalColor
8789
color: "transparent"
8890

@@ -163,4 +165,4 @@ PopupWindow {
163165
DStyle.Style.behindWindowBlur.darkNoBlurColor)
164166
}
165167
}
166-
}
168+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/shule/src/dde-shell/panels/dock/package

0 commit comments

Comments
 (0)