From 2e6b9bfb7e0dcbc9c6b616c1af76e9241f3376b4 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 13 Nov 2023 22:37:08 -0800 Subject: [PATCH] taskpanel: Remove unused code --- containments/taskpanel/CMakeLists.txt | 5 -- containments/taskpanel/taskpanel.cpp | 103 +------------------------- containments/taskpanel/taskpanel.h | 42 +---------- 3 files changed, 2 insertions(+), 148 deletions(-) diff --git a/containments/taskpanel/CMakeLists.txt b/containments/taskpanel/CMakeLists.txt index bf280455..89cee8be 100644 --- a/containments/taskpanel/CMakeLists.txt +++ b/containments/taskpanel/CMakeLists.txt @@ -3,8 +3,6 @@ # SPDX-FileCopyrightText: 2021 Nicolas Fella # SPDX-License-Identifier: GPL-2.0-or-later -qt_add_dbus_interfaces(DBUS_SRCS ${KWIN_VIRTUALKEYBOARD_INTERFACE}) - add_library(org.kde.plasma.mobile.taskpanel MODULE taskpanel.cpp ${DBUS_SRCS}) target_link_libraries(org.kde.plasma.mobile.taskpanel @@ -13,9 +11,6 @@ target_link_libraries(org.kde.plasma.mobile.taskpanel Qt::Qml Qt::Quick KF6::Plasma - KF6::I18n - KF6::Service - KF6::WaylandClient ) diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index 5634412f..2957d17a 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -6,119 +6,18 @@ #include "taskpanel.h" +#include #include #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include - -#include - // register type for Keyboards.KWinVirtualKeyboard.forceActivate(); Q_DECLARE_METATYPE(QDBusPendingReply<>) TaskPanel::TaskPanel(QObject *parent, const KPluginMetaData &data, const QVariantList &args) : Plasma::Containment(parent, data, args) { - setHasConfigurationInterface(true); - initWayland(); - - qmlRegisterUncreatableType("org.kde.plasma.mobile.taskpanel", 1, 0, "Output", "nope"); - - // register type for Keyboards.KWinVirtualKeyboard.forceActivate(); - qRegisterMetaType>(); - - connect(this, &Plasma::Containment::locationChanged, this, &TaskPanel::locationChanged); - connect(this, &Plasma::Containment::locationChanged, this, [this] { - auto l = location(); - setFormFactor(l == Plasma::Types::LeftEdge || l == Plasma::Types::RightEdge ? Plasma::Types::Vertical : Plasma::Types::Horizontal); - }); -} - -void TaskPanel::initWayland() -{ - 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::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) { - m_shellInterface = registry->createPlasmaShell(name, version, this); - - if (!m_panel) { - return; - } - Surface *s = Surface::fromWindow(m_panel); - if (!s) { - return; - } - m_shellSurface = m_shellInterface->createSurface(s, this); - m_shellSurface->setSkipTaskbar(true); - }); - registry->setup(); - connection->roundtrip(); -} - -QWindow *TaskPanel::panel() -{ - return m_panel; -} - -void TaskPanel::setPanel(QWindow *panel) -{ - if (panel == m_panel) { - return; - } - - if (m_panel) { - disconnect(m_panel, &QWindow::visibilityChanged, this, &TaskPanel::updatePanelVisibility); - } - m_panel = panel; - connect(m_panel, &QWindow::visibilityChanged, this, &TaskPanel::updatePanelVisibility, Qt::QueuedConnection); - Q_EMIT panelChanged(); - updatePanelVisibility(); -} - -void TaskPanel::setPanelHeight(qreal height) -{ - if (m_panel) { - m_panel->setHeight(height); - } -} - -void TaskPanel::updatePanelVisibility() -{ - using namespace KWayland::Client; - if (!m_panel->isVisible()) { - return; - } - - Surface *s = Surface::fromWindow(m_panel); - - if (!s) { - return; - } - - m_shellSurface = m_shellInterface->createSurface(s, this); - if (m_shellSurface) { - m_shellSurface->setSkipTaskbar(true); - } } void TaskPanel::triggerTaskSwitcher() const diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h index 5ce59ff1..4135531f 100644 --- a/containments/taskpanel/taskpanel.h +++ b/containments/taskpanel/taskpanel.h @@ -4,56 +4,16 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef TASKPANEL_H -#define TASKPANEL_H +#pragma once #include -#include - -class OutputsModel; -class QAbstractItemModel; - -namespace KWayland -{ -namespace Client -{ -class Output; -class PlasmaWindowManagement; -class PlasmaWindow; -class PlasmaShell; -class PlasmaShellSurface; -class Surface; -} -} class TaskPanel : public Plasma::Containment { Q_OBJECT - Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged) public: TaskPanel(QObject *parent, const KPluginMetaData &data, const QVariantList &args); - QWindow *panel(); - void setPanel(QWindow *panel); - - Q_INVOKABLE void setPanelHeight(qreal height); - - QAbstractItemModel *outputs() const; - Q_INVOKABLE void triggerTaskSwitcher() const; - -Q_SIGNALS: - void panelChanged(); - void locationChanged(); - -private: - void initWayland(); - void updatePanelVisibility(); - QWindow *m_panel = nullptr; - KWayland::Client::PlasmaShellSurface *m_shellSurface = nullptr; - KWayland::Client::Surface *m_surface = nullptr; - KWayland::Client::PlasmaShell *m_shellInterface = nullptr; }; - -#endif