From 31fceb18f8106473e93468c824c365bee7301725 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 24 Feb 2021 02:05:41 +0100 Subject: [PATCH] Prioritise hiding the virtual keyboard Now that the virtual keyboard appears right over the panel, change the close window button to a hide button. When the virtual keyboard is hidden, now you get the big X to close. --- CMakeLists.txt | 1 + containments/taskpanel/CMakeLists.txt | 6 ++---- .../taskpanel/package/contents/ui/main.qml | 10 +++++++--- containments/taskpanel/taskpanel.cpp | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b3cff21..9ad8d5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications Wayland ) +find_package(KWinDBusInterface) include(CheckIncludeFiles) diff --git a/containments/taskpanel/CMakeLists.txt b/containments/taskpanel/CMakeLists.txt index c8a7d90a..0c407b6c 100644 --- a/containments/taskpanel/CMakeLists.txt +++ b/containments/taskpanel/CMakeLists.txt @@ -1,8 +1,6 @@ -set(taskpanel_SRCS - taskpanel.cpp -) +qt5_add_dbus_interfaces(DBUS_SRCS ${KWIN_VIRTUALKEYBOARD_INTERFACE}) -add_library(plasma_containment_phone_taskpanel MODULE ${taskpanel_SRCS}) +add_library(plasma_containment_phone_taskpanel MODULE taskpanel.cpp ${DBUS_SRCS}) kcoreaddons_desktop_to_json(plasma_containment_phone_taskpanel package/metadata.desktop) diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index a44e10a2..230ff06b 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -16,8 +16,8 @@ import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.nanoshell 2.0 as NanoShell - import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.phone.taskpanel 1.0 as TaskPanel PlasmaCore.ColorScope { id: root @@ -266,9 +266,13 @@ PlasmaCore.ColorScope { height: parent.height width: parent.width*0.8/3 mouseArea: mainMouseArea - enabled: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible + enabled: TaskPanel.KWinVirtualKeyboard.active || (plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible) onClicked: { if (!enabled) { + return + } + if (TaskPanel.KWinVirtualKeyboard.active) { + TaskPanel.KWinVirtualKeyboard.active = false return; } if (!plasmoid.nativeInterface.hasCloseableActiveWindow) { @@ -286,7 +290,7 @@ PlasmaCore.ColorScope { implicitWidth: implicitHeight opacity: parent.enabled ? 1 : 0.5 svg: panelSvg - elementId: "mobile-close-app" + elementId: TaskPanel.KWinVirtualKeyboard.active ? "go-down" : "mobile-close-app" Behavior on opacity { NumberAnimation { duration: units.shortDuration } diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index e3c17698..feef3e16 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -12,7 +12,6 @@ #include #include - #include #include #include @@ -20,9 +19,23 @@ #include #include +#include + static const QString s_kwinService = QStringLiteral("org.kde.KWin"); constexpr int ACTIVE_WINDOW_UPDATE_INVERVAL = 250; +// helper class to expose the NOTIFY in the properties +class KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface +{ + Q_OBJECT + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) +public: + KwinVirtualKeyboardInterface() : + OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) + {} +}; + TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) , m_showingDesktop(false) @@ -34,6 +47,10 @@ TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) m_activeTimer->setInterval(ACTIVE_WINDOW_UPDATE_INVERVAL); connect(m_activeTimer, &QTimer::timeout, this, &TaskPanel::updateActiveWindow); initWayland(); + + qmlRegisterSingletonType("org.kde.plasma.phone.taskpanel", 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * { + return new KwinVirtualKeyboardInterface; + }); } TaskPanel::~TaskPanel() = default;