components/mobileshell: Use qrc and qtquickcompiler to improve load times

Also enables us to check for QML syntax errors and compile time.
This commit is contained in:
Devin Lin 2022-03-05 13:52:03 -05:00
parent ad3a2b2fb1
commit e1d1f8ee1a
5 changed files with 149 additions and 43 deletions

View file

@ -25,6 +25,8 @@ include(ECMInstallIcons)
include(ECMSetupVersion) include(ECMSetupVersion)
include(ECMMarkNonGuiExecutable) include(ECMMarkNonGuiExecutable)
include(ECMGenerateHeaders) include(ECMGenerateHeaders)
include(ECMQMLModules)
include(ECMGenerateQmlTypes)
include(GenerateExportHeader) include(GenerateExportHeader)
include(KDEGitCommitHooks) include(KDEGitCommitHooks)
include(KDEClangFormat) include(KDEClangFormat)
@ -36,6 +38,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED
Core Core
Qml Qml
Quick Quick
QuickCompiler
) )
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS

View file

@ -19,7 +19,9 @@ set(mobileshellplugin_SRCS
${DBUS_SRCS} ${DBUS_SRCS}
) )
add_library(mobileshellplugin ${mobileshellplugin_SRCS}) qtquick_compiler_add_resources(RESOURCES resources.qrc)
add_library(mobileshellplugin ${mobileshellplugin_SRCS} ${RESOURCES})
target_link_libraries(mobileshellplugin target_link_libraries(mobileshellplugin
PUBLIC PUBLIC
@ -41,6 +43,8 @@ target_link_libraries(mobileshellplugin
KF5::Service KF5::Service
) )
install(TARGETS mobileshellplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) # we compiled the qml files, just install qmldir
install(FILES qml/qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell)
install(DIRECTORY qml/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) ecm_generate_qmltypes(org.kde.plasma.private.mobileshell 1.0 DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell)
install(TARGETS mobileshellplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell)

View file

@ -18,6 +18,11 @@
#include "virtualkeyboardinterface.h" #include "virtualkeyboardinterface.h"
#include "vkbdinterface.h" #include "vkbdinterface.h"
QUrl resolvePath(std::string str)
{
return QUrl("qrc:/org/kde/plasma/private/mobileshell/qml/" + QString::fromStdString(str));
}
void MobileShellPlugin::registerTypes(const char *uri) void MobileShellPlugin::registerTypes(const char *uri)
{ {
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell")); Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell"));
@ -41,4 +46,46 @@ void MobileShellPlugin::registerTypes(const char *uri)
// notifications // notifications
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer"); qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");
qmlRegisterType<NotificationFileMenu>(uri, 1, 0, "NotificationFileMenu"); qmlRegisterType<NotificationFileMenu>(uri, 1, 0, "NotificationFileMenu");
// qml modules
// /actiondrawer
qmlRegisterType(resolvePath("actiondrawer/ActionDrawer.qml"), uri, 1, 0, "ActionDrawer");
qmlRegisterType(resolvePath("actiondrawer/ActionDrawerOpenSurface.qml"), uri, 1, 0, "ActionDrawerOpenSurface");
// /components
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/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
// /dataproviders
qmlRegisterSingletonType(resolvePath("dataproviders/BatteryProvider.qml"), uri, 1, 0, "BatteryProvider");
qmlRegisterSingletonType(resolvePath("dataproviders/BluetoothProvider.qml"), uri, 1, 0, "BluetoothProvider");
qmlRegisterSingletonType(resolvePath("dataproviders/SignalStrengthProvider.qml"), uri, 1, 0, "SignalStrengthProvider");
qmlRegisterSingletonType(resolvePath("dataproviders/VolumeProvider.qml"), uri, 1, 0, "VolumeProvider");
qmlRegisterSingletonType(resolvePath("dataproviders/WifiProvider.qml"), uri, 1, 0, "WifiProvider");
// /navigationpanel
qmlRegisterType(resolvePath("navigationpanel/NavigationGestureArea.qml"), uri, 1, 0, "NavigationGestureArea");
qmlRegisterType(resolvePath("navigationpanel/NavigationPanel.qml"), uri, 1, 0, "NavigationPanel");
qmlRegisterType(resolvePath("navigationpanel/NavigationPanelAction.qml"), uri, 1, 0, "NavigationPanelAction");
// /statusbar
qmlRegisterType(resolvePath("statusbar/StatusBar.qml"), uri, 1, 0, "StatusBar");
// /taskswitcher
qmlRegisterType(resolvePath("taskswitcher/TaskSwitcher.qml"), uri, 1, 0, "TaskSwitcher");
// /widgets
qmlRegisterType(resolvePath("widgets/krunner/KRunnerWidget.qml"), uri, 1, 0, "KRunnerWidget");
qmlRegisterType(resolvePath("widgets/mediacontrols/MediaControlsWidget.qml"), uri, 1, 0, "MediaControlsWidget");
qmlRegisterType(resolvePath("widgets/notifications/NotificationsWidget.qml"), uri, 1, 0, "NotificationsWidget");
qmlRegisterType(resolvePath("widgets/notifications/NotificationsModelType.qml"), uri, 1, 0, "NotificationsModelType");
// /
qmlRegisterSingletonType(resolvePath("HomeScreenControls.qml"), uri, 1, 0, "HomeScreenControls");
qmlRegisterSingletonType(resolvePath("Shell.qml"), uri, 1, 0, "Shell");
qmlRegisterSingletonType(resolvePath("TaskPanelControls.qml"), uri, 1, 0, "TaskPanelControls");
qmlRegisterSingletonType(resolvePath("TopPanelControls.qml"), uri, 1, 0, "TopPanelControls");
} }

