Skip to content

Commit

Permalink
Use material icon for folders.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander authored and mgallien committed Oct 6, 2023
1 parent 646baf2 commit 7f58be4
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 13 deletions.
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<file>src/gui/tray/CallNotificationDialog.qml</file>
<file>src/gui/tray/EditFileLocallyLoadingDialog.qml</file>
<file>src/gui/tray/NCBusyIndicator.qml</file>
<file>src/gui/tray/NCIconWithBackgroundImage.qml</file>
<file>src/gui/tray/NCToolTip.qml</file>
<file>src/gui/tray/NCProgressBar.qml</file>
<file>src/gui/tray/EnforcedPlainTextLabel.qml</file>
Expand Down
56 changes: 56 additions & 0 deletions src/gui/tray/NCIconWithBackgroundImage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2023 by Oleksandr Zolotov <[email protected]>
*
* 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

Item {
id: root

property alias source: icon.source
property alias sourceSize: icon.sourceSize
property alias backgroundIconSource: backgroundImage.source

implicitWidth: backgroundImage.source !== "" ? backgroundImage.implicitWidth : icon.implicitWidth
implicitHeight: backgroundImage.source !== "" ? backgroundImage.implicitHeight : icon.implicitHeight

Image {
id: backgroundImage

anchors.fill: parent

cache: true
mipmap: true

sourceSize {
width: root.width
height: root.height
}

fillMode: Image.PreserveAspectFit
visible: source !== ""
}

Image {
id: icon

anchors.centerIn: parent

cache: true
mipmap: true

fillMode: Image.PreserveAspectFit
visible: source !== ""
}
}
14 changes: 7 additions & 7 deletions src/gui/tray/TrayFolderListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,13 +46,12 @@ MenuItem {
anchors.rightMargin: Style.trayWindowMenuEntriesMargin
spacing: Style.trayHorizontalMargin

Image {
NCIconWithBackgroundImage {
source: root.iconSource
cache: true
sourceSize.width: root.height * Style.smallIconScaleFactor
sourceSize.height: root.height * Style.smallIconScaleFactor
verticalAlignment: Qt.AlignVCenter
horizontalAlignment: Qt.AlignHCenter
sourceSize.width: root.height * 0.25
sourceSize.height: root.height * 0.25

backgroundIconSource: root.backgroundIconSource

Layout.preferredHeight: root.height * Style.smallIconScaleFactor
Layout.preferredWidth: root.height * Style.smallIconScaleFactor
Expand Down
14 changes: 10 additions & 4 deletions src/gui/tray/TrayFoldersMenuButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions theme.qrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<file>theme/white/state-sync-64.png</file>
<file>theme/white/state-sync-128.png</file>
<file>theme/white/state-sync-256.png</file>
<file>theme/black/account-group.svg</file>
<file>theme/black/change.svg</file>
<file>theme/black/clear.svg</file>
<file>theme/black/comment.svg</file>
Expand Down
1 change: 1 addition & 0 deletions theme/black/account-group.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/black/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/white/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7f58be4

Please sign in to comment.