新增文件夹图标显示功能
This commit is contained in:
parent
60d12e76f3
commit
2c50db611f
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,22 +6,36 @@ import org.ukui.menu.core 1.0
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: control
|
id: control
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
// ToolTip.visible: content.textTruncated && control.containsMouse
|
||||||
|
// ToolTip.text: name
|
||||||
|
|
||||||
StyleBackground {
|
StyleBackground {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 4
|
radius: 4
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
|
alpha: control.containsPress ? 0.82 : control.containsMouse ? 0.55 : 0.00
|
||||||
ToolTip.visible: content.textTruncated && control.containsMouse
|
|
||||||
ToolTip.text: name
|
|
||||||
|
|
||||||
IconLabel {
|
RowLayout {
|
||||||
id: content
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
iconHeight: 32; iconWidth: iconHeight
|
anchors.leftMargin: 12
|
||||||
appName: name; appIcon: icon
|
|
||||||
display: Display.TextBesideIcon
|
|
||||||
spacing: 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,3 +7,4 @@ FolderItem 1.0 FolderItem.qml
|
||||||
LabelItem 1.0 LabelItem.qml
|
LabelItem 1.0 LabelItem.qml
|
||||||
IconLabel 1.0 IconLabel.qml
|
IconLabel 1.0 IconLabel.qml
|
||||||
RoundButton 1.0 RoundButton.qml
|
RoundButton 1.0 RoundButton.qml
|
||||||
|
FolderIcon 1.0 FolderIcon.qml
|
||||||
|
|
|
@ -25,7 +25,10 @@ import org.ukui.menu.core 1.0
|
||||||
SwipeView {
|
SwipeView {
|
||||||
id: root
|
id: root
|
||||||
interactive: false
|
interactive: false
|
||||||
required property AppPageHeader appPageHeader
|
// 5.15
|
||||||
|
// required property AppPageHeader appPageHeader
|
||||||
|
// 5.12
|
||||||
|
property AppPageHeader appPageHeader: null
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: appListBase
|
id: appListBase
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<file>extensions/RecentFileExtension.qml</file>
|
<file>extensions/RecentFileExtension.qml</file>
|
||||||
<file>extensions/FavoriteExtension.qml</file>
|
<file>extensions/FavoriteExtension.qml</file>
|
||||||
<file>AppControls2/RoundButton.qml</file>
|
<file>AppControls2/RoundButton.qml</file>
|
||||||
|
<file>AppControls2/FolderIcon.qml</file>
|
||||||
<file>AppUI/SelectionPage.qml</file>
|
<file>AppUI/SelectionPage.qml</file>
|
||||||
<file>AppUI/AppPageContent.qml</file>
|
<file>AppUI/AppPageContent.qml</file>
|
||||||
<file>AppUI/PluginSelectMenu.qml</file>
|
<file>AppUI/PluginSelectMenu.qml</file>
|
||||||
|
|
|
@ -121,7 +121,7 @@ void AllAppDataProvider::reloadFolderData()
|
||||||
for (const auto &folder : folders) {
|
for (const auto &folder : folders) {
|
||||||
folderItem.setId(QString::number(folder.getId()));
|
folderItem.setId(QString::number(folder.getId()));
|
||||||
folderItem.setType(DataType::Folder);
|
folderItem.setType(DataType::Folder);
|
||||||
folderItem.setIcon("image://appicon/text-plain");
|
folderItem.setIcon(AppFolderHelper::folderIcon(folder).join(" "));
|
||||||
folderItem.setName(folder.getName());
|
folderItem.setName(folder.getName());
|
||||||
|
|
||||||
folderData.append(folderItem);
|
folderData.append(folderItem);
|
||||||
|
|
Loading…
Reference in New Issue