Speedup GUI: higher priority, us eonly one qml engine on notifications, make asynchronous effets on notification,

This commit is contained in:
Julien Wadel 2024-10-15 17:27:41 +02:00
parent c1be71191a
commit 5f2cfde69b
7 changed files with 83 additions and 62 deletions

View file

@ -261,7 +261,7 @@ App::App(int &argc, char *argv[])
: SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) { : SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) {
// Do not use APPLICATION_NAME here. // Do not use APPLICATION_NAME here.
// The EXECUTABLE_NAME will be used in qt standard paths. It's our goal. // The EXECUTABLE_NAME will be used in qt standard paths. It's our goal.
QThread::currentThread()->setPriority(QThread::HighPriority);
QCoreApplication::setApplicationName(EXECUTABLE_NAME); QCoreApplication::setApplicationName(EXECUTABLE_NAME);
QApplication::setOrganizationDomain(EXECUTABLE_NAME); QApplication::setOrganizationDomain(EXECUTABLE_NAME);
QCoreApplication::setApplicationVersion(APPLICATION_SEMVER); QCoreApplication::setApplicationVersion(APPLICATION_SEMVER);

View file

@ -153,20 +153,11 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
// Use QQuickView to create a visual root object that is // Use QQuickView to create a visual root object that is
// independant from current application Window // independant from current application Window
QScreen *screen = allScreens[i]; QScreen *screen = allScreens[i];
// auto engine = App::getInstance()->mEngine; auto engine = App::getInstance()->mEngine;
auto engine = new QQmlApplicationEngine();
engine->addImageProvider(ImageProvider::ProviderId, new ImageProvider());
engine->addImageProvider(AvatarProvider::ProviderId, new AvatarProvider());
engine->addImportPath(":/");
// if(showAsTool) window->setProperty("showAsTool",true);
engine->setInitialProperties(data);
// engine->rootContext()->setContextProperty("applicationDirPath",QGuiApplication::applicationDirPath());
// engine->setInitialProperties({{"screenIndex", i}});
//, {"x", screen->geometry().x()}, {"y", screen->geometry().y()}});
const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename); const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename);
QObject::connect( QObject::connect(
engine, &QQmlApplicationEngine::objectCreated, this, engine, &QQmlApplicationEngine::objectCreated, this,
[this, url, screen, engine, type](QObject *obj, const QUrl &objUrl) { [this, url, screen, engine, type, data](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl) { if (!obj && url == objUrl) {
lCritical() << "[App] Notifier.qml couldn't be load."; lCritical() << "[App] Notifier.qml couldn't be load.";
engine->deleteLater(); engine->deleteLater();
@ -175,6 +166,9 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
lDebug() << engine->rootObjects()[0]; lDebug() << engine->rootObjects()[0];
auto window = qobject_cast<QQuickWindow *>(obj); auto window = qobject_cast<QQuickWindow *>(obj);
if (window) { if (window) {
window->setProperty(NotificationPropertyData, data);
// for (auto it = data.begin(); it != data.end(); ++it)
// window->setProperty(it.key().toLatin1(), it.value());
int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization
QRect availableGeometry = screen->availableGeometry(); QRect availableGeometry = screen->availableGeometry();
int heightOffset = int heightOffset =
@ -195,7 +189,8 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
} }
} }
}, },
Qt::QueuedConnection); static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::SingleShotConnection));
lDebug() << log().arg("Engine loading notification");
engine->load(url); engine->load(url);
} }
} }

View file

