Merge pull request #6798 from nextcloud/bugfix/kde-qml

Fix broken tray GUI on Linux
This commit is contained in:
Claudio Cambra 2024-06-07 01:03:29 +08:00 committed by GitHub
commit 370be3346f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 132 additions and 29 deletions

View file

@ -108,9 +108,11 @@ QImage createSvgImageWithCustomColor(const QString &fileName,
return {};
}
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")};
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()) {

View file

@ -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;

View file

@ -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
@ -33,7 +32,6 @@ Button {
icon.width: Style.headerButtonIconSize
icon.height: Style.headerButtonIconSize
icon.color: palette.brightText
Layout.alignment: Qt.AlignRight
Layout.preferredWidth: Style.trayWindowHeaderHeight
@ -43,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
}
}
}
}

View file

@ -124,7 +124,7 @@ HeaderButton {
width: imageWidth
height: imageHeight
anchors.verticalCenter: parent
anchors.verticalCenter: parent.verticalCenter
}
@ -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
}

View file

@ -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

View file

@ -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
@ -640,7 +624,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 +640,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) {

View file

@ -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);
}
}

View file

@ -238,5 +238,7 @@
<file>theme/delete.svg</file>
<file>theme/send.svg</file>
<file>theme/call-notification.wav</file>
<file>theme/more-apps.svg</file>
<file>theme/talk-app.svg</file>
</qresource>
</RCC>

