mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 10:44:46 +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 {
|
ScriptAction {
|
||||||
script: {
|
script: {
|
||||||
if (background.x != 0) {
|
if (background.x != 0) {
|
||||||
window.executeJob("close", model.Id);
|
plasmoid.nativeInterface.windowModel.requestClose(model.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ Item {
|
||||||
onPressed: delegate.z = 10;
|
onPressed: delegate.z = 10;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
window.hide();
|
window.hide();
|
||||||
window.executeJob("activate", model.Id);
|
plasmoid.nativeInterface.windowModel.requestActivate(model.index);
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
delegate.z = 0;
|
delegate.z = 0;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Window 2.2
|
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.components 2.0 as PlasmaComponents
|
||||||
import org.kde.plasma.mobilecomponents 0.2
|
import org.kde.plasma.mobilecomponents 0.2
|
||||||
|
|
||||||
|
|
@ -56,19 +56,6 @@ FullScreenPanel {
|
||||||
scrollAnim.running = true;
|
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 {
|
SequentialAnimation {
|
||||||
id: scrollAnim
|
id: scrollAnim
|
||||||
property alias to: internalAnim.to
|
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 {
|
header: Item {
|
||||||
width: window.width
|
width: window.width
|
||||||
height: window.height
|
height: window.height
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||||
|
#include <KWayland/Client/plasmawindowmodel.h>
|
||||||
#include <KWayland/Client/registry.h>
|
#include <KWayland/Client/registry.h>
|
||||||
|
|
||||||
static const QString s_kwinService = QStringLiteral("org.kde.KWin");
|
static const QString s_kwinService = QStringLiteral("org.kde.KWin");
|
||||||
|
|
@ -66,6 +67,9 @@ void TaskPanel::initWayland()
|
||||||
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
|
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
|
||||||
[this, registry] (quint32 name, quint32 version) {
|
[this, registry] (quint32 name, quint32 version) {
|
||||||
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
|
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,
|
connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this,
|
||||||
[this] (bool showing) {
|
[this] (bool showing) {
|
||||||
if (showing == m_showingDesktop) {
|
if (showing == m_showingDesktop) {
|
||||||
|
|
@ -82,6 +86,11 @@ void TaskPanel::initWayland()
|
||||||
registry->setup();
|
registry->setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAbstractItemModel *TaskPanel::windowModel() const
|
||||||
|
{
|
||||||
|
return m_windowModel;
|
||||||
|
}
|
||||||
|
|
||||||
void TaskPanel::updateActiveWindow()
|
void TaskPanel::updateActiveWindow()
|
||||||
{
|
{
|
||||||
if (!m_windowManagement) {
|
if (!m_windowManagement) {
|
||||||
|
|
|
||||||
|
|
@ -21,21 +21,24 @@
|
||||||
#ifndef TASKPANEL_H
|
#ifndef TASKPANEL_H
|
||||||
#define TASKPANEL_H
|
#define TASKPANEL_H
|
||||||
|
|
||||||
|
|
||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
|
|
||||||
|
class QAbstractItemModel;
|
||||||
|
|
||||||
namespace KWayland
|
namespace KWayland
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
{
|
{
|
||||||
class PlasmaWindowManagement;
|
class PlasmaWindowManagement;
|
||||||
class PlasmaWindow;
|
class PlasmaWindow;
|
||||||
|
class PlasmaWindowModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TaskPanel : public Plasma::Containment
|
class TaskPanel : public Plasma::Containment
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QAbstractItemModel* windowModel READ windowModel NOTIFY windowModelChanged)
|
||||||
Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
|
Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
|
||||||
Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged)
|
Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged)
|
||||||
|
|
||||||
|
|
@ -43,6 +46,8 @@ public:
|
||||||
TaskPanel( QObject *parent, const QVariantList &args );
|
TaskPanel( QObject *parent, const QVariantList &args );
|
||||||
~TaskPanel();
|
~TaskPanel();
|
||||||
|
|
||||||
|
QAbstractItemModel *windowModel() const;
|
||||||
|
|
||||||
Q_INVOKABLE void closeActiveWindow();
|
Q_INVOKABLE void closeActiveWindow();
|
||||||
|
|
||||||
bool isShowingDesktop() const {
|
bool isShowingDesktop() const {
|
||||||
|
|
@ -53,6 +58,7 @@ public:
|
||||||
bool hasCloseableActiveWindow() const;
|
bool hasCloseableActiveWindow() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void windowModelChanged();
|
||||||
void showingDesktopChanged(bool);
|
void showingDesktopChanged(bool);
|
||||||
void hasCloseableActiveWindowChanged();
|
void hasCloseableActiveWindowChanged();
|
||||||
|
|
||||||
|
|
@ -61,8 +67,8 @@ private:
|
||||||
void updateActiveWindow();
|
void updateActiveWindow();
|
||||||
bool m_showingDesktop;
|
bool m_showingDesktop;
|
||||||
KWayland::Client::PlasmaWindowManagement *m_windowManagement;
|
KWayland::Client::PlasmaWindowManagement *m_windowManagement;
|
||||||
|
KWayland::Client::PlasmaWindowModel *m_windowModel = nullptr;
|
||||||
KWayland::Client::PlasmaWindow *m_activeWindow = nullptr;
|
KWayland::Client::PlasmaWindow *m_activeWindow = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue