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) {
// Do not use APPLICATION_NAME here.
// The EXECUTABLE_NAME will be used in qt standard paths. It's our goal.
QThread::currentThread()->setPriority(QThread::HighPriority);
QCoreApplication::setApplicationName(EXECUTABLE_NAME);
QApplication::setOrganizationDomain(EXECUTABLE_NAME);
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
// independant from current application Window
QScreen *screen = allScreens[i];
// 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()}});
auto engine = App::getInstance()->mEngine;
const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename);
QObject::connect(
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) {
lCritical() << "[App] Notifier.qml couldn't be load.";
engine->deleteLater();
@ -175,6 +166,9 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
lDebug() << engine->rootObjects()[0];
auto window = qobject_cast<QQuickWindow *>(obj);
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
QRect availableGeometry = screen->availableGeometry();
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);
}
}

View file

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

View file

@ -40,21 +40,21 @@ import Qt.labs.platform
*/
// ---------------------------------------------------------------------------
objectName: '__internalWindow'
property bool isFrameLess : false;
property bool showAsTool : false
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure to have the Window on Top and fullscreen independant
flags: Qt.BypassWindowManagerHint | (showAsTool?Qt.Tool:Qt.WindowStaysOnTopHint) | Qt.Window | Qt.FramelessWindowHint;
opacity: 1.0
height: _content[0] != null ? _content[0].height : 0
width: _content[0] != null ? _content[0].width : 0
visible:true
Item {
objectName: '__internalWindow'
property bool isFrameLess : false;
property bool showAsTool : false
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure to have the Window on Top and fullscreen independant
flags: Qt.BypassWindowManagerHint | (showAsTool?Qt.Tool:Qt.WindowStaysOnTopHint) | Qt.Window | Qt.FramelessWindowHint;
opacity: 1.0
height: _content[0] != null ? _content[0].height : 0
width: _content[0] != null ? _content[0].width : 0
visible:true
Item {
id: content
anchors.fill:parent
property var $parent: mainItem
}
}
// ---------------------------------------------------------------------------
/*

View file

@ -17,6 +17,8 @@ DesktopPopup {
default property alias _content: content.data
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
function deleteNotificationSlot(){
@ -29,42 +31,46 @@ DesktopPopup {
}
deleteNotificationSlot();
}
Rectangle {
id: background
anchors.fill: parent
visible: backgroundLoader.status != Loader.Ready
color: DefaultStyle.grey_0
height: mainItem.overriddenHeight
width: mainItem.overriddenWidth
radius: mainItem.radius
border {
color: DefaultStyle.grey_400
width: 1 * DefaultStyle.dp
}
Item {
id: content
anchors.fill: parent
}
Image {
id: iconSign
anchors {
left: parent.left
top: parent.top
}
Loader{
id: backgroundLoader
asynchronous: true
sourceComponent: Item{
width: mainItem.overriddenWidth
height: mainItem.overriddenHeight
Rectangle {
id: background
anchors.fill: parent
visible: backgroundLoader.status != Loader.Ready
color: DefaultStyle.grey_0
radius: mainItem.radius
border {
color: DefaultStyle.grey_400
width: 1 * DefaultStyle.dp
}
}
MultiEffect {
source: background
anchors.fill: background
shadowEnabled: true
shadowColor: DefaultStyle.grey_1000
shadowOpacity: 0.1
shadowBlur: 0.1
}
}
}
MultiEffect {
source: background
anchors.fill: background
shadowEnabled: true
shadowColor: DefaultStyle.grey_1000
shadowOpacity: 0.1
shadowBlur: 0.1
Item {
id: content
anchors.fill: parent
}
}

View file

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

View file

@ -287,6 +287,7 @@ AbstractWindow {
}
/************************* CONTENT ********************************/
Rectangle {
anchors.fill: parent
color: DefaultStyle.grey_900
@ -533,7 +534,9 @@ AbstractWindow {
}
}
}
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
@ -561,6 +564,8 @@ AbstractWindow {
headerValidateButtonText: qsTr("Ajouter")
}
}
Component {
id: contactsListPanel
Item {
@ -1352,18 +1357,24 @@ AbstractWindow {
}
Component {
id: inCallItem
Item {
property string objectName: "inCallItem"
CallLayout{
anchors.fill: parent
anchors.leftMargin: 20 * DefaultStyle.dp
anchors.rightMargin: (rightPanel.visible ? 0 : 10) * DefaultStyle.dp // Grid and AS have 10 in right margin (so apply -10 here)
anchors.topMargin: 10 * DefaultStyle.dp
call: mainWindow.call
callTerminatedByUser: mainWindow.callTerminatedByUser
Loader{
asynchronous: true
sourceComponent: Item {
property string objectName: "inCallItem"
CallLayout{
anchors.fill: parent
anchors.leftMargin: 20 * DefaultStyle.dp
anchors.rightMargin: (rightPanel.visible ? 0 : 10) * DefaultStyle.dp // Grid and AS have 10 in right margin (so apply -10 here)
anchors.topMargin: 10 * DefaultStyle.dp
call: mainWindow.call
callTerminatedByUser: mainWindow.callTerminatedByUser
}
}
}
}
RowLayout {
id: bottomButtonsLayout
Layout.alignment: Qt.AlignHCenter
@ -1723,6 +1734,8 @@ AbstractWindow {
}
}
}
}
}
}