|
3 | 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | 4 |
|
5 | 5 | #include "dockglobalelementmodel.h" |
| 6 | +#include "applicationinterface.h" |
6 | 7 | #include "globals.h" |
7 | 8 | #include "taskmanager.h" |
8 | 9 | #include "taskmanagersettings.h" |
9 | 10 |
|
10 | 11 | #include <QAbstractListModel> |
| 12 | +#include <QDBusConnection> |
11 | 13 | #include <QJsonDocument> |
12 | 14 | #include <QJsonObject> |
13 | 15 | #include <QProcess> |
@@ -234,6 +236,11 @@ void DockGlobalElementModel::loadDockedElements() |
234 | 236 | } |
235 | 237 |
|
236 | 238 | m_dockedElements = newDocked; |
| 239 | + |
| 240 | + if (!m_data.isEmpty()) { |
| 241 | + // MenusRole should also be handled here due to it contains the copywriting of docked or undocked |
| 242 | + Q_EMIT dataChanged(index(0, 0), index(m_data.size() - 1, 0), {TaskManager::DockedRole, TaskManager::MenusRole}); |
| 243 | + } |
237 | 244 | } |
238 | 245 |
|
239 | 246 | QString DockGlobalElementModel::getMenus(const QModelIndex &index) const |
@@ -318,15 +325,33 @@ void DockGlobalElementModel::requestActivate(const QModelIndex &index) const |
318 | 325 |
|
319 | 326 | void DockGlobalElementModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const |
320 | 327 | { |
321 | | - Q_UNUSED(index) |
322 | | - Q_UNUSED(urls) |
| 328 | + auto data = m_data.value(index.row()); |
| 329 | + auto id = std::get<0>(data); |
| 330 | + |
| 331 | + QStringList urlStrings; |
| 332 | + for (const QUrl &url : urls) { |
| 333 | + urlStrings.append(url.toLocalFile()); |
| 334 | + } |
| 335 | + |
| 336 | + QString dbusPath = QStringLiteral("/org/desktopspec/ApplicationManager1/") + escapeToObjectPath(id); |
| 337 | + using Application = org::desktopspec::ApplicationManager1::Application; |
| 338 | + Application appInterface(QStringLiteral("org.desktopspec.ApplicationManager1"), dbusPath, QDBusConnection::sessionBus()); |
| 339 | + |
| 340 | + if (appInterface.isValid()) { |
| 341 | + appInterface.Launch(QString(), urlStrings, QVariantMap()); |
| 342 | + } |
323 | 343 | } |
324 | 344 |
|
325 | 345 | void DockGlobalElementModel::requestNewInstance(const QModelIndex &index, const QString &action) const |
326 | 346 | { |
327 | 347 | if (action == DOCK_ACTION_DOCK) { |
| 348 | + auto data = m_data.value(index.row()); |
| 349 | + auto id = std::get<0>(data); |
| 350 | + TaskManagerSettings::instance()->toggleDockedElement(QStringLiteral("desktop/%1").arg(id)); |
328 | 351 | } else if (action == DOCK_ACTION_FORCEQUIT) { |
| 352 | + requestClose(index, true); |
329 | 353 | } else if (action == DOCK_ACTION_CLOSEALL) { |
| 354 | + requestClose(index); |
330 | 355 | } else { |
331 | 356 | auto data = m_data.value(index.row()); |
332 | 357 | auto id = std::get<0>(data); |
|
0 commit comments