Skip to content
Merged
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
4 changes: 2 additions & 2 deletions panels/dock/taskmanager/desktopfileabstractparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ void DesktopfileAbstractParser::setDocked(bool docked)
auto desktopElement = QStringLiteral("desktop/%1").arg(id());

if (docked) {
TaskManagerSettings::instance()->appendDockedElements(desktopElement);
TaskManagerSettings::instance()->appendDockedElement(desktopElement);
} else {
TaskManagerSettings::instance()->removeDockedElements(desktopElement);
TaskManagerSettings::instance()->removeDockedElement(desktopElement);
}

Q_EMIT dockedChanged();
Expand Down
29 changes: 27 additions & 2 deletions panels/dock/taskmanager/dockglobalelementmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "dockglobalelementmodel.h"
#include "applicationinterface.h"

Check warning on line 6 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "applicationinterface.h" not found.
#include "globals.h"
#include "taskmanager.h"
#include "taskmanagersettings.h"

#include <QAbstractListModel>

Check warning on line 11 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 13 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in panels/dock/taskmanager/dockglobalelementmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <algorithm>
#include <tuple>
Expand Down Expand Up @@ -234,6 +236,11 @@
}

m_dockedElements = newDocked;

if (!m_data.isEmpty()) {
// MenusRole should also be handled here due to it contains the copywriting of docked or undocked
Q_EMIT dataChanged(index(0, 0), index(m_data.size() - 1, 0), {TaskManager::DockedRole, TaskManager::MenusRole});
}
}

QString DockGlobalElementModel::getMenus(const QModelIndex &index) const
Expand Down Expand Up @@ -318,15 +325,33 @@

void DockGlobalElementModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const
{
Q_UNUSED(index)
Q_UNUSED(urls)
auto data = m_data.value(index.row());
auto id = std::get<0>(data);

QStringList urlStrings;
for (const QUrl &url : urls) {
urlStrings.append(url.toLocalFile());
}

QString dbusPath = QStringLiteral("/org/desktopspec/ApplicationManager1/") + escapeToObjectPath(id);
using Application = org::desktopspec::ApplicationManager1::Application;
Application appInterface(QStringLiteral("org.desktopspec.ApplicationManager1"), dbusPath, QDBusConnection::sessionBus());

if (appInterface.isValid()) {
appInterface.Launch(QString(), urlStrings, QVariantMap());
}
}

void DockGlobalElementModel::requestNewInstance(const QModelIndex &index, const QString &action) const
{
if (action == DOCK_ACTION_DOCK) {
auto data = m_data.value(index.row());
auto id = std::get<0>(data);
TaskManagerSettings::instance()->toggleDockedElement(QStringLiteral("desktop/%1").arg(id));
} else if (action == DOCK_ACTION_FORCEQUIT) {
requestClose(index, true);
} else if (action == DOCK_ACTION_CLOSEALL) {
requestClose(index);
} else {
auto data = m_data.value(index.row());
auto id = std::get<0>(data);
Expand Down
6 changes: 0 additions & 6 deletions panels/dock/taskmanager/dockgroupmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ void DockGroupModel::requestActivate(const QModelIndex &index) const
interface->requestActivate(sourceIndex);
}

void DockGroupModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const
{
Q_UNUSED(index)
Q_UNUSED(urls)
}

void DockGroupModel::requestClose(const QModelIndex &index, bool force) const
{
auto interface = dynamic_cast<AbstractTaskManagerInterface *>(sourceModel());
Expand Down
1 change: 0 additions & 1 deletion panels/dock/taskmanager/dockgroupmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class DockGroupModel : public RoleGroupModel, public AbstractTaskManagerInterfac
Q_INVOKABLE virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;

void requestActivate(const QModelIndex &index) const override;
void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const override;
void requestClose(const QModelIndex &index, bool force = false) const override;
void requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) const override;
void requestPreview(const QModelIndexList &indexes,
Expand Down
13 changes: 10 additions & 3 deletions panels/dock/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,17 @@ void TaskManager::clickItem(const QString& itemId, const QString& menuId)

void TaskManager::dropFilesOnItem(const QString& itemId, const QStringList& urls)
{
auto item = ItemModel::instance()->getItemById(itemId);
if(!item) return;
auto indexes = m_itemModel->match(m_itemModel->index(0, 0), TaskManager::ItemIdRole, itemId, 1, Qt::MatchExactly);
if (indexes.isEmpty()) {
return;
}

QList<QUrl> urlList;
for (const QString &url : urls) {
urlList.append(QUrl::fromLocalFile(url));
}

item->handleFileDrop(urls);
m_itemModel->requestOpenUrls(indexes.first(), urlList);
}

void TaskManager::showItemPreview(const QString &itemId, QObject *relativePositionItem, int32_t previewXoffset, int32_t previewYoffset, uint32_t direction)
Expand Down
13 changes: 11 additions & 2 deletions panels/dock/taskmanager/taskmanagersettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,23 @@
saveDockedElements();
}

void TaskManagerSettings::appendDockedElements(const QString &element)
void TaskManagerSettings::toggleDockedElement(const QString &element)

Check warning on line 151 in panels/dock/taskmanager/taskmanagersettings.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'toggleDockedElement' is never used.
{
if (isDocked(element)) {
removeDockedElement(element);
} else {
appendDockedElement(element);
}
}

void TaskManagerSettings::appendDockedElement(const QString &element)
{
m_dockedElements.append(element);
Q_EMIT dockedElementsChanged();
saveDockedElements();
}

void TaskManagerSettings::removeDockedElements(const QString &element)
void TaskManagerSettings::removeDockedElement(const QString &element)
{
m_dockedElements.removeAll(element);
Q_EMIT dockedElementsChanged();
Expand Down
5 changes: 3 additions & 2 deletions panels/dock/taskmanager/taskmanagersettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class TaskManagerSettings : public QObject
bool cgroupsBasedGrouping() const;

void setDockedElements(const QStringList &elements);
void appendDockedElements(const QString &element);
void removeDockedElements(const QString &element);
void toggleDockedElement(const QString &element);
void appendDockedElement(const QString &element);
void removeDockedElement(const QString &element);
QStringList dockedElements() const;
bool isDocked(const QString &elementId) const;

Expand Down