View file

@ -1,46 +1,7 @@
# SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org> # SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
module org.kde.plasma.private.mobileshell module org.kde.plasma.private.mobileshell
plugin mobileshellplugin plugin mobileshellplugin
# /actiondrawer
ActionDrawer 1.0 actiondrawer/ActionDrawer.qml
ActionDrawerOpenSurface 1.0 actiondrawer/ActionDrawerOpenSurface.qml
# /components
BaseItem 1.0 components/BaseItem.qml
Direction 1.0 components/Direction.qml
StartupFeedback 1.0 components/StartupFeedback.qml
VelocityCalculator 1.0 components/VelocityCalculator.qml
# /dataproviders
singleton BatteryProvider 1.0 dataproviders/BatteryProvider.qml
singleton BluetoothProvider 1.0 dataproviders/BluetoothProvider.qml
singleton SignalStrengthProvider 1.0 dataproviders/SignalStrengthProvider.qml
singleton VolumeProvider 1.0 dataproviders/VolumeProvider.qml
singleton WifiProvider 1.0 dataproviders/WifiProvider.qml
# /navigationpanel
NavigationGestureArea 1.0 navigationpanel/NavigationGestureArea.qml
NavigationPanel 1.0 navigationpanel/NavigationPanel.qml
NavigationPanelAction 1.0 navigationpanel/NavigationPanelAction.qml
# /statusbar
StatusBar 1.0 statusbar/StatusBar.qml
# /taskswitcher
TaskSwitcher 1.0 taskswitcher/TaskSwitcher.qml
# /widgets
KRunnerWidget 1.0 widgets/krunner/KRunnerWidget.qml
MediaControlsWidget 1.0 widgets/mediacontrols/MediaControlsWidget.qml
NotificationsWidget 1.0 widgets/notifications/NotificationsWidget.qml
NotificationsModelType 1.0 widgets/notifications/NotificationsModelType.qml
# /
singleton HomeScreenControls 1.0 HomeScreenControls.qml
singleton Shell 1.0 Shell.qml
singleton TaskPanelControls 1.0 TaskPanelControls.qml
singleton TopPanelControls 1.0 TopPanelControls.qml

View file

