From 2c50db611f79452036ad6beac2647b2e5866d36e Mon Sep 17 00:00:00 2001 From: hewenfei Date: Mon, 3 Apr 2023 15:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppControls2/FolderIcon.qml | 49 ++++++++++++++++++++ qml/AppControls2/FolderItem.qml | 28 ++++++++--- qml/AppControls2/qmldir | 1 + qml/AppUI/AppPageContent.qml | 5 +- qml/qml.qrc | 1 + src/appdata/plugin/all-app-data-provider.cpp | 2 +- 6 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 qml/AppControls2/FolderIcon.qml diff --git a/qml/AppControls2/FolderIcon.qml b/qml/AppControls2/FolderIcon.qml new file mode 100644 index 0000000..1ff8110 --- /dev/null +++ b/qml/AppControls2/FolderIcon.qml @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +import QtQuick 2.12 +import org.ukui.menu.core 1.0 + +StyleBackground { + property alias icons: iconGrid.icons + property alias rows: iconGrid.rows + property alias columns: iconGrid.columns + property alias padding: iconGrid.padding + property alias spacing: iconGrid.spacing + + radius: 4 + paletteRole: Palette.Text + useStyleTransparent: false + alpha: 0.12 + + Grid { + id: iconGrid + anchors.fill: parent + property string icons: "" + property int cellWidth: Math.floor((width - padding*2 - spacing*(columns - 1)) / columns) + property int cellHeight: Math.floor((height - padding*2 - spacing*(rows - 1)) / rows) + Repeater { + model: icons.split(" ").slice(0, rows*columns) + delegate: Image { + width: iconGrid.cellWidth + height: iconGrid.cellHeight + source: modelData + } + } + } +} diff --git a/qml/AppControls2/FolderItem.qml b/qml/AppControls2/FolderItem.qml index 66ec400..cf61a1a 100644 --- a/qml/AppControls2/FolderItem.qml +++ b/qml/AppControls2/FolderItem.qml @@ -6,22 +6,36 @@ import org.ukui.menu.core 1.0 MouseArea { id: control hoverEnabled: true + // ToolTip.visible: content.textTruncated && control.containsMouse + // ToolTip.text: name StyleBackground { anchors.fill: parent radius: 4 useStyleTransparent: false alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00 - ToolTip.visible: content.textTruncated && control.containsMouse - ToolTip.text: name - IconLabel { - id: content + RowLayout { anchors.fill: parent - iconHeight: 32; iconWidth: iconHeight - appName: name; appIcon: icon - display: Display.TextBesideIcon + anchors.leftMargin: 12 spacing: 12 + FolderIcon { + rows: 2; columns: 2 + spacing: 2; padding: 2 + icons: icon + Layout.alignment: Qt.AlignVCenter + Layout.preferredWidth: 32 + Layout.preferredHeight: 32 + } + + Text { + Layout.fillWidth: true + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + elide: Text.ElideRight + text: name + } } } } diff --git a/qml/AppControls2/qmldir b/qml/AppControls2/qmldir index d475ec1..4961582 100644 --- a/qml/AppControls2/qmldir +++ b/qml/AppControls2/qmldir @@ -7,3 +7,4 @@ FolderItem 1.0 FolderItem.qml LabelItem 1.0 LabelItem.qml IconLabel 1.0 IconLabel.qml RoundButton 1.0 RoundButton.qml +FolderIcon 1.0 FolderIcon.qml diff --git a/qml/AppUI/AppPageContent.qml b/qml/AppUI/AppPageContent.qml index 667b375..b59bbc5 100644 --- a/qml/AppUI/AppPageContent.qml +++ b/qml/AppUI/AppPageContent.qml @@ -25,7 +25,10 @@ import org.ukui.menu.core 1.0 SwipeView { id: root interactive: false - required property AppPageHeader appPageHeader + // 5.15 + // required property AppPageHeader appPageHeader + // 5.12 + property AppPageHeader appPageHeader: null Item { id: appListBase diff --git a/qml/qml.qrc b/qml/qml.qrc index 9504dff..653990c 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -29,6 +29,7 @@ extensions/RecentFileExtension.qml extensions/FavoriteExtension.qml AppControls2/RoundButton.qml + AppControls2/FolderIcon.qml AppUI/SelectionPage.qml AppUI/AppPageContent.qml AppUI/PluginSelectMenu.qml diff --git a/src/appdata/plugin/all-app-data-provider.cpp b/src/appdata/plugin/all-app-data-provider.cpp index 591d073..e36db82 100644 --- a/src/appdata/plugin/all-app-data-provider.cpp +++ b/src/appdata/plugin/all-app-data-provider.cpp @@ -121,7 +121,7 @@ void AllAppDataProvider::reloadFolderData() for (const auto &folder : folders) { folderItem.setId(QString::number(folder.getId())); folderItem.setType(DataType::Folder); - folderItem.setIcon("image://appicon/text-plain"); + folderItem.setIcon(AppFolderHelper::folderIcon(folder).join(" ")); folderItem.setName(folder.getName()); folderData.append(folderItem);