mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
components: Port Direction enum to c++ to improve load times
According to flame graph testing with qmlprofiler, this caused quite some overhead in QML.
This commit is contained in:
parent
2d6d0c6789
commit
2deea1b4d0
7 changed files with 39 additions and 30 deletions
|
|
@ -13,6 +13,7 @@ set(mobileshellplugin_SRCS
|
||||||
savedquicksettingsmodel.cpp
|
savedquicksettingsmodel.cpp
|
||||||
shellutil.cpp
|
shellutil.cpp
|
||||||
windowutil.cpp
|
windowutil.cpp
|
||||||
|
components/direction.cpp
|
||||||
notifications/notificationthumbnailer.cpp
|
notifications/notificationthumbnailer.cpp
|
||||||
notifications/notificationfilemenu.cpp
|
notifications/notificationfilemenu.cpp
|
||||||
homescreen/applicationlistmodel.cpp
|
homescreen/applicationlistmodel.cpp
|
||||||
|
|
|
||||||
7
components/mobileshell/components/direction.cpp
Normal file
7
components/mobileshell/components/direction.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "direction.h"
|
||||||
18
components/mobileshell/components/direction.h
Normal file
18
components/mobileshell/components/direction.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class Direction : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Type { None = 0, Up, Down, Left, Right };
|
||||||
|
Q_ENUM(Type)
|
||||||
|
};
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
#include "components/direction.h"
|
||||||
|
|
||||||
#include "notifications/notificationfilemenu.h"
|
#include "notifications/notificationfilemenu.h"
|
||||||
#include "notifications/notificationthumbnailer.h"
|
#include "notifications/notificationthumbnailer.h"
|
||||||
|
|
||||||
|
|
@ -48,8 +50,8 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
||||||
return WindowUtil::instance();
|
return WindowUtil::instance();
|
||||||
});
|
});
|
||||||
|
|
||||||
// taskswitcher
|
// components
|
||||||
qmlRegisterType<DisplaysModel>(uri, 1, 0, "DisplaysModel");
|
qmlRegisterType<Direction>(uri, 1, 0, "Direction");
|
||||||
|
|
||||||
// homescreen
|
// homescreen
|
||||||
qmlRegisterSingletonType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
qmlRegisterSingletonType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||||
|
|
@ -63,6 +65,9 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
||||||
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");
|
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");
|
||||||
qmlRegisterType<NotificationFileMenu>(uri, 1, 0, "NotificationFileMenu");
|
qmlRegisterType<NotificationFileMenu>(uri, 1, 0, "NotificationFileMenu");
|
||||||
|
|
||||||
|
// taskswitcher
|
||||||
|
qmlRegisterType<DisplaysModel>(uri, 1, 0, "DisplaysModel");
|
||||||
|
|
||||||
// qml modules
|
// qml modules
|
||||||
|
|
||||||
// /actiondrawer
|
// /actiondrawer
|
||||||
|
|
@ -72,7 +77,6 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
||||||
|
|
||||||
// /components
|
// /components
|
||||||
qmlRegisterType(resolvePath("components/BaseItem.qml"), uri, 1, 0, "BaseItem");
|
qmlRegisterType(resolvePath("components/BaseItem.qml"), uri, 1, 0, "BaseItem");
|
||||||
qmlRegisterType(resolvePath("components/Direction.qml"), uri, 1, 0, "Direction");
|
|
||||||
qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
|
qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
|
||||||
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
|
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@ import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
||||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||||
|
|
||||||
import "../components" as Components
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
@ -60,7 +58,7 @@ Item {
|
||||||
/**
|
/**
|
||||||
* Direction the panel is currently moving in.
|
* Direction the panel is currently moving in.
|
||||||
*/
|
*/
|
||||||
property int direction: Components.Direction.None
|
property int direction: MobileShell.Direction.None
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mode of the action drawer (portrait or landscape).
|
* The mode of the action drawer (portrait or landscape).
|
||||||
|
|
@ -111,8 +109,8 @@ Item {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
root.direction = (oldOffset === offset)
|
root.direction = (oldOffset === offset)
|
||||||
? Components.Direction.None
|
? MobileShell.Direction.None
|
||||||
: (offset > oldOffset ? Components.Direction.Down : Components.Direction.Up);
|
: (offset > oldOffset ? MobileShell.Direction.Down : MobileShell.Direction.Up);
|
||||||
|
|
||||||
oldOffset = offset;
|
oldOffset = offset;
|
||||||
|
|
||||||
|
|
@ -152,7 +150,7 @@ Item {
|
||||||
// close immediately, so that we don't have to wait PlasmaCore.Units.longDuration
|
// close immediately, so that we don't have to wait PlasmaCore.Units.longDuration
|
||||||
root.visible = false;
|
root.visible = false;
|
||||||
close();
|
close();
|
||||||
} else if (root.direction === Components.Direction.None || !root.opened) {
|
} else if (root.direction === MobileShell.Direction.None || !root.opened) {
|
||||||
if (root.offset < openThreshold) {
|
if (root.offset < openThreshold) {
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -161,12 +159,12 @@ Item {
|
||||||
} else if (root.offset > contentContainerLoader.maximizedQuickSettingsOffset) {
|
} else if (root.offset > contentContainerLoader.maximizedQuickSettingsOffset) {
|
||||||
expand();
|
expand();
|
||||||
} else if (root.offset > contentContainerLoader.minimizedQuickSettingsOffset) {
|
} else if (root.offset > contentContainerLoader.minimizedQuickSettingsOffset) {
|
||||||
if (root.direction === Components.Direction.Down) {
|
if (root.direction === MobileShell.Direction.Down) {
|
||||||
expand();
|
expand();
|
||||||
} else {
|
} else {
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
} else if (root.direction === Components.Direction.Down) {
|
} else if (root.direction === MobileShell.Direction.Down) {
|
||||||
open();
|
open();
|
||||||
} else {
|
} else {
|
||||||
close();
|
close();
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
enum Type {
|
|
||||||
None = 0,
|
|
||||||
Up,
|
|
||||||
Down,
|
|
||||||
Left,
|
|
||||||
Right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
<file>qml/actiondrawer/PortraitContentContainer.qml</file>
|
<file>qml/actiondrawer/PortraitContentContainer.qml</file>
|
||||||
|
|
||||||
<file>qml/components/BaseItem.qml</file>
|
<file>qml/components/BaseItem.qml</file>
|
||||||
<file>qml/components/Direction.qml</file>
|
|
||||||
<file>qml/components/StartupFeedback.qml</file>
|
<file>qml/components/StartupFeedback.qml</file>
|
||||||
<file>qml/components/util.js</file>
|
<file>qml/components/util.js</file>
|
||||||
<file>qml/components/VelocityCalculator.qml</file>
|
<file>qml/components/VelocityCalculator.qml</file>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue