diff --git a/containments/taskpanel/package/contents/ui/Task.qml b/containments/taskpanel/package/contents/ui/Task.qml index 61c9c41047715a8b9d4685bab750eaa261f4ae42..13747a522db2fa9cad3433cbd4123b06adb2c5bb 100644 --- a/containments/taskpanel/package/contents/ui/Task.qml +++ b/containments/taskpanel/package/contents/ui/Task.qml @@ -20,6 +20,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 +import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.mobilecomponents 0.2 @@ -42,7 +43,7 @@ Item { target: tasksView onContentYChanged: { var pos = delegate.mapToItem(tasksView, 0, 0); - plasmoid.nativeInterface.setTaskGeometry(filteredWindowModel.mapRowToSource(model.index), pos.x, pos.y, delegate.width, delegate.height); + tasksModel.requestPublishDelegateGeometry(model.index, Qt.rect(pos.x, pos.y, delegate.width, delegate.height)); } } @@ -65,7 +66,7 @@ Item { ScriptAction { script: { if (background.x != 0) { - plasmoid.nativeInterface.windowModel.requestClose(filteredWindowModel.mapRowToSource(model.index)); + tasksModel.requestClose(model.index); } } } @@ -95,7 +96,7 @@ Item { anchors.centerIn: parent width: Math.min(parent.width, parent.height) / 2 height: width - source: model.DecorationRole + source: model.decoration } PlasmaComponents.Label { anchors { @@ -105,7 +106,7 @@ Item { } horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight - text: model.DisplayRole + text: model.AppName } MouseArea { anchors.fill: parent diff --git a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml index 26eb04568c27fe775302dacb4d0c5c40a5e86361..9b22b03db8488e68a7f365925bbb98835faa3bf7 100644 --- a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml +++ b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml @@ -20,6 +20,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 +import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.mobilecomponents 0.2 @@ -33,7 +34,7 @@ FullScreenPanel { height: Screen.height property int offset: 0 property int overShoot: units.gridUnit * 2 - property int tasksCount: filteredWindowModel.count + property int tasksCount: tasksModel.count property int currentTaskIndex: -1 color: Qt.rgba(0, 0, 0, 0.8 * Math.min( @@ -41,7 +42,7 @@ FullScreenPanel { ((tasksView.contentHeight - tasksView.contentY - tasksView.headerItem.height - tasksView.footerItem.height)/tasksView.height))) function show() { - if (filteredWindowModel.count == 0) { + if (tasksModel.count == 0) { return; } if (!visible) { @@ -65,20 +66,16 @@ FullScreenPanel { function setSingleActiveWindow(id) { var task; - for (var i = 0; i < filteredWindowModel.count; ++i) { - task = filteredWindowModel.get(i); + for (var i = 0; i < tasksModel.count; ++i) { + task = filterModel.get(i); - if (i == id && task.IsMinimized) { - //plasmoid.nativeInterface.windowModel.requestToggleMinimized(filteredWindowModel.mapRowToSource(i)); - plasmoid.nativeInterface.windowModel.requestActivate(filteredWindowModel.mapRowToSource(i)); + if (i == id) { + tasksModel.requestActivate(tasksModel.index(i, 0)); + currentTaskIndex = id; } else if (i != id && !task.IsMinimized) { - plasmoid.nativeInterface.windowModel.requestToggleMinimized(filteredWindowModel.mapRowToSource(i)); + tasksModel.requestToggleMinimized(tasksModel.index(i, 0)); } } - if (id >= 0) { - plasmoid.nativeInterface.windowModel.requestActivate(filteredWindowModel.mapRowToSource(id)); - currentTaskIndex = id; - } } onOffsetChanged: tasksView.contentY = offset @@ -155,11 +152,13 @@ FullScreenPanel { } } + TaskManager.TasksModel { + id: tasksModel + } + //This proxy is only used for "get" PlasmaCore.SortFilterModel { - id: filteredWindowModel - filterRole: "SkipTaskbar" - filterRegExp: "false" - sourceModel: plasmoid.nativeInterface.windowModel + id: filterModel + sourceModel: TaskManager.TasksModel {} onCountChanged: { if (count == 0) { window.hide(); @@ -167,7 +166,7 @@ FullScreenPanel { } } - model: filteredWindowModel + model: tasksModel header: Item { width: window.width height: window.height diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index ea179bfc2c4faeb5c57ed97b51e72224d1187ba2..bf8dfbedcf9a3499495e50df4966a7aca8eddc45 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -20,6 +20,7 @@ import QtQuick 2.4 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 +import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents @@ -54,7 +55,7 @@ PlasmaCore.ColorScope { startMouseY = oldMouseY = mouse.y; taskSwitcher.offset = -taskSwitcher.height } - onPressed: managePressed(); + onPressed: managePressed(mouse); onPositionChanged: { if (!isDragging && Math.abs(startMouseY - oldMouseY) < root.height) { oldMouseY = mouse.y; diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index 1662f70c3d3e04b6856923e730ebb93fcc56a776..9b2b0bfc5c2ab993ecb02bdbd13d601563e6905d 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -72,8 +72,6 @@ void TaskPanel::initWayland() [this, registry] (quint32 name, quint32 version) { m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); qRegisterMetaType >("QVector"); - m_windowModel = m_windowManagement->createWindowModel(); - emit windowModelChanged(); connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this, [this] (bool showing) { if (showing == m_showingDesktop) { @@ -85,11 +83,6 @@ void TaskPanel::initWayland() ); connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, &TaskPanel::updateActiveWindow); updateActiveWindow(); - - //if a new window is open, show it, not the desktop - connect(m_windowModel, &PlasmaWindowModel::rowsInserted, [this] () { - requestShowingDesktop(false); - }); } ); connect(registry, &Registry::plasmaShellAnnounced, this, @@ -110,11 +103,6 @@ void TaskPanel::initWayland() registry->setup(); } -QAbstractItemModel *TaskPanel::windowModel() const -{ - return m_windowModel; -} - QWindow *TaskPanel::panel() { return m_panel; @@ -184,23 +172,6 @@ void TaskPanel::closeActiveWindow() } } -void TaskPanel::setTaskGeometry(int row, int x, int y, int width, int height) -{ - using namespace KWayland::Client; - if (!m_shellSurface) { - if (!m_shellInterface || !m_panel || !m_panel->isVisible()) { - return; - } - m_surface = Surface::fromWindow(m_panel); - if (!m_surface) { - return; - } - m_shellSurface = m_shellInterface->createSurface(m_surface, this); - } - - m_windowModel->setMinimizedGeometry(row, m_surface, QRect(x, y, width, height)); -} - K_EXPORT_PLASMA_APPLET_WITH_JSON(taskpanel, TaskPanel, "metadata.json") #include "taskpanel.moc" diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h index 0ee5e69a72e1ae0e3b8fd27276004079b6d2b165..911535a70d71eb0e43791506ec761a77555a25cb 100644 --- a/containments/taskpanel/taskpanel.h +++ b/containments/taskpanel/taskpanel.h @@ -41,7 +41,6 @@ class Surface; class TaskPanel : public Plasma::Containment { Q_OBJECT - Q_PROPERTY(QAbstractItemModel* windowModel READ windowModel NOTIFY windowModelChanged) Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged) Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged) Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged) @@ -50,8 +49,6 @@ public: TaskPanel( QObject *parent, const QVariantList &args ); ~TaskPanel(); - QAbstractItemModel *windowModel() const; - QWindow *panel(); void setPanel(QWindow *panel); @@ -64,13 +61,10 @@ public: bool hasCloseableActiveWindow() const; - Q_INVOKABLE void setTaskGeometry(int row, int x, int y, int width, int height); - public Q_SLOTS: void forgetActiveWindow(); Q_SIGNALS: - void windowModelChanged(); void showingDesktopChanged(bool); void hasCloseableActiveWindowChanged(); void panelChanged();