Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/waylandtasksmodel.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 95 | q->dataChanged(q->index(0, 0), q->index(windows.count() - 1, 0), | |||
---|---|---|---|---|---|
98 | AbstractTasksModel::LauncherUrl, | 98 | AbstractTasksModel::LauncherUrl, | ||
99 | AbstractTasksModel::LauncherUrlWithoutIcon, | 99 | AbstractTasksModel::LauncherUrlWithoutIcon, | ||
100 | AbstractTasksModel::SkipTaskbar}); | 100 | AbstractTasksModel::SkipTaskbar}); | ||
101 | }; | 101 | }; | ||
102 | 102 | | |||
103 | rulesConfig = KSharedConfig::openConfig(QStringLiteral("taskmanagerrulesrc")); | 103 | rulesConfig = KSharedConfig::openConfig(QStringLiteral("taskmanagerrulesrc")); | ||
104 | configWatcher = new KDirWatch(q); | 104 | configWatcher = new KDirWatch(q); | ||
105 | 105 | | |||
106 | foreach (const QString &location, QStandardPaths::standardLocations(QStandardPaths::ConfigLocation)) { | 106 | const auto locations = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); | ||
107 | for (const QString &location : locations) { | ||||
107 | configWatcher->addFile(location + QLatin1String("/taskmanagerrulesrc")); | 108 | configWatcher->addFile(location + QLatin1String("/taskmanagerrulesrc")); | ||
108 | } | 109 | } | ||
109 | 110 | | |||
110 | auto rulesConfigChange = [this, clearCacheAndRefresh] { | 111 | auto rulesConfigChange = [this, clearCacheAndRefresh] { | ||
111 | rulesConfig->reparseConfiguration(); | 112 | rulesConfig->reparseConfiguration(); | ||
112 | clearCacheAndRefresh(); | 113 | clearCacheAndRefresh(); | ||
113 | }; | 114 | }; | ||
114 | 115 | | |||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Line(s) | 623 | { | |||
626 | 627 | | |||
627 | if (!index.isValid() || index.model() != this || index.row() < 0 || index.row() >= d->windows.count()) { | 628 | if (!index.isValid() || index.model() != this || index.row() < 0 || index.row() >= d->windows.count()) { | ||
628 | return; | 629 | return; | ||
629 | } | 630 | } | ||
630 | 631 | | |||
631 | KWayland::Client::PlasmaWindow *window = d->windows.at(index.row()); | 632 | KWayland::Client::PlasmaWindow *window = d->windows.at(index.row()); | ||
632 | 633 | | |||
633 | if (desktops.isEmpty()) { | 634 | if (desktops.isEmpty()) { | ||
634 | foreach (const QVariant &desktop, window->plasmaVirtualDesktops()) { | 635 | const auto virtualDesktops = window->plasmaVirtualDesktops(); | ||
636 | for (const QVariant &desktop : virtualDesktops) { | ||||
635 | window->requestLeaveVirtualDesktop(desktop.toString()); | 637 | window->requestLeaveVirtualDesktop(desktop.toString()); | ||
636 | } | 638 | } | ||
637 | } else { | 639 | } else { | ||
638 | const QStringList &now = window->plasmaVirtualDesktops(); | 640 | const QStringList &now = window->plasmaVirtualDesktops(); | ||
639 | QStringList next; | 641 | QStringList next; | ||
640 | 642 | | |||
641 | foreach (const QVariant &desktop, desktops) { | 643 | for (const QVariant &desktop : desktops) { | ||
642 | const QString &desktopId = desktop.toString(); | 644 | const QString &desktopId = desktop.toString(); | ||
643 | 645 | | |||
644 | if (!desktopId.isEmpty()) { | 646 | if (!desktopId.isEmpty()) { | ||
645 | next << desktopId; | 647 | next << desktopId; | ||
646 | 648 | | |||
647 | if (!now.contains(desktopId)) { | 649 | if (!now.contains(desktopId)) { | ||
648 | window->requestEnterVirtualDesktop(desktopId); | 650 | window->requestEnterVirtualDesktop(desktopId); | ||
649 | } | 651 | } | ||
650 | } | 652 | } | ||
651 | } | 653 | } | ||
652 | 654 | | |||
653 | foreach (const QString &desktop, now) { | 655 | for (const QString &desktop : now) { | ||
654 | if (!next.contains(desktop)) { | 656 | if (!next.contains(desktop)) { | ||
655 | window->requestLeaveVirtualDesktop(desktop); | 657 | window->requestLeaveVirtualDesktop(desktop); | ||
656 | } | 658 | } | ||
657 | } | 659 | } | ||
658 | } | 660 | } | ||
659 | } | 661 | } | ||
660 | 662 | | |||
661 | void WaylandTasksModel::requestNewVirtualDesktop(const QModelIndex &index) | 663 | void WaylandTasksModel::requestNewVirtualDesktop(const QModelIndex &index) | ||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |