mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Port to PlasmaWindowModel.
This commit is contained in:
parent
758d3694a1
commit
d5b6503797
4 changed files with 28 additions and 19 deletions
|
|
@ -46,7 +46,7 @@ Item {
|
|||
ScriptAction {
|
||||
script: {
|
||||
if (background.x != 0) {
|
||||
window.executeJob("close", model.Id);
|
||||
plasmoid.nativeInterface.windowModel.requestClose(model.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ Item {
|
|||
onPressed: delegate.z = 10;
|
||||
onClicked: {
|
||||
window.hide();
|
||||
window.executeJob("activate", model.Id);
|
||||
plasmoid.nativeInterface.windowModel.requestActivate(model.index);
|
||||
}
|
||||
onReleased: {
|
||||
delegate.z = 0;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.2
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
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
|
||||
|
||||
|
|
@ -56,19 +56,6 @@ FullScreenPanel {
|
|||
scrollAnim.running = true;
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: tasksSource
|
||||
engine: "tasks"
|
||||
|
||||
connectedSources: "tasks"
|
||||
}
|
||||
function executeJob(operationName, id) {
|
||||
var service = tasksSource.serviceForSource("tasks");
|
||||
var operation = service.operationDescription(operationName);
|
||||
operation.Id = id;
|
||||
service.startOperationCall(operation);
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: scrollAnim
|
||||
property alias to: internalAnim.to
|
||||
|
|
@ -140,7 +127,14 @@ FullScreenPanel {
|
|||
}
|
||||
}
|
||||
|
||||
model: tasksSource.models.tasks
|
||||
PlasmaCore.SortFilterModel {
|
||||
id: filteredWindowModel
|
||||
filterRole: "DisplayRole"
|
||||
filterRegExp: ".+"
|
||||
sourceModel: plasmoid.nativeInterface.windowModel
|
||||
}
|
||||
|
||||
model: filteredWindowModel
|
||||
header: Item {
|
||||
width: window.width
|
||||
height: window.height
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||
#include <KWayland/Client/plasmawindowmodel.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
|
||||
static const QString s_kwinService = QStringLiteral("org.kde.KWin");
|
||||
|
|
@ -66,6 +67,9 @@ void TaskPanel::initWayland()
|
|||
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
|
||||
[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) {
|
||||
|
|
@ -82,6 +86,11 @@ void TaskPanel::initWayland()
|
|||
registry->setup();
|
||||
}
|
||||
|
||||
QAbstractItemModel *TaskPanel::windowModel() const
|
||||
{
|
||||
return m_windowModel;
|
||||
}
|
||||
|
||||
void TaskPanel::updateActiveWindow()
|
||||
{
|
||||
if (!m_windowManagement) {
|
||||
|
|
|
|||
|
|
@ -21,21 +21,24 @@
|
|||
#ifndef TASKPANEL_H
|
||||
#define TASKPANEL_H
|
||||
|
||||
|
||||
#include <Plasma/Containment>
|
||||
|
||||
class QAbstractItemModel;
|
||||
|
||||
namespace KWayland
|
||||
{
|
||||
namespace Client
|
||||
{
|
||||
class PlasmaWindowManagement;
|
||||
class PlasmaWindow;
|
||||
class PlasmaWindowModel;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -43,6 +46,8 @@ public:
|
|||
TaskPanel( QObject *parent, const QVariantList &args );
|
||||
~TaskPanel();
|
||||
|
||||
QAbstractItemModel *windowModel() const;
|
||||
|
||||
Q_INVOKABLE void closeActiveWindow();
|
||||
|
||||
bool isShowingDesktop() const {
|
||||
|
|
@ -53,6 +58,7 @@ public:
|
|||
bool hasCloseableActiveWindow() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void windowModelChanged();
|
||||
void showingDesktopChanged(bool);
|
||||
void hasCloseableActiveWindowChanged();
|
||||
|
||||
|
|
@ -61,8 +67,8 @@ private:
|
|||
void updateActiveWindow();
|
||||
bool m_showingDesktop;
|
||||
KWayland::Client::PlasmaWindowManagement *m_windowManagement;
|
||||
KWayland::Client::PlasmaWindowModel *m_windowModel = nullptr;
|
||||
KWayland::Client::PlasmaWindow *m_activeWindow = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue