From c7cc40c464cd7cf8bfe514c421978e449b555975 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:43:21 +0800 Subject: [PATCH 01/11] Correctly fall back to originalSize if requestedSize not valid in svg image provider Signed-off-by: Claudio Cambra --- src/gui/iconutils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/iconutils.cpp b/src/gui/iconutils.cpp index c25adbc76d00..ba9204e03926 100644 --- a/src/gui/iconutils.cpp +++ b/src/gui/iconutils.cpp @@ -108,9 +108,11 @@ QImage createSvgImageWithCustomColor(const QString &fileName, return {}; } + const auto sizeToUse = requestedSize.isValid() ? requestedSize : *originalSize; + // some icons are present in white or black only, so, we need to check both when needed const auto iconBaseColors = QStringList{QStringLiteral("black"), QStringLiteral("white")}; - const auto customColorImage = findImageWithCustomColor(fileName, customColor, iconBaseColors, requestedSize); + const auto customColorImage = findImageWithCustomColor(fileName, customColor, iconBaseColors, sizeToUse); if (!customColorImage.isNull()) { return customColorImage; @@ -125,7 +127,7 @@ QImage createSvgImageWithCustomColor(const QString &fileName, return {}; } - const auto result = drawSvgWithCustomFillColor(sourceSvg, customColor, originalSize, requestedSize); + const auto result = drawSvgWithCustomFillColor(sourceSvg, customColor, originalSize, sizeToUse); Q_ASSERT(!result.isNull()); if (result.isNull()) { From ed56219da6e5101316af1af73f6a6d28411a92ce Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:46:14 +0800 Subject: [PATCH 02/11] Add non-white talk and more-apps svgs Signed-off-by: Claudio Cambra --- theme.qrc.in | 2 ++ theme/more-apps.svg | 55 +++++++++++++++++++++++++++++++++++++++++++++ theme/talk-app.svg | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 theme/more-apps.svg create mode 100644 theme/talk-app.svg diff --git a/theme.qrc.in b/theme.qrc.in index e8d88fc8a1b0..2405e4335afe 100644 --- a/theme.qrc.in +++ b/theme.qrc.in @@ -238,5 +238,7 @@ theme/delete.svg theme/send.svg theme/call-notification.wav + theme/more-apps.svg + theme/talk-app.svg diff --git a/theme/more-apps.svg b/theme/more-apps.svg new file mode 100644 index 000000000000..6b1fd877350e --- /dev/null +++ b/theme/more-apps.svg @@ -0,0 +1,55 @@ + + diff --git a/theme/talk-app.svg b/theme/talk-app.svg new file mode 100644 index 000000000000..40e01fe81cae --- /dev/null +++ b/theme/talk-app.svg @@ -0,0 +1,40 @@ + + + + + + From 82e2ec0f67ee44de7e91268609b22ede9f70f566 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:48:10 +0800 Subject: [PATCH 03/11] Fix breakages in autosizing menu when item does not have expected internal properties Signed-off-by: Claudio Cambra --- src/gui/tray/AutoSizingMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tray/AutoSizingMenu.qml b/src/gui/tray/AutoSizingMenu.qml index 5be41907c678..1d3134b37306 100644 --- a/src/gui/tray/AutoSizingMenu.qml +++ b/src/gui/tray/AutoSizingMenu.qml @@ -8,7 +8,7 @@ Menu { var padding = 0; for (var i = 0; i < count; ++i) { var item = itemAt(i); - result = Math.max(item.contentItem.implicitWidth, result); + result = Math.max(item.implicitWidth, result); padding = Math.max(item.padding, padding); } return result + padding * 2; From 99cf137b2eedfbe7d0bd61802d49c1840cdc0b83 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:48:28 +0800 Subject: [PATCH 04/11] Remove unneeded qt5compat import in headerbutton Signed-off-by: Claudio Cambra --- src/gui/tray/HeaderButton.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/tray/HeaderButton.qml b/src/gui/tray/HeaderButton.qml index ca46a3e1cfb6..d126c6c4ccdf 100644 --- a/src/gui/tray/HeaderButton.qml +++ b/src/gui/tray/HeaderButton.qml @@ -18,7 +18,6 @@ import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 -import Qt5Compat.GraphicalEffects // Custom qml modules are in /theme (and included by resources.qrc) import Style 1.0 From 3da63f99797b662d061991c355c6a96302077622 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:48:52 +0800 Subject: [PATCH 05/11] Fix vertical center anchor in trayfoldersmenubutton Signed-off-by: Claudio Cambra --- src/gui/tray/TrayFoldersMenuButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tray/TrayFoldersMenuButton.qml b/src/gui/tray/TrayFoldersMenuButton.qml index 546ea447b806..b39a722a0699 100644 --- a/src/gui/tray/TrayFoldersMenuButton.qml +++ b/src/gui/tray/TrayFoldersMenuButton.qml @@ -124,7 +124,7 @@ HeaderButton { width: imageWidth height: imageHeight - anchors.verticalCenter: parent + anchors.verticalCenter: parent.verticalCenter } From 8d025a0d9d9e3ae9b08654f7a73590579fd253a8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:49:11 +0800 Subject: [PATCH 06/11] Fix use of sourceSize in TrayFoldersMenuButton Signed-off-by: Claudio Cambra --- src/gui/tray/TrayFoldersMenuButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tray/TrayFoldersMenuButton.qml b/src/gui/tray/TrayFoldersMenuButton.qml index b39a722a0699..00c878dcc0d8 100644 --- a/src/gui/tray/TrayFoldersMenuButton.qml +++ b/src/gui/tray/TrayFoldersMenuButton.qml @@ -146,7 +146,7 @@ HeaderButton { cache: true source: "image://svgimage-custom-color/caret-down.svg/" + Style.currentUserHeaderTextColor - sourceSize: { + sourceSize { width: openLocalFolderButtonCaretIconLoader.imageWidth height: openLocalFolderButtonCaretIconLoader.imageHeight } From 04e1736616da834a4a7b4284ee747ea9e602d24c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:51:07 +0800 Subject: [PATCH 07/11] Ensure svg icons generated by svgimageprovider have a reasonable default size Signed-off-by: Claudio Cambra --- src/gui/tray/svgimageprovider.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/tray/svgimageprovider.cpp b/src/gui/tray/svgimageprovider.cpp index ab57607004ac..b8297b27e6f9 100644 --- a/src/gui/tray/svgimageprovider.cpp +++ b/src/gui/tray/svgimageprovider.cpp @@ -45,6 +45,10 @@ namespace Ui { return {}; } + if (size != nullptr && (size->width() <= 0 || size->height() <= 0)) { + *size = QSize(64, 64); + } + return IconUtils::createSvgImageWithCustomColor(pixmapName, pixmapColor, size, requestedSize); } } From 78ae106ea0fc5866823a174fda732179146773c9 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:51:48 +0800 Subject: [PATCH 08/11] Fix displaying of header buttons in tray window Signed-off-by: Claudio Cambra --- src/gui/tray/HeaderButton.qml | 17 ++++++++++++++++- src/gui/tray/Window.qml | 5 ++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/tray/HeaderButton.qml b/src/gui/tray/HeaderButton.qml index d126c6c4ccdf..3d16aa350961 100644 --- a/src/gui/tray/HeaderButton.qml +++ b/src/gui/tray/HeaderButton.qml @@ -32,7 +32,6 @@ Button { icon.width: Style.headerButtonIconSize icon.height: Style.headerButtonIconSize - icon.color: palette.brightText Layout.alignment: Qt.AlignRight Layout.preferredWidth: Style.trayWindowHeaderHeight @@ -42,4 +41,20 @@ Button { color: root.hovered || root.visualFocus ? Style.currentUserHeaderTextColor : "transparent" opacity: 0.2 } + + contentItem: Item { + anchors.fill: parent + + Image { + id: internalImage + anchors.centerIn: parent + width: root.icon.width + height: root.icon.height + source: root.icon.source + sourceSize { + width: root.icon.width + height: root.icon.height + } + } + } } diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index f14b054f8420..034ca13b532c 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -640,7 +640,7 @@ ApplicationWindow { id: trayWindowTalkButton visible: UserModel.currentUser && UserModel.currentUser.serverHasTalk - icon.source: "qrc:///client/theme/white/talk-app.svg" + icon.source: "image://svgimage-custom-color/talk-app.svg" + "/" + Style.currentUserHeaderTextColor icon.color: Style.currentUserHeaderTextColor onClicked: UserModel.openCurrentAccountTalk() @@ -656,8 +656,7 @@ ApplicationWindow { HeaderButton { id: trayWindowAppsButton - icon.source: "qrc:///client/theme/white/more-apps.svg" - icon.color: Style.currentUserHeaderTextColor + icon.source: "image://svgimage-custom-color/more-apps.svg" + "/" + Style.currentUserHeaderTextColor onClicked: { if(appsMenuListView.count <= 0) { From 4ff0cce787a7ebca81ca87dd24c41c37f9b03b90 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 17:58:21 +0800 Subject: [PATCH 09/11] Fix displaying of more button in UserLine Signed-off-by: Claudio Cambra --- src/gui/tray/UserLine.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 8b5ebcebe19d..a546cf557307 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -141,9 +141,6 @@ AbstractButton { Layout.fillHeight: true flat: true - icon.source: "qrc:///client/theme/more.svg" - icon.color: palette.buttonText - Accessible.role: Accessible.ButtonMenu Accessible.name: qsTr("Account actions") Accessible.onPressAction: userMoreButtonMouseArea.clicked() @@ -155,6 +152,12 @@ AbstractButton { color: userMoreButton.hovered || userMoreButton.visualFocus ? palette.highlight : "transparent" } + contentItem: Image { + anchors.fill: parent + source: "image://svgimage-custom-color/more.svg" + "/" + palette.buttonText + fillMode: Image.PreserveAspectFit + } + AutoSizingMenu { id: userMoreButtonMenu closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape From 4db90b052e2f6e0215373a836bdcdf16474ac376 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 18:14:59 +0800 Subject: [PATCH 10/11] Remove broken and unneeded scroll view in tray user menu Signed-off-by: Claudio Cambra --- src/gui/tray/Window.qml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 034ca13b532c..dd21ccccaf6f 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -312,22 +312,6 @@ ApplicationWindow { radius: Style.currentAccountButtonRadius } - contentItem: ScrollView { - id: accMenuScrollView - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - - data: WheelHandler { - target: accMenuScrollView.contentItem - } - ListView { - implicitHeight: contentHeight - model: accountMenu.contentModel - interactive: true - clip: true - currentIndex: accountMenu.currentIndex - } - } - onClosed: { // HACK: reload account Instantiator immediately by restting it - could be done better I guess // see also onVisibleChanged above From d61a209e532c106712c1853f0c94e43482d3d750 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 6 Jun 2024 22:36:02 +0800 Subject: [PATCH 11/11] Prevent crash when originalSize is null Signed-off-by: Claudio Cambra --- src/gui/iconutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/iconutils.cpp b/src/gui/iconutils.cpp index ba9204e03926..22ce38f85aab 100644 --- a/src/gui/iconutils.cpp +++ b/src/gui/iconutils.cpp @@ -108,7 +108,7 @@ QImage createSvgImageWithCustomColor(const QString &fileName, return {}; } - const auto sizeToUse = requestedSize.isValid() ? requestedSize : *originalSize; + const auto sizeToUse = requestedSize.isValid() || originalSize == nullptr ? requestedSize : *originalSize; // some icons are present in white or black only, so, we need to check both when needed const auto iconBaseColors = QStringList{QStringLiteral("black"), QStringLiteral("white")};