From 37b22c021c10b77d4894bcc8410c92a1a3fada58 Mon Sep 17 00:00:00 2001 From: alex-z Date: Wed, 4 Oct 2023 17:05:39 +0200 Subject: [PATCH] Use material icon for folders. Signed-off-by: alex-z --- resources.qrc | 1 + src/gui/tray/NCIconWithBackgroundImage.qml | 37 ++++++++++++++++++++++ src/gui/tray/TrayFolderListItem.qml | 19 ++++++----- src/gui/tray/TrayFoldersMenuButton.qml | 14 +++++--- theme.qrc.in | 1 + theme/black/account-group.svg | 1 + theme/black/folder.svg | 2 +- theme/white/folder.svg | 2 +- 8 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 src/gui/tray/NCIconWithBackgroundImage.qml create mode 100644 theme/black/account-group.svg diff --git a/resources.qrc b/resources.qrc index afe9e7836..fc6595694 100644 --- a/resources.qrc +++ b/resources.qrc @@ -48,6 +48,7 @@ src/gui/tray/CallNotificationDialog.qml src/gui/tray/EditFileLocallyLoadingDialog.qml src/gui/tray/NCBusyIndicator.qml + src/gui/tray/NCIconWithBackgroundImage.qml src/gui/tray/NCToolTip.qml src/gui/tray/NCProgressBar.qml src/gui/tray/EnforcedPlainTextLabel.qml diff --git a/src/gui/tray/NCIconWithBackgroundImage.qml b/src/gui/tray/NCIconWithBackgroundImage.qml new file mode 100644 index 000000000..0ef155ad9 --- /dev/null +++ b/src/gui/tray/NCIconWithBackgroundImage.qml @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 by Oleksandr Zolotov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +import QtQuick 2.15 +import Style 1.0 + +Image { + id: root + + property alias icon: icon + + cache: true + mipmap: true + fillMode: Image.PreserveAspectFit + + Image { + id: icon + + anchors.centerIn: parent + + cache: true + mipmap: true + fillMode: Image.PreserveAspectFit + visible: source !== "" + } +} diff --git a/src/gui/tray/TrayFolderListItem.qml b/src/gui/tray/TrayFolderListItem.qml index 60fd21570..b83160bc6 100644 --- a/src/gui/tray/TrayFolderListItem.qml +++ b/src/gui/tray/TrayFolderListItem.qml @@ -21,7 +21,8 @@ MenuItem { id: root property string subline: "" - property string iconSource: "image://svgimage-custom-color/folder-group.svg/" + palette.buttonText + property string iconSource: "image://svgimage-custom-color/account-group.svg/" + palette.buttonText + property string backgroundIconSource: value property string toolTipText: root.text NCToolTip { @@ -45,13 +46,12 @@ MenuItem { anchors.rightMargin: Style.trayWindowMenuEntriesMargin spacing: Style.trayHorizontalMargin - Image { - source: root.iconSource - cache: true - sourceSize.width: root.height * Style.smallIconScaleFactor - sourceSize.height: root.height * Style.smallIconScaleFactor - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter + NCIconWithBackgroundImage { + source: root.backgroundIconSource + + icon.source: root.iconSource + icon.height: height * Style.smallIconScaleFactor + icon.width: icon.height Layout.preferredHeight: root.height * Style.smallIconScaleFactor Layout.preferredWidth: root.height * Style.smallIconScaleFactor @@ -64,7 +64,10 @@ MenuItem { spacing: Style.extraSmallSpacing + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + } } } diff --git a/src/gui/tray/TrayFoldersMenuButton.qml b/src/gui/tray/TrayFoldersMenuButton.qml index 2953ae12a..1b6d07e18 100644 --- a/src/gui/tray/TrayFoldersMenuButton.qml +++ b/src/gui/tray/TrayFoldersMenuButton.qml @@ -100,9 +100,14 @@ HeaderButton { Image { id: openLocalFolderButtonIcon - cache: false + cache: true source: "image://svgimage-custom-color/folder.svg/" + Style.currentUserHeaderTextColor + sourceSize { + width: Style.headerButtonIconSize + height: Style.headerButtonIconSize + } + verticalAlignment: Qt.AlignCenter Accessible.role: Accessible.Graphic @@ -185,9 +190,10 @@ HeaderButton { subline: model.modelData.parentPath width: foldersMenuListView.width height: Style.standardPrimaryButtonHeight - iconSource: !isGroupFolder ? - "image://svgimage-custom-color/folder.svg/" + palette.buttonText : - "image://svgimage-custom-color/folder-group.svg/" + palette.buttonText + backgroundIconSource: "image://svgimage-custom-color/folder.svg/" + palette.buttonText + iconSource: isGroupFolder + ? "image://svgimage-custom-color/account-group.svg/" + palette.brightText + : "" onTriggered: { foldersMenu.close(); diff --git a/theme.qrc.in b/theme.qrc.in index 60f25c4fc..e8d88fc8a 100644 --- a/theme.qrc.in +++ b/theme.qrc.in @@ -44,6 +44,7 @@ theme/white/state-sync-64.png theme/white/state-sync-128.png theme/white/state-sync-256.png + theme/black/account-group.svg theme/black/change.svg theme/black/clear.svg theme/black/comment.svg diff --git a/theme/black/account-group.svg b/theme/black/account-group.svg new file mode 100644 index 000000000..01159f5f6 --- /dev/null +++ b/theme/black/account-group.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theme/black/folder.svg b/theme/black/folder.svg index 9289fb05d..bc31144b6 100644 --- a/theme/black/folder.svg +++ b/theme/black/folder.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/theme/white/folder.svg b/theme/white/folder.svg index a32ffc857..f0f077be5 100644 --- a/theme/white/folder.svg +++ b/theme/white/folder.svg @@ -1 +1 @@ - + \ No newline at end of file