@ -21,6 +21,7 @@ Control.Button {
property bool shadowEnabled: enabled && (activeFocus || containsMouse) property bool shadowEnabled: enabled && (activeFocus || containsMouse)
property var contentImageColor property var contentImageColor
property alias containsMouse: mouseArea.containsMouse property alias containsMouse: mouseArea.containsMouse
property bool asynchronous: true
hoverEnabled: true hoverEnabled: true
activeFocusOnTab: true activeFocusOnTab: true
// leftPadding: 20 * DefaultStyle.dp // leftPadding: 20 * DefaultStyle.dp
@ -38,7 +39,7 @@ Control.Button {
} }
background: Loader{ background: Loader{
asynchronous: true asynchronous: mainItem.asynchronous
anchors.fill: parent anchors.fill: parent
sourceComponent: sourceComponent:

View file

@ -17,6 +17,8 @@ DesktopPopup {
default property alias _content: content.data default property alias _content: content.data
signal deleteNotification (var notification) signal deleteNotification (var notification)
width: mainItem.overriddenWidth
height: mainItem.overriddenHeight
// Use as an intermediate between signal/slot without propagate the notification var : last signal parameter will be the last notification instance // Use as an intermediate between signal/slot without propagate the notification var : last signal parameter will be the last notification instance
function deleteNotificationSlot(){ function deleteNotificationSlot(){
@ -29,34 +31,32 @@ DesktopPopup {
} }
deleteNotificationSlot(); deleteNotificationSlot();
} }
Rectangle { Rectangle {
id: background anchors.fill: parent
visible: backgroundLoader.status != Loader.Ready
color: DefaultStyle.grey_0 color: DefaultStyle.grey_0
height: mainItem.overriddenHeight
width: mainItem.overriddenWidth
radius: mainItem.radius radius: mainItem.radius
border { border {
color: DefaultStyle.grey_400 color: DefaultStyle.grey_400
width: 1 * DefaultStyle.dp width: 1 * DefaultStyle.dp
} }
}
Item { Loader{
id: content id: backgroundLoader
asynchronous: true
sourceComponent: Item{
width: mainItem.overriddenWidth
height: mainItem.overriddenHeight
Rectangle {
id: background
anchors.fill: parent anchors.fill: parent
} visible: backgroundLoader.status != Loader.Ready
color: DefaultStyle.grey_0
Image { radius: mainItem.radius
id: iconSign border {
color: DefaultStyle.grey_400
anchors { width: 1 * DefaultStyle.dp
left: parent.left
top: parent.top
}
} }
} }
MultiEffect { MultiEffect {
@ -68,3 +68,9 @@ DesktopPopup {
shadowBlur: 0.1 shadowBlur: 0.1
} }
} }
}
Item {
id: content
anchors.fill: parent
}
}

View file

@ -9,6 +9,7 @@ Notification {
radius: 20 * DefaultStyle.dp radius: 20 * DefaultStyle.dp
overriddenWidth: content.implicitWidth//101 * DefaultStyle.dp overriddenWidth: content.implicitWidth//101 * DefaultStyle.dp
overriddenHeight: content.implicitHeight//422 * DefaultStyle.dp overriddenHeight: content.implicitHeight//422 * DefaultStyle.dp
readonly property var call: notificationData && notificationData.call readonly property var call: notificationData && notificationData.call
property var state: call.core.state property var state: call.core.state
property var status: call.core.status property var status: call.core.status
@ -86,6 +87,7 @@ Notification {
color: DefaultStyle.success_500main color: DefaultStyle.success_500main
Layout.preferredWidth: 75 * DefaultStyle.dp Layout.preferredWidth: 75 * DefaultStyle.dp
Layout.preferredHeight: 55 * DefaultStyle.dp Layout.preferredHeight: 55 * DefaultStyle.dp
asynchronous: false
contentItem: EffectImage { contentItem: EffectImage {
colorizationColor: DefaultStyle.grey_0 colorizationColor: DefaultStyle.grey_0
imageSource: AppIcons.phone imageSource: AppIcons.phone
@ -93,6 +95,7 @@ Notification {
imageHeight: 32 * DefaultStyle.dp imageHeight: 32 * DefaultStyle.dp
} }
onClicked: { onClicked: {
console.debug("[NotificationReceivedCall] Accept click")
UtilsCpp.openCallsWindow(mainItem.call) UtilsCpp.openCallsWindow(mainItem.call)
mainItem.call.core.lAccept(false) mainItem.call.core.lAccept(false)
} }
@ -101,6 +104,7 @@ Notification {
color: DefaultStyle.danger_500main color: DefaultStyle.danger_500main
Layout.preferredWidth: 75 * DefaultStyle.dp Layout.preferredWidth: 75 * DefaultStyle.dp
Layout.preferredHeight: 55 * DefaultStyle.dp Layout.preferredHeight: 55 * DefaultStyle.dp
asynchronous: false
contentItem: EffectImage { contentItem: EffectImage {
colorizationColor: DefaultStyle.grey_0 colorizationColor: DefaultStyle.grey_0
imageSource: AppIcons.endCall imageSource: AppIcons.endCall
@ -108,10 +112,12 @@ Notification {
imageHeight: 32 * DefaultStyle.dp imageHeight: 32 * DefaultStyle.dp
} }
onClicked: { onClicked: {
console.debug("[NotificationReceivedCall] Decline click")
mainItem.call.core.lDecline() mainItem.call.core.lDecline()
} }
} }
} }
} }
} }
} }

View file

@ -287,6 +287,7 @@ AbstractWindow {
} }
/************************* CONTENT ********************************/ /************************* CONTENT ********************************/
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: DefaultStyle.grey_900 color: DefaultStyle.grey_900
@ -533,7 +534,9 @@ AbstractWindow {
} }
} }
} }
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@ -561,6 +564,8 @@ AbstractWindow {
headerValidateButtonText: qsTr("Ajouter") headerValidateButtonText: qsTr("Ajouter")
} }
} }
Component { Component {
id: contactsListPanel id: contactsListPanel
Item { Item {
@ -1352,7 +1357,9 @@ AbstractWindow {
} }
Component { Component {
id: inCallItem id: inCallItem
Item { Loader{
asynchronous: true
sourceComponent: Item {
property string objectName: "inCallItem" property string objectName: "inCallItem"
CallLayout{ CallLayout{
anchors.fill: parent anchors.fill: parent
@ -1364,6 +1371,10 @@ AbstractWindow {
} }
} }
} }
}
RowLayout { RowLayout {
id: bottomButtonsLayout id: bottomButtonsLayout
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -1723,6 +1734,8 @@ AbstractWindow {
} }
} }
} }
} }
} }
} }