From e1d1f8ee1a634229436cb54b9a107d1a96330563 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 5 Mar 2022 13:52:03 -0500 Subject: [PATCH] components/mobileshell: Use qrc and qtquickcompiler to improve load times Also enables us to check for QML syntax errors and compile time. --- CMakeLists.txt | 3 + components/mobileshell/CMakeLists.txt | 10 ++- components/mobileshell/mobileshellplugin.cpp | 47 ++++++++++ components/mobileshell/qml/qmldir | 41 +-------- components/mobileshell/resources.qrc | 91 ++++++++++++++++++++ 5 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 components/mobileshell/resources.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index d69cbe54..c706c763 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ include(ECMInstallIcons) include(ECMSetupVersion) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) +include(ECMQMLModules) +include(ECMGenerateQmlTypes) include(GenerateExportHeader) include(KDEGitCommitHooks) include(KDEClangFormat) @@ -36,6 +38,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Qml Quick + QuickCompiler ) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index 5d91f657..9fa5b8de 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -19,7 +19,9 @@ set(mobileshellplugin_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 PUBLIC @@ -41,6 +43,8 @@ target_link_libraries(mobileshellplugin 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) diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 8f81041b..8c3c2ddf 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -18,6 +18,11 @@ #include "virtualkeyboardinterface.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) { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell")); @@ -41,4 +46,46 @@ void MobileShellPlugin::registerTypes(const char *uri) // notifications qmlRegisterType(uri, 1, 0, "NotificationThumbnailer"); qmlRegisterType(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"); } diff --git a/components/mobileshell/qml/qmldir b/components/mobileshell/qml/qmldir index faf58dc4..53c3101e 100644 --- a/components/mobileshell/qml/qmldir +++ b/components/mobileshell/qml/qmldir @@ -1,46 +1,7 @@ -# SPDX-FileCopyrightText: 2021 Devin Lin +# SPDX-FileCopyrightText: 2021-2022 Devin Lin # SPDX-License-Identifier: GPL-2.0-or-later module org.kde.plasma.private.mobileshell 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 diff --git a/components/mobileshell/resources.qrc b/components/mobileshell/resources.qrc new file mode 100644 index 00000000..47700b6a --- /dev/null +++ b/components/mobileshell/resources.qrc @@ -0,0 +1,91 @@ + + + + + qml/actiondrawer/quicksettings/BrightnessItem.qml + qml/actiondrawer/quicksettings/Handle.qml + qml/actiondrawer/quicksettings/QuickSettings.qml + qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml + qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml + qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml + qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml + qml/actiondrawer/quicksettings/QuickSettingsPanel.qml + qml/actiondrawer/quicksettings/SettingsModel.qml + + qml/actiondrawer/ActionDrawer.qml + qml/actiondrawer/ActionDrawerOpenSurface.qml + qml/actiondrawer/LandscapeContentContainer.qml + qml/actiondrawer/PortraitContentContainer.qml + + qml/components/BaseItem.qml + qml/components/Direction.qml + qml/components/StartupFeedback.qml + qml/components/util.js + qml/components/VelocityCalculator.qml + + qml/dataproviders/BatteryProvider.qml + qml/dataproviders/BluetoothProvider.qml + qml/dataproviders/SignalStrengthProvider.qml + qml/dataproviders/VolumeProvider.qml + qml/dataproviders/WifiProvider.qml + + qml/navigationpanel/NavigationGestureArea.qml + qml/navigationpanel/NavigationPanel.qml + qml/navigationpanel/NavigationPanelAction.qml + qml/navigationpanel/NavigationPanelButton.qml + + qml/osd/volume/AudioApplet.qml + qml/osd/volume/DeviceListItem.qml + qml/osd/volume/icon.js + qml/osd/volume/ListItemBase.qml + qml/osd/volume/PopupCard.qml + qml/osd/volume/StreamListItem.qml + qml/osd/volume/VolumeOSD.qml + + qml/statusbar/indicators/BatteryIndicator.qml + qml/statusbar/indicators/BluetoothIndicator.qml + qml/statusbar/indicators/SignalStrengthIndicator.qml + qml/statusbar/indicators/VolumeIndicator.qml + qml/statusbar/indicators/WifiIndicator.qml + + qml/statusbar/ClockText.qml + qml/statusbar/StatusBar.qml + qml/statusbar/TaskWidget.qml + + qml/taskswitcher/FlickContainer.qml + qml/taskswitcher/Task.qml + qml/taskswitcher/TaskIcon.qml + qml/taskswitcher/TaskList.qml + qml/taskswitcher/TaskSwitcher.qml + qml/taskswitcher/TaskSwitcherState.qml + qml/taskswitcher/Thumbnail.qml + + qml/widgets/krunner/KRunnerWidget.qml + + qml/widgets/mediacontrols/BlurredBackground.qml + qml/widgets/mediacontrols/MediaControlsSource.qml + qml/widgets/mediacontrols/MediaControlsWidget.qml + + qml/widgets/notifications/BaseNotificationItem.qml + qml/widgets/notifications/NotificationBodyLabel.qml + qml/widgets/notifications/NotificationCard.qml + qml/widgets/notifications/NotificationFooterActions.qml + qml/widgets/notifications/NotificationGroupHeader.qml + qml/widgets/notifications/NotificationItem.qml + qml/widgets/notifications/NotificationReplyField.qml + qml/widgets/notifications/NotificationsModelType.qml + qml/widgets/notifications/NotificationsWidget.qml + qml/widgets/notifications/NotificationTimeText.qml + qml/widgets/notifications/ThumbnailStrip.qml + qml/widgets/notifications/util.js + + qml/HomeScreenControls.qml + qml/Shell.qml + qml/TaskPanelControls.qml + qml/TopPanelControls.qml + + +