55
theme/more-apps.svg Normal file
View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="32"
height="32"
enable-background="new 0 0 595.275 311.111"
version="1.1"
viewBox="0 0 32 32"
xml:space="preserve"
id="svg4"
sodipodi:docname="more-apps.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs4" /><sodipodi:namedview
id="namedview4"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="23.40625"
inkscape:cx="15.978638"
inkscape:cy="24.672897"
inkscape:window-width="1707"
inkscape:window-height="995"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" /><g
transform="matrix(.44643 0 0 .44643 260.1 -.096653)"
stroke-width="2"
id="g1"
style="fill:#000000"><path
d="m-572.71 3.5765c-1.108 0-2 0.892-2 2v4c0 1.108 0.892 2 2 2s2-0.892 2-2v-4c0-1.108-0.892-2-2-2zm16 0c-1.108 0-2 0.892-2 2v4c0 1.108 0.892 2 2 2s2-0.892 2-2v-4c0-1.108-0.892-2-2-2zm-13 4v2c0 1.662-1.338 3-3 3s-3-1.338-3-3v-1.875c-1.728 0.44254-3 2.0052-3 3.875v16c0 2.216 1.784 4 4 4h20c2.216 0 4-1.784 4-4v-16c0-1.8698-1.272-3.4325-3-3.875v1.875c0 1.662-1.338 3-3 3s-3-1.338-3-3v-2zm-5.9062 9h21.812c0.0554 0 0.0937 0.03835 0.0937 0.09375v11.812c0 0.0554-0.0384 0.09375-0.0937 0.09375h-21.812c-0.0554 0-0.0937-0.03835-0.0937-0.09375v-11.812c0-0.0554 0.0384-0.09375 0.0937-0.09375z"
fill="#fff"
stroke-width="4"
id="path1"
style="fill:#000000" /></g><g
fill="#fff"
id="g4"
style="fill:#000000"><path
d="m20.551 3.0408c-0.96 0-1.7744 0.70205-1.7744 1.608 0.0068 0.28636 0.03242 0.6395 0.20332 1.3862v0.0185l0.0185 0.01849c0.05485 0.15714 0.13469 0.24703 0.24028 0.36967s0.23147 0.26699 0.35117 0.38815c0.0141 0.01427 0.02311 0.02307 0.03695 0.03699 0.02376 0.10331 0.0525 0.21449 0.07393 0.31422 0.05703 0.26534 0.05118 0.45324 0.03695 0.5175-0.4125 0.14484-0.9257 0.31734-1.3862 0.5175-0.25853 0.1124-0.49247 0.21277-0.68385 0.33271-0.19138 0.11994-0.38172 0.21055-0.44358 0.48057-8.5e-4 0.01228-8.5e-4 0.02466 0 0.03699-0.06045 0.55505-0.1519 1.3713-0.2218 1.9223-0.01509 0.11598 0.04603 0.23822 0.14786 0.29574 0.8361 0.45164 2.1205 0.6334 3.4008 0.62845 1.2804-5e-3 2.5545-0.19746 3.3638-0.62845 0.10182-0.05751 0.16295-0.17976 0.14786-0.29574-0.02233-0.17222-0.04973-0.56055-0.07393-0.94265-0.02419-0.3821-0.04521-0.758-0.07393-0.97965-0.01-0.05495-0.036-0.10688-0.07393-0.14786-0.25712-0.30704-0.64125-0.49471-1.0905-0.6839-0.41012-0.1727-0.89095-0.35204-1.3677-0.5545-0.02669-0.05945-0.05319-0.23241 0-0.49906 0.01427-0.0716 0.03665-0.14828 0.05545-0.2218 0.04481-0.05018 0.07973-0.0912 0.12938-0.14787 0.10589-0.12086 0.21967-0.24765 0.3142-0.36967 0.09454-0.12202 0.17188-0.2267 0.2218-0.36967l0.01849-0.0185c0.19319-0.77975 0.1933-1.1051 0.20332-1.3862v-0.0185c0-0.906-0.81435-1.608-1.7744-1.608zm5.0755-1.4756c-1.3996 0-2.5869 1.0236-2.5869 2.3444 0.0099 0.41749 0.04727 0.93235 0.29642 2.021v0.02695l0.02694 0.02695c0.07998 0.22909 0.19637 0.36014 0.35031 0.53895 0.15394 0.1788 0.33747 0.38924 0.512 0.5659 0.02052 0.02078 0.03367 0.03367 0.05389 0.05391 0.03463 0.15061 0.07654 0.3127 0.10779 0.4581 0.08314 0.38683 0.07461 0.6608 0.0539 0.75455-0.6014 0.21117-1.3496 0.46264-2.021 0.75455-0.37693 0.16386-0.718 0.31019-0.99705 0.48505-0.27904 0.17486-0.55655 0.30697-0.64675 0.70065-0.0013 0.01794-0.0013 0.03596 0 0.05391-0.08814 0.80925-0.22146 1.9993-0.32336 2.8025-0.02199 0.16908 0.06712 0.34731 0.21558 0.43115 1.219 0.65845 3.0916 0.9235 4.9584 0.9162 1.8666-0.0073 3.7243-0.28787 4.9044-0.9162 0.14846-0.08384 0.23758-0.26207 0.21558-0.43115-0.03255-0.25107-0.0725-0.8172-0.10779-1.3743-0.03527-0.55705-0.06592-1.105-0.10778-1.4282-0.01461-0.0801-0.05248-0.15582-0.10779-0.21558-0.37486-0.44763-0.93495-0.72125-1.5899-0.99705-0.59795-0.25178-1.299-0.51325-1.994-0.8084-0.03889-0.08667-0.07756-0.33883 0-0.7276 0.02082-0.10438 0.05344-0.21619 0.08084-0.32336 0.06533-0.07317 0.11624-0.13296 0.18863-0.21558 0.15438-0.1762 0.32027-0.36105 0.4581-0.53895 0.13783-0.17789 0.2506-0.3305 0.32336-0.53895l0.02695-0.02694c0.2825-1.1368 0.2825-1.6111 0.297-2.021v-0.02695c0-1.3208-1.1874-2.3444-2.5869-2.3444z"
color="#000000"
style="text-indent:0;text-transform:none;fill:#000000"
id="path2" /><path
d="m1.7778 19.75c-0.4309 0-0.7778 0.3472-0.7778 0.77805v7.195c0 0.43094 0.34689 0.777 0.7778 0.777h12.444c0.431 0 0.778-0.346 0.778-0.777v-7.195c0-0.43105-0.347-0.77825-0.778-0.77825zm0.65625 0.8996 5.323 5.323h0.46183l5.347-5.323 0.5347 0.5347-3.184 3.2326 2.4062 2.4548-0.5347 0.5347-2.4548-2.4548-1.7744 1.7986h-1.1175l-1.774-1.798-2.455 2.479-0.53475-0.5595 2.4308-2.4545-3.2085-3.2326z"
id="path3"
style="fill:#000000" /><path
d="m18.5 22.25a1.75 1.75 0 1 1 0 3.5 1.75 1.75 0 0 1 0-3.5zm5.5 0a1.75 1.75 0 1 1 0 3.5 1.75 1.75 0 0 1 0-3.5zm5.5 0a1.75 1.75 0 1 1 0 3.5 1.75 1.75 0 1 1 0-3.5z"
id="path4"
style="fill:#000000" /></g></svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

40
theme/talk-app.svg Normal file
View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="16"
width="16"
version="1.1"
viewBox="0 0 16 16"
id="svg1"
sodipodi:docname="talk-app.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="46.8125"
inkscape:cx="7.9893191"
inkscape:cy="10.435247"
inkscape:window-width="1707"
inkscape:window-height="995"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<path
d="m7.9992 0.999a6.9993 6.9994 0 0 0 -6.9992 6.9996 6.9993 6.9994 0 0 0 6.9992 6.9994 6.9993 6.9994 0 0 0 3.6308 -1.024c0.86024 0.34184 2.7871 1.356 3.2457 0.91794 0.47922-0.45765-0.56261-2.6116-0.81238-3.412a6.9993 6.9994 0 0 0 0.935 -3.4814 6.9993 6.9994 0 0 0 -6.9991 -6.9993zm0.0008 2.6611a4.34 4.3401 0 0 1 4.34 4.3401 4.34 4.3401 0 0 1 -4.34 4.3398 4.34 4.3401 0 0 1 -4.34 -4.3398 4.34 4.3401 0 0 1 4.34 -4.3401z"
stroke-width="0.14"
fill="#fff"
id="path1"
style="fill:#000000" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB