libmobileshell: Move non-API components to declarative and use PW API for keyboard

t
This commit is contained in:
Devin Lin 2022-03-18 22:58:19 -04:00
parent c2474b385e
commit 72f36f1bf6
12 changed files with 24 additions and 70 deletions

View file

@ -10,6 +10,7 @@ import QtQuick.Window 2.15
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
@ -25,7 +26,7 @@ MobileShell.NavigationPanel {
if (root.taskSwitcher.visible) {
return Qt.rgba(0, 0, 0, 0.1);
} else {
return (MobileShell.KWinVirtualKeyboard.visible || appIsShown) ? PlasmaCore.ColorScope.backgroundColor : "transparent";
return (Keyboards.KWinVirtualKeyboard.visible || appIsShown) ? PlasmaCore.ColorScope.backgroundColor : "transparent";
}
}
foregroundColorGroup: (!root.taskSwitcher.visible && appIsShown) ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
@ -81,15 +82,15 @@ MobileShell.NavigationPanel {
rightAction: MobileShell.NavigationPanelAction {
id: closeAppAction
enabled: MobileShell.KWinVirtualKeyboard.visible || root.taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow
iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
enabled: Keyboards.KWinVirtualKeyboard.visible || root.taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow
iconSource: Keyboards.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
// mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons
iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75
iconSizeFactor: Keyboards.KWinVirtualKeyboard.visible ? 1 : 0.75
onTriggered: {
if (MobileShell.KWinVirtualKeyboard.active) {
if (Keyboards.KWinVirtualKeyboard.active) {
// close keyboard if it is open
MobileShell.KWinVirtualKeyboard.active = false;
Keyboards.KWinVirtualKeyboard.active = false;
} else if (taskSwitcher.visible) {
// if task switcher is open, close the current window shown
let indexToClose = root.taskSwitcher.tasksModel.index(root.taskSwitcher.currentTaskIndex, 0);

View file

@ -7,20 +7,13 @@ if (BUILD_TESTING)
add_subdirectory(autotests)
endif()
qt_add_dbus_interfaces(DBUS_SRCS ${KWIN_VIRTUALKEYBOARD_INTERFACE})
set(mobileshell_LIB_SRCS
displaysmodel.cpp
mobileshellsettings.cpp
shellutil.cpp
kwinvirtualkeyboardinterface.cpp
quicksetting.cpp
quicksettingsmodel.cpp
savedquicksettingsmodel.cpp
savedquicksettings.cpp
${DBUS_SRCS}
)
add_library(mobileshell ${mobileshell_LIB_SRCS})
@ -57,10 +50,7 @@ set_target_properties(mobileshell PROPERTIES
install(TARGETS mobileshell EXPORT mobileshellLibraryTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} )
install(FILES
displaysmodel.h
kwinvirtualkeyboardinterface.h
mobileshellsettings.h
shellutil.h
quicksetting.h
quicksettingsmodel.h

View file

@ -6,8 +6,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
set(mobileshellplugin_SRCS
mobileshellplugin.cpp
shellutil.cpp
notifications/notificationthumbnailer.cpp
notifications/notificationfilemenu.cpp
taskswitcher/displaysmodel.cpp
)
if(QUICK_COMPILER)

View file

@ -12,12 +12,11 @@
#include "notifications/notificationfilemenu.h"
#include "notifications/notificationthumbnailer.h"
#include "displaysmodel.h"
#include "kwinvirtualkeyboardinterface.h"
#include "mobileshellsettings.h"
#include "quicksetting.h"
#include "quicksettingsmodel.h"
#include "shellutil.h"
#include "taskswitcher/displaysmodel.h"
using namespace MobileShell;
@ -44,9 +43,6 @@ void MobileShellPlugin::registerTypes(const char *uri)
qmlRegisterType<SavedQuickSettingsModel>(uri, 1, 0, "SavedQuickSettingsModel");
qmlRegisterType<DisplaysModel>(uri, 1, 0, "DisplaysModel");
qmlRegisterSingletonType<KwinVirtualKeyboardInterface>(uri, 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * {
return new KwinVirtualKeyboardInterface;
});
// notifications
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");

View file

@ -1,14 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 Aleix Pol <apol@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwinvirtualkeyboardinterface.h"
using namespace MobileShell;
KwinVirtualKeyboardInterface::KwinVirtualKeyboardInterface()
: OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus())
{
}

View file

@ -1,30 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 Aleix Pol <apol@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QDBusConnection>
#include <QObject>
#include <QString>
#include <virtualkeyboardinterface.h>
#include "mobileshell_export.h"
namespace MobileShell
{
class MOBILESHELL_EXPORT 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)
Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
public:
KwinVirtualKeyboardInterface();
};
} // namespace MobileShell

View file

@ -19,7 +19,12 @@
namespace MobileShell
{
/**
* @short A model that reads quick settings configurations
* from the config and presents models to display them.
*
* @author Devin Lin <devin@kde.org>
**/
class MOBILESHELL_EXPORT SavedQuickSettings : public QObject
{
Q_OBJECT

View file

@ -16,7 +16,11 @@
namespace MobileShell
{
/**
* @short A list model for serving quick settings metadata.
*
* @author Devin Lin <devin@kde.org>
**/
class MOBILESHELL_EXPORT SavedQuickSettingsModel : public QAbstractListModel
{
Q_OBJECT
@ -25,9 +29,9 @@ public:
SavedQuickSettingsModel(QObject *parent = nullptr);
enum {
NameRole,
IdRole,
IconRole,
NameRole, /**< The name of the quick setting. */
IdRole, /**< The plugin id of the quick setting package. */
IconRole, /**< The icon of the quick setting. */
};
QVariant data(const QModelIndex &index, int role) const override;