From 76b3c4ec4da34893e0f0ab42b454f22e05299723 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 18 Mar 2023 19:29:43 -0700 Subject: [PATCH] mobileshell: Remove unused displaysmodel --- components/mobileshell/CMakeLists.txt | 1 - components/mobileshell/mobileshellplugin.cpp | 5 - .../taskswitcher/displaysmodel.cpp | 99 ------------------- .../mobileshell/taskswitcher/displaysmodel.h | 44 --------- 4 files changed, 149 deletions(-) delete mode 100644 components/mobileshell/taskswitcher/displaysmodel.cpp delete mode 100644 components/mobileshell/taskswitcher/displaysmodel.h diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index 5360ba39..cba025ae 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -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}) diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index d70b7233..a6e9f962 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -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(uri, 1, 0, "NotificationThumbnailer"); qmlRegisterType(uri, 1, 0, "NotificationFileMenu"); - // taskswitcher - qmlRegisterType(uri, 1, 0, "DisplaysModel"); - // qml modules // /actiondrawer diff --git a/components/mobileshell/taskswitcher/displaysmodel.cpp b/components/mobileshell/taskswitcher/displaysmodel.cpp deleted file mode 100644 index 223f089a..00000000 --- a/components/mobileshell/taskswitcher/displaysmodel.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Aleix Pol - * SPDX-FileCopyrightText: 2021 Devin Lin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "displaysmodel.h" - -#include - -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 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(o); - } - return {}; -} diff --git a/components/mobileshell/taskswitcher/displaysmodel.h b/components/mobileshell/taskswitcher/displaysmodel.h deleted file mode 100644 index ea8f1bad..00000000 --- a/components/mobileshell/taskswitcher/displaysmodel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Aleix Pol - * SPDX-FileCopyrightText: 2021 Devin Lin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include - -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 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 m_outputs; -};