@ -0,0 +1,91 @@
<!--
- Copyright 2022 Devin Lin <devin@kde.org>
- SPDX-License-Identifier: GPL-2.0-or-later
-->
<RCC>
<qresource prefix="/org/kde/plasma/private/mobileshell/">
<file>qml/actiondrawer/quicksettings/BrightnessItem.qml</file>
<file>qml/actiondrawer/quicksettings/Handle.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettings.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml</file>
<file>qml/actiondrawer/quicksettings/QuickSettingsPanel.qml</file>
<file>qml/actiondrawer/quicksettings/SettingsModel.qml</file>
<file>qml/actiondrawer/ActionDrawer.qml</file>
<file>qml/actiondrawer/ActionDrawerOpenSurface.qml</file>
<file>qml/actiondrawer/LandscapeContentContainer.qml</file>
<file>qml/actiondrawer/PortraitContentContainer.qml</file>
<file>qml/components/BaseItem.qml</file>
<file>qml/components/Direction.qml</file>
<file>qml/components/StartupFeedback.qml</file>
<file>qml/components/util.js</file>
<file>qml/components/VelocityCalculator.qml</file>
<file>qml/dataproviders/BatteryProvider.qml</file>
<file>qml/dataproviders/BluetoothProvider.qml</file>
<file>qml/dataproviders/SignalStrengthProvider.qml</file>
<file>qml/dataproviders/VolumeProvider.qml</file>
<file>qml/dataproviders/WifiProvider.qml</file>
<file>qml/navigationpanel/NavigationGestureArea.qml</file>
<file>qml/navigationpanel/NavigationPanel.qml</file>
<file>qml/navigationpanel/NavigationPanelAction.qml</file>
<file>qml/navigationpanel/NavigationPanelButton.qml</file>
<file>qml/osd/volume/AudioApplet.qml</file>
<file>qml/osd/volume/DeviceListItem.qml</file>
<file>qml/osd/volume/icon.js</file>
<file>qml/osd/volume/ListItemBase.qml</file>
<file>qml/osd/volume/PopupCard.qml</file>
<file>qml/osd/volume/StreamListItem.qml</file>
<file>qml/osd/volume/VolumeOSD.qml</file>
<file>qml/statusbar/indicators/BatteryIndicator.qml</file>
<file>qml/statusbar/indicators/BluetoothIndicator.qml</file>
<file>qml/statusbar/indicators/SignalStrengthIndicator.qml</file>
<file>qml/statusbar/indicators/VolumeIndicator.qml</file>
<file>qml/statusbar/indicators/WifiIndicator.qml</file>
<file>qml/statusbar/ClockText.qml</file>
<file>qml/statusbar/StatusBar.qml</file>
<file>qml/statusbar/TaskWidget.qml</file>
<file>qml/taskswitcher/FlickContainer.qml</file>
<file>qml/taskswitcher/Task.qml</file>
<file>qml/taskswitcher/TaskIcon.qml</file>
<file>qml/taskswitcher/TaskList.qml</file>
<file>qml/taskswitcher/TaskSwitcher.qml</file>
<file>qml/taskswitcher/TaskSwitcherState.qml</file>
<file>qml/taskswitcher/Thumbnail.qml</file>
<file>qml/widgets/krunner/KRunnerWidget.qml</file>
<file>qml/widgets/mediacontrols/BlurredBackground.qml</file>
<file>qml/widgets/mediacontrols/MediaControlsSource.qml</file>
<file>qml/widgets/mediacontrols/MediaControlsWidget.qml</file>
<file>qml/widgets/notifications/BaseNotificationItem.qml</file>
<file>qml/widgets/notifications/NotificationBodyLabel.qml</file>
<file>qml/widgets/notifications/NotificationCard.qml</file>
<file>qml/widgets/notifications/NotificationFooterActions.qml</file>
<file>qml/widgets/notifications/NotificationGroupHeader.qml</file>
<file>qml/widgets/notifications/NotificationItem.qml</file>
<file>qml/widgets/notifications/NotificationReplyField.qml</file>
<file>qml/widgets/notifications/NotificationsModelType.qml</file>
<file>qml/widgets/notifications/NotificationsWidget.qml</file>
<file>qml/widgets/notifications/NotificationTimeText.qml</file>
<file>qml/widgets/notifications/ThumbnailStrip.qml</file>
<file>qml/widgets/notifications/util.js</file>
<file>qml/HomeScreenControls.qml</file>
<file>qml/Shell.qml</file>
<file>qml/TaskPanelControls.qml</file>
<file>qml/TopPanelControls.qml</file>
</qresource>
</RCC>