mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
mobileshell: Remove unused displaysmodel
This commit is contained in:
parent
acb7ae1d96
commit
76b3c4ec4d
4 changed files with 0 additions and 149 deletions
|
|
@ -10,7 +10,6 @@ set(mobileshellplugin_SRCS
|
|||
components/direction.cpp
|
||||
notifications/notificationthumbnailer.cpp
|
||||
notifications/notificationfilemenu.cpp
|
||||
taskswitcher/displaysmodel.cpp
|
||||
)
|
||||
qt_add_resources(RESOURCES resources.qrc)
|
||||
add_library(mobileshellplugin SHARED ${mobileshellplugin_SRCS} ${RESOURCES})
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
#include "notifications/notificationfilemenu.h"
|
||||
#include "notifications/notificationthumbnailer.h"
|
||||
|
||||
#include "taskswitcher/displaysmodel.h"
|
||||
|
||||
#include "shellutil.h"
|
||||
|
||||
QUrl resolvePath(std::string str)
|
||||
|
|
@ -38,9 +36,6 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
|||
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");
|
||||
qmlRegisterType<NotificationFileMenu>(uri, 1, 0, "NotificationFileMenu");
|
||||
|
||||
// taskswitcher
|
||||
qmlRegisterType<DisplaysModel>(uri, 1, 0, "DisplaysModel");
|
||||
|
||||
// qml modules
|
||||
|
||||
// /actiondrawer
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Aleix Pol <apol@kde.org>
|
||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "displaysmodel.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
DisplaysModel::DisplaysModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
|
||||
return;
|
||||
}
|
||||
|
||||
using namespace KWayland::Client;
|
||||
ConnectionThread *connection = ConnectionThread::fromApplication(this);
|
||||
|
||||
if (!connection) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *registry = new Registry(this);
|
||||
registry->create(connection);
|
||||
|
||||
connect(registry, &Registry::outputAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
||||
createOutput(registry->bindOutput(name, version));
|
||||
});
|
||||
connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
||||
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
|
||||
});
|
||||
|
||||
registry->setup();
|
||||
connection->roundtrip();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DisplaysModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{Model, "modelName"},
|
||||
{Geometry, "geometry"},
|
||||
{Position, "position"},
|
||||
{Output, "output"},
|
||||
};
|
||||
}
|
||||
|
||||
void DisplaysModel::createOutput(wl_output *output)
|
||||
{
|
||||
auto newOutput = new KWayland::Client::Output(this);
|
||||
connect(newOutput, &KWayland::Client::Output::removed, this, [this, newOutput] {
|
||||
auto i = m_outputs.indexOf(newOutput);
|
||||
Q_ASSERT(i >= 0);
|
||||
beginRemoveRows({}, i, i);
|
||||
m_outputs.removeAt(i);
|
||||
endRemoveRows();
|
||||
});
|
||||
newOutput->setup(output);
|
||||
beginInsertRows({}, m_outputs.count(), m_outputs.count());
|
||||
m_outputs.append(newOutput);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void DisplaysModel::sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output)
|
||||
{
|
||||
const auto windows = m_windowManagement->windows();
|
||||
for (auto w : windows) {
|
||||
if (w->uuid() == uuid) {
|
||||
w->sendToOutput(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int DisplaysModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : m_outputs.count();
|
||||
}
|
||||
|
||||
QVariant DisplaysModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() >= m_outputs.count()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto o = m_outputs[index.row()];
|
||||
switch (role) {
|
||||
case Model:
|
||||
return o->model();
|
||||
case Geometry:
|
||||
return o->geometry();
|
||||
case Position:
|
||||
return o->globalPosition();
|
||||
case Output:
|
||||
return QVariant::fromValue<QObject *>(o);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Aleix Pol <apol@kde.org>
|
||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QRect>
|
||||
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/output.h>
|
||||
#include <KWayland/Client/plasmashell.h>
|
||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
|
||||
class DisplaysModel : public QAbstractListModel
|
||||
{
|
||||
public:
|
||||
enum Roles {
|
||||
Model = Qt::DisplayRole,
|
||||
Geometry = Qt::UserRole,
|
||||
Position,
|
||||
Output,
|
||||
};
|
||||
|
||||
DisplaysModel(QObject *parent = nullptr);
|
||||
|
||||
void createOutput(wl_output *output);
|
||||
|
||||
Q_INVOKABLE void sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output);
|
||||
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr;
|
||||
|
||||
QVector<KWayland::Client::Output *> m_outputs;
|
||||
};
|
||||
Loading…
Reference in a new issue