Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions applets/dde-apps/appgroup.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -15,11 +15,11 @@
namespace apps {
AppGroup::AppGroup(const QString &groupId, const QString &name, const QList<QStringList> &appIDs)
: AppItem(groupId, AppItemModel::FolderItemType)
, m_itemsPage(new ItemsPage(name, groupId == QStringLiteral("internal/folder/0") ? (4 * 8) : (3 * 4)))
, m_itemsPage(new ItemsPage(name, parseGroupId(groupId) == 0 ? (4 * 8) : (3 * 4)))
{
setItemsPerPage(m_itemsPage->maxItemCountPerPage());
setAppName(m_itemsPage->name());
// folder id is a part of its groupId: "internal/folder/{folderId}"
// folder id is a part of its groupId: "internal/folders/{folderId}"
setFolderId(parseGroupId(groupId));

for (const QStringList &items : appIDs) {
Expand Down Expand Up @@ -47,21 +47,35 @@
return m_itemsPage;
}

bool AppGroup::idIsFolder(const QString & id)

Check warning on line 50 in applets/dde-apps/appgroup.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'idIsFolder' is never used.
{
return id.startsWith(QStringLiteral("internal/folder/"));
return parseGroupId(id) >= 0;
}

QString AppGroup::groupIdFromNumber(int groupId)

Check warning on line 55 in applets/dde-apps/appgroup.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'groupIdFromNumber' is never used.
{
return QStringLiteral("internal/folder/%1").arg(groupId);
return QStringLiteral("internal/folders/%1").arg(groupId);
}

int AppGroup::parseGroupId(const QString & id)
{
using namespace std::string_view_literals;
constexpr size_t len = "internal/folder/"sv.size();
return QStringView{id}.mid(len + 1).toInt();
constexpr QLatin1StringView prefix("internal/folders/");
if (!id.startsWith(prefix))
return -1;

const QStringView number = QStringView(id).sliced(prefix.size());

if (number.isEmpty())
return -1;

for (const QChar ch : number) {
if (!ch.isDigit())

Check warning on line 72 in applets/dde-apps/appgroup.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::any_of algorithm instead of a raw loop.
return -1;
}

bool ok = false;
const int groupId = number.toInt(&ok);
return ok && groupId >= 0 ? groupId : -1;
}

void AppGroup::setItemsPerPage(int number)
Expand Down
2 changes: 1 addition & 1 deletion applets/dde-apps/appgroup.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down
21 changes: 11 additions & 10 deletions applets/dde-apps/appgroupmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ QModelIndex AppGroupManager::groupIndexById(int groupId)
{
for (int i = 0; i < rowCount(); i++) {
auto groupIndex = index(i, 0);
auto data = groupIndex.data(GroupIdRole);
if (data.toInt() == groupId) {
auto appGroup = static_cast<AppGroup *>(itemFromIndex(groupIndex));
if (appGroup && appGroup->folderId() == groupId) {
return groupIndex;
}
}
Expand Down Expand Up @@ -352,8 +352,8 @@ void AppGroupManager::loadAppGroupInfo()
}

// always ensure top-level group exists
if (rowCount() == 0) {
auto p = appendGroup(assignGroupId(), "Top Level", {});
if (!group(TOPLEVEL_FOLDERID)) {
auto p = appendGroup(AppGroup::groupIdFromNumber(TOPLEVEL_FOLDERID), "Top Level", {});
Q_ASSERT(p->folderId() == TOPLEVEL_FOLDERID);
}
}
Expand All @@ -375,18 +375,19 @@ void AppGroupManager::saveAppGroupInfo()

QString AppGroupManager::assignGroupId() const
{
QStringList knownGroupIds;
QSet<int> knownGroupIds;
for (int i = 0; i < rowCount(); i++) {
auto group = index(i, 0);
knownGroupIds.append(group.data(AppItemModel::DesktopIdRole).toString());
auto appGroup = static_cast<AppGroup *>(itemFromIndex(index(i, 0)));
if (appGroup && appGroup->folderId() >= 0)
knownGroupIds.insert(appGroup->folderId());
}

int idNumber = 0;
while (knownGroupIds.contains(QString("internal/group/%1").arg(idNumber))) {
int idNumber = 1;
while (knownGroupIds.contains(idNumber)) {
idNumber++;
}

return QString("internal/group/%1").arg(idNumber);
return AppGroup::groupIdFromNumber(idNumber);
}

AppGroup * AppGroupManager::appendGroup(int groupId, QString groupName, const QList<QStringList> &appItemIDs)
Expand Down
50 changes: 49 additions & 1 deletion applets/dde-apps/appsapplet.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "appsapplet.h"
#include "amappitem.h"
#include "amappitemmodel.h"
#include "appgroup.h"
#include "appgroupmanager.h"
#include "appitemmodel.h"
#include "itemspage.h"
#include "pluginfactory.h"

Check warning on line 12 in applets/dde-apps/appsapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "pluginfactory.h" not found.

#include <DUtil>

Check warning on line 14 in applets/dde-apps/appsapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DUtil> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtConcurrent>

namespace apps
{
static AMAppItem *findApplication(AMAppItemModel *model, const QString &desktopId)
{
if (auto item = model->appItem(desktopId))
return item;

const auto alternateId = desktopId.endsWith(QStringLiteral(".desktop"))
? desktopId.chopped(8)
: desktopId + QStringLiteral(".desktop");
return model->appItem(alternateId);
}

AppsApplet::AppsApplet(QObject *parent)
: DApplet(parent)
, m_appModel(new AMAppItemModel(this))
Expand Down Expand Up @@ -40,6 +55,39 @@
return m_appModel;
}

QVariantList AppsApplet::groupItemDetails(const QString &groupId) const
{
const int id = AppGroup::parseGroupId(groupId);
auto group = id > 0 ? m_groupModel->group(id) : nullptr;
if (!group)
return {};

const auto items = group->itemsPage()->allArrangedItems();
QVariantList result;
result.reserve(items.size());
for (const auto &desktopId : items) {
const auto item = findApplication(m_appModel, desktopId);
if (!item)
continue;
result.append(QVariantMap{
{QStringLiteral("desktopId"), desktopId},
{QStringLiteral("name"), item->data(AppItemModel::NameRole)},
{QStringLiteral("iconName"), item->data(AppItemModel::IconNameRole)},
});
}
return result;
}

bool AppsApplet::launchApplication(const QString &desktopId)
{
if (auto item = findApplication(m_appModel, desktopId)) {
item->launch({}, {}, {{QStringLiteral("_launch_type"), QStringLiteral("dde-shell")}});
return true;
}

return false;
}

bool AppsApplet::appModelReady() const
{
return m_appModel->ready();
Expand Down
8 changes: 6 additions & 2 deletions applets/dde-apps/appsapplet.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -13,6 +13,7 @@ DS_USE_NAMESPACE

namespace apps {
class AMAppItemModel;
class AppGroupManager;
class AppItem;
class AppsApplet : public DApplet
{
Expand All @@ -30,6 +31,9 @@ class AppsApplet : public DApplet
QAbstractItemModel *appModel() const;
QAbstractItemModel *groupModel() const;

Q_INVOKABLE QVariantList groupItemDetails(const QString &groupId) const;
Q_INVOKABLE bool launchApplication(const QString &desktopId);

bool appModelReady() const;

signals:
Expand All @@ -38,6 +42,6 @@ class AppsApplet : public DApplet
private:
bool m_appModelReady;
AMAppItemModel *m_appModel;
QAbstractItemModel *m_groupModel;
AppGroupManager *m_groupModel;
};
}
10 changes: 9 additions & 1 deletion frame/qml/PanelPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Item {
property bool readyBinding: false
property bool openPending: false
property bool grabInactivePending: false
property bool closeOnInactive: true
property int grabInactiveTimeout: 200
// WM_NAME, used for kwin.
property string windowTitle: "dde-shell/panelpopup"
Expand Down Expand Up @@ -117,6 +118,9 @@ Item {
if (!popupWindow || !readyBinding || popupWindow.currentItem !== control || !popup.visible) {
return
}
if (!control.closeOnInactive) {
return
}
if (!popupWindow.active) {
control.close()
}
Expand All @@ -139,6 +143,9 @@ Item {
grabInactiveTimer.stop()
return
}
if (!control.closeOnInactive) {
return
}
if (control.grabInactivePending || popupWindow.x11GrabFocusTransition) {
return
}
Expand Down Expand Up @@ -175,7 +182,8 @@ Item {
|| !readyBinding
|| popupWindow.currentItem !== control
|| !popup.visible
|| control.grabInactivePending) {
|| control.grabInactivePending
|| !control.closeOnInactive) {
return
}
if (!popupWindow.active) {
Expand Down
6 changes: 6 additions & 0 deletions panels/dock/DockCompositor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Item {
property ListModel trayPluginSurfaces: ListModel {}
property ListModel quickPluginSurfaces: ListModel {}
property ListModel fixedPluginSurfaces: ListModel {}
property ListModel cardPluginSurfaces: ListModel {}

property var compositor: waylandCompositor
property var panelScale: 1.0
Expand Down Expand Up @@ -62,6 +63,7 @@ Item {
let ret = findSurfaceFromModel(trayPluginSurfaces, surfaceId)
if (ret === null) ret = findSurfaceFromModel(quickPluginSurfaces, surfaceId)
if (ret === null) ret = findSurfaceFromModel(fixedPluginSurfaces, surfaceId)
if (ret === null) ret = findSurfaceFromModel(cardPluginSurfaces, surfaceId)
return ret
}

Expand Down Expand Up @@ -92,6 +94,8 @@ Item {
quickPluginSurfaces.append({shellSurface: dockPluginSurface})
} else if (dockPluginSurface.pluginType === Dock.Fixed) {
fixedPluginSurfaces.append({shellSurface: dockPluginSurface})
} else if (dockPluginSurface.pluginType === Dock.Card) {
cardPluginSurfaces.append({shellSurface: dockPluginSurface})
}
dockCompositor.pluginSurfacesUpdated()
}
Expand All @@ -104,6 +108,8 @@ Item {
removeDockPluginSurface(quickPluginSurfaces, dockPluginSurface)
} else if (dockPluginSurface.pluginType === Dock.Fixed) {
removeDockPluginSurface(fixedPluginSurfaces, dockPluginSurface)
} else if (dockPluginSurface.pluginType === Dock.Card) {
removeDockPluginSurface(cardPluginSurfaces, dockPluginSurface)
}
dockCompositor.pluginSurfacesUpdated()
}
Expand Down
4 changes: 2 additions & 2 deletions panels/dock/MenuHelper.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -21,8 +21,8 @@ Item {
if (activeMenu) {
activeMenu.close()
}
menu.open()
activeMenu = menu
menu.open()
}
function closeMenu(menu: Menu) {
menu.close()
Expand Down
10 changes: 10 additions & 0 deletions panels/dock/OverflowContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ Item {
}

function calculateImplicitWidth(prev, current) {
// Zero-width delegates are hidden (for example, items moved into the
// overflow popup) and must not leave an extra spacing slot behind.
if (current <= 0) {
return prev
}
if (useColumnLayout) {
return Math.max(prev, current)
} else {
Expand All @@ -41,6 +46,11 @@ Item {
}

function calculateImplicitHeight(prev, current) {
// Keep the vertical layout consistent with the horizontal one: hidden
// delegates contribute neither size nor spacing.
if (current <= 0) {
return prev
}
if (useColumnLayout) {
if (prev == 0) {
return current
Expand Down
5 changes: 5 additions & 0 deletions panels/dock/cardleft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

ds_install_package(PACKAGE org.deepin.ds.dock.cardleft)
Loading
Loading