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.
This commit is contained in:
Aleix Pol 2021-02-24 02:05:41 +01:00 committed by Aleix Pol Gonzalez
parent 17001ddef9
commit 31fceb18f8
4 changed files with 28 additions and 8 deletions

View file

@ -37,6 +37,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Notifications
Wayland
)
find_package(KWinDBusInterface)
include(CheckIncludeFiles)

View file

@ -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)

View file

@ -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 }

View file

@ -12,7 +12,6 @@
#include <QQuickWindow>
#include <Plasma/Package>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/plasmawindowmodel.h>
@ -20,9 +19,23 @@
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
#include <virtualkeyboardinterface.h>
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<OrgKdeKwinVirtualKeyboardInterface>("org.kde.plasma.phone.taskpanel", 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * {
return new KwinVirtualKeyboardInterface;
});
}
TaskPanel::~TaskPanel() = default;