Commit 18b4af0d authored by Marco Martin's avatar Marco Martin

port to new libtaskmanager

almost entirely port the task switcher to the new
libtaskmanager. still needs porting
for the single close current window button
parent b18580da
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -72,8 +72,6 @@ void TaskPanel::initWayland()
[this, registry] (quint32 name, quint32 version) {
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
qRegisterMetaType<QVector<int> >("QVector<int>");
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